@@ -42,7 +41,10 @@ describe('Input Tokenization', () => {
});
function tokensAsList() {
- const iter = createTokenIterator({ editor: coreEditor, position: { lineNumber: 1, column: 1 } });
+ const iter = createTokenIterator({
+ editor: coreEditor,
+ position: { lineNumber: 1, column: 1 },
+ });
const ret = [];
let t = iter.getCurrentToken();
const parser = new RowParser(coreEditor);
@@ -67,12 +69,11 @@ describe('Input Tokenization', () => {
if (prefix) {
data = prefix + '\n' + data;
}
- }
- else {
+ } else {
data = prefix;
}
- test('Token test ' + testCount++ + ' prefix: ' + prefix, async function () {
+ test('Token test ' + testCount++ + ' prefix: ' + prefix, async function() {
await coreEditor.setValue(data, true);
const tokens = tokensAsList();
const normTokenList = [];
@@ -84,25 +85,25 @@ describe('Input Tokenization', () => {
});
}
- tokenTest(
- ['method', 'GET', 'url.part', '_search'],
- 'GET _search'
- );
+ tokenTest(['method', 'GET', 'url.part', '_search'], 'GET _search');
- tokenTest(
- ['method', 'GET', 'url.slash', '/', 'url.part', '_search'],
- 'GET /_search'
- );
+ tokenTest(['method', 'GET', 'url.slash', '/', 'url.part', '_search'], 'GET /_search');
tokenTest(
- ['method', 'GET', 'url.protocol_host', 'http://somehost', 'url.slash', '/', 'url.part', '_search'],
+ [
+ 'method',
+ 'GET',
+ 'url.protocol_host',
+ 'http://somehost',
+ 'url.slash',
+ '/',
+ 'url.part',
+ '_search',
+ ],
'GET http://somehost/_search'
);
- tokenTest(
- ['method', 'GET', 'url.protocol_host', 'http://somehost'],
- 'GET http://somehost'
- );
+ tokenTest(['method', 'GET', 'url.protocol_host', 'http://somehost'], 'GET http://somehost');
tokenTest(
['method', 'GET', 'url.protocol_host', 'http://somehost', 'url.slash', '/'],
@@ -120,20 +121,27 @@ describe('Input Tokenization', () => {
);
tokenTest(
- ['method', 'GET', 'url.slash', '/', 'url.part', '_cluster', 'url.slash', '/', 'url.part', 'nodes'],
+ [
+ 'method',
+ 'GET',
+ 'url.slash',
+ '/',
+ 'url.part',
+ '_cluster',
+ 'url.slash',
+ '/',
+ 'url.part',
+ 'nodes',
+ ],
'GET /_cluster/nodes'
);
-
tokenTest(
['method', 'GET', 'url.part', 'index', 'url.slash', '/', 'url.part', '_search'],
'GET index/_search'
);
- tokenTest(
- ['method', 'GET', 'url.part', 'index'],
- 'GET index'
- );
+ tokenTest(['method', 'GET', 'url.part', 'index'], 'GET index');
tokenTest(
['method', 'GET', 'url.part', 'index', 'url.slash', '/', 'url.part', 'type'],
@@ -141,48 +149,154 @@ describe('Input Tokenization', () => {
);
tokenTest(
- ['method', 'GET', 'url.slash', '/', 'url.part', 'index', 'url.slash', '/', 'url.part', 'type', 'url.slash', '/'],
+ [
+ 'method',
+ 'GET',
+ 'url.slash',
+ '/',
+ 'url.part',
+ 'index',
+ 'url.slash',
+ '/',
+ 'url.part',
+ 'type',
+ 'url.slash',
+ '/',
+ ],
'GET /index/type/'
);
tokenTest(
- ['method', 'GET', 'url.part', 'index', 'url.slash', '/', 'url.part', 'type', 'url.slash', '/', 'url.part', '_search'],
+ [
+ 'method',
+ 'GET',
+ 'url.part',
+ 'index',
+ 'url.slash',
+ '/',
+ 'url.part',
+ 'type',
+ 'url.slash',
+ '/',
+ 'url.part',
+ '_search',
+ ],
'GET index/type/_search'
);
tokenTest(
- ['method', 'GET', 'url.part', 'index', 'url.slash', '/', 'url.part', 'type', 'url.slash', '/', 'url.part', '_search',
- 'url.questionmark', '?', 'url.param', 'value', 'url.equal', '=', 'url.value', '1'
+ [
+ 'method',
+ 'GET',
+ 'url.part',
+ 'index',
+ 'url.slash',
+ '/',
+ 'url.part',
+ 'type',
+ 'url.slash',
+ '/',
+ 'url.part',
+ '_search',
+ 'url.questionmark',
+ '?',
+ 'url.param',
+ 'value',
+ 'url.equal',
+ '=',
+ 'url.value',
+ '1',
],
'GET index/type/_search?value=1'
);
-
tokenTest(
- ['method', 'GET', 'url.part', 'index', 'url.slash', '/', 'url.part', 'type', 'url.slash', '/', 'url.part', '1'],
+ [
+ 'method',
+ 'GET',
+ 'url.part',
+ 'index',
+ 'url.slash',
+ '/',
+ 'url.part',
+ 'type',
+ 'url.slash',
+ '/',
+ 'url.part',
+ '1',
+ ],
'GET index/type/1'
);
-
tokenTest(
- ['method', 'GET', 'url.slash', '/', 'url.part', 'index1', 'url.comma', ',', 'url.part', 'index2', 'url.slash', '/'],
+ [
+ 'method',
+ 'GET',
+ 'url.slash',
+ '/',
+ 'url.part',
+ 'index1',
+ 'url.comma',
+ ',',
+ 'url.part',
+ 'index2',
+ 'url.slash',
+ '/',
+ ],
'GET /index1,index2/'
);
tokenTest(
- ['method', 'GET', 'url.slash', '/', 'url.part', 'index1', 'url.comma', ',', 'url.part', 'index2', 'url.slash', '/',
- 'url.part', '_search'],
+ [
+ 'method',
+ 'GET',
+ 'url.slash',
+ '/',
+ 'url.part',
+ 'index1',
+ 'url.comma',
+ ',',
+ 'url.part',
+ 'index2',
+ 'url.slash',
+ '/',
+ 'url.part',
+ '_search',
+ ],
'GET /index1,index2/_search'
);
tokenTest(
- ['method', 'GET', 'url.part', 'index1', 'url.comma', ',', 'url.part', 'index2', 'url.slash', '/',
- 'url.part', '_search'],
+ [
+ 'method',
+ 'GET',
+ 'url.part',
+ 'index1',
+ 'url.comma',
+ ',',
+ 'url.part',
+ 'index2',
+ 'url.slash',
+ '/',
+ 'url.part',
+ '_search',
+ ],
'GET index1,index2/_search'
);
tokenTest(
- ['method', 'GET', 'url.slash', '/', 'url.part', 'index1', 'url.comma', ',', 'url.part', 'index2'],
+ [
+ 'method',
+ 'GET',
+ 'url.slash',
+ '/',
+ 'url.part',
+ 'index1',
+ 'url.comma',
+ ',',
+ 'url.part',
+ 'index2',
+ ],
'GET /index1,index2'
);
@@ -196,7 +310,6 @@ describe('Input Tokenization', () => {
'GET /index1,'
);
-
tokenTest(
['method', 'PUT', 'url.slash', '/', 'url.part', 'index', 'url.slash', '/'],
'PUT /index/'
@@ -207,52 +320,130 @@ describe('Input Tokenization', () => {
'GET index/_search '
);
- tokenTest(
- ['method', 'PUT', 'url.slash', '/', 'url.part', 'index'],
- 'PUT /index'
- );
+ tokenTest(['method', 'PUT', 'url.slash', '/', 'url.part', 'index'], 'PUT /index');
tokenTest(
- ['method', 'PUT', 'url.slash', '/', 'url.part', 'index1', 'url.comma', ',', 'url.part', 'index2',
- 'url.slash', '/', 'url.part', 'type1', 'url.comma', ',', 'url.part', 'type2'],
+ [
+ 'method',
+ 'PUT',
+ 'url.slash',
+ '/',
+ 'url.part',
+ 'index1',
+ 'url.comma',
+ ',',
+ 'url.part',
+ 'index2',
+ 'url.slash',
+ '/',
+ 'url.part',
+ 'type1',
+ 'url.comma',
+ ',',
+ 'url.part',
+ 'type2',
+ ],
'PUT /index1,index2/type1,type2'
);
tokenTest(
- ['method', 'PUT', 'url.slash', '/', 'url.part', 'index1',
- 'url.slash', '/', 'url.part', 'type1', 'url.comma', ',', 'url.part', 'type2', 'url.comma', ','],
+ [
+ 'method',
+ 'PUT',
+ 'url.slash',
+ '/',
+ 'url.part',
+ 'index1',
+ 'url.slash',
+ '/',
+ 'url.part',
+ 'type1',
+ 'url.comma',
+ ',',
+ 'url.part',
+ 'type2',
+ 'url.comma',
+ ',',
+ ],
'PUT /index1/type1,type2,'
);
tokenTest(
- ['method', 'PUT', 'url.part', 'index1', 'url.comma', ',', 'url.part', 'index2',
- 'url.slash', '/', 'url.part', 'type1', 'url.comma', ',', 'url.part', 'type2', 'url.slash', '/',
- 'url.part', '1234'],
+ [
+ 'method',
+ 'PUT',
+ 'url.part',
+ 'index1',
+ 'url.comma',
+ ',',
+ 'url.part',
+ 'index2',
+ 'url.slash',
+ '/',
+ 'url.part',
+ 'type1',
+ 'url.comma',
+ ',',
+ 'url.part',
+ 'type2',
+ 'url.slash',
+ '/',
+ 'url.part',
+ '1234',
+ ],
'PUT index1,index2/type1,type2/1234'
);
-
tokenTest(
- ['method', 'POST', 'url.part', '_search', 'paren.lparen', '{', 'variable', '"q"', 'punctuation.colon', ':',
- 'paren.lparen', '{', 'paren.rparen', '}', 'paren.rparen', '}'
+ [
+ 'method',
+ 'POST',
+ 'url.part',
+ '_search',
+ 'paren.lparen',
+ '{',
+ 'variable',
+ '"q"',
+ 'punctuation.colon',
+ ':',
+ 'paren.lparen',
+ '{',
+ 'paren.rparen',
+ '}',
+ 'paren.rparen',
+ '}',
],
- 'POST _search\n' +
- '{\n' +
- ' "q": {}\n' +
- ' \n' +
- '}'
+ 'POST _search\n' + '{\n' + ' "q": {}\n' + ' \n' + '}'
);
tokenTest(
- ['method', 'POST', 'url.part', '_search', 'paren.lparen', '{', 'variable', '"q"', 'punctuation.colon', ':',
- 'paren.lparen', '{', 'variable', '"s"', 'punctuation.colon', ':', 'paren.lparen', '{', 'paren.rparen', '}',
- 'paren.rparen', '}', 'paren.rparen', '}'
+ [
+ 'method',
+ 'POST',
+ 'url.part',
+ '_search',
+ 'paren.lparen',
+ '{',
+ 'variable',
+ '"q"',
+ 'punctuation.colon',
+ ':',
+ 'paren.lparen',
+ '{',
+ 'variable',
+ '"s"',
+ 'punctuation.colon',
+ ':',
+ 'paren.lparen',
+ '{',
+ 'paren.rparen',
+ '}',
+ 'paren.rparen',
+ '}',
+ 'paren.rparen',
+ '}',
],
- 'POST _search\n' +
- '{\n' +
- ' "q": { "s": {}}\n' +
- ' \n' +
- '}'
+ 'POST _search\n' + '{\n' + ' "q": { "s": {}}\n' + ' \n' + '}'
);
function statesAsList() {
@@ -262,7 +453,6 @@ describe('Input Tokenization', () => {
return ret;
}
-
function statesTest(statesList, prefix, data) {
if (data && typeof data !== 'string') {
data = JSON.stringify(data, null, 3);
@@ -271,124 +461,99 @@ describe('Input Tokenization', () => {
if (prefix) {
data = prefix + '\n' + data;
}
- }
- else {
+ } else {
data = prefix;
}
- test('States test ' + testCount++ + ' prefix: ' + prefix, async function () {
+ test('States test ' + testCount++ + ' prefix: ' + prefix, async function() {
await coreEditor.setValue(data, true);
const modes = statesAsList();
expect(modes).toEqual(statesList);
});
}
-
statesTest(
['start', 'json', 'json', 'start'],
- 'POST _search\n' +
- '{\n' +
- ' "query": { "match_all": {} }\n' +
- '}'
+ 'POST _search\n' + '{\n' + ' "query": { "match_all": {} }\n' + '}'
);
statesTest(
['start', 'json', ['json', 'json'], ['json', 'json'], 'json', 'start'],
- 'POST _search\n' +
- '{\n' +
- ' "query": { \n' +
- ' "match_all": {} \n' +
- ' }\n' +
- '}'
+ 'POST _search\n' + '{\n' + ' "query": { \n' + ' "match_all": {} \n' + ' }\n' + '}'
);
statesTest(
['start', 'json', 'json', 'start'],
- 'POST _search\n' +
- '{\n' +
- ' "script": { "source": "" }\n' +
- '}'
+ 'POST _search\n' + '{\n' + ' "script": { "source": "" }\n' + '}'
);
statesTest(
['start', 'json', 'json', 'start'],
- 'POST _search\n' +
- '{\n' +
- ' "script": ""\n' +
- '}'
+ 'POST _search\n' + '{\n' + ' "script": ""\n' + '}'
);
statesTest(
['start', 'json', ['json', 'json'], 'json', 'start'],
- 'POST _search\n' +
- '{\n' +
- ' "script": {\n' +
- ' }\n' +
- '}'
+ 'POST _search\n' + '{\n' + ' "script": {\n' + ' }\n' + '}'
);
-
statesTest(
- ['start', 'json', ['script-start', 'json', 'json', 'json'], ['script-start', 'json', 'json', 'json'],
- ['json', 'json'], 'json', 'start'],
+ [
+ 'start',
+ 'json',
+ ['script-start', 'json', 'json', 'json'],
+ ['script-start', 'json', 'json', 'json'],
+ ['json', 'json'],
+ 'json',
+ 'start',
+ ],
'POST _search\n' +
- '{\n' +
- ' "test": { "script": """\n' +
- ' test script\n' +
- ' """\n' +
- ' }\n' +
- '}'
+ '{\n' +
+ ' "test": { "script": """\n' +
+ ' test script\n' +
+ ' """\n' +
+ ' }\n' +
+ '}'
);
statesTest(
['start', 'json', ['script-start', 'json'], ['script-start', 'json'], 'json', 'start'],
- 'POST _search\n' +
- '{\n' +
- ' "script": """\n' +
- ' test script\n' +
- ' """,\n' +
- '}'
+ 'POST _search\n' + '{\n' + ' "script": """\n' + ' test script\n' + ' """,\n' + '}'
);
statesTest(
['start', 'json', 'json', 'start'],
- 'POST _search\n' +
- '{\n' +
- ' "script": """test script""",\n' +
- '}'
+ 'POST _search\n' + '{\n' + ' "script": """test script""",\n' + '}'
);
-
statesTest(
['start', 'json', ['string_literal', 'json'], ['string_literal', 'json'], 'json', 'start'],
- 'POST _search\n' +
- '{\n' +
- ' "something": """\n' +
- ' test script\n' +
- ' """,\n' +
- '}'
+ 'POST _search\n' + '{\n' + ' "something": """\n' + ' test script\n' + ' """,\n' + '}'
);
statesTest(
- ['start', 'json', ['string_literal', 'json', 'json', 'json'], ['string_literal', 'json', 'json', 'json'],
- ['json', 'json'], ['json', 'json'],
- 'json', 'start'],
+ [
+ 'start',
+ 'json',
+ ['string_literal', 'json', 'json', 'json'],
+ ['string_literal', 'json', 'json', 'json'],
+ ['json', 'json'],
+ ['json', 'json'],
+ 'json',
+ 'start',
+ ],
'POST _search\n' +
- '{\n' +
- ' "something": { "f" : """\n' +
- ' test script\n' +
- ' """,\n' +
- ' "g": 1\n' +
- ' }\n' +
- '}'
+ '{\n' +
+ ' "something": { "f" : """\n' +
+ ' test script\n' +
+ ' """,\n' +
+ ' "g": 1\n' +
+ ' }\n' +
+ '}'
);
statesTest(
['start', 'json', 'json', 'start'],
- 'POST _search\n' +
- '{\n' +
- ' "something": """test script""",\n' +
- '}'
+ 'POST _search\n' + '{\n' + ' "something": """test script""",\n' + '}'
);
});
-
diff --git a/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/__tests__/output_tokenization.test.js b/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/__tests__/output_tokenization.test.js
index b860f691dadb..6a93d007a6cd 100644
--- a/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/__tests__/output_tokenization.test.js
+++ b/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/__tests__/output_tokenization.test.js
@@ -56,8 +56,8 @@ describe('Output Tokenization', () => {
data = JSON.stringify(data, null, 3);
}
- test('Token test ' + testCount++, async function (done) {
- output.update(data, function () {
+ test('Token test ' + testCount++, async function(done) {
+ output.update(data, function() {
const tokens = tokensAsList();
const normTokenList = [];
for (let i = 0; i < tokenList.length; i++) {
@@ -71,16 +71,7 @@ describe('Output Tokenization', () => {
}
tokenTest(
- [
- 'warning',
- '#! warning',
- 'comment',
- '# GET url',
- 'paren.lparen',
- '{',
- 'paren.rparen',
- '}',
- ],
+ ['warning', '#! warning', 'comment', '# GET url', 'paren.lparen', '{', 'paren.rparen', '}'],
'#! warning\n' + '# GET url\n' + '{}'
);
diff --git a/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/input.js b/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/input.js
index f86afaeebcbe..da101b61f803 100644
--- a/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/input.js
+++ b/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/input.js
@@ -37,18 +37,18 @@ export function Mode() {
this.$behaviour = new CstyleBehaviour();
this.foldingRules = new CStyleFoldMode();
this.createModeDelegates({
- 'script-': ScriptMode
+ 'script-': ScriptMode,
});
}
oop.inherits(Mode, TextMode);
-(function () {
- this.getCompletions = function () {
+(function() {
+ this.getCompletions = function() {
// autocomplete is done by the autocomplete module.
return [];
};
- this.getNextLineIndent = function (state, line, tab) {
+ this.getNextLineIndent = function(state, line, tab) {
let indent = this.$getIndent(line);
if (state !== 'string_literal') {
@@ -61,26 +61,24 @@ oop.inherits(Mode, TextMode);
return indent;
};
- this.checkOutdent = function (state, line, input) {
+ this.checkOutdent = function(state, line, input) {
return this.$outdent.checkOutdent(line, input);
};
- this.autoOutdent = function (state, doc, row) {
+ this.autoOutdent = function(state, doc, row) {
this.$outdent.autoOutdent(doc, row);
};
- this.createWorker = function (session) {
+ this.createWorker = function(session) {
const worker = new WorkerClient(['ace', 'sense_editor'], workerModule, 'SenseWorker');
worker.attachToDocument(session.getDocument());
- worker.on('error', function (e) {
+ worker.on('error', function(e) {
session.setAnnotations([e.data]);
});
- worker.on('ok', function (anno) {
+ worker.on('ok', function(anno) {
session.setAnnotations(anno.data);
});
return worker;
};
-
-
-}).call(Mode.prototype);
+}.call(Mode.prototype));
diff --git a/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/input_highlight_rules.js b/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/input_highlight_rules.js
index 9ef1a8f31ac7..95f3a3eb1113 100644
--- a/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/input_highlight_rules.js
+++ b/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/input_highlight_rules.js
@@ -33,7 +33,7 @@ export function InputHighlightRules() {
}
return [
{ token: tokens.concat(['whitespace']), regex: reg + '(\\s*)$', next: nextIfEOL },
- { token: tokens, regex: reg, next: normalNext }
+ { token: tokens, regex: reg, next: normalNext },
];
}
@@ -41,40 +41,46 @@ export function InputHighlightRules() {
// regexps are ordered -> the first match is used
/*jshint -W015 */
this.$rules = {
- 'start': mergeTokens([
- { 'token': 'warning', 'regex': '#!.*$' },
- { token: 'comment', regex: /^#.*$/ },
- { token: 'paren.lparen', regex: '{', next: 'json', push: true }
- ],
- addEOL(['method'], /([a-zA-Z]+)/, 'start', 'method_sep')
- ,
- [
- {
- token: 'whitespace',
- regex: '\\s+'
- },
- {
- token: 'text',
- regex: '.+?'
- }
- ]),
- 'method_sep': mergeTokens(
- addEOL(['whitespace', 'url.protocol_host', 'url.slash'], /(\s+)(https?:\/\/[^?\/,]+)(\/)/, 'start', 'url'),
+ start: mergeTokens(
+ [
+ { token: 'warning', regex: '#!.*$' },
+ { token: 'comment', regex: /^#.*$/ },
+ { token: 'paren.lparen', regex: '{', next: 'json', push: true },
+ ],
+ addEOL(['method'], /([a-zA-Z]+)/, 'start', 'method_sep'),
+ [
+ {
+ token: 'whitespace',
+ regex: '\\s+',
+ },
+ {
+ token: 'text',
+ regex: '.+?',
+ },
+ ]
+ ),
+ method_sep: mergeTokens(
+ addEOL(
+ ['whitespace', 'url.protocol_host', 'url.slash'],
+ /(\s+)(https?:\/\/[^?\/,]+)(\/)/,
+ 'start',
+ 'url'
+ ),
addEOL(['whitespace', 'url.protocol_host'], /(\s+)(https?:\/\/[^?\/,]+)/, 'start', 'url'),
addEOL(['whitespace', 'url.slash'], /(\s+)(\/)/, 'start', 'url'),
addEOL(['whitespace'], /(\s+)/, 'start', 'url')
),
- 'url': mergeTokens(
+ url: mergeTokens(
addEOL(['url.part'], /([^?\/,\s]+)/, 'start'),
addEOL(['url.comma'], /(,)/, 'start'),
addEOL(['url.slash'], /(\/)/, 'start'),
addEOL(['url.questionmark'], /(\?)/, 'start', 'urlParams')
),
- 'urlParams': mergeTokens(
+ urlParams: mergeTokens(
addEOL(['url.param', 'url.equal', 'url.value'], /([^&=]+)(=)([^&]*)/, 'start'),
addEOL(['url.param'], /([^&=]+)/, 'start'),
addEOL(['url.amp'], /(&)/, 'start')
- )
+ ),
};
addToRules(this);
@@ -82,7 +88,6 @@ export function InputHighlightRules() {
if (this.constructor === InputHighlightRules) {
this.normalizeRules();
}
-
}
oop.inherits(InputHighlightRules, TextHighlightRules);
diff --git a/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/output.js b/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/output.js
index e2598f2a73d7..40e3128e396a 100644
--- a/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/output.js
+++ b/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/output.js
@@ -17,10 +17,9 @@
* under the License.
*/
-import ace from 'brace';
+import ace from 'brace';
require('./output_highlight_rules');
-
const oop = ace.acequire('ace/lib/oop');
const JSONMode = ace.acequire('ace/mode/json').Mode;
const HighlightRules = require('./output_highlight_rules').OutputJsonHighlightRules;
@@ -38,10 +37,10 @@ export function Mode() {
}
oop.inherits(Mode, JSONMode);
-(function () {
- this.createWorker = function () {
+(function() {
+ this.createWorker = function() {
return null;
};
this.$id = 'sense/mode/input';
-}).call(Mode.prototype);
+}.call(Mode.prototype));
diff --git a/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/output_highlight_rules.js b/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/output_highlight_rules.js
index 435761e26d7a..920bdff1798d 100644
--- a/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/output_highlight_rules.js
+++ b/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/output_highlight_rules.js
@@ -25,26 +25,24 @@ const oop = ace.acequire('ace/lib/oop');
const JsonHighlightRules = ace.acequire('ace/mode/json_highlight_rules').JsonHighlightRules;
export function OutputJsonHighlightRules() {
-
this.$rules = {};
addToRules(this, 'start');
this.$rules.start.unshift(
{
- 'token': 'warning',
- 'regex': '#!.*$'
+ token: 'warning',
+ regex: '#!.*$',
},
{
- 'token': 'comment',
- 'regex': '#.*$'
+ token: 'comment',
+ regex: '#.*$',
}
);
if (this.constructor === OutputJsonHighlightRules) {
this.normalizeRules();
}
-
}
oop.inherits(OutputJsonHighlightRules, JsonHighlightRules);
diff --git a/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/script.js b/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/script.js
index 1e3766653bdb..b6b74c637723 100644
--- a/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/script.js
+++ b/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/script.js
@@ -37,11 +37,10 @@ export function ScriptMode() {
oop.inherits(ScriptMode, TextMode);
-(function () {
-
+(function() {
this.HighlightRules = ScriptHighlightRules;
- this.getNextLineIndent = function (state, line, tab) {
+ this.getNextLineIndent = function(state, line, tab) {
let indent = this.$getIndent(line);
const match = line.match(/^.*[\{\[]\s*$/);
if (match) {
@@ -51,11 +50,11 @@ oop.inherits(ScriptMode, TextMode);
return indent;
};
- this.checkOutdent = function (state, line, input) {
+ this.checkOutdent = function(state, line, input) {
return this.$outdent.checkOutdent(line, input);
};
- this.autoOutdent = function (state, doc, row) {
+ this.autoOutdent = function(state, doc, row) {
this.$outdent.autoOutdent(doc, row);
};
@@ -63,7 +62,6 @@ oop.inherits(ScriptMode, TextMode);
// const worker = new WorkerClient(['ace', 'sense_editor'], 'sense_editor/mode/worker', 'SenseWorker', 'sense_editor/mode/worker');
// worker.attachToDocument(session.getDocument());
-
// worker.on('error', function (e) {
// session.setAnnotations([e.data]);
// });
@@ -74,6 +72,4 @@ oop.inherits(ScriptMode, TextMode);
// return worker;
// };
-
-
-}).call(ScriptMode.prototype);
+}.call(ScriptMode.prototype));
diff --git a/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/script_highlight_rules.js b/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/script_highlight_rules.js
index 997a23d144ac..b38c61c046db 100644
--- a/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/script_highlight_rules.js
+++ b/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/script_highlight_rules.js
@@ -17,68 +17,67 @@
* under the License.
*/
-
const ace = require('brace');
const oop = ace.acequire('ace/lib/oop');
const { TextHighlightRules } = ace.acequire('ace/mode/text_highlight_rules');
-const 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'
-);
+const 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 function ScriptHighlightRules() {
this.name = 'ScriptHighlightRules';
this.$rules = {
- 'start': [
+ start: [
{
token: 'script.comment',
- regex: '\\/\\/.*$'
+ regex: '\\/\\/.*$',
},
{
token: 'script.string.regexp',
- regex: '[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)'
+ regex: '[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)',
},
{
token: 'script.string', // single line
- regex: '[\'](?:(?:\\\\.)|(?:[^\'\\\\]))*?[\']'
+ regex: "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']",
},
{
token: 'script.constant.numeric', // hex
- regex: '0[xX][0-9a-fA-F]+\\b'
+ regex: '0[xX][0-9a-fA-F]+\\b',
},
{
token: 'script.constant.numeric', // float
- regex: '[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b'
+ regex: '[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b',
},
{
token: 'script.constant.language.boolean',
- regex: '(?:true|false)\\b'
+ regex: '(?:true|false)\\b',
},
{
token: 'script.keyword',
- regex: painlessKeywords
+ regex: painlessKeywords,
},
{
token: 'script.text',
- regex: '[a-zA-Z_$][a-zA-Z0-9_$]*\\b'
+ regex: '[a-zA-Z_$][a-zA-Z0-9_$]*\\b',
},
{
token: 'script.keyword.operator',
// eslint-disable-next-line max-len
- regex: '\\?\\.|\\*\\.|=~|==~|!|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|->|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|typeof|void)'
+ regex:
+ '\\?\\.|\\*\\.|=~|==~|!|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|->|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|typeof|void)',
},
{
token: 'script.lparen',
- regex: '[[({]'
+ regex: '[[({]',
},
{
token: 'script.rparen',
- regex: '[\\])}]'
+ regex: '[\\])}]',
},
{
token: 'script.text',
- regex: '\\s+'
- }
- ]
+ regex: '\\s+',
+ },
+ ],
};
}
diff --git a/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/worker/index.js b/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/worker/index.js
index 3d5a719b9fd1..b13ee7ca572a 100644
--- a/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/worker/index.js
+++ b/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/worker/index.js
@@ -21,5 +21,5 @@ import src from '!!raw-loader!./worker.js';
export const workerModule = {
id: 'sense_editor/mode/worker',
- src
+ src,
};
diff --git a/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/x_json_highlight_rules.js b/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/x_json_highlight_rules.js
index 28453a409bf2..aaef050ddeed 100644
--- a/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/x_json_highlight_rules.js
+++ b/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/x_json_highlight_rules.js
@@ -20,111 +20,119 @@
const _ = require('lodash');
const ScriptHighlightRules = require('./script_highlight_rules').ScriptHighlightRules;
-const jsonRules = function (root) {
+const jsonRules = function(root) {
root = root ? root : 'json';
const rules = {};
rules[root] = [
{
- token: ['variable', 'whitespace', 'ace.punctuation.colon', 'whitespace', 'punctuation.start_triple_quote'],
+ token: [
+ 'variable',
+ 'whitespace',
+ 'ace.punctuation.colon',
+ 'whitespace',
+ 'punctuation.start_triple_quote',
+ ],
regex: '("(?:[^"]*_)?script"|"inline"|"source")(\\s*?)(:)(\\s*?)(""")',
next: 'script-start',
merge: false,
- push: true
+ push: true,
},
{
token: 'variable', // single line
- regex: '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]\\s*(?=:)'
+ regex: '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]\\s*(?=:)',
},
{
token: 'punctuation.start_triple_quote',
regex: '"""',
next: 'string_literal',
merge: false,
- push: true
+ push: true,
},
{
token: 'string', // single line
- regex: '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
+ regex: '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]',
},
{
token: 'constant.numeric', // hex
- regex: '0[xX][0-9a-fA-F]+\\b'
+ regex: '0[xX][0-9a-fA-F]+\\b',
},
{
token: 'constant.numeric', // float
- regex: '[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b'
+ regex: '[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b',
},
{
token: 'constant.language.boolean',
- regex: '(?:true|false)\\b'
+ regex: '(?:true|false)\\b',
},
{
token: 'invalid.illegal', // single quoted strings are not allowed
- regex: '[\'](?:(?:\\\\.)|(?:[^\'\\\\]))*?[\']'
+ regex: "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']",
},
{
token: 'invalid.illegal', // comments are not allowed
- regex: '\\/\\/.*$'
+ regex: '\\/\\/.*$',
},
{
token: 'paren.lparen',
merge: false,
regex: '{',
next: root,
- push: true
+ push: true,
},
{
token: 'paren.lparen',
merge: false,
- regex: '[[(]'
+ regex: '[[(]',
},
{
token: 'paren.rparen',
merge: false,
- regex: '[\\])]'
+ regex: '[\\])]',
},
{
token: 'paren.rparen',
regex: '}',
merge: false,
- next: 'pop'
+ next: 'pop',
},
{
token: 'punctuation.comma',
- regex: ','
+ regex: ',',
},
{
token: 'punctuation.colon',
- regex: ':'
+ regex: ':',
},
{
token: 'whitespace',
- regex: '\\s+'
+ regex: '\\s+',
},
{
token: 'text',
- regex: '.+?'
- }
+ regex: '.+?',
+ },
];
rules.string_literal = [
{
token: 'punctuation.end_triple_quote',
regex: '"""',
- next: 'pop'
+ next: 'pop',
},
{
token: 'multi_string',
- regex: '.'
- }
+ regex: '.',
+ },
];
return rules;
};
export function addToRules(otherRules, embedUnder) {
otherRules.$rules = _.defaultsDeep(otherRules.$rules, jsonRules(embedUnder));
- otherRules.embedRules(ScriptHighlightRules, 'script-', [{
- token: 'punctuation.end_triple_quote',
- regex: '"""',
- next: 'pop',
- }]);
+ otherRules.embedRules(ScriptHighlightRules, 'script-', [
+ {
+ token: 'punctuation.end_triple_quote',
+ regex: '"""',
+ next: 'pop',
+ },
+ ]);
}
diff --git a/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/theme_sense_dark.js b/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/theme_sense_dark.js
index 045f1042febe..2e91845ac2e7 100644
--- a/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/theme_sense_dark.js
+++ b/src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/theme_sense_dark.js
@@ -21,11 +21,11 @@
/* eslint max-len: 0 */
const ace = require('brace');
-ace.define('ace/theme/sense-dark', ['require', 'exports', 'module'],
- function (require, exports) {
- exports.isDark = true;
- exports.cssClass = 'ace-sense-dark';
- exports.cssText = '.ace-sense-dark .ace_gutter {\
+ace.define('ace/theme/sense-dark', ['require', 'exports', 'module'], function(require, exports) {
+ exports.isDark = true;
+ exports.cssClass = 'ace-sense-dark';
+ exports.cssText =
+ '.ace-sense-dark .ace_gutter {\
background: #2e3236;\
color: #bbbfc2;\
}\
@@ -130,7 +130,6 @@ text-decoration: underline\
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWNQ11D6z7Bq1ar/ABCKBG6g04U2AAAAAElFTkSuQmCC) right repeat-y\
}';
- const dom = require('ace/lib/dom');
- dom.importCssString(exports.cssText, exports.cssClass);
- });
-
+ const dom = require('ace/lib/dom');
+ dom.importCssString(exports.cssText, exports.cssClass);
+});
diff --git a/src/legacy/core_plugins/console/public/np_ready/application/models/sense_editor/__tests__/integration.test.js b/src/legacy/core_plugins/console/public/np_ready/application/models/sense_editor/__tests__/integration.test.js
index 0950992f1c0f..1a09b6b00da9 100644
--- a/src/legacy/core_plugins/console/public/np_ready/application/models/sense_editor/__tests__/integration.test.js
+++ b/src/legacy/core_plugins/console/public/np_ready/application/models/sense_editor/__tests__/integration.test.js
@@ -41,7 +41,7 @@ describe('Integration', () => {
});
function processContextTest(data, mapping, kbSchemes, requestLine, testToRun) {
- test(testToRun.name, async function (done) {
+ test(testToRun.name, async function(done) {
let lineOffset = 0; // add one for the extra method line
let editorValue = data;
if (requestLine != null) {
@@ -61,13 +61,13 @@ describe('Integration', () => {
json[test.name] = kbSchemes || {};
const testApi = kb._test.loadApisFromJson(json);
if (kbSchemes) {
- // if (kbSchemes.globals) {
- // $.each(kbSchemes.globals, function (parent, rules) {
- // testApi.addGlobalAutocompleteRules(parent, rules);
- // });
- // }
+ // if (kbSchemes.globals) {
+ // $.each(kbSchemes.globals, function (parent, rules) {
+ // testApi.addGlobalAutocompleteRules(parent, rules);
+ // });
+ // }
if (kbSchemes.endpoints) {
- $.each(kbSchemes.endpoints, function (endpoint, scheme) {
+ $.each(kbSchemes.endpoints, function(endpoint, scheme) {
testApi.addEndpointDescription(endpoint, scheme);
});
}
@@ -81,7 +81,7 @@ describe('Integration', () => {
//setTimeout(function () {
senseEditor.completer = {
base: {},
- changeListener: function () {},
+ changeListener: function() {},
}; // mimic auto complete
senseEditor.autocomplete._test.getCompletions(
@@ -89,7 +89,7 @@ describe('Integration', () => {
null,
{ row: cursor.lineNumber - 1, column: cursor.column - 1 },
'',
- function (err, terms) {
+ function(err, terms) {
if (testToRun.assertThrows) {
done();
return;
@@ -112,7 +112,7 @@ describe('Integration', () => {
}
if (testToRun.autoCompleteSet) {
- const expectedTerms = _.map(testToRun.autoCompleteSet, function (t) {
+ const expectedTerms = _.map(testToRun.autoCompleteSet, function(t) {
if (typeof t !== 'object') {
t = { name: t };
}
@@ -121,13 +121,10 @@ describe('Integration', () => {
if (terms.length !== expectedTerms.length) {
expect(_.pluck(terms, 'name')).toEqual(_.pluck(expectedTerms, 'name'));
} else {
- const filteredActualTerms = _.map(terms, function (
- actualTerm,
- i
- ) {
+ const filteredActualTerms = _.map(terms, function(actualTerm, i) {
const expectedTerm = expectedTerms[i];
const filteredTerm = {};
- _.each(expectedTerm, function (v, p) {
+ _.each(expectedTerm, function(v, p) {
filteredTerm[p] = actualTerm[p];
});
return filteredTerm;
@@ -137,7 +134,9 @@ describe('Integration', () => {
}
const context = terms[0].context;
- const { cursor: { lineNumber, column } } = testToRun;
+ const {
+ cursor: { lineNumber, column },
+ } = testToRun;
senseEditor.autocomplete._test.addReplacementInfoToContext(
context,
{ lineNumber, column },
@@ -396,7 +395,6 @@ describe('Integration', () => {
]
);
-
contextTests(
{
object: 1,
@@ -562,7 +560,6 @@ describe('Integration', () => {
]
);
-
contextTests(
{
string: 'value',
@@ -745,7 +742,7 @@ describe('Integration', () => {
},
],
g: {
- __scope_link: function () {
+ __scope_link: function() {
return {
a: 1,
b: 2,
@@ -1029,13 +1026,7 @@ describe('Integration', () => {
{
name: 'Endpoints with slashes - no slash',
cursor: { lineNumber: 1, column: 9 },
- autoCompleteSet: [
- '_cluster/nodes/stats',
- '_cluster/stats',
- '_search',
- 'index1',
- 'index2',
- ],
+ autoCompleteSet: ['_cluster/nodes/stats', '_cluster/stats', '_search', 'index1', 'index2'],
prefixToAdd: '',
suffixToAdd: '',
},
@@ -1045,26 +1036,14 @@ describe('Integration', () => {
{
name: 'Endpoints with slashes - before slash',
cursor: { lineNumber: 1, column: 8 },
- autoCompleteSet: [
- '_cluster/nodes/stats',
- '_cluster/stats',
- '_search',
- 'index1',
- 'index2',
- ],
+ autoCompleteSet: ['_cluster/nodes/stats', '_cluster/stats', '_search', 'index1', 'index2'],
prefixToAdd: '',
suffixToAdd: '',
},
{
name: 'Endpoints with slashes - on slash',
cursor: { lineNumber: 1, column: 13 },
- autoCompleteSet: [
- '_cluster/nodes/stats',
- '_cluster/stats',
- '_search',
- 'index1',
- 'index2',
- ],
+ autoCompleteSet: ['_cluster/nodes/stats', '_cluster/stats', '_search', 'index1', 'index2'],
prefixToAdd: '',
suffixToAdd: '',
},
@@ -1133,7 +1112,7 @@ describe('Integration', () => {
prefixToAdd: '',
suffixToAdd: '',
initialValue: 'cl',
- method: 'GET'
+ method: 'GET',
},
]);
@@ -1213,51 +1192,39 @@ describe('Integration', () => {
},
]);
- contextTests(
- null,
- MAPPING,
- CLUSTER_KB,
- 'GET _search?format=yaml&search_type=cou',
- [
- {
- name: 'Params on existing value',
- cursor: { lineNumber: 1, column: 38 },
- rangeToReplace: {
- start: { lineNumber: 1, column: 37 },
- end: { lineNumber: 1, column: 40 },
- },
- autoCompleteSet: [
- { name: 'count', meta: 'search_type' },
- { name: 'query_then_fetch', meta: 'search_type' },
- ],
- prefixToAdd: '',
- suffixToAdd: '',
+ contextTests(null, MAPPING, CLUSTER_KB, 'GET _search?format=yaml&search_type=cou', [
+ {
+ name: 'Params on existing value',
+ cursor: { lineNumber: 1, column: 38 },
+ rangeToReplace: {
+ start: { lineNumber: 1, column: 37 },
+ end: { lineNumber: 1, column: 40 },
},
- ]
- );
+ autoCompleteSet: [
+ { name: 'count', meta: 'search_type' },
+ { name: 'query_then_fetch', meta: 'search_type' },
+ ],
+ prefixToAdd: '',
+ suffixToAdd: '',
+ },
+ ]);
- contextTests(
- null,
- MAPPING,
- CLUSTER_KB,
- 'GET _search?format=yaml&search_type=cou',
- [
- {
- name: 'Params on just after = with existing value',
- cursor: { lineNumber: 1, column: 37 },
- rangeToReplace: {
- start: { lineNumber: 1, column: 37 },
- end: { lineNumber: 1, column: 37 },
- },
- autoCompleteSet: [
- { name: 'count', meta: 'search_type' },
- { name: 'query_then_fetch', meta: 'search_type' },
- ],
- prefixToAdd: '',
- suffixToAdd: '',
+ contextTests(null, MAPPING, CLUSTER_KB, 'GET _search?format=yaml&search_type=cou', [
+ {
+ name: 'Params on just after = with existing value',
+ cursor: { lineNumber: 1, column: 37 },
+ rangeToReplace: {
+ start: { lineNumber: 1, column: 37 },
+ end: { lineNumber: 1, column: 37 },
},
- ]
- );
+ autoCompleteSet: [
+ { name: 'count', meta: 'search_type' },
+ { name: 'query_then_fetch', meta: 'search_type' },
+ ],
+ prefixToAdd: '',
+ suffixToAdd: '',
+ },
+ ]);
contextTests(
{
diff --git a/src/legacy/core_plugins/console/public/np_ready/application/models/sense_editor/__tests__/sense_editor.test.js b/src/legacy/core_plugins/console/public/np_ready/application/models/sense_editor/__tests__/sense_editor.test.js
index ae66b1aa8e75..a66bc20685df 100644
--- a/src/legacy/core_plugins/console/public/np_ready/application/models/sense_editor/__tests__/sense_editor.test.js
+++ b/src/legacy/core_plugins/console/public/np_ready/application/models/sense_editor/__tests__/sense_editor.test.js
@@ -28,29 +28,26 @@ const utils = require('../../../../lib/utils/utils');
describe('Editor', () => {
let input;
- beforeEach(function () {
+ beforeEach(function() {
// Set up our document body
- document.body.innerHTML =
- `
+ document.body.innerHTML = `
`;
- input = create(
- document.querySelector('#ConAppEditor')
- );
+ input = create(document.querySelector('#ConAppEditor'));
$(input.getCoreEditor().getContainer()).show();
input.autocomplete._test.removeChangeListener();
});
- afterEach(function () {
+ afterEach(function() {
$(input.getCoreEditor().getContainer()).hide();
input.autocomplete._test.addChangeListener();
});
let testCount = 0;
- const callWithEditorMethod = (editorMethod, fn) => async (done) => {
+ const callWithEditorMethod = (editorMethod, fn) => async done => {
const results = await input[editorMethod]();
fn(results, done);
};
@@ -72,7 +69,7 @@ describe('Editor', () => {
data = prefix;
}
- test('Utils test ' + id + ' : ' + name, async function (done) {
+ test('Utils test ' + id + ' : ' + name, async function(done) {
await input.update(data, true);
testToRun(done);
});
@@ -84,7 +81,7 @@ describe('Editor', () => {
expected = [expected];
}
- _.each(requests, function (r) {
+ _.each(requests, function(r) {
delete r.range;
});
expect(requests).toEqual(expected);
@@ -106,10 +103,7 @@ describe('Editor', () => {
const multiDocRequest = {
prefix: 'POST _bulk',
- data_as_array: [
- '{ "index": { "_index": "index", "_type":"type" } }',
- '{ "field": 1 }',
- ],
+ data_as_array: ['{ "index": { "_index": "index", "_type":"type" } }', '{ "field": 1 }'],
};
multiDocRequest.data = multiDocRequest.data_as_array.join('\n');
@@ -118,7 +112,10 @@ describe('Editor', () => {
simpleRequest.prefix,
simpleRequest.data,
callWithEditorMethod('getRequestRange', (range, done) => {
- compareRequest(range, { start: { lineNumber: 1, column: 1 }, end: { lineNumber: 4, column: 2 } });
+ compareRequest(range, {
+ start: { lineNumber: 1, column: 1 },
+ end: { lineNumber: 4, column: 2 },
+ });
done();
})
);
@@ -145,7 +142,7 @@ describe('Editor', () => {
callWithEditorMethod('getRequestRange', (range, done) => {
expect(range).toEqual({
start: { lineNumber: 1, column: 1 },
- end: { lineNumber: 4, column: 2 }
+ end: { lineNumber: 4, column: 2 },
});
done();
})
@@ -167,7 +164,6 @@ describe('Editor', () => {
})
);
-
utilsTest(
'simple request range, suffixed with spaces',
simpleRequest.prefix + ' ',
@@ -175,7 +171,7 @@ describe('Editor', () => {
callWithEditorMethod('getRequestRange', (range, done) => {
compareRequest(range, {
start: { lineNumber: 1, column: 1 },
- end: { lineNumber: 4, column: 2 }
+ end: { lineNumber: 4, column: 2 },
});
done();
})
@@ -197,7 +193,6 @@ describe('Editor', () => {
})
);
-
utilsTest(
'single line request range',
singleLineRequest.prefix,
@@ -205,7 +200,7 @@ describe('Editor', () => {
callWithEditorMethod('getRequestRange', (range, done) => {
compareRequest(range, {
start: { lineNumber: 1, column: 1 },
- end: { lineNumber: 2, column: 33 }
+ end: { lineNumber: 2, column: 33 },
});
done();
})
@@ -312,13 +307,7 @@ describe('Editor', () => {
const scriptRequest = {
prefix: 'POST _search',
- data: [
- '{',
- ' "query": { "script": """',
- ' some script ',
- ' """}',
- '}',
- ].join('\n'),
+ data: ['{', ' "query": { "script": """', ' some script ', ' """}', '}'].join('\n'),
};
utilsTest(
@@ -334,7 +323,6 @@ describe('Editor', () => {
})
);
-
utilsTest(
'simple request data',
simpleRequest.prefix,
@@ -352,12 +340,11 @@ describe('Editor', () => {
);
function multiReqTest(name, editorInput, range, expected) {
- utilsTest('multi request select - ' + name, editorInput, async function (done) {
+ utilsTest('multi request select - ' + name, editorInput, async function(done) {
const requests = await input.getRequestsInRange(range, false);
// convert to format returned by request.
- _.each(expected, function (req) {
- req.data =
- req.data == null ? [] : [JSON.stringify(req.data, null, 2)];
+ _.each(expected, function(req) {
+ req.data = req.data == null ? [] : [JSON.stringify(req.data, null, 2)];
});
compareRequest(requests, expected);
@@ -464,7 +451,7 @@ describe('Editor', () => {
);
function multiReqCopyAsCurlTest(name, editorInput, range, expected) {
- utilsTest('multi request copy as curl - ' + name, editorInput, async function (done) {
+ utilsTest('multi request copy as curl - ' + name, editorInput, async function(done) {
const curl = await input.getRequestsAsCURL('http://localhost:9200', range);
expect(curl).toEqual(expected);
done();
diff --git a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/__tests__/url_autocomplete.test.js b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/__tests__/url_autocomplete.test.js
index 77c211a71d98..40fcd551fb6f 100644
--- a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/__tests__/url_autocomplete.test.js
+++ b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/__tests__/url_autocomplete.test.js
@@ -22,35 +22,26 @@ const _ = require('lodash');
import {
URL_PATH_END_MARKER,
UrlPatternMatcher,
- ListComponent
+ ListComponent,
} from '../../autocomplete/components';
import { populateContext } from '../../autocomplete/engine';
describe('Url autocomplete', () => {
- function patternsTest(
- name,
- endpoints,
- tokenPath,
- expectedContext,
- globalUrlComponentFactories
- ) {
- test(name, function () {
+ function patternsTest(name, endpoints, tokenPath, expectedContext, globalUrlComponentFactories) {
+ test(name, function() {
const patternMatcher = new UrlPatternMatcher(globalUrlComponentFactories);
- _.each(endpoints, function (e, id) {
+ _.each(endpoints, function(e, id) {
e.id = id;
- _.each(e.patterns, function (p) {
+ _.each(e.patterns, function(p) {
patternMatcher.addEndpoint(p, e);
});
});
if (typeof tokenPath === 'string') {
if (tokenPath[tokenPath.length - 1] === '$') {
- tokenPath =
- tokenPath.substr(0, tokenPath.length - 1) +
- '/' +
- URL_PATH_END_MARKER;
+ tokenPath = tokenPath.substr(0, tokenPath.length - 1) + '/' + URL_PATH_END_MARKER;
}
- tokenPath = _.map(tokenPath.split('/'), function (p) {
+ tokenPath = _.map(tokenPath.split('/'), function(p) {
p = p.split(',');
if (p.length === 1) {
return p[0];
@@ -60,19 +51,13 @@ describe('Url autocomplete', () => {
}
if (expectedContext.autoCompleteSet) {
- expectedContext.autoCompleteSet = _.map(
- expectedContext.autoCompleteSet,
- function (t) {
- if (_.isString(t)) {
- t = { name: t };
- }
- return t;
+ expectedContext.autoCompleteSet = _.map(expectedContext.autoCompleteSet, function(t) {
+ if (_.isString(t)) {
+ t = { name: t };
}
- );
- expectedContext.autoCompleteSet = _.sortBy(
- expectedContext.autoCompleteSet,
- 'name'
- );
+ return t;
+ });
+ expectedContext.autoCompleteSet = _.sortBy(expectedContext.autoCompleteSet, 'name');
}
const context = {};
@@ -107,76 +92,64 @@ describe('Url autocomplete', () => {
return name;
}
- (function () {
+ (function() {
const endpoints = {
'1': {
patterns: ['a/b'],
- methods: ['GET']
+ methods: ['GET'],
},
};
patternsTest('simple single path - completion', endpoints, 'a/b$', {
endpoint: '1',
- method: 'GET'
+ method: 'GET',
});
- patternsTest(
- 'simple single path - completion, with auto complete',
- endpoints,
- 'a/b',
- { method: 'GET', autoCompleteSet: [] }
- );
+ patternsTest('simple single path - completion, with auto complete', endpoints, 'a/b', {
+ method: 'GET',
+ autoCompleteSet: [],
+ });
- patternsTest(
- 'simple single path - partial, without auto complete',
- endpoints,
- 'a',
- {}
- );
+ patternsTest('simple single path - partial, without auto complete', endpoints, 'a', {});
- patternsTest(
- 'simple single path - partial, with auto complete',
- endpoints,
- 'a',
- { method: 'GET', autoCompleteSet: ['b'] }
- );
+ patternsTest('simple single path - partial, with auto complete', endpoints, 'a', {
+ method: 'GET',
+ autoCompleteSet: ['b'],
+ });
- patternsTest(
- 'simple single path - partial, with auto complete',
- endpoints,
- [],
- { method: 'GET', autoCompleteSet: ['a/b'] }
- );
+ patternsTest('simple single path - partial, with auto complete', endpoints, [], {
+ method: 'GET',
+ autoCompleteSet: ['a/b'],
+ });
patternsTest('simple single path - different path', endpoints, 'a/c', {});
- }());
+ })();
- (function () {
+ (function() {
const endpoints = {
'1': {
patterns: ['a/b', 'a/b/{p}'],
- methods: ['GET']
+ methods: ['GET'],
},
'2': {
patterns: ['a/c'],
- methods: ['GET']
+ methods: ['GET'],
},
};
patternsTest('shared path - completion 1', endpoints, 'a/b$', {
endpoint: '1',
- method: 'GET'
+ method: 'GET',
});
patternsTest('shared path - completion 2', endpoints, 'a/c$', {
endpoint: '2',
- method: 'GET'
+ method: 'GET',
});
- patternsTest(
- 'shared path - completion 1 with param',
- endpoints,
- 'a/b/v$',
- { method: 'GET', endpoint: '1', p: 'v' }
- );
+ patternsTest('shared path - completion 1 with param', endpoints, 'a/b/v$', {
+ method: 'GET',
+ endpoint: '1',
+ p: 'v',
+ });
patternsTest('shared path - partial, with auto complete', endpoints, 'a', {
autoCompleteSet: ['b', 'c'],
@@ -190,40 +163,30 @@ describe('Url autocomplete', () => {
{ method: 'GET', autoCompleteSet: [] }
);
- patternsTest(
- 'shared path - partial, without auto complete',
- endpoints,
- 'a',
- { method: 'GET', }
- );
+ patternsTest('shared path - partial, without auto complete', endpoints, 'a', { method: 'GET' });
- patternsTest(
- 'shared path - different path - with auto complete',
- endpoints,
- 'a/e',
- { method: 'GET', autoCompleteSet: [] }
- );
+ patternsTest('shared path - different path - with auto complete', endpoints, 'a/e', {
+ method: 'GET',
+ autoCompleteSet: [],
+ });
- patternsTest(
- 'shared path - different path - without auto complete',
- endpoints,
- 'a/e',
- { method: 'GET', }
- );
- }());
+ patternsTest('shared path - different path - without auto complete', endpoints, 'a/e', {
+ method: 'GET',
+ });
+ })();
- (function () {
+ (function() {
const endpoints = {
'1': {
patterns: ['a/{p}'],
url_components: {
p: ['a', 'b'],
},
- methods: [ 'GET' ]
+ methods: ['GET'],
},
'2': {
patterns: ['a/c'],
- methods: [ 'GET' ]
+ methods: ['GET'],
},
};
patternsTest('option testing - completion 1', endpoints, 'a/a$', {
@@ -249,46 +212,39 @@ describe('Url autocomplete', () => {
endpoint: '2',
});
- patternsTest('option testing - completion 5', endpoints, 'a/d$', { method: 'GET', });
+ patternsTest('option testing - completion 5', endpoints, 'a/d$', { method: 'GET' });
- patternsTest(
- 'option testing - partial, with auto complete',
- endpoints,
- 'a',
- { method: 'GET', autoCompleteSet: [t('a', 'p'), t('b', 'p'), 'c'] }
- );
+ patternsTest('option testing - partial, with auto complete', endpoints, 'a', {
+ method: 'GET',
+ autoCompleteSet: [t('a', 'p'), t('b', 'p'), 'c'],
+ });
- patternsTest(
- 'option testing - partial, without auto complete',
- endpoints,
- 'a',
- { method: 'GET', }
- );
+ patternsTest('option testing - partial, without auto complete', endpoints, 'a', {
+ method: 'GET',
+ });
- patternsTest(
- 'option testing - different path - with auto complete',
- endpoints,
- 'a/e',
- { method: 'GET', autoCompleteSet: [] }
- );
- }());
+ patternsTest('option testing - different path - with auto complete', endpoints, 'a/e', {
+ method: 'GET',
+ autoCompleteSet: [],
+ });
+ })();
- (function () {
+ (function() {
const endpoints = {
'1': {
patterns: ['a/{p}'],
url_components: {
p: ['a', 'b'],
},
- methods: [ 'GET' ]
+ methods: ['GET'],
},
'2': {
patterns: ['b/{p}'],
- methods: [ 'GET' ]
+ methods: ['GET'],
},
'3': {
patterns: ['b/{l}/c'],
- methods: [ 'GET' ],
+ methods: ['GET'],
url_components: {
l: {
type: 'list',
@@ -299,12 +255,12 @@ describe('Url autocomplete', () => {
},
};
const globalFactories = {
- p: function (name, parent) {
+ p: function(name, parent) {
return new ListComponent(name, ['g1', 'g2'], parent);
},
getComponent(name) {
return this[name];
- }
+ },
};
patternsTest(
@@ -337,12 +293,7 @@ describe('Url autocomplete', () => {
'b',
{
method: 'GET',
- autoCompleteSet: [
- t('g1', 'p'),
- t('g2', 'p'),
- t('la', 'l'),
- t('lb', 'l'),
- ],
+ autoCompleteSet: [t('g1', 'p'), t('g2', 'p'), t('la', 'l'), t('lb', 'l')],
},
globalFactories
);
@@ -361,13 +312,13 @@ describe('Url autocomplete', () => {
{ method: 'GET', autoCompleteSet: ['c'], l: ['non_valid'] },
globalFactories
);
- }());
+ })();
- (function () {
+ (function() {
const endpoints = {
'1': {
patterns: ['a/b/{p}/c/e'],
- methods: [ 'GET' ]
+ methods: ['GET'],
},
};
patternsTest('look ahead - autocomplete before param 1', endpoints, 'a', {
@@ -380,22 +331,20 @@ describe('Url autocomplete', () => {
autoCompleteSet: ['a/b'],
});
- patternsTest(
- 'look ahead - autocomplete after param 1',
- endpoints,
- 'a/b/v',
- { method: 'GET', autoCompleteSet: ['c/e'], p: 'v' }
- );
+ patternsTest('look ahead - autocomplete after param 1', endpoints, 'a/b/v', {
+ method: 'GET',
+ autoCompleteSet: ['c/e'],
+ p: 'v',
+ });
- patternsTest(
- 'look ahead - autocomplete after param 2',
- endpoints,
- 'a/b/v/c',
- { method: 'GET', autoCompleteSet: ['e'], p: 'v' }
- );
- }());
+ patternsTest('look ahead - autocomplete after param 2', endpoints, 'a/b/v/c', {
+ method: 'GET',
+ autoCompleteSet: ['e'],
+ p: 'v',
+ });
+ })();
- (function () {
+ (function() {
const endpoints = {
'1_param': {
patterns: ['a/{p}'],
@@ -428,9 +377,9 @@ describe('Url autocomplete', () => {
method: 'GET',
endpoint: '2_explicit',
});
- }());
+ })();
- (function () {
+ (function() {
const endpoints = {
'1_GET': {
patterns: ['a'],
@@ -449,30 +398,21 @@ describe('Url autocomplete', () => {
methods: ['DELETE'],
},
};
- patternsTest(
- 'Competing endpoint - sub url of another - auto complete',
- endpoints,
- 'a',
- { method: 'GET', autoCompleteSet: ['b'] }
- );
- patternsTest(
- 'Competing endpoint - sub url of another, complete 1',
- endpoints,
- 'a$',
- { method: 'GET', endpoint: '1_GET' }
- );
- patternsTest(
- 'Competing endpoint - sub url of another, complete 2',
- endpoints,
- 'a$',
- { method: 'PUT', endpoint: '1_PUT' }
- );
- patternsTest(
- 'Competing endpoint - sub url of another, complete 3',
- endpoints,
- 'a$',
- { method: 'DELETE' }
- );
+ patternsTest('Competing endpoint - sub url of another - auto complete', endpoints, 'a', {
+ method: 'GET',
+ autoCompleteSet: ['b'],
+ });
+ patternsTest('Competing endpoint - sub url of another, complete 1', endpoints, 'a$', {
+ method: 'GET',
+ endpoint: '1_GET',
+ });
+ patternsTest('Competing endpoint - sub url of another, complete 2', endpoints, 'a$', {
+ method: 'PUT',
+ endpoint: '1_PUT',
+ });
+ patternsTest('Competing endpoint - sub url of another, complete 3', endpoints, 'a$', {
+ method: 'DELETE',
+ });
patternsTest(
'Competing endpoint - extension of another, complete 1, auto complete',
@@ -481,24 +421,17 @@ describe('Url autocomplete', () => {
{ method: 'PUT', autoCompleteSet: [] }
);
- patternsTest(
- 'Competing endpoint - extension of another, complete 1',
- endpoints,
- 'a/b$',
- { method: 'GET', endpoint: '2_GET' }
- );
+ patternsTest('Competing endpoint - extension of another, complete 1', endpoints, 'a/b$', {
+ method: 'GET',
+ endpoint: '2_GET',
+ });
- patternsTest(
- 'Competing endpoint - extension of another, complete 1',
- endpoints,
- 'a/b$',
- { method: 'DELETE', endpoint: '2_DELETE' }
- );
- patternsTest(
- 'Competing endpoint - extension of another, complete 1',
- endpoints,
- 'a/b$',
- { method: 'PUT' }
- );
- }());
+ patternsTest('Competing endpoint - extension of another, complete 1', endpoints, 'a/b$', {
+ method: 'DELETE',
+ endpoint: '2_DELETE',
+ });
+ patternsTest('Competing endpoint - extension of another, complete 1', endpoints, 'a/b$', {
+ method: 'PUT',
+ });
+ })();
});
diff --git a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/__tests__/url_params.test.js b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/__tests__/url_params.test.js
index b91c463bb14f..ce2a2553b19e 100644
--- a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/__tests__/url_params.test.js
+++ b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/__tests__/url_params.test.js
@@ -25,17 +25,11 @@ import { UrlParams } from '../../autocomplete/url_params';
import { populateContext } from '../../autocomplete/engine';
describe('Url params', () => {
- function paramTest(
- name,
- description,
- tokenPath,
- expectedContext,
- globalParams
- ) {
- test(name, function () {
+ function paramTest(name, description, tokenPath, expectedContext, globalParams) {
+ test(name, function() {
const urlParams = new UrlParams(description, globalParams || {});
if (typeof tokenPath === 'string') {
- tokenPath = _.map(tokenPath.split('/'), function (p) {
+ tokenPath = _.map(tokenPath.split('/'), function(p) {
p = p.split(',');
if (p.length === 1) {
return p[0];
@@ -45,19 +39,13 @@ describe('Url params', () => {
}
if (expectedContext.autoCompleteSet) {
- expectedContext.autoCompleteSet = _.map(
- expectedContext.autoCompleteSet,
- function (t) {
- if (_.isString(t)) {
- t = { name: t };
- }
- return t;
+ expectedContext.autoCompleteSet = _.map(expectedContext.autoCompleteSet, function(t) {
+ if (_.isString(t)) {
+ t = { name: t };
}
- );
- expectedContext.autoCompleteSet = _.sortBy(
- expectedContext.autoCompleteSet,
- 'name'
- );
+ return t;
+ });
+ expectedContext.autoCompleteSet = _.sortBy(expectedContext.autoCompleteSet, 'name');
}
const context = {};
@@ -95,7 +83,7 @@ describe('Url params', () => {
return r;
}
- (function () {
+ (function() {
const params = {
a: ['1', '2'],
b: '__flag__',
@@ -123,5 +111,5 @@ describe('Url params', () => {
paramTest('autocomplete values flag', params, 'b', {
autoCompleteSet: [t('true', 'b'), t('false', 'b')],
});
- }());
+ })();
});
diff --git a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/body_completer.js b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/body_completer.js
index 567971b8c350..e23a58780a36 100644
--- a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/body_completer.js
+++ b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/body_completer.js
@@ -44,9 +44,13 @@ function CompilingContext(endpointId, parametrizedComponentFactories) {
* which should return the top level components for the given endpoint
*/
-
function resolvePathToComponents(tokenPath, context, editor, components) {
- const walkStates = walkTokenPath(tokenPath, [new WalkingState('ROOT', components, [])], context, editor);
+ const walkStates = walkTokenPath(
+ tokenPath,
+ [new WalkingState('ROOT', components, [])],
+ context,
+ editor
+ );
const result = [].concat.apply([], _.pluck(walkStates, 'components'));
return result;
}
@@ -58,8 +62,7 @@ class ScopeResolver extends SharedComponent {
// relative link, inject current endpoint
if (link === '.') {
link = compilingContext.endpointId;
- }
- else {
+ } else {
link = compilingContext.endpointId + link;
}
}
@@ -88,13 +91,11 @@ class ScopeResolver extends SharedComponent {
const term = path[2];
components = context.globalComponentResolver(term);
path = path.slice(3);
- }
- else {
+ } else {
path = path.slice(1);
components = context.endpointComponentResolver(endpoint);
}
- }
- catch (e) {
+ } catch (e) {
throw new Error('failed to resolve link [' + this.link + ']: ' + e);
}
return resolvePathToComponents(path, context, editor, components);
@@ -103,7 +104,7 @@ class ScopeResolver extends SharedComponent {
getTerms(context, editor) {
const options = [];
const components = this.resolveLinkToComponents(context, editor);
- _.each(components, function (component) {
+ _.each(components, function(component) {
options.push.apply(options, component.getTerms(context, editor));
});
return options;
@@ -111,11 +112,11 @@ class ScopeResolver extends SharedComponent {
match(token, context, editor) {
const result = {
- next: []
+ next: [],
};
const components = this.resolveLinkToComponents(context, editor);
- _.each(components, function (component) {
+ _.each(components, function(component) {
const componentResult = component.match(token, context, editor);
if (componentResult && componentResult.next) {
result.next.push.apply(result.next, componentResult.next);
@@ -193,7 +194,7 @@ function compileDescription(description, compilingContext) {
}
if (description.__one_of) {
return _.flatten(
- _.map(description.__one_of, function (d) {
+ _.map(description.__one_of, function(d) {
return compileDescription(d, compilingContext);
})
);
@@ -215,7 +216,7 @@ function compileParametrizedValue(value, compilingContext, template) {
value = value.substr(1, value.length - 2).toLowerCase();
let component = compilingContext.parametrizedComponentFactories.getComponent(value, true);
if (!component) {
- throw new Error('no factory found for \'' + value + '\'');
+ throw new Error("no factory found for '" + value + "'");
}
component = component(value, null, template);
if (!_.isUndefined(template)) {
@@ -228,7 +229,7 @@ function compileObject(objDescription, compilingContext) {
const objectC = new ConstantComponent('{');
const constants = [];
const patterns = [];
- _.each(objDescription, function (desc, key) {
+ _.each(objDescription, function(desc, key) {
if (key.indexOf('__') === 0) {
// meta key
return;
@@ -237,11 +238,7 @@ function compileObject(objDescription, compilingContext) {
const options = getOptions(desc);
let component;
if (/^\{.*\}$/.test(key)) {
- component = compileParametrizedValue(
- key,
- compilingContext,
- options.template
- );
+ component = compileParametrizedValue(key, compilingContext, options.template);
patterns.push(component);
} else if (key === '*') {
component = new SharedComponent(key);
@@ -251,7 +248,7 @@ function compileObject(objDescription, compilingContext) {
component = new ConstantComponent(key, null, [options]);
constants.push(component);
}
- _.map(compileDescription(desc, compilingContext), function (subComponent) {
+ _.map(compileDescription(desc, compilingContext), function(subComponent) {
component.addComponent(subComponent);
});
});
@@ -261,8 +258,8 @@ function compileObject(objDescription, compilingContext) {
function compileList(listRule, compilingContext) {
const listC = new ConstantComponent('[');
- _.each(listRule, function (desc) {
- _.each(compileDescription(desc, compilingContext), function (component) {
+ _.each(listRule, function(desc) {
+ _.each(compileDescription(desc, compilingContext), function(component) {
listC.addComponent(component);
});
});
@@ -272,7 +269,7 @@ function compileList(listRule, compilingContext) {
/** takes a compiled object and wraps in a {@link ConditionalProxy }*/
function compileCondition(description, compiledObject) {
if (description.lines_regex) {
- return new ConditionalProxy(function (context, editor) {
+ return new ConditionalProxy(function(context, editor) {
const lines = editor
.getLines(context.requestStartRow, editor.getCurrentPosition().lineNumber)
.join('\n');
@@ -301,11 +298,7 @@ export function globalsOnlyAutocompleteComponents() {
* }
* }
*/
-export function compileBodyDescription(
- endpointId,
- description,
- parametrizedComponentFactories
-) {
+export function compileBodyDescription(endpointId, description, parametrizedComponentFactories) {
return compileDescription(
description,
new CompilingContext(endpointId, parametrizedComponentFactories)
diff --git a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/constant_component.js b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/constant_component.js
index 582ae44084e0..44361d646c4a 100644
--- a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/constant_component.js
+++ b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/constant_component.js
@@ -45,6 +45,5 @@ export class ConstantComponent extends SharedComponent {
}
return super.match(token, context, editor);
-
}
}
diff --git a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/field_autocomplete_component.js b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/field_autocomplete_component.js
index e07db78c4cca..0574ffbcfc3a 100644
--- a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/field_autocomplete_component.js
+++ b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/field_autocomplete_component.js
@@ -21,7 +21,7 @@ import mappings from '../../mappings/mappings';
import { ListComponent } from './list_component';
function FieldGenerator(context) {
- return _.map(mappings.getFields(context.indices, context.types), function (field) {
+ return _.map(mappings.getFields(context.indices, context.types), function(field) {
return { name: field.name, meta: field.type };
});
}
@@ -35,7 +35,7 @@ export class FieldAutocompleteComponent extends ListComponent {
return false;
}
- return !_.find(tokens, function (token) {
+ return !_.find(tokens, function(token) {
return token.match(/[^\w.?*]/);
});
}
diff --git a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/global_only_component.js b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/global_only_component.js
index 6ac7da79a7a8..64e349d3ec12 100644
--- a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/global_only_component.js
+++ b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/global_only_component.js
@@ -25,7 +25,7 @@ export class GlobalOnlyComponent extends SharedComponent {
match(token, context) {
const result = {
- next: []
+ next: [],
};
// try to link to GLOBAL rules
@@ -41,6 +41,5 @@ export class GlobalOnlyComponent extends SharedComponent {
result.next = [this];
return result;
-
}
}
diff --git a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/id_autocomplete_component.js b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/id_autocomplete_component.js
index 6fc694b92214..d6deadc75ed7 100644
--- a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/id_autocomplete_component.js
+++ b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/id_autocomplete_component.js
@@ -19,7 +19,7 @@
import _ from 'lodash';
import { SharedComponent } from './shared_component';
-export class IdAutocompleteComponent extends SharedComponent {
+export class IdAutocompleteComponent extends SharedComponent {
constructor(name, parent, multi) {
super(name, parent);
this.multi_match = multi;
@@ -32,9 +32,11 @@ export class IdAutocompleteComponent extends SharedComponent {
return null;
}
token = Array.isArray(token) ? token : [token];
- if (_.find(token, function (t) {
- return t.match(/[\/,]/);
- })) {
+ if (
+ _.find(token, function(t) {
+ return t.match(/[\/,]/);
+ })
+ ) {
return null;
}
const r = super.match(token, context, editor);
diff --git a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/list_component.js b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/list_component.js
index d023779fac55..2f443ffaf6c9 100644
--- a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/list_component.js
+++ b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/list_component.js
@@ -23,9 +23,11 @@ import { SharedComponent } from './shared_component';
export class ListComponent extends SharedComponent {
constructor(name, list, parent, multiValued, allowNonValidValues) {
super(name, parent);
- this.listGenerator = Array.isArray(list) ? function () {
- return list;
- } : list;
+ this.listGenerator = Array.isArray(list)
+ ? function() {
+ return list;
+ }
+ : list;
this.multiValued = _.isUndefined(multiValued) ? true : multiValued;
this.allowNonValidValues = _.isUndefined(allowNonValidValues) ? false : allowNonValidValues;
}
@@ -42,9 +44,9 @@ export class ListComponent extends SharedComponent {
if (this.getDefaultTermMeta()) {
const meta = this.getDefaultTermMeta();
- ret = _.map(ret, function (term) {
+ ret = _.map(ret, function(term) {
if (_.isString(term)) {
- term = { 'name': term };
+ term = { name: term };
}
return _.defaults(term, { meta: meta });
});
@@ -60,7 +62,7 @@ export class ListComponent extends SharedComponent {
// verify we have all tokens
const list = this.listGenerator();
- const notFound = _.any(tokens, function (token) {
+ const notFound = _.any(tokens, function(token) {
return list.indexOf(token) === -1;
});
diff --git a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/object_component.js b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/object_component.js
index 5cff4a15647c..f73625cccf38 100644
--- a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/object_component.js
+++ b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/object_component.js
@@ -32,10 +32,10 @@ export class ObjectComponent extends SharedComponent {
}
getTerms(context, editor) {
const options = [];
- _.each(this.constants, function (component) {
+ _.each(this.constants, function(component) {
options.push.apply(options, component.getTerms(context, editor));
});
- _.each(this.patternsAndWildCards, function (component) {
+ _.each(this.patternsAndWildCards, function(component) {
options.push.apply(options, component.getTerms(context, editor));
});
return options;
@@ -43,9 +43,9 @@ export class ObjectComponent extends SharedComponent {
match(token, context, editor) {
const result = {
- next: []
+ next: [],
};
- _.each(this.constants, function (component) {
+ _.each(this.constants, function(component) {
const componentResult = component.match(token, context, editor);
if (componentResult && componentResult.next) {
result.next.push.apply(result.next, componentResult.next);
@@ -61,7 +61,7 @@ export class ObjectComponent extends SharedComponent {
if (result.next.length) {
return result;
}
- _.each(this.patternsAndWildCards, function (component) {
+ _.each(this.patternsAndWildCards, function(component) {
const componentResult = component.match(token, context, editor);
if (componentResult && componentResult.next) {
result.next.push.apply(result.next, componentResult.next);
@@ -69,6 +69,5 @@ export class ObjectComponent extends SharedComponent {
});
return result;
-
}
}
diff --git a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/shared_component.js b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/shared_component.js
index f996a5de6672..eeebf9506370 100644
--- a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/shared_component.js
+++ b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/shared_component.js
@@ -18,7 +18,7 @@
*/
import _ from 'lodash';
import { AutocompleteComponent } from './autocomplete_component';
-export class SharedComponent extends AutocompleteComponent {
+export class SharedComponent extends AutocompleteComponent {
constructor(name, parent) {
super(name);
this._nextDict = {};
diff --git a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/simple_param_component.js b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/simple_param_component.js
index 6a315c45066e..f7d5eb7277ef 100644
--- a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/simple_param_component.js
+++ b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/simple_param_component.js
@@ -29,4 +29,3 @@ export class SimpleParamComponent extends SharedComponent {
return result;
}
}
-
diff --git a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/type_autocomplete_component.js b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/type_autocomplete_component.js
index ca317fec9e27..507817c1ed8c 100644
--- a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/type_autocomplete_component.js
+++ b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/type_autocomplete_component.js
@@ -25,7 +25,7 @@ function TypeGenerator(context) {
function nonValidIndexType(token) {
return !(token === '_all' || token[0] !== '_');
}
-export class TypeAutocompleteComponent extends ListComponent {
+export class TypeAutocompleteComponent extends ListComponent {
constructor(name, parent, multiValued) {
super(name, TypeGenerator, parent, multiValued);
}
diff --git a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/url_pattern_matcher.js b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/url_pattern_matcher.js
index dfae1382bed9..fc3e1dd1420d 100644
--- a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/url_pattern_matcher.js
+++ b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/url_pattern_matcher.js
@@ -41,24 +41,24 @@ export class UrlPatternMatcher {
// We'll group endpoints by the methods which are attached to them,
//to avoid suggesting endpoints that are incompatible with the
//method that the user has entered.
- ['HEAD', 'GET', 'PUT', 'POST', 'DELETE'].forEach((method) => {
+ ['HEAD', 'GET', 'PUT', 'POST', 'DELETE'].forEach(method => {
this[method] = {
rootComponent: new SharedComponent('ROOT'),
parametrizedComponentFactories: parametrizedComponentFactories || {
- getComponent: () => {}
- }
+ getComponent: () => {},
+ },
};
});
}
addEndpoint(pattern, endpoint) {
- endpoint.methods.forEach((method) => {
+ endpoint.methods.forEach(method => {
let c;
let activeComponent = this[method].rootComponent;
const endpointComponents = endpoint.url_components || {};
const partList = pattern.split('/');
_.each(
partList,
- function (part, partIndex) {
+ function(part, partIndex) {
if (part.search(/^{.+}$/) >= 0) {
part = part.substr(1, part.length - 2);
if (activeComponent.getComponent(part)) {
@@ -128,7 +128,7 @@ export class UrlPatternMatcher {
});
}
- getTopLevelComponents = function (method) {
+ getTopLevelComponents = function(method) {
const methodRoot = this[method];
if (!methodRoot) {
return [];
diff --git a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/engine.js b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/engine.js
index 23a27d8eeef3..f4df8af871eb 100644
--- a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/engine.js
+++ b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/engine.js
@@ -21,33 +21,34 @@ const _ = require('lodash');
export function wrapComponentWithDefaults(component, defaults) {
const originalGetTerms = component.getTerms;
- component.getTerms = function (context, editor) {
+ component.getTerms = function(context, editor) {
let result = originalGetTerms.call(component, context, editor);
if (!result) {
return result;
}
- result = _.map(result, function (term) {
- if (!_.isObject(term)) {
- term = { name: term };
- }
- return _.defaults(term, defaults);
- }, this);
+ result = _.map(
+ result,
+ function(term) {
+ if (!_.isObject(term)) {
+ term = { name: term };
+ }
+ return _.defaults(term, defaults);
+ },
+ this
+ );
return result;
};
return component;
}
-const tracer = function () {
+const tracer = function() {
if (window.engine_trace) {
console.log.call(console, arguments);
}
};
-
function passThroughContext(context, extensionList) {
- function PTC() {
-
- }
+ function PTC() {}
PTC.prototype = context;
const result = new PTC();
@@ -67,19 +68,18 @@ export function WalkingState(parentName, components, contextExtensionList, depth
this.priority = priority;
}
-
export function walkTokenPath(tokenPath, walkingStates, context, editor) {
if (!tokenPath || tokenPath.length === 0) {
return walkingStates;
}
const token = tokenPath[0];
- const nextWalkingStates = [];
+ const nextWalkingStates = [];
tracer('starting token evaluation [' + token + ']');
- _.each(walkingStates, function (ws) {
+ _.each(walkingStates, function(ws) {
const contextForState = passThroughContext(context, ws.contextExtensionList);
- _.each(ws.components, function (component) {
+ _.each(ws.components, function(component) {
tracer('evaluating [' + token + '] with [' + component.name + ']', component);
const result = component.match(token, contextForState, editor);
if (result && !_.isEmpty(result)) {
@@ -88,16 +88,14 @@ export function walkTokenPath(tokenPath, walkingStates, context, editor) {
let extensionList;
if (result.next && !Array.isArray(result.next)) {
next = [result.next];
- }
- else {
+ } else {
next = result.next;
}
if (result.context_values) {
extensionList = [];
[].push.apply(extensionList, ws.contextExtensionList);
extensionList.push(result.context_values);
- }
- else {
+ } else {
extensionList = ws.contextExtensionList;
}
@@ -105,20 +103,21 @@ export function walkTokenPath(tokenPath, walkingStates, context, editor) {
if (_.isNumber(result.priority)) {
if (_.isNumber(priority)) {
priority = Math.min(priority, result.priority);
- }
- else {
+ } else {
priority = result.priority;
}
}
- nextWalkingStates.push(new WalkingState(component.name, next, extensionList, ws.depth + 1, priority));
+ nextWalkingStates.push(
+ new WalkingState(component.name, next, extensionList, ws.depth + 1, priority)
+ );
}
});
});
if (nextWalkingStates.length === 0) {
// no where to go, still return context variables returned so far..
- return _.map(walkingStates, function (ws) {
+ return _.map(walkingStates, function(ws) {
return new WalkingState(ws.name, [], ws.contextExtensionList);
});
}
@@ -127,14 +126,18 @@ export function walkTokenPath(tokenPath, walkingStates, context, editor) {
}
export function populateContext(tokenPath, context, editor, includeAutoComplete, components) {
-
- let walkStates = walkTokenPath(tokenPath, [new WalkingState('ROOT', components, [])], context, editor);
+ let walkStates = walkTokenPath(
+ tokenPath,
+ [new WalkingState('ROOT', components, [])],
+ context,
+ editor
+ );
if (includeAutoComplete) {
let autoCompleteSet = [];
- _.each(walkStates, function (ws) {
+ _.each(walkStates, function(ws) {
const contextForState = passThroughContext(context, ws.contextExtensionList);
- _.each(ws.components, function (component) {
- _.each(component.getTerms(contextForState, editor), function (term) {
+ _.each(ws.components, function(component) {
+ _.each(component.getTerms(contextForState, editor), function(term) {
if (!_.isObject(term)) {
term = { name: term };
}
@@ -149,22 +152,25 @@ export function populateContext(tokenPath, context, editor, includeAutoComplete,
// apply what values were set so far to context, selecting the deepest on which sets the context
if (walkStates.length !== 0) {
let wsToUse;
- walkStates = _.sortBy(walkStates, function (ws) {
+ walkStates = _.sortBy(walkStates, function(ws) {
return _.isNumber(ws.priority) ? ws.priority : Number.MAX_VALUE;
});
- wsToUse = _.find(walkStates, function (ws) {
+ wsToUse = _.find(walkStates, function(ws) {
return _.isEmpty(ws.components);
});
if (!wsToUse && walkStates.length > 1 && !includeAutoComplete) {
- console.info('more then one context active for current path, but autocomplete isn\'t requested', walkStates);
+ console.info(
+ "more then one context active for current path, but autocomplete isn't requested",
+ walkStates
+ );
}
if (!wsToUse) {
wsToUse = walkStates[0];
}
- _.each(wsToUse.contextExtensionList, function (extension) {
+ _.each(wsToUse.contextExtensionList, function(extension) {
_.assign(context, extension);
});
}
diff --git a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/url_params.js b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/url_params.js
index 78b1701582df..3f05b9ce85aa 100644
--- a/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/url_params.js
+++ b/src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/url_params.js
@@ -29,8 +29,7 @@ export class ParamComponent extends ConstantComponent {
const t = { name: this.name };
if (this.description === '__flag__') {
t.meta = 'flag';
- }
- else {
+ } else {
t.meta = 'param';
t.insertValue = this.name + '=';
}
@@ -40,26 +39,29 @@ export class ParamComponent extends ConstantComponent {
export class UrlParams {
constructor(description, defaults) {
- // This is not really a component, just a handy container to make iteration logic simpler
+ // This is not really a component, just a handy container to make iteration logic simpler
this.rootComponent = new SharedComponent('ROOT');
if (_.isUndefined(defaults)) {
defaults = {
- 'pretty': '__flag__',
- 'format': ['json', 'yaml'],
- 'filter_path': '',
+ pretty: '__flag__',
+ format: ['json', 'yaml'],
+ filter_path: '',
};
}
description = _.clone(description || {});
_.defaults(description, defaults);
- _.each(description, function (pDescription, param) {
- const component = new ParamComponent(param, this.rootComponent, pDescription);
- if (Array.isArray(pDescription)) {
- new ListComponent(param, pDescription, component);
- }
- else if (pDescription === '__flag__') {
- new ListComponent(param, ['true', 'false'], component);
- }
- }, this);
+ _.each(
+ description,
+ function(pDescription, param) {
+ const component = new ParamComponent(param, this.rootComponent, pDescription);
+ if (Array.isArray(pDescription)) {
+ new ListComponent(param, pDescription, component);
+ } else if (pDescription === '__flag__') {
+ new ListComponent(param, ['true', 'false'], component);
+ }
+ },
+ this
+ );
}
getTopLevelComponents() {
return this.rootComponent.next;
diff --git a/src/legacy/core_plugins/console/public/np_ready/lib/curl_parsing/__tests__/curl_parsing.test.js b/src/legacy/core_plugins/console/public/np_ready/lib/curl_parsing/__tests__/curl_parsing.test.js
index bf783b3dfe8a..49a54eaefa9e 100644
--- a/src/legacy/core_plugins/console/public/np_ready/lib/curl_parsing/__tests__/curl_parsing.test.js
+++ b/src/legacy/core_plugins/console/public/np_ready/lib/curl_parsing/__tests__/curl_parsing.test.js
@@ -22,32 +22,26 @@ const curl = require('../curl');
import curlTests from './curl_parsing.txt';
describe('CURL', () => {
- const notCURLS = [
- 'sldhfsljfhs',
- 's;kdjfsldkfj curl -XDELETE ""',
- '{ "hello": 1 }'
- ];
- _.each(notCURLS, function (notCURL, i) {
- test('cURL Detection - broken strings ' + i, function () {
+ const notCURLS = ['sldhfsljfhs', 's;kdjfsldkfj curl -XDELETE ""', '{ "hello": 1 }'];
+ _.each(notCURLS, function(notCURL, i) {
+ test('cURL Detection - broken strings ' + i, function() {
expect(curl.detectCURL(notCURL)).toEqual(false);
});
});
- curlTests.split(/^=+$/m).forEach(function (fixture) {
+ curlTests.split(/^=+$/m).forEach(function(fixture) {
if (fixture.trim() === '') {
return;
}
fixture = fixture.split(/^-+$/m);
const name = fixture[0].trim();
- const curlText = fixture[1];
- const response = fixture[2].trim();
+ const curlText = fixture[1];
+ const response = fixture[2].trim();
- test('cURL Detection - ' + name, function () {
+ test('cURL Detection - ' + name, function() {
expect(curl.detectCURL(curlText)).toBe(true);
const r = curl.parseCURL(curlText);
expect(r).toEqual(response);
});
});
});
-
-
diff --git a/src/legacy/core_plugins/console/public/np_ready/lib/curl_parsing/curl.js b/src/legacy/core_plugins/console/public/np_ready/lib/curl_parsing/curl.js
index 806540922ecf..f609e580d016 100644
--- a/src/legacy/core_plugins/console/public/np_ready/lib/curl_parsing/curl.js
+++ b/src/legacy/core_plugins/console/public/np_ready/lib/curl_parsing/curl.js
@@ -80,15 +80,13 @@ export function parseCURL(text) {
// Is the next char a single or double quote?
// If so remove it
function detectQuote() {
- if (line.substr(0, 1) === '\'') {
+ if (line.substr(0, 1) === "'") {
line = line.substr(1);
state = 'SINGLE_QUOTE';
- }
- else if (line.substr(0, 1) === '"') {
+ } else if (line.substr(0, 1) === '"') {
line = line.substr(1);
state = 'DOUBLE_QUOTE';
- }
- else {
+ } else {
state = 'UNQUOTED';
}
}
@@ -112,8 +110,7 @@ export function parseCURL(text) {
body.push(matches[1]);
line = line.substr(matches[0].length);
detectQuote();
- }
- else {
+ } else {
body.push(line);
line = '';
}
@@ -123,30 +120,27 @@ export function parseCURL(text) {
let verb = 'GET';
let request = '';
let matches;
- if (matches = line.match(CurlVerb)) {
+ if ((matches = line.match(CurlVerb))) {
verb = matches[1];
}
// JS regexen don't support possessive quantifiers, so
// we need two distinct patterns
- const pattern = HasProtocol.test(line)
- ? CurlRequestWithProto
- : CurlRequestWithoutProto;
+ const pattern = HasProtocol.test(line) ? CurlRequestWithProto : CurlRequestWithoutProto;
- if (matches = line.match(pattern)) {
+ if ((matches = line.match(pattern))) {
request = matches[1];
}
out.push(verb + ' /' + request + '\n');
- if (matches = line.match(CurlData)) {
+ if ((matches = line.match(CurlData))) {
line = line.substr(matches[0].length);
detectQuote();
if (EmptyLine.test(line)) {
line = '';
}
- }
- else {
+ } else {
state = 'NONE';
line = '';
out.push('');
@@ -154,17 +148,12 @@ export function parseCURL(text) {
}
while (nextLine()) {
-
if (state === 'SINGLE_QUOTE') {
consumeMatching(ClosingSingleQuote);
- }
-
- else if (state === 'DOUBLE_QUOTE') {
+ } else if (state === 'DOUBLE_QUOTE') {
consumeMatching(ClosingDoubleQuote);
unescapeLastBodyEl();
- }
-
- else if (state === 'UNQUOTED') {
+ } else if (state === 'UNQUOTED') {
consumeMatching(EscapedQuotes);
if (body.length) {
unescapeLastBodyEl();
@@ -181,32 +170,23 @@ export function parseCURL(text) {
else if (state === 'BODY') {
if (Comment.test(line) || EmptyLine.test(line)) {
addBodyToOut();
- }
- else {
+ } else {
body.push(line);
line = '';
}
- }
-
- else if (EmptyLine.test(line)) {
+ } else if (EmptyLine.test(line)) {
if (state !== 'LF') {
out.push('\n');
state = 'LF';
}
line = '';
- }
-
- else if (matches = line.match(Comment)) {
+ } else if ((matches = line.match(Comment))) {
out.push('#' + matches[1] + '\n');
state = 'NONE';
line = '';
- }
-
- else if (LooksLikeCurl.test(line)) {
+ } else if (LooksLikeCurl.test(line)) {
parseCurlLine();
- }
-
- else if (matches = line.match(SenseLine)) {
+ } else if ((matches = line.match(SenseLine))) {
out.push(matches[1] + ' /' + matches[2] + '\n');
line = '';
state = 'BODY';
diff --git a/src/legacy/core_plugins/console/public/np_ready/lib/es/__tests__/content_type.test.js b/src/legacy/core_plugins/console/public/np_ready/lib/es/__tests__/content_type.test.js
index acc33e331c9f..e800fe41cb01 100644
--- a/src/legacy/core_plugins/console/public/np_ready/lib/es/__tests__/content_type.test.js
+++ b/src/legacy/core_plugins/console/public/np_ready/lib/es/__tests__/content_type.test.js
@@ -22,14 +22,16 @@ import { getContentType } from '../es';
const APPLICATION_JSON = 'application/json';
describe('Content type', () => {
test('body', () => {
- const contentType = getContentType([
- JSON.stringify({
- foo: 'baz'
- }),
- JSON.stringify({
- foo: 'bar'
- })
- ].join('\n'));
+ const contentType = getContentType(
+ [
+ JSON.stringify({
+ foo: 'baz',
+ }),
+ JSON.stringify({
+ foo: 'bar',
+ }),
+ ].join('\n')
+ );
expect(contentType).toEqual(APPLICATION_JSON);
});
@@ -40,4 +42,3 @@ describe('Content type', () => {
expect(contentType).toBeUndefined();
});
});
-
diff --git a/src/legacy/core_plugins/console/public/np_ready/lib/es/es.js b/src/legacy/core_plugins/console/public/np_ready/lib/es/es.js
index 914142f5fb4b..9012b875e0f2 100644
--- a/src/legacy/core_plugins/console/public/np_ready/lib/es/es.js
+++ b/src/legacy/core_plugins/console/public/np_ready/lib/es/es.js
@@ -33,7 +33,7 @@ export function getContentType(body) {
}
export function send(method, path, data) {
- const wrappedDfd = $.Deferred(); // eslint-disable-line new-cap
+ const wrappedDfd = $.Deferred(); // eslint-disable-line new-cap
const options = {
url: '../api/console/proxy?' + formatQueryString({ path, method }),
@@ -46,15 +46,17 @@ export function send(method, path, data) {
};
$.ajax(options).then(
- function (data, textStatus, jqXHR) {
+ function(data, textStatus, jqXHR) {
wrappedDfd.resolveWith(this, [data, textStatus, jqXHR]);
},
- function (jqXHR, textStatus, errorThrown) {
+ function(jqXHR, textStatus, errorThrown) {
if (jqXHR.status === 0) {
- jqXHR.responseText = '\n\nFailed to connect to Console\'s backend.\nPlease check the Kibana server is up and running';
+ jqXHR.responseText =
+ "\n\nFailed to connect to Console's backend.\nPlease check the Kibana server is up and running";
}
wrappedDfd.rejectWith(this, [jqXHR, textStatus, errorThrown]);
- });
+ }
+ );
return wrappedDfd;
}
diff --git a/src/legacy/core_plugins/console/public/np_ready/lib/kb/__tests__/kb.test.js b/src/legacy/core_plugins/console/public/np_ready/lib/kb/__tests__/kb.test.js
index ad29f9808a6c..c2c69314a172 100644
--- a/src/legacy/core_plugins/console/public/np_ready/lib/kb/__tests__/kb.test.js
+++ b/src/legacy/core_plugins/console/public/np_ready/lib/kb/__tests__/kb.test.js
@@ -58,15 +58,12 @@ describe('Knowledge base', () => {
function testUrlContext(tokenPath, otherTokenValues, expectedContext) {
if (expectedContext.autoCompleteSet) {
- expectedContext.autoCompleteSet = _.map(
- expectedContext.autoCompleteSet,
- function (t) {
- if (_.isString(t)) {
- t = { name: t };
- }
- return t;
+ expectedContext.autoCompleteSet = _.map(expectedContext.autoCompleteSet, function(t) {
+ if (_.isString(t)) {
+ t = { name: t };
}
- );
+ return t;
+ });
}
const context = { otherTokenValues: otherTokenValues };
@@ -93,10 +90,7 @@ describe('Knowledge base', () => {
}
if (context.autoCompleteSet) {
- context.autoCompleteSet = _.sortBy(
- _.map(context.autoCompleteSet, norm),
- 'name'
- );
+ context.autoCompleteSet = _.sortBy(_.map(context.autoCompleteSet, norm), 'name');
}
if (expectedContext.autoCompleteSet) {
expectedContext.autoCompleteSet = _.sortBy(
@@ -117,7 +111,7 @@ describe('Knowledge base', () => {
}
function indexTest(name, tokenPath, otherTokenValues, expectedContext) {
- test(name, function () {
+ test(name, function() {
// eslint-disable-next-line new-cap
const testApi = new kb._test.loadApisFromJson(
{
@@ -167,7 +161,7 @@ describe('Knowledge base', () => {
});
function typeTest(name, tokenPath, otherTokenValues, expectedContext) {
- test(name, function () {
+ test(name, function() {
const testApi = kb._test.loadApisFromJson(
{
typeTest: {
@@ -213,7 +207,10 @@ describe('Knowledge base', () => {
typeTest(
'Type integration 5',
- [['index1', 'index2'], ['type1.2', 'type1.1']],
+ [
+ ['index1', 'index2'],
+ ['type1.2', 'type1.1'],
+ ],
[],
{
indices: ['index1', 'index2'],
diff --git a/src/legacy/core_plugins/console/public/np_ready/lib/kb/api.js b/src/legacy/core_plugins/console/public/np_ready/lib/kb/api.js
index f2f05179eea7..eeec87060b77 100644
--- a/src/legacy/core_plugins/console/public/np_ready/lib/kb/api.js
+++ b/src/legacy/core_plugins/console/public/np_ready/lib/kb/api.js
@@ -20,8 +20,10 @@
const _ = require('lodash');
import { UrlPatternMatcher } from '../autocomplete/components';
import { UrlParams } from '../autocomplete/url_params';
-import { globalsOnlyAutocompleteComponents, compileBodyDescription } from '../autocomplete/body_completer';
-
+import {
+ globalsOnlyAutocompleteComponents,
+ compileBodyDescription,
+} from '../autocomplete/body_completer';
/**
*
@@ -39,58 +41,65 @@ function Api(urlParametrizedComponentFactories, bodyParametrizedComponentFactori
this.name = '';
}
-(function (cls) {
- cls.addGlobalAutocompleteRules = function (parentNode, rules) {
+(function(cls) {
+ cls.addGlobalAutocompleteRules = function(parentNode, rules) {
this.globalRules[parentNode] = compileBodyDescription(
- 'GLOBAL.' + parentNode, rules, this.globalBodyComponentFactories);
+ 'GLOBAL.' + parentNode,
+ rules,
+ this.globalBodyComponentFactories
+ );
};
- cls.getGlobalAutocompleteComponents = function (term, throwOnMissing) {
+ cls.getGlobalAutocompleteComponents = function(term, throwOnMissing) {
const result = this.globalRules[term];
if (_.isUndefined(result) && (throwOnMissing || _.isUndefined(throwOnMissing))) {
- throw new Error('failed to resolve global components for [\'' + term + '\']');
+ throw new Error("failed to resolve global components for ['" + term + "']");
}
return result;
};
- cls.addEndpointDescription = function (endpoint, description) {
-
+ cls.addEndpointDescription = function(endpoint, description) {
const copiedDescription = {};
_.extend(copiedDescription, description || {});
_.defaults(copiedDescription, {
id: endpoint,
patterns: [endpoint],
- methods: ['GET']
+ methods: ['GET'],
});
- _.each(copiedDescription.patterns, function (p) {
- this.urlPatternMatcher.addEndpoint(p, copiedDescription);
- }, this);
+ _.each(
+ copiedDescription.patterns,
+ function(p) {
+ this.urlPatternMatcher.addEndpoint(p, copiedDescription);
+ },
+ this
+ );
copiedDescription.paramsAutocomplete = new UrlParams(copiedDescription.url_params);
copiedDescription.bodyAutocompleteRootComponents = compileBodyDescription(
- copiedDescription.id, copiedDescription.data_autocomplete_rules, this.globalBodyComponentFactories);
+ copiedDescription.id,
+ copiedDescription.data_autocomplete_rules,
+ this.globalBodyComponentFactories
+ );
this.endpoints[endpoint] = copiedDescription;
};
- cls.getEndpointDescriptionByEndpoint = function (endpoint) {
+ cls.getEndpointDescriptionByEndpoint = function(endpoint) {
return this.endpoints[endpoint];
};
-
- cls.getTopLevelUrlCompleteComponents = function (method) {
+ cls.getTopLevelUrlCompleteComponents = function(method) {
return this.urlPatternMatcher.getTopLevelComponents(method);
};
- cls.getUnmatchedEndpointComponents = function () {
+ cls.getUnmatchedEndpointComponents = function() {
return globalsOnlyAutocompleteComponents();
};
- cls.clear = function () {
+ cls.clear = function() {
this.endpoints = {};
this.globalRules = {};
};
-}(Api.prototype));
-
+})(Api.prototype);
export default Api;
diff --git a/src/legacy/core_plugins/console/public/np_ready/lib/kb/kb.js b/src/legacy/core_plugins/console/public/np_ready/lib/kb/kb.js
index ffba14fad3f3..95896bed0298 100644
--- a/src/legacy/core_plugins/console/public/np_ready/lib/kb/kb.js
+++ b/src/legacy/core_plugins/console/public/np_ready/lib/kb/kb.js
@@ -38,62 +38,62 @@ const idAutocompleteComponentFactory = (name, parent) => {
return new IdAutocompleteComponent(name, parent);
};
const parametrizedComponentFactories = {
- getComponent: function (name, parent, provideDefault) {
+ getComponent: function(name, parent, provideDefault) {
if (this[name]) {
return this[name];
} else if (provideDefault) {
return idAutocompleteComponentFactory;
}
},
- index: function (name, parent) {
+ index: function(name, parent) {
if (isNotAnIndexName(name)) return;
return new IndexAutocompleteComponent(name, parent, false);
},
- indices: function (name, parent) {
+ indices: function(name, parent) {
if (isNotAnIndexName(name)) return;
return new IndexAutocompleteComponent(name, parent, true);
},
- type: function (name, parent) {
+ type: function(name, parent) {
return new TypeAutocompleteComponent(name, parent, false);
},
- types: function (name, parent) {
+ types: function(name, parent) {
return new TypeAutocompleteComponent(name, parent, true);
},
- id: function (name, parent) {
+ id: function(name, parent) {
return idAutocompleteComponentFactory(name, parent);
},
- transform_id: function (name, parent) {
+ transform_id: function(name, parent) {
return idAutocompleteComponentFactory(name, parent);
},
- username: function (name, parent) {
+ username: function(name, parent) {
return new UsernameAutocompleteComponent(name, parent);
},
- user: function (name, parent) {
+ user: function(name, parent) {
return new UsernameAutocompleteComponent(name, parent);
},
- template: function (name, parent) {
+ template: function(name, parent) {
return new TemplateAutocompleteComponent(name, parent);
},
- task_id: function (name, parent) {
+ task_id: function(name, parent) {
return idAutocompleteComponentFactory(name, parent);
},
- ids: function (name, parent) {
+ ids: function(name, parent) {
return idAutocompleteComponentFactory(name, parent, true);
},
- fields: function (name, parent) {
+ fields: function(name, parent) {
return new FieldAutocompleteComponent(name, parent, true);
},
- field: function (name, parent) {
+ field: function(name, parent) {
return new FieldAutocompleteComponent(name, parent, false);
},
- nodes: function (name, parent) {
+ nodes: function(name, parent) {
return new ListComponent(
name,
['_local', '_master', 'data:true', 'data:false', 'master:true', 'master:false'],
parent
);
},
- node: function (name, parent) {
+ node: function(name, parent) {
return new ListComponent(name, [], parent, false);
},
};
@@ -109,7 +109,7 @@ export function getEndpointDescriptionByEndpoint(endpoint) {
export function getEndpointBodyCompleteComponents(endpoint) {
const desc = getEndpointDescriptionByEndpoint(endpoint);
if (!desc) {
- throw new Error('failed to resolve endpoint [\'' + endpoint + '\']');
+ throw new Error("failed to resolve endpoint ['" + endpoint + "']");
}
return desc.bodyAutocompleteRootComponents;
}
@@ -133,12 +133,12 @@ function loadApisFromJson(
bodyParametrizedComponentFactories || urlParametrizedComponentFactories;
const api = new Api(urlParametrizedComponentFactories, bodyParametrizedComponentFactories);
const names = [];
- _.each(json, function (apiJson, name) {
+ _.each(json, function(apiJson, name) {
names.unshift(name);
- _.each(apiJson.globals || {}, function (globalJson, globalName) {
+ _.each(apiJson.globals || {}, function(globalJson, globalName) {
api.addGlobalAutocompleteRules(globalName, globalJson);
});
- _.each(apiJson.endpoints || {}, function (endpointJson, endpointName) {
+ _.each(apiJson.endpoints || {}, function(endpointJson, endpointName) {
api.addEndpointDescription(endpointName, endpointJson);
});
});
@@ -156,11 +156,11 @@ export function setActiveApi(api) {
encodeURIComponent(api),
dataType: 'json', // disable automatic guessing
}).then(
- function (data) {
+ function(data) {
setActiveApi(loadApisFromJson(data));
},
- function (jqXHR) {
- console.log('failed to load API \'' + api + '\': ' + jqXHR.responseText);
+ function(jqXHR) {
+ console.log("failed to load API '" + api + "': " + jqXHR.responseText);
}
);
return;
diff --git a/src/legacy/core_plugins/console/public/np_ready/lib/mappings/__tests__/mapping.test.js b/src/legacy/core_plugins/console/public/np_ready/lib/mappings/__tests__/mapping.test.js
index 875a16402e39..27b3ce26b558 100644
--- a/src/legacy/core_plugins/console/public/np_ready/lib/mappings/__tests__/mapping.test.js
+++ b/src/legacy/core_plugins/console/public/np_ready/lib/mappings/__tests__/mapping.test.js
@@ -41,7 +41,7 @@ describe('Mappings', () => {
return { name: name, type: type || 'string' };
}
- test('Multi fields 1.0 style', function () {
+ test('Multi fields 1.0 style', function() {
mappings.loadMappings({
index: {
properties: {
@@ -72,7 +72,7 @@ describe('Mappings', () => {
]);
});
- test('Simple fields', function () {
+ test('Simple fields', function() {
mappings.loadMappings({
index: {
properties: {
@@ -86,13 +86,10 @@ describe('Mappings', () => {
},
});
- expect(mappings.getFields('index').sort(fc)).toEqual([
- f('number', 'int'),
- f('str', 'string'),
- ]);
+ expect(mappings.getFields('index').sort(fc)).toEqual([f('number', 'int'), f('str', 'string')]);
});
- test('Simple fields - 1.0 style', function () {
+ test('Simple fields - 1.0 style', function() {
mappings.loadMappings({
index: {
mappings: {
@@ -108,13 +105,10 @@ describe('Mappings', () => {
},
});
- expect(mappings.getFields('index').sort(fc)).toEqual([
- f('number', 'int'),
- f('str', 'string'),
- ]);
+ expect(mappings.getFields('index').sort(fc)).toEqual([f('number', 'int'), f('str', 'string')]);
});
- test('Nested fields', function () {
+ test('Nested fields', function() {
mappings.loadMappings({
index: {
properties: {
@@ -143,7 +137,7 @@ describe('Mappings', () => {
]);
});
- test('Enabled fields', function () {
+ test('Enabled fields', function() {
mappings.loadMappings({
index: {
properties: {
@@ -162,13 +156,10 @@ describe('Mappings', () => {
},
});
- expect(mappings.getFields('index', []).sort(fc)).toEqual([
- f('message'),
- f('person.sid'),
- ]);
+ expect(mappings.getFields('index', []).sort(fc)).toEqual([f('message'), f('person.sid')]);
});
- test('Path tests', function () {
+ test('Path tests', function() {
mappings.loadMappings({
index: {
properties: {
@@ -200,7 +191,7 @@ describe('Mappings', () => {
]);
});
- test('Use index_name tests', function () {
+ test('Use index_name tests', function() {
mappings.loadMappings({
index: {
properties: {
@@ -212,7 +203,7 @@ describe('Mappings', () => {
expect(mappings.getFields().sort(fc)).toEqual([f('i_last_1')]);
});
- test('Aliases', function () {
+ test('Aliases', function() {
mappings.loadAliases({
test_index1: {
aliases: {
@@ -252,10 +243,7 @@ describe('Mappings', () => {
'test_index1',
'test_index2',
]);
- expect(mappings.getIndices(false).sort()).toEqual([
- 'test_index1',
- 'test_index2',
- ]);
+ expect(mappings.getIndices(false).sort()).toEqual(['test_index1', 'test_index2']);
expect(mappings.expandAliases(['alias1', 'test_index2']).sort()).toEqual([
'test_index1',
'test_index2',
diff --git a/src/legacy/core_plugins/console/public/np_ready/lib/mappings/mappings.js b/src/legacy/core_plugins/console/public/np_ready/lib/mappings/mappings.js
index b0acf369260e..e0db361f9b42 100644
--- a/src/legacy/core_plugins/console/public/np_ready/lib/mappings/mappings.js
+++ b/src/legacy/core_plugins/console/public/np_ready/lib/mappings/mappings.js
@@ -45,7 +45,7 @@ function expandAliases(indicesOrAliases) {
if (typeof indicesOrAliases === 'string') {
indicesOrAliases = [indicesOrAliases];
}
- indicesOrAliases = $.map(indicesOrAliases, function (iOrA) {
+ indicesOrAliases = $.map(indicesOrAliases, function(iOrA) {
if (perAliasIndexes[iOrA]) {
return perAliasIndexes[iOrA];
}
@@ -54,7 +54,7 @@ function expandAliases(indicesOrAliases) {
let ret = [].concat.apply([], indicesOrAliases);
ret.sort();
let last;
- ret = $.map(ret, function (v) {
+ ret = $.map(ret, function(v) {
const r = last === v ? null : v;
last = v;
return r;
@@ -63,7 +63,7 @@ function expandAliases(indicesOrAliases) {
}
function getTemplates() {
- return [ ...templates ];
+ return [...templates];
}
function getFields(indices, types) {
@@ -82,7 +82,7 @@ function getFields(indices, types) {
ret = f ? f : [];
} else {
// filter what we need
- $.each(typeDict, function (type, fields) {
+ $.each(typeDict, function(type, fields) {
if (!types || types.length === 0 || $.inArray(type, types) !== -1) {
ret.push(fields);
}
@@ -92,7 +92,7 @@ function getFields(indices, types) {
}
} else {
// multi index mode.
- $.each(perIndexTypes, function (index) {
+ $.each(perIndexTypes, function(index) {
if (!indices || indices.length === 0 || $.inArray(index, indices) !== -1) {
ret.push(getFields(index, types));
}
@@ -100,7 +100,7 @@ function getFields(indices, types) {
ret = [].concat.apply([], ret);
}
- return _.uniq(ret, function (f) {
+ return _.uniq(ret, function(f) {
return f.name + ':' + f.type;
});
}
@@ -115,14 +115,12 @@ function getTypes(indices) {
}
// filter what we need
- $.each(typeDict, function (type) {
+ $.each(typeDict, function(type) {
ret.push(type);
});
-
- }
- else {
+ } else {
// multi index mode.
- $.each(perIndexTypes, function (index) {
+ $.each(perIndexTypes, function(index) {
if (!indices || $.inArray(index, indices) !== -1) {
ret.push(getTypes(index));
}
@@ -135,11 +133,11 @@ function getTypes(indices) {
function getIndices(includeAliases) {
const ret = [];
- $.each(perIndexTypes, function (index) {
+ $.each(perIndexTypes, function(index) {
ret.push(index);
});
if (typeof includeAliases === 'undefined' ? true : includeAliases) {
- $.each(perAliasIndexes, function (alias) {
+ $.each(perAliasIndexes, function(alias) {
ret.push(alias);
});
}
@@ -155,7 +153,7 @@ function getFieldNamesFromFieldMapping(fieldName, fieldMapping) {
function applyPathSettings(nestedFieldNames) {
const pathType = fieldMapping.path || 'full';
if (pathType === 'full') {
- return $.map(nestedFieldNames, function (f) {
+ return $.map(nestedFieldNames, function(f) {
f.name = fieldName + '.' + f.name;
return f;
});
@@ -178,7 +176,7 @@ function getFieldNamesFromFieldMapping(fieldName, fieldMapping) {
}
if (fieldMapping.fields) {
- nestedFields = $.map(fieldMapping.fields, function (fieldMapping, fieldName) {
+ nestedFields = $.map(fieldMapping.fields, function(fieldMapping, fieldName) {
return getFieldNamesFromFieldMapping(fieldName, fieldMapping);
});
nestedFields = applyPathSettings(nestedFields);
@@ -190,13 +188,12 @@ function getFieldNamesFromFieldMapping(fieldName, fieldMapping) {
}
function getFieldNamesFromProperties(properties = {}) {
- const fieldList =
- $.map(properties, function (fieldMapping, fieldName) {
- return getFieldNamesFromFieldMapping(fieldName, fieldMapping);
- });
+ const fieldList = $.map(properties, function(fieldMapping, fieldName) {
+ return getFieldNamesFromFieldMapping(fieldName, fieldMapping);
+ });
// deduping
- return _.uniq(fieldList, function (f) {
+ return _.uniq(fieldList, function(f) {
return f.name + ':' + f.type;
});
}
@@ -208,7 +205,7 @@ function loadTemplates(templatesObject = {}) {
function loadMappings(mappings) {
perIndexTypes = {};
- $.each(mappings, function (index, indexMapping) {
+ $.each(mappings, function(index, indexMapping) {
const normalizedIndexMappings = {};
// Migrate 1.0.0 mappings. This format has changed, so we need to extract the underlying mapping.
@@ -216,7 +213,7 @@ function loadMappings(mappings) {
indexMapping = indexMapping.mappings;
}
- $.each(indexMapping, function (typeName, typeMapping) {
+ $.each(indexMapping, function(typeName, typeMapping) {
if (typeName === 'properties') {
const fieldList = getFieldNamesFromProperties(typeMapping);
normalizedIndexMappings[typeName] = fieldList;
@@ -231,11 +228,11 @@ function loadMappings(mappings) {
function loadAliases(aliases) {
perAliasIndexes = {};
- $.each(aliases || {}, function (index, omdexAliases) {
+ $.each(aliases || {}, function(index, omdexAliases) {
// verify we have an index defined. useful when mapping loading is disabled
perIndexTypes[index] = perIndexTypes[index] || {};
- $.each(omdexAliases.aliases || {}, function (alias) {
+ $.each(omdexAliases.aliases || {}, function(alias) {
if (alias === index) {
return;
} // alias which is identical to index means no index.
@@ -275,7 +272,7 @@ function retrieveSettings(settingsKey, settingsToRetrieve) {
return settingsPromise.resolve();
}
// If the user doesn't want autocomplete suggestions, then clear any that exist
- return settingsPromise.resolveWith(this, [ [JSON.stringify({})] ]);
+ return settingsPromise.resolveWith(this, [[JSON.stringify({})]]);
}
}
@@ -290,57 +287,58 @@ function retrieveSettings(settingsKey, settingsToRetrieve) {
// unchanged alone (both selected and unselected).
// 3. Poll: Use saved. Fetch selected. Ignore unselected.
-
function clearSubscriptions() {
if (pollTimeoutId) {
clearTimeout(pollTimeoutId);
}
}
-
-function retrieveAutoCompleteInfo(settingsToRetrieve = legacyBackDoorToSettings().getAutocomplete()) {
+function retrieveAutoCompleteInfo(
+ settingsToRetrieve = legacyBackDoorToSettings().getAutocomplete()
+) {
clearSubscriptions();
const mappingPromise = retrieveSettings('fields', settingsToRetrieve);
const aliasesPromise = retrieveSettings('indices', settingsToRetrieve);
const templatesPromise = retrieveSettings('templates', settingsToRetrieve);
- $.when(mappingPromise, aliasesPromise, templatesPromise)
- .done((mappings, aliases, templates) => {
- let mappingsResponse;
- if (mappings) {
- const maxMappingSize = mappings[0].length > 10 * 1024 * 1024;
- if (maxMappingSize) {
- console.warn(`Mapping size is larger than 10MB (${mappings[0].length / 1024 / 1024} MB). Ignoring...`);
- mappingsResponse = '[{}]';
- } else {
- mappingsResponse = mappings[0];
- }
- loadMappings(JSON.parse(mappingsResponse));
+ $.when(mappingPromise, aliasesPromise, templatesPromise).done((mappings, aliases, templates) => {
+ let mappingsResponse;
+ if (mappings) {
+ const maxMappingSize = mappings[0].length > 10 * 1024 * 1024;
+ if (maxMappingSize) {
+ console.warn(
+ `Mapping size is larger than 10MB (${mappings[0].length / 1024 / 1024} MB). Ignoring...`
+ );
+ mappingsResponse = '[{}]';
+ } else {
+ mappingsResponse = mappings[0];
}
+ loadMappings(JSON.parse(mappingsResponse));
+ }
- if (aliases) {
- loadAliases(JSON.parse(aliases[0]));
- }
+ if (aliases) {
+ loadAliases(JSON.parse(aliases[0]));
+ }
- if (templates) {
- loadTemplates(JSON.parse(templates[0]));
- }
+ if (templates) {
+ loadTemplates(JSON.parse(templates[0]));
+ }
- if (mappings && aliases) {
- // Trigger an update event with the mappings, aliases
- $(mappingObj).trigger('update', [mappingsResponse, aliases[0]]);
- }
+ if (mappings && aliases) {
+ // Trigger an update event with the mappings, aliases
+ $(mappingObj).trigger('update', [mappingsResponse, aliases[0]]);
+ }
- // Schedule next request.
- pollTimeoutId = setTimeout(() => {
- // This looks strange/inefficient, but it ensures correct behavior because we don't want to send
- // a scheduled request if the user turns off polling.
- if (legacyBackDoorToSettings().getPolling()) {
- retrieveAutoCompleteInfo();
- }
- }, POLL_INTERVAL);
- });
+ // Schedule next request.
+ pollTimeoutId = setTimeout(() => {
+ // This looks strange/inefficient, but it ensures correct behavior because we don't want to send
+ // a scheduled request if the user turns off polling.
+ if (legacyBackDoorToSettings().getPolling()) {
+ retrieveAutoCompleteInfo();
+ }
+ }, POLL_INTERVAL);
+ });
}
export default {
@@ -353,5 +351,5 @@ export default {
expandAliases,
clear,
retrieveAutoCompleteInfo,
- clearSubscriptions
+ clearSubscriptions,
};
diff --git a/src/legacy/core_plugins/console/public/np_ready/lib/utils/__tests__/utils.test.js b/src/legacy/core_plugins/console/public/np_ready/lib/utils/__tests__/utils.test.js
index 827beadee0f0..374ad6706015 100644
--- a/src/legacy/core_plugins/console/public/np_ready/lib/utils/__tests__/utils.test.js
+++ b/src/legacy/core_plugins/console/public/np_ready/lib/utils/__tests__/utils.test.js
@@ -23,7 +23,6 @@ const collapsingTests = require('./utils_string_collapsing.txt');
const expandingTests = require('./utils_string_expanding.txt');
describe('Utils class', () => {
-
describe('collapseLiteralStrings', () => {
it('will collapse multiline strings', () => {
const multiline = '{ "foo": """bar\nbaz""" }';
@@ -36,8 +35,7 @@ describe('Utils class', () => {
});
});
-
- _.each(collapsingTests.split(/^=+$/m), function (fixture) {
+ _.each(collapsingTests.split(/^=+$/m), function(fixture) {
if (fixture.trim() === '') {
return;
}
@@ -46,12 +44,12 @@ describe('Utils class', () => {
const expanded = fixture[1].trim();
const collapsed = fixture[2].trim();
- test('Literal collapse - ' + name, function () {
+ test('Literal collapse - ' + name, function() {
expect(utils.collapseLiteralStrings(expanded)).toEqual(collapsed);
});
});
- _.each(expandingTests.split(/^=+$/m), function (fixture) {
+ _.each(expandingTests.split(/^=+$/m), function(fixture) {
if (fixture.trim() === '') {
return;
}
@@ -60,47 +58,77 @@ describe('Utils class', () => {
const collapsed = fixture[1].trim();
const expanded = fixture[2].trim();
- test('Literal expand - ' + name, function () {
+ test('Literal expand - ' + name, function() {
expect(utils.expandLiteralStrings(collapsed)).toEqual(expanded);
});
- test('extract deprecation messages', function () {
- expect(utils.extractDeprecationMessages(
- '299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning" "Mon, 27 Feb 2017 14:52:14 GMT"')).toEqual(
- ['#! Deprecation: this is a warning']);
- expect(utils.extractDeprecationMessages(
- '299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning"')).toEqual(
- ['#! Deprecation: this is a warning']);
-
- expect(utils.extractDeprecationMessages( //eslint-disable-next-line max-len
- '299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning" "Mon, 27 Feb 2017 14:52:14 GMT", 299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a second warning" "Mon, 27 Feb 2017 14:52:14 GMT"')).toEqual(
- ['#! Deprecation: this is a warning', '#! Deprecation: this is a second warning']);
- expect(utils.extractDeprecationMessages( //eslint-disable-next-line max-len
- '299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning", 299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a second warning"')).toEqual(
- ['#! Deprecation: this is a warning', '#! Deprecation: this is a second warning']);
-
- expect(utils.extractDeprecationMessages( //eslint-disable-next-line max-len
- '299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning, and it includes a comma" "Mon, 27 Feb 2017 14:52:14 GMT"')).toEqual(
- ['#! Deprecation: this is a warning, and it includes a comma']);
- expect(utils.extractDeprecationMessages( //eslint-disable-next-line max-len
- '299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning, and it includes a comma"')).toEqual(
- ['#! Deprecation: this is a warning, and it includes a comma']);
-
- expect(utils.extractDeprecationMessages( //eslint-disable-next-line max-len
- '299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning, and it includes an escaped backslash \\\\ and a pair of \\\"escaped quotes\\\"" "Mon, 27 Feb 2017 14:52:14 GMT"')).toEqual(
- ['#! Deprecation: this is a warning, and it includes an escaped backslash \\ and a pair of "escaped quotes"']);
- expect(utils.extractDeprecationMessages( //eslint-disable-next-line max-len
- '299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning, and it includes an escaped backslash \\\\ and a pair of \\\"escaped quotes\\\""')).toEqual(
- ['#! Deprecation: this is a warning, and it includes an escaped backslash \\ and a pair of "escaped quotes"']);
+ test('extract deprecation messages', function() {
+ expect(
+ utils.extractDeprecationMessages(
+ '299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning" "Mon, 27 Feb 2017 14:52:14 GMT"'
+ )
+ ).toEqual(['#! Deprecation: this is a warning']);
+ expect(
+ utils.extractDeprecationMessages(
+ '299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning"'
+ )
+ ).toEqual(['#! Deprecation: this is a warning']);
+
+ expect(
+ utils.extractDeprecationMessages(
+ //eslint-disable-next-line max-len
+ '299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning" "Mon, 27 Feb 2017 14:52:14 GMT", 299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a second warning" "Mon, 27 Feb 2017 14:52:14 GMT"'
+ )
+ ).toEqual(['#! Deprecation: this is a warning', '#! Deprecation: this is a second warning']);
+ expect(
+ utils.extractDeprecationMessages(
+ //eslint-disable-next-line max-len
+ '299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning", 299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a second warning"'
+ )
+ ).toEqual(['#! Deprecation: this is a warning', '#! Deprecation: this is a second warning']);
+
+ expect(
+ utils.extractDeprecationMessages(
+ //eslint-disable-next-line max-len
+ '299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning, and it includes a comma" "Mon, 27 Feb 2017 14:52:14 GMT"'
+ )
+ ).toEqual(['#! Deprecation: this is a warning, and it includes a comma']);
+ expect(
+ utils.extractDeprecationMessages(
+ //eslint-disable-next-line max-len
+ '299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning, and it includes a comma"'
+ )
+ ).toEqual(['#! Deprecation: this is a warning, and it includes a comma']);
+
+ expect(
+ utils.extractDeprecationMessages(
+ //eslint-disable-next-line max-len
+ '299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning, and it includes an escaped backslash \\\\ and a pair of \\"escaped quotes\\"" "Mon, 27 Feb 2017 14:52:14 GMT"'
+ )
+ ).toEqual([
+ '#! Deprecation: this is a warning, and it includes an escaped backslash \\ and a pair of "escaped quotes"',
+ ]);
+ expect(
+ utils.extractDeprecationMessages(
+ //eslint-disable-next-line max-len
+ '299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning, and it includes an escaped backslash \\\\ and a pair of \\"escaped quotes\\""'
+ )
+ ).toEqual([
+ '#! Deprecation: this is a warning, and it includes an escaped backslash \\ and a pair of "escaped quotes"',
+ ]);
});
- test('unescape', function () {
+ test('unescape', function() {
expect(utils.unescape('escaped backslash \\\\')).toEqual('escaped backslash \\');
- expect(utils.unescape('a pair of \\\"escaped quotes\\\"')).toEqual('a pair of "escaped quotes"');
- expect(utils.unescape('escaped quotes do not have to come in pairs: \\\"')).toEqual('escaped quotes do not have to come in pairs: "');
+ expect(utils.unescape('a pair of \\"escaped quotes\\"')).toEqual(
+ 'a pair of "escaped quotes"'
+ );
+ expect(utils.unescape('escaped quotes do not have to come in pairs: \\"')).toEqual(
+ 'escaped quotes do not have to come in pairs: "'
+ );
});
- test('split on unquoted comma followed by space', function () {
+ test('split on unquoted comma followed by space', function() {
expect(utils.splitOnUnquotedCommaSpace('a, b')).toEqual(['a', 'b']);
expect(utils.splitOnUnquotedCommaSpace('a,b, c')).toEqual(['a,b', 'c']);
expect(utils.splitOnUnquotedCommaSpace('"a, b"')).toEqual(['"a, b"']);
@@ -108,8 +136,12 @@ describe('Utils class', () => {
expect(utils.splitOnUnquotedCommaSpace('"a, b\\", c"')).toEqual(['"a, b\\", c"']);
expect(utils.splitOnUnquotedCommaSpace(', a, b')).toEqual(['', 'a', 'b']);
expect(utils.splitOnUnquotedCommaSpace('a, b, ')).toEqual(['a', 'b', '']);
- expect(utils.splitOnUnquotedCommaSpace('\\"a, b", "c, d\\", e", f"')).toEqual(['\\"a', 'b", "c', 'd\\"', 'e", f"']);
+ expect(utils.splitOnUnquotedCommaSpace('\\"a, b", "c, d\\", e", f"')).toEqual([
+ '\\"a',
+ 'b", "c',
+ 'd\\"',
+ 'e", f"',
+ ]);
});
});
-
});
diff --git a/src/legacy/core_plugins/console/server/__tests__/elasticsearch_proxy_config.js b/src/legacy/core_plugins/console/server/__tests__/elasticsearch_proxy_config.js
index 45d834693663..2942e76f2762 100644
--- a/src/legacy/core_plugins/console/server/__tests__/elasticsearch_proxy_config.js
+++ b/src/legacy/core_plugins/console/server/__tests__/elasticsearch_proxy_config.js
@@ -35,9 +35,9 @@ const getDefaultElasticsearchConfig = () => {
};
};
-describe('plugins/console', function () {
- describe('#getElasticsearchProxyConfig', function () {
- it('sets timeout', function () {
+describe('plugins/console', function() {
+ describe('#getElasticsearchProxyConfig', function() {
+ it('sets timeout', function() {
const value = 1000;
const proxyConfig = getElasticsearchProxyConfig({
...getDefaultElasticsearchConfig(),
@@ -46,7 +46,7 @@ describe('plugins/console', function () {
expect(proxyConfig.timeout).to.be(value);
});
- it(`uses https.Agent when url's protocol is https`, function () {
+ it(`uses https.Agent when url's protocol is https`, function() {
const { agent } = getElasticsearchProxyConfig({
...getDefaultElasticsearchConfig(),
hosts: ['https://localhost:9200'],
@@ -54,82 +54,84 @@ describe('plugins/console', function () {
expect(agent).to.be.a(https.Agent);
});
- it(`uses http.Agent when url's protocol is http`, function () {
+ it(`uses http.Agent when url's protocol is http`, function() {
const { agent } = getElasticsearchProxyConfig(getDefaultElasticsearchConfig());
expect(agent).to.be.a(http.Agent);
});
- describe('ssl', function () {
+ describe('ssl', function() {
let config;
- beforeEach(function () {
+ beforeEach(function() {
config = {
...getDefaultElasticsearchConfig(),
hosts: ['https://localhost:9200'],
};
});
- it('sets rejectUnauthorized to false when verificationMode is none', function () {
+ it('sets rejectUnauthorized to false when verificationMode is none', function() {
const { agent } = getElasticsearchProxyConfig({
...config,
- ssl: { ...config.ssl, verificationMode: 'none' }
+ ssl: { ...config.ssl, verificationMode: 'none' },
});
expect(agent.options.rejectUnauthorized).to.be(false);
});
- it('sets rejectUnauthorized to true when verificationMode is certificate', function () {
+ it('sets rejectUnauthorized to true when verificationMode is certificate', function() {
const { agent } = getElasticsearchProxyConfig({
...config,
- ssl: { ...config.ssl, verificationMode: 'certificate' }
+ ssl: { ...config.ssl, verificationMode: 'certificate' },
});
expect(agent.options.rejectUnauthorized).to.be(true);
});
- it('sets checkServerIdentity to not check hostname when verificationMode is certificate', function () {
+ it('sets checkServerIdentity to not check hostname when verificationMode is certificate', function() {
const { agent } = getElasticsearchProxyConfig({
...config,
- ssl: { ...config.ssl, verificationMode: 'certificate' }
+ ssl: { ...config.ssl, verificationMode: 'certificate' },
});
const cert = {
subject: {
- CN: 'wrong.com'
- }
+ CN: 'wrong.com',
+ },
};
- expect(agent.options.checkServerIdentity).withArgs('right.com', cert).to.not.throwException();
+ expect(agent.options.checkServerIdentity)
+ .withArgs('right.com', cert)
+ .to.not.throwException();
const result = agent.options.checkServerIdentity('right.com', cert);
expect(result).to.be(undefined);
});
- it('sets rejectUnauthorized to true when verificationMode is full', function () {
+ it('sets rejectUnauthorized to true when verificationMode is full', function() {
const { agent } = getElasticsearchProxyConfig({
...config,
- ssl: { ...config.ssl, verificationMode: 'full' }
+ ssl: { ...config.ssl, verificationMode: 'full' },
});
expect(agent.options.rejectUnauthorized).to.be(true);
});
- it(`doesn't set checkServerIdentity when verificationMode is full`, function () {
+ it(`doesn't set checkServerIdentity when verificationMode is full`, function() {
const { agent } = getElasticsearchProxyConfig({
...config,
- ssl: { ...config.ssl, verificationMode: 'full' }
+ ssl: { ...config.ssl, verificationMode: 'full' },
});
expect(agent.options.checkServerIdentity).to.be(undefined);
});
- it(`sets ca when certificateAuthorities are specified`, function () {
+ it(`sets ca when certificateAuthorities are specified`, function() {
const { agent } = getElasticsearchProxyConfig({
...config,
- ssl: { ...config.ssl, certificateAuthorities: [__dirname + '/fixtures/ca.crt'] }
+ ssl: { ...config.ssl, certificateAuthorities: [__dirname + '/fixtures/ca.crt'] },
});
expect(agent.options.ca).to.contain('test ca certificate\n');
});
describe('when alwaysPresentCertificate is false', () => {
- it(`doesn't set cert and key when certificate and key paths are specified`, function () {
+ it(`doesn't set cert and key when certificate and key paths are specified`, function() {
const { agent } = getElasticsearchProxyConfig({
...config,
ssl: {
@@ -137,14 +139,14 @@ describe('plugins/console', function () {
alwaysPresentCertificate: false,
certificate: __dirname + '/fixtures/cert.crt',
key: __dirname + '/fixtures/cert.key',
- }
+ },
});
expect(agent.options.cert).to.be(undefined);
expect(agent.options.key).to.be(undefined);
});
- it(`doesn't set passphrase when certificate, key and keyPassphrase are specified`, function () {
+ it(`doesn't set passphrase when certificate, key and keyPassphrase are specified`, function() {
const { agent } = getElasticsearchProxyConfig({
...config,
ssl: {
@@ -153,7 +155,7 @@ describe('plugins/console', function () {
certificate: __dirname + '/fixtures/cert.crt',
key: __dirname + '/fixtures/cert.key',
keyPassphrase: 'secret',
- }
+ },
});
expect(agent.options.passphrase).to.be(undefined);
@@ -161,7 +163,7 @@ describe('plugins/console', function () {
});
describe('when alwaysPresentCertificate is true', () => {
- it(`sets cert and key when certificate and key paths are specified`, async function () {
+ it(`sets cert and key when certificate and key paths are specified`, async function() {
const certificatePath = __dirname + '/fixtures/cert.crt';
const keyPath = __dirname + '/fixtures/cert.key';
@@ -172,14 +174,14 @@ describe('plugins/console', function () {
alwaysPresentCertificate: true,
certificate: certificatePath,
key: keyPath,
- }
+ },
});
expect(agent.options.cert).to.be(await readFileAsync(certificatePath, 'utf8'));
expect(agent.options.key).to.be(await readFileAsync(keyPath, 'utf8'));
});
- it(`sets passphrase when certificate, key and keyPassphrase are specified`, function () {
+ it(`sets passphrase when certificate, key and keyPassphrase are specified`, function() {
const { agent } = getElasticsearchProxyConfig({
...config,
ssl: {
@@ -188,13 +190,13 @@ describe('plugins/console', function () {
certificate: __dirname + '/fixtures/cert.crt',
key: __dirname + '/fixtures/cert.key',
keyPassphrase: 'secret',
- }
+ },
});
expect(agent.options.passphrase).to.be('secret');
});
- it(`doesn't set cert when only certificate path is specified`, async function () {
+ it(`doesn't set cert when only certificate path is specified`, async function() {
const certificatePath = __dirname + '/fixtures/cert.crt';
const { agent } = getElasticsearchProxyConfig({
...config,
@@ -203,14 +205,14 @@ describe('plugins/console', function () {
alwaysPresentCertificate: true,
certificate: certificatePath,
key: undefined,
- }
+ },
});
expect(agent.options.cert).to.be(undefined);
expect(agent.options.key).to.be(undefined);
});
- it(`doesn't set key when only key path is specified`, async function () {
+ it(`doesn't set key when only key path is specified`, async function() {
const keyPath = __dirname + '/fixtures/cert.key';
const { agent } = getElasticsearchProxyConfig({
...config,
@@ -219,13 +221,12 @@ describe('plugins/console', function () {
alwaysPresentCertificate: true,
certificate: undefined,
key: keyPath,
- }
+ },
});
expect(agent.options.cert).to.be(undefined);
expect(agent.options.key).to.be(undefined);
});
-
});
});
});
diff --git a/src/legacy/core_plugins/console/server/__tests__/proxy_config.js b/src/legacy/core_plugins/console/server/__tests__/proxy_config.js
index dd6d9c4de760..821fb8bef64d 100644
--- a/src/legacy/core_plugins/console/server/__tests__/proxy_config.js
+++ b/src/legacy/core_plugins/console/server/__tests__/proxy_config.js
@@ -30,34 +30,34 @@ import { ProxyConfig } from '../proxy_config';
const matchGoogle = {
protocol: 'https',
host: 'google.com',
- path: '/search'
+ path: '/search',
};
const parsedGoogle = parseUrl('https://google.com/search');
const parsedLocalEs = parseUrl('https://localhost:5601/search');
-describe('ProxyConfig', function () {
- beforeEach(function () {
- sinon.stub(fs, 'readFileSync').callsFake((path) => ({ path }));
+describe('ProxyConfig', function() {
+ beforeEach(function() {
+ sinon.stub(fs, 'readFileSync').callsFake(path => ({ path }));
});
- afterEach(function () {
+ afterEach(function() {
fs.readFileSync.restore();
});
- describe('constructor', function () {
- beforeEach(function () {
+ describe('constructor', function() {
+ beforeEach(function() {
sinon.stub(https, 'Agent');
});
- afterEach(function () {
+ afterEach(function() {
https.Agent.restore();
});
- it('uses ca to create sslAgent', function () {
+ it('uses ca to create sslAgent', function() {
const config = new ProxyConfig({
ssl: {
- ca: ['path/to/ca']
- }
+ ca: ['path/to/ca'],
+ },
});
expect(config.sslAgent).to.be.a(https.Agent);
@@ -67,16 +67,16 @@ describe('ProxyConfig', function () {
ca: [{ path: 'path/to/ca' }],
cert: undefined,
key: undefined,
- rejectUnauthorized: true
+ rejectUnauthorized: true,
});
});
- it('uses cert, and key to create sslAgent', function () {
+ it('uses cert, and key to create sslAgent', function() {
const config = new ProxyConfig({
ssl: {
cert: 'path/to/cert',
- key: 'path/to/key'
- }
+ key: 'path/to/key',
+ },
});
expect(config.sslAgent).to.be.a(https.Agent);
@@ -86,18 +86,18 @@ describe('ProxyConfig', function () {
ca: undefined,
cert: { path: 'path/to/cert' },
key: { path: 'path/to/key' },
- rejectUnauthorized: true
+ rejectUnauthorized: true,
});
});
- it('uses ca, cert, and key to create sslAgent', function () {
+ it('uses ca, cert, and key to create sslAgent', function() {
const config = new ProxyConfig({
ssl: {
ca: ['path/to/ca'],
cert: 'path/to/cert',
key: 'path/to/key',
- rejectUnauthorized: true
- }
+ rejectUnauthorized: true,
+ },
});
expect(config.sslAgent).to.be.a(https.Agent);
@@ -107,90 +107,90 @@ describe('ProxyConfig', function () {
ca: [{ path: 'path/to/ca' }],
cert: { path: 'path/to/cert' },
key: { path: 'path/to/key' },
- rejectUnauthorized: true
+ rejectUnauthorized: true,
});
});
});
- describe('#getForParsedUri', function () {
- describe('parsed url does not match', function () {
- it('returns {}', function () {
+ describe('#getForParsedUri', function() {
+ describe('parsed url does not match', function() {
+ it('returns {}', function() {
const config = new ProxyConfig({
match: matchGoogle,
- timeout: 100
+ timeout: 100,
});
expect(config.getForParsedUri(parsedLocalEs)).to.eql({});
});
});
- describe('parsed url does match', function () {
- it('assigns timeout value', function () {
+ describe('parsed url does match', function() {
+ it('assigns timeout value', function() {
const football = {};
const config = new ProxyConfig({
match: matchGoogle,
- timeout: football
+ timeout: football,
});
expect(config.getForParsedUri(parsedGoogle).timeout).to.be(football);
});
- it('assigns ssl.verify to rejectUnauthorized', function () {
+ it('assigns ssl.verify to rejectUnauthorized', function() {
const football = {};
const config = new ProxyConfig({
match: matchGoogle,
ssl: {
- verify: football
- }
+ verify: football,
+ },
});
expect(config.getForParsedUri(parsedGoogle).rejectUnauthorized).to.be(football);
});
- describe('uri us http', function () {
- describe('ca is set', function () {
- it('creates but does not output the agent', function () {
+ describe('uri us http', function() {
+ describe('ca is set', function() {
+ it('creates but does not output the agent', function() {
const config = new ProxyConfig({
ssl: {
- ca: ['path/to/ca']
- }
+ ca: ['path/to/ca'],
+ },
});
expect(config.sslAgent).to.be.an(HttpsAgent);
expect(config.getForParsedUri({ protocol: 'http:' }).agent).to.be(undefined);
});
});
- describe('cert is set', function () {
- it('creates but does not output the agent', function () {
+ describe('cert is set', function() {
+ it('creates but does not output the agent', function() {
const config = new ProxyConfig({
ssl: {
- cert: 'path/to/cert'
- }
+ cert: 'path/to/cert',
+ },
});
expect(config.sslAgent).to.be.an(HttpsAgent);
expect(config.getForParsedUri({ protocol: 'http:' }).agent).to.be(undefined);
});
});
- describe('key is set', function () {
- it('creates but does not output the agent', function () {
+ describe('key is set', function() {
+ it('creates but does not output the agent', function() {
const config = new ProxyConfig({
ssl: {
- key: 'path/to/key'
- }
+ key: 'path/to/key',
+ },
});
expect(config.sslAgent).to.be.an(HttpsAgent);
expect(config.getForParsedUri({ protocol: 'http:' }).agent).to.be(undefined);
});
});
- describe('cert + key are set', function () {
- it('creates but does not output the agent', function () {
+ describe('cert + key are set', function() {
+ it('creates but does not output the agent', function() {
const config = new ProxyConfig({
ssl: {
cert: 'path/to/cert',
- key: 'path/to/key'
- }
+ key: 'path/to/key',
+ },
});
expect(config.sslAgent).to.be.an(HttpsAgent);
@@ -199,50 +199,50 @@ describe('ProxyConfig', function () {
});
});
- describe('uri us https', function () {
- describe('ca is set', function () {
- it('creates and outputs the agent', function () {
+ describe('uri us https', function() {
+ describe('ca is set', function() {
+ it('creates and outputs the agent', function() {
const config = new ProxyConfig({
ssl: {
- ca: ['path/to/ca']
- }
+ ca: ['path/to/ca'],
+ },
});
expect(config.sslAgent).to.be.an(HttpsAgent);
expect(config.getForParsedUri({ protocol: 'https:' }).agent).to.be(config.sslAgent);
});
});
- describe('cert is set', function () {
- it('creates and outputs the agent', function () {
+ describe('cert is set', function() {
+ it('creates and outputs the agent', function() {
const config = new ProxyConfig({
ssl: {
- cert: 'path/to/cert'
- }
+ cert: 'path/to/cert',
+ },
});
expect(config.sslAgent).to.be.an(HttpsAgent);
expect(config.getForParsedUri({ protocol: 'https:' }).agent).to.be(config.sslAgent);
});
});
- describe('key is set', function () {
- it('creates and outputs the agent', function () {
+ describe('key is set', function() {
+ it('creates and outputs the agent', function() {
const config = new ProxyConfig({
ssl: {
- key: 'path/to/key'
- }
+ key: 'path/to/key',
+ },
});
expect(config.sslAgent).to.be.an(HttpsAgent);
expect(config.getForParsedUri({ protocol: 'https:' }).agent).to.be(config.sslAgent);
});
});
- describe('cert + key are set', function () {
- it('creates and outputs the agent', function () {
+ describe('cert + key are set', function() {
+ it('creates and outputs the agent', function() {
const config = new ProxyConfig({
ssl: {
cert: 'path/to/cert',
- key: 'path/to/key'
- }
+ key: 'path/to/key',
+ },
});
expect(config.sslAgent).to.be.an(HttpsAgent);
diff --git a/src/legacy/core_plugins/console/server/__tests__/proxy_config_collection.js b/src/legacy/core_plugins/console/server/__tests__/proxy_config_collection.js
index e575b0f707aa..1791ca9865d2 100644
--- a/src/legacy/core_plugins/console/server/__tests__/proxy_config_collection.js
+++ b/src/legacy/core_plugins/console/server/__tests__/proxy_config_collection.js
@@ -26,12 +26,12 @@ import { Agent as HttpsAgent } from 'https';
import { ProxyConfigCollection } from '../proxy_config_collection';
-describe('ProxyConfigCollection', function () {
- beforeEach(function () {
+describe('ProxyConfigCollection', function() {
+ beforeEach(function() {
sinon.stub(fs, 'readFileSync').callsFake(() => Buffer.alloc(0));
});
- afterEach(function () {
+ afterEach(function() {
fs.readFileSync.restore();
});
@@ -41,7 +41,7 @@ describe('ProxyConfigCollection', function () {
protocol: 'https',
host: 'localhost',
port: 5601,
- path: '/.kibana'
+ path: '/.kibana',
},
timeout: 1,
@@ -51,7 +51,7 @@ describe('ProxyConfigCollection', function () {
match: {
protocol: 'https',
host: 'localhost',
- port: 5601
+ port: 5601,
},
timeout: 2,
@@ -60,7 +60,7 @@ describe('ProxyConfigCollection', function () {
{
match: {
host: 'localhost',
- port: 5601
+ port: 5601,
},
timeout: 3,
@@ -68,7 +68,7 @@ describe('ProxyConfigCollection', function () {
{
match: {
- host: 'localhost'
+ host: 'localhost',
},
timeout: 4,
@@ -77,8 +77,8 @@ describe('ProxyConfigCollection', function () {
{
match: {},
- timeout: 5
- }
+ timeout: 5,
+ },
];
function getTimeout(uri) {
@@ -86,87 +86,87 @@ describe('ProxyConfigCollection', function () {
return collection.configForUri(uri).timeout;
}
- describe('http://localhost:5601', function () {
- it('defaults to the first matching timeout', function () {
+ describe('http://localhost:5601', function() {
+ it('defaults to the first matching timeout', function() {
expect(getTimeout('http://localhost:5601')).to.be(3);
});
});
- describe('https://localhost:5601/.kibana', function () {
- it('defaults to the first matching timeout', function () {
+ describe('https://localhost:5601/.kibana', function() {
+ it('defaults to the first matching timeout', function() {
expect(getTimeout('https://localhost:5601/.kibana')).to.be(1);
});
});
- describe('http://localhost:5602', function () {
- it('defaults to the first matching timeout', function () {
+ describe('http://localhost:5602', function() {
+ it('defaults to the first matching timeout', function() {
expect(getTimeout('http://localhost:5602')).to.be(4);
});
});
- describe('https://localhost:5602', function () {
- it('defaults to the first matching timeout', function () {
+ describe('https://localhost:5602', function() {
+ it('defaults to the first matching timeout', function() {
expect(getTimeout('https://localhost:5602')).to.be(4);
});
});
- describe('http://localhost:5603', function () {
- it('defaults to the first matching timeout', function () {
+ describe('http://localhost:5603', function() {
+ it('defaults to the first matching timeout', function() {
expect(getTimeout('http://localhost:5603')).to.be(4);
});
});
- describe('https://localhost:5603', function () {
- it('defaults to the first matching timeout', function () {
+ describe('https://localhost:5603', function() {
+ it('defaults to the first matching timeout', function() {
expect(getTimeout('https://localhost:5603')).to.be(4);
});
});
- describe('https://localhost:5601/index', function () {
- it('defaults to the first matching timeout', function () {
+ describe('https://localhost:5601/index', function() {
+ it('defaults to the first matching timeout', function() {
expect(getTimeout('https://localhost:5601/index')).to.be(2);
});
});
- describe('http://localhost:5601/index', function () {
- it('defaults to the first matching timeout', function () {
+ describe('http://localhost:5601/index', function() {
+ it('defaults to the first matching timeout', function() {
expect(getTimeout('http://localhost:5601/index')).to.be(3);
});
});
- describe('https://localhost:5601/index/type', function () {
- it('defaults to the first matching timeout', function () {
+ describe('https://localhost:5601/index/type', function() {
+ it('defaults to the first matching timeout', function() {
expect(getTimeout('https://localhost:5601/index/type')).to.be(2);
});
});
- describe('http://notlocalhost', function () {
- it('defaults to the first matching timeout', function () {
+ describe('http://notlocalhost', function() {
+ it('defaults to the first matching timeout', function() {
expect(getTimeout('http://notlocalhost')).to.be(5);
});
});
- describe('collection with ssl config and root level verify:false', function () {
+ describe('collection with ssl config and root level verify:false', function() {
function makeCollection() {
return new ProxyConfigCollection([
{
match: { host: '*.internal.org' },
- ssl: { ca: ['path/to/ca'] }
+ ssl: { ca: ['path/to/ca'] },
},
{
match: { host: '*' },
- ssl: { verify: false }
- }
+ ssl: { verify: false },
+ },
]);
}
- it('verifies for config that produces ssl agent', function () {
+ it('verifies for config that produces ssl agent', function() {
const conf = makeCollection().configForUri('https://es.internal.org/_search');
expect(conf.agent.options).to.have.property('rejectUnauthorized', true);
expect(conf.agent).to.be.an(HttpsAgent);
});
- it('disabled verification for * config', function () {
+ it('disabled verification for * config', function() {
const conf = makeCollection().configForUri('https://extenal.org/_search');
expect(conf).to.have.property('rejectUnauthorized', false);
expect(conf.agent).to.be(undefined);
diff --git a/src/legacy/core_plugins/console/server/__tests__/proxy_route/body.js b/src/legacy/core_plugins/console/server/__tests__/proxy_route/body.js
index a7fd8df1b10f..923567769a6b 100644
--- a/src/legacy/core_plugins/console/server/__tests__/proxy_route/body.js
+++ b/src/legacy/core_plugins/console/server/__tests__/proxy_route/body.js
@@ -29,7 +29,6 @@ describe('Console Proxy Route', () => {
const teardowns = [];
let request;
-
beforeEach(() => {
request = async (method, path, response) => {
sandbox.stub(requestModule, 'sendRequest').callsFake(createResponseStub(response));
diff --git a/src/legacy/core_plugins/console/server/__tests__/proxy_route/headers.js b/src/legacy/core_plugins/console/server/__tests__/proxy_route/headers.js
index 347b8dae80e2..3a8233775f9b 100644
--- a/src/legacy/core_plugins/console/server/__tests__/proxy_route/headers.js
+++ b/src/legacy/core_plugins/console/server/__tests__/proxy_route/headers.js
@@ -55,7 +55,7 @@ describe('Console Proxy Route', () => {
await Promise.all(teardowns.splice(0).map(fn => fn()));
});
- describe('headers', function () {
+ describe('headers', function() {
this.timeout(Infinity);
it('forwards the remote header info', async () => {
diff --git a/src/legacy/core_plugins/console/server/__tests__/proxy_route/stubs.js b/src/legacy/core_plugins/console/server/__tests__/proxy_route/stubs.js
index 6305741b4af1..18ad277c0bf6 100644
--- a/src/legacy/core_plugins/console/server/__tests__/proxy_route/stubs.js
+++ b/src/legacy/core_plugins/console/server/__tests__/proxy_route/stubs.js
@@ -27,14 +27,14 @@ export function createResponseStub(response) {
this.push(response);
}
this.push(null);
- }
+ },
});
resp.statusCode = 200;
resp.statusMessage = 'OK';
resp.headers = {
'content-type': 'text/plain',
- 'content-length': String(response ? response.length : 0)
+ 'content-length': String(response ? response.length : 0),
};
return resp;
diff --git a/src/legacy/core_plugins/console/server/__tests__/set_headers.js b/src/legacy/core_plugins/console/server/__tests__/set_headers.js
index a270cca1e586..3cab23a05884 100644
--- a/src/legacy/core_plugins/console/server/__tests__/set_headers.js
+++ b/src/legacy/core_plugins/console/server/__tests__/set_headers.js
@@ -20,18 +20,18 @@
import expect from '@kbn/expect';
import { setHeaders } from '../set_headers';
-describe('#set_headers', function () {
- it('throws if not given an object as the first argument', function () {
+describe('#set_headers', function() {
+ it('throws if not given an object as the first argument', function() {
const fn = () => setHeaders(null, {});
expect(fn).to.throwError();
});
- it('throws if not given an object as the second argument', function () {
+ it('throws if not given an object as the second argument', function() {
const fn = () => setHeaders({}, null);
expect(fn).to.throwError();
});
- it('returns a new object', function () {
+ it('returns a new object', function() {
const originalHeaders = {};
const newHeaders = {};
const returnedHeaders = setHeaders(originalHeaders, newHeaders);
@@ -39,14 +39,14 @@ describe('#set_headers', function () {
expect(returnedHeaders).not.to.be(newHeaders);
});
- it('returns object with newHeaders merged with originalHeaders', function () {
+ it('returns object with newHeaders merged with originalHeaders', function() {
const originalHeaders = { foo: 'bar' };
const newHeaders = { one: 'two' };
const returnedHeaders = setHeaders(originalHeaders, newHeaders);
expect(returnedHeaders).to.eql({ foo: 'bar', one: 'two' });
});
- it('returns object where newHeaders takes precedence for any matching keys', function () {
+ it('returns object where newHeaders takes precedence for any matching keys', function() {
const originalHeaders = { foo: 'bar' };
const newHeaders = { one: 'two', foo: 'notbar' };
const returnedHeaders = setHeaders(originalHeaders, newHeaders);
diff --git a/src/legacy/core_plugins/console/server/__tests__/wildcard_matcher.js b/src/legacy/core_plugins/console/server/__tests__/wildcard_matcher.js
index 4eb0de4e5ebe..5969b94d7e67 100644
--- a/src/legacy/core_plugins/console/server/__tests__/wildcard_matcher.js
+++ b/src/legacy/core_plugins/console/server/__tests__/wildcard_matcher.js
@@ -32,9 +32,8 @@ function shouldNot(candidate, ...constructorArgs) {
}
}
-
-describe('WildcardMatcher', function () {
- describe('pattern = *', function () {
+describe('WildcardMatcher', function() {
+ describe('pattern = *', function() {
it('matches http', () => should('http', '*'));
it('matches https', () => should('https', '*'));
it('matches nothing', () => should('', '*'));
@@ -42,12 +41,12 @@ describe('WildcardMatcher', function () {
it('matches localhost', () => should('localhost', '*'));
it('matches a path', () => should('/index/type/_search', '*'));
- describe('defaultValue = /', function () {
+ describe('defaultValue = /', function() {
it('matches /', () => should('/', '*', '/'));
});
});
- describe('pattern = http', function () {
+ describe('pattern = http', function() {
it('matches http', () => should('http', 'http'));
it('does not match https', () => shouldNot('https', 'http'));
it('does not match nothing', () => shouldNot('', 'http'));
@@ -55,7 +54,7 @@ describe('WildcardMatcher', function () {
it('does not match a path', () => shouldNot('/index/type/_search', 'http'));
});
- describe('pattern = 560{1..9}', function () {
+ describe('pattern = 560{1..9}', function() {
it('does not match http', () => shouldNot('http', '560{1..9}'));
it('does not matches 5600', () => shouldNot('5600', '560{1..9}'));
it('matches 5601', () => should('5601', '560{1..9}'));
diff --git a/src/legacy/core_plugins/console/server/api_server/api.js b/src/legacy/core_plugins/console/server/api_server/api.js
index 7a24cf8ea821..9c3835013bce 100644
--- a/src/legacy/core_plugins/console/server/api_server/api.js
+++ b/src/legacy/core_plugins/console/server/api_server/api.js
@@ -28,7 +28,7 @@ class Api {
addGlobalAutocompleteRules = (parentNode, rules) => {
this.globalRules[parentNode] = rules;
- }
+ };
addEndpointDescription = (endpoint, description = {}) => {
let copiedDescription = {};
@@ -36,7 +36,7 @@ class Api {
copiedDescription = { ...this.endpoints[endpoint] };
}
let urlParamsDef;
- _.each(description.patterns || [], function (p) {
+ _.each(description.patterns || [], function(p) {
if (p.indexOf('{indices}') >= 0) {
urlParamsDef = urlParamsDef || {};
urlParamsDef.ignore_unavailable = '__flag__';
@@ -54,20 +54,19 @@ class Api {
_.defaults(copiedDescription, {
id: endpoint,
patterns: [endpoint],
- methods: ['GET']
+ methods: ['GET'],
});
this.endpoints[endpoint] = copiedDescription;
- }
+ };
asJson() {
return {
- 'name': this.name,
- 'globals': this.globalRules,
- 'endpoints': this.endpoints
+ name: this.name,
+ globals: this.globalRules,
+ endpoints: this.endpoints,
};
}
-
}
export default Api;
diff --git a/src/legacy/core_plugins/console/server/api_server/es_6_0/aggregations.js b/src/legacy/core_plugins/console/server/api_server/es_6_0/aggregations.js
index c2596dc4258d..629e143aa2b4 100644
--- a/src/legacy/core_plugins/console/server/api_server/es_6_0/aggregations.js
+++ b/src/legacy/core_plugins/console/server/api_server/es_6_0/aggregations.js
@@ -526,7 +526,7 @@ const rules = {
},
};
const { terms, histogram, date_histogram } = rules['*'];
-export default function (api) {
+export default function(api) {
api.addGlobalAutocompleteRules('aggregations', rules);
api.addGlobalAutocompleteRules('aggs', rules);
api.addGlobalAutocompleteRules('groupByAggs', { '*': { terms, histogram, date_histogram } });
diff --git a/src/legacy/core_plugins/console/server/api_server/es_6_0/aliases.js b/src/legacy/core_plugins/console/server/api_server/es_6_0/aliases.js
index babc17a25b8c..f46713fb8dd3 100644
--- a/src/legacy/core_plugins/console/server/api_server/es_6_0/aliases.js
+++ b/src/legacy/core_plugins/console/server/api_server/es_6_0/aliases.js
@@ -17,14 +17,14 @@
* under the License.
*/
-export default function (api) {
+export default function(api) {
const aliasRules = {
filter: {},
routing: '1',
search_routing: '1,2',
- index_routing: '1'
+ index_routing: '1',
};
api.addGlobalAutocompleteRules('aliases', {
- '*': aliasRules
+ '*': aliasRules,
});
}
diff --git a/src/legacy/core_plugins/console/server/api_server/es_6_0/document.js b/src/legacy/core_plugins/console/server/api_server/es_6_0/document.js
index d8776f9414bd..2bdaa2ec2af9 100644
--- a/src/legacy/core_plugins/console/server/api_server/es_6_0/document.js
+++ b/src/legacy/core_plugins/console/server/api_server/es_6_0/document.js
@@ -17,63 +17,55 @@
* under the License.
*/
-export default function (api) {
+export default function(api) {
api.addEndpointDescription('update', {
data_autocomplete_rules: {
- 'script': {
+ script: {
// populated by a global rule
},
- 'doc': {},
- 'upsert': {},
- 'scripted_upsert': { __one_of: [true, false] }
- }
-
+ doc: {},
+ upsert: {},
+ scripted_upsert: { __one_of: [true, false] },
+ },
});
api.addEndpointDescription('put_script', {
methods: ['POST', 'PUT'],
- patterns: [
- '_scripts/{lang}/{id}',
- '_scripts/{lang}/{id}/_create'
- ],
+ patterns: ['_scripts/{lang}/{id}', '_scripts/{lang}/{id}/_create'],
url_components: {
- 'lang': [
- 'groovy',
- 'expressions'
- ]
+ lang: ['groovy', 'expressions'],
},
data_autocomplete_rules: {
- 'script': ''
- }
+ script: '',
+ },
});
api.addEndpointDescription('termvectors', {
data_autocomplete_rules: {
- fields: [
- '{field}'
- ],
+ fields: ['{field}'],
offsets: { __one_of: [false, true] },
payloads: { __one_of: [false, true] },
positions: { __one_of: [false, true] },
term_statistics: { __one_of: [true, false] },
field_statistics: { __one_of: [false, true] },
per_field_analyzer: {
- __template: { 'FIELD': '' },
- '{field}': ''
+ __template: { FIELD: '' },
+ '{field}': '',
},
routing: '',
version: 1,
version_type: ['external', 'external_gt', 'external_gte', 'force', 'internal'],
doc: {},
- filter: { // TODO: Exclude from global filter rules
- 'max_num_terms': 1,
- 'min_term_freq': 1,
- 'max_term_freq': 1,
- 'min_doc_freq': 1,
- 'max_doc_freq': 1,
- 'min_word_length': 1,
- 'max_word_length': 1
- }
- }
+ filter: {
+ // TODO: Exclude from global filter rules
+ max_num_terms: 1,
+ min_term_freq: 1,
+ max_term_freq: 1,
+ min_doc_freq: 1,
+ max_doc_freq: 1,
+ min_word_length: 1,
+ max_word_length: 1,
+ },
+ },
});
}
diff --git a/src/legacy/core_plugins/console/server/api_server/es_6_0/filter.js b/src/legacy/core_plugins/console/server/api_server/es_6_0/filter.js
index 710e43845a64..2a1a903c8565 100644
--- a/src/legacy/core_plugins/console/server/api_server/es_6_0/filter.js
+++ b/src/legacy/core_plugins/console/server/api_server/es_6_0/filter.js
@@ -21,256 +21,239 @@ const filters = {};
filters.and = {
__template: {
- filters: [
- {}
- ]
+ filters: [{}],
},
filters: [
{
- __scope_link: '.'
- }
+ __scope_link: '.',
+ },
],
};
-
filters.bool = {
- __scope_link: 'GLOBAL.query'
+ __scope_link: 'GLOBAL.query',
};
-
filters.exists = {
__template: {
- 'field': 'FIELD_NAME'
+ field: 'FIELD_NAME',
},
- 'field': '{field}'
+ field: '{field}',
};
-
filters.ids = {
__template: {
- 'values': ['ID']
+ values: ['ID'],
},
- 'type': '{type}',
- 'values': ['']
+ type: '{type}',
+ values: [''],
};
-
filters.limit = {
__template: {
- value: 100
+ value: 100,
},
- value: 100
+ value: 100,
};
-
filters.type = {
__template: {
- value: 'TYPE'
+ value: 'TYPE',
},
- value: '{type}'
+ value: '{type}',
};
-
filters.geo_bounding_box = {
__template: {
- 'FIELD': {
- 'top_left': {
- 'lat': 40.73,
- 'lon': -74.1
+ FIELD: {
+ top_left: {
+ lat: 40.73,
+ lon: -74.1,
},
- 'bottom_right': {
- 'lat': 40.717,
- 'lon': -73.99
- }
- }
+ bottom_right: {
+ lat: 40.717,
+ lon: -73.99,
+ },
+ },
},
'{field}': {
top_left: {
lat: 40.73,
- lon: -74.1
+ lon: -74.1,
},
bottom_right: {
lat: 40.73,
- lon: -74.1
- }
+ lon: -74.1,
+ },
},
type: {
- __one_of: ['memory', 'indexed']
+ __one_of: ['memory', 'indexed'],
},
};
-
filters.geo_distance = {
__template: {
distance: 100,
distance_unit: 'km',
- 'FIELD': {
+ FIELD: {
lat: 40.73,
- lon: -74.1
- }
+ lon: -74.1,
+ },
},
distance: 100,
distance_unit: {
- __one_of: ['km', 'miles']
+ __one_of: ['km', 'miles'],
},
distance_type: {
- __one_of: ['arc', 'plane']
+ __one_of: ['arc', 'plane'],
},
optimize_bbox: {
- __one_of: ['memory', 'indexed', 'none']
+ __one_of: ['memory', 'indexed', 'none'],
},
'{field}': {
lat: 40.73,
- lon: -74.1
+ lon: -74.1,
},
};
-
filters.geo_distance_range = {
__template: {
from: 100,
to: 200,
distance_unit: 'km',
- 'FIELD': {
+ FIELD: {
lat: 40.73,
- lon: -74.1
- }
+ lon: -74.1,
+ },
},
from: 100,
to: 200,
distance_unit: {
- __one_of: ['km', 'miles']
+ __one_of: ['km', 'miles'],
},
distance_type: {
- __one_of: ['arc', 'plane']
+ __one_of: ['arc', 'plane'],
},
include_lower: {
- __one_of: [true, false]
+ __one_of: [true, false],
},
include_upper: {
- __one_of: [true, false]
+ __one_of: [true, false],
},
'{field}': {
lat: 40.73,
- lon: -74.1
- }
+ lon: -74.1,
+ },
};
-
filters.geo_polygon = {
__template: {
- 'FIELD': {
- 'points': [
+ FIELD: {
+ points: [
{
lat: 40.73,
- lon: -74.1
+ lon: -74.1,
},
{
lat: 40.83,
- lon: -75.1
- }
- ]
- }
+ lon: -75.1,
+ },
+ ],
+ },
},
'{field}': {
points: [
{
lat: 40.73,
- lon: -74.1
- }
- ]
- }
+ lon: -74.1,
+ },
+ ],
+ },
};
-
filters.geo_shape = {
__template: {
- 'FIELD': {
+ FIELD: {
shape: {
type: 'envelope',
coordinates: [
[-45, 45],
- [45, -45]
- ]
+ [45, -45],
+ ],
},
- 'relation': 'within'
- }
+ relation: 'within',
+ },
},
'{field}': {
shape: {
type: '',
- coordinates: []
+ coordinates: [],
},
indexed_shape: {
id: '',
index: '{index}',
type: '{type}',
- shape_field_name: 'shape'
+ shape_field_name: 'shape',
},
relation: {
- __one_of: ['within', 'intersects', 'disjoint']
- }
- }
+ __one_of: ['within', 'intersects', 'disjoint'],
+ },
+ },
};
-
filters.has_child = {
__template: {
type: 'TYPE',
- filter: {}
+ filter: {},
},
type: '{type}',
query: {},
filter: {},
_scope: '',
min_children: 1,
- max_children: 10
+ max_children: 10,
};
-
filters.has_parent = {
__template: {
parent_type: 'TYPE',
- filter: {}
+ filter: {},
},
parent_type: '{type}',
query: {},
filter: {},
- _scope: ''
+ _scope: '',
};
-
filters.m = filters.missing = {
__template: {
- field: 'FIELD'
+ field: 'FIELD',
},
existence: {
- __one_of: [true, false]
+ __one_of: [true, false],
},
null_value: {
- __one_of: [true, false]
+ __one_of: [true, false],
},
- field: '{field}'
+ field: '{field}',
};
-
filters.not = {
__template: {
- filter: {}
+ filter: {},
},
- filter: {}
+ filter: {},
};
-
filters.range = {
__template: {
- 'FIELD': {
+ FIELD: {
gte: 10,
- lte: 20
- }
+ lte: 20,
+ },
},
'{field}': {
gte: 1,
@@ -278,78 +261,69 @@ filters.range = {
lte: 20,
lt: 20,
time_zone: '+1:00',
- 'format': 'dd/MM/yyyy||yyyy',
- execution: { __one_of: ['index', 'fielddata'] }
- }
+ format: 'dd/MM/yyyy||yyyy',
+ execution: { __one_of: ['index', 'fielddata'] },
+ },
};
-
filters.or = {
__template: {
- filters: [
- {}
- ]
+ filters: [{}],
},
filters: [
{
- __scope_link: '.'
- }
- ]
+ __scope_link: '.',
+ },
+ ],
};
-
filters.prefix = {
__template: {
- 'FIELD': 'VALUE'
+ FIELD: 'VALUE',
},
- '{field}': ''
+ '{field}': '',
};
-
filters.query = {
// global query
};
filters.script = {
__template: {
- script: {}
+ script: {},
},
script: {
// populated by a global rule
- }
+ },
};
-
filters.term = {
__template: {
- 'FIELD': 'VALUE'
+ FIELD: 'VALUE',
},
- '{field}': ''
+ '{field}': '',
};
-
filters.terms = {
__template: {
- 'FIELD': ['VALUE1', 'VALUE2']
+ FIELD: ['VALUE1', 'VALUE2'],
},
field: ['{field}'],
execution: {
- __one_of: ['plain', 'bool', 'and', 'or', 'bool_nocache', 'and_nocache', 'or_nocache']
- }
+ __one_of: ['plain', 'bool', 'and', 'or', 'bool_nocache', 'and_nocache', 'or_nocache'],
+ },
};
-
filters.nested = {
__template: {
path: 'path_to_nested_doc',
- query: {}
+ query: {},
},
query: {},
path: '',
- _name: ''
+ _name: '',
};
-export default function (api) {
+export default function(api) {
api.addGlobalAutocompleteRules('filter', filters);
}
-
diff --git a/src/legacy/core_plugins/console/server/api_server/es_6_0/globals.js b/src/legacy/core_plugins/console/server/api_server/es_6_0/globals.js
index 1a2e9f585f35..316a76c8c943 100644
--- a/src/legacy/core_plugins/console/server/api_server/es_6_0/globals.js
+++ b/src/legacy/core_plugins/console/server/api_server/es_6_0/globals.js
@@ -21,20 +21,20 @@ const highlightOptions = {
boundary_chars: {},
boundary_max_scan: 20,
boundary_scanner: {
- __one_of: [ 'chars', 'sentence', 'word' ]
+ __one_of: ['chars', 'sentence', 'word'],
},
boundary_scanner_locale: {},
encoder: {
- __one_of: [ 'default', 'html' ]
+ __one_of: ['default', 'html'],
},
force_source: {
- __one_of: [ 'false', 'true' ]
+ __one_of: ['false', 'true'],
},
fragmenter: {
- __one_of: [ 'simple', 'span' ]
+ __one_of: ['simple', 'span'],
},
highlight_query: {
- __scope_link: 'GLOBAL.query'
+ __scope_link: 'GLOBAL.query',
},
matched_fields: ['FIELD'],
order: {},
@@ -44,30 +44,30 @@ const highlightOptions = {
pre_tags: {},
post_tags: {},
require_field_match: {
- __one_of: [ 'true', 'false' ]
+ __one_of: ['true', 'false'],
},
- tags_schema: {}
+ tags_schema: {},
};
-export default function (api) {
+export default function(api) {
api.addGlobalAutocompleteRules('highlight', {
...highlightOptions,
fields: {
'{field}': {
fragment_size: 20,
number_of_fragments: 3,
- ...highlightOptions
- }
- }
+ ...highlightOptions,
+ },
+ },
});
api.addGlobalAutocompleteRules('script', {
__template: {
- source: 'SCRIPT'
+ source: 'SCRIPT',
},
source: 'SCRIPT',
file: 'FILE_SCRIPT_NAME',
id: 'SCRIPT_ID',
lang: '',
- params: {}
+ params: {},
});
}
diff --git a/src/legacy/core_plugins/console/server/api_server/es_6_0/ingest.js b/src/legacy/core_plugins/console/server/api_server/es_6_0/ingest.js
index 0c072d6bbfeb..edc9cc7b3e45 100644
--- a/src/legacy/core_plugins/console/server/api_server/es_6_0/ingest.js
+++ b/src/legacy/core_plugins/console/server/api_server/es_6_0/ingest.js
@@ -20,10 +20,10 @@
const commonPipelineParams = {
on_failure: [],
ignore_failure: {
- __one_of: [ false, true ]
+ __one_of: [false, true],
},
if: '',
- tag: ''
+ tag: '',
};
// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/append-processor.html
@@ -31,27 +31,27 @@ const appendProcessorDefinition = {
append: {
__template: {
field: '',
- value: []
+ value: [],
},
field: '',
value: [],
- ...commonPipelineParams
- }
+ ...commonPipelineParams,
+ },
};
// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/bytes-processor.html
const bytesProcessorDefinition = {
bytes: {
__template: {
- field: ''
+ field: '',
},
field: '',
target_field: '',
ignore_missing: {
- __one_of: [ false, true ]
+ __one_of: [false, true],
},
- ...commonPipelineParams
- }
+ ...commonPipelineParams,
+ },
};
// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/convert-processor.html
@@ -59,18 +59,18 @@ const convertProcessorDefinition = {
convert: {
__template: {
field: '',
- type: ''
+ type: '',
},
field: '',
type: {
- __one_of: [ 'integer', 'float', 'string', 'boolean', 'auto' ]
+ __one_of: ['integer', 'float', 'string', 'boolean', 'auto'],
},
target_field: '',
ignore_missing: {
- __one_of: [ false, true ]
+ __one_of: [false, true],
},
- ...commonPipelineParams
- }
+ ...commonPipelineParams,
+ },
};
// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/date-processor.html
@@ -78,15 +78,15 @@ const dateProcessorDefinition = {
date: {
__template: {
field: '',
- formats: []
+ formats: [],
},
field: '',
target_field: '@timestamp',
formats: [],
timezone: 'UTC',
locale: 'ENGLISH',
- ...commonPipelineParams
- }
+ ...commonPipelineParams,
+ },
};
// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/date-index-name-processor.html
@@ -94,18 +94,18 @@ const dateIndexNameProcessorDefinition = {
date_index_name: {
__template: {
field: '',
- date_rounding: ''
+ date_rounding: '',
},
field: '',
date_rounding: {
- __one_of: [ 'y', 'M', 'w', 'd', 'h', 'm', 's' ]
+ __one_of: ['y', 'M', 'w', 'd', 'h', 'm', 's'],
},
date_formats: [],
timezone: 'UTC',
locale: 'ENGLISH',
index_name_format: 'yyyy-MM-dd',
- ...commonPipelineParams
- }
+ ...commonPipelineParams,
+ },
};
// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/dissect-processor.html
@@ -113,47 +113,47 @@ const dissectProcessorDefinition = {
dissect: {
__template: {
field: '',
- pattern: ''
+ pattern: '',
},
field: '',
pattern: '',
append_separator: '',
ignore_missing: {
- __one_of: [ false, true ]
+ __one_of: [false, true],
},
- ...commonPipelineParams
- }
+ ...commonPipelineParams,
+ },
};
// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/dot-expand-processor.html
const dotExpanderProcessorDefinition = {
dot_expander: {
__template: {
- field: ''
+ field: '',
},
field: '',
path: '',
- ...commonPipelineParams
- }
+ ...commonPipelineParams,
+ },
};
// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/drop-processor.html
const dropProcessorDefinition = {
drop: {
__template: {},
- ...commonPipelineParams
- }
+ ...commonPipelineParams,
+ },
};
// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/fail-processor.html
const failProcessorDefinition = {
fail: {
__template: {
- message: ''
+ message: '',
},
message: '',
- ...commonPipelineParams
- }
+ ...commonPipelineParams,
+ },
};
// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/foreach-processor.html
@@ -161,14 +161,14 @@ const foreachProcessorDefinition = {
foreach: {
__template: {
field: '',
- processor: {}
+ processor: {},
},
field: '',
processor: {
- __scope_link: '_processor'
+ __scope_link: '_processor',
},
- ...commonPipelineParams
- }
+ ...commonPipelineParams,
+ },
};
// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/grok-processor.html
@@ -176,19 +176,19 @@ const grokProcessorDefinition = {
grok: {
__template: {
field: '',
- patterns: []
+ patterns: [],
},
field: '',
patterns: [],
pattern_definitions: {},
trace_match: {
- __one_of: [ false, true ]
+ __one_of: [false, true],
},
ignore_missing: {
- __one_of: [ false, true ]
+ __one_of: [false, true],
},
- ...commonPipelineParams
- }
+ ...commonPipelineParams,
+ },
};
// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/gsub-processor.html
@@ -197,13 +197,13 @@ const gsubProcessorDefinition = {
__template: {
field: '',
pattern: '',
- replacement: ''
+ replacement: '',
},
field: '',
pattern: '',
replacement: '',
- ...commonPipelineParams
- }
+ ...commonPipelineParams,
+ },
};
// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/join-processor.html
@@ -211,27 +211,27 @@ const joinProcessorDefinition = {
join: {
__template: {
field: '',
- separator: ''
+ separator: '',
},
field: '',
separator: '',
- ...commonPipelineParams
- }
+ ...commonPipelineParams,
+ },
};
// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/json-processor.html
const jsonProcessorDefinition = {
json: {
__template: {
- field: ''
+ field: '',
},
field: '',
target_field: '',
add_to_root: {
- __one_of: [ false, true ]
+ __one_of: [false, true],
},
- ...commonPipelineParams
- }
+ ...commonPipelineParams,
+ },
};
// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/kv-processor.html
@@ -240,7 +240,7 @@ const kvProcessorDefinition = {
__template: {
field: '',
field_split: '',
- value_split: ''
+ value_split: '',
},
field: '',
field_split: '',
@@ -248,46 +248,46 @@ const kvProcessorDefinition = {
target_field: '',
include_keys: [],
ignore_missing: {
- __one_of: [ false, true ]
+ __one_of: [false, true],
},
- ...commonPipelineParams
- }
+ ...commonPipelineParams,
+ },
};
// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/lowercase-processor.html
const lowercaseProcessorDefinition = {
lowercase: {
__template: {
- field: ''
+ field: '',
},
field: '',
ignore_missing: {
- __one_of: [ false, true ]
+ __one_of: [false, true],
},
- ...commonPipelineParams
- }
+ ...commonPipelineParams,
+ },
};
// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/pipeline-processor.html
const pipelineProcessorDefinition = {
pipeline: {
__template: {
- name: ''
+ name: '',
},
name: '',
- ...commonPipelineParams
- }
+ ...commonPipelineParams,
+ },
};
// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/remove-processor.html
const removeProcessorDefinition = {
remove: {
__template: {
- field: ''
+ field: '',
},
field: '',
- ...commonPipelineParams
- }
+ ...commonPipelineParams,
+ },
};
// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/rename-processor.html
@@ -295,15 +295,15 @@ const renameProcessorDefinition = {
rename: {
__template: {
field: '',
- target_field: ''
+ target_field: '',
},
field: '',
target_field: '',
ignore_missing: {
- __one_of: [ false, true ]
+ __one_of: [false, true],
},
- ...commonPipelineParams
- }
+ ...commonPipelineParams,
+ },
};
// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/script-processor.html
@@ -315,8 +315,8 @@ const scriptProcessorDefinition = {
id: '',
source: '',
params: {},
- ...commonPipelineParams
- }
+ ...commonPipelineParams,
+ },
};
// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/set-processor.html
@@ -324,15 +324,15 @@ const setProcessorDefinition = {
set: {
__template: {
field: '',
- value: ''
+ value: '',
},
field: '',
value: '',
override: {
- __one_of: [ true, false ]
+ __one_of: [true, false],
},
- ...commonPipelineParams
- }
+ ...commonPipelineParams,
+ },
};
// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/split-processor.html
@@ -340,55 +340,55 @@ const splitProcessorDefinition = {
split: {
__template: {
field: '',
- separator: ''
+ separator: '',
},
field: '',
separator: '',
ignore_missing: {
- __one_of: [ false, true ]
+ __one_of: [false, true],
},
- ...commonPipelineParams
- }
+ ...commonPipelineParams,
+ },
};
// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/sort-processor.html
const sortProcessorDefinition = {
sort: {
__template: {
- field: ''
+ field: '',
},
field: '',
order: 'asc',
- ...commonPipelineParams
- }
+ ...commonPipelineParams,
+ },
};
// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/trim-processor.html
const trimProcessorDefinition = {
trim: {
__template: {
- field: ''
+ field: '',
},
field: '',
ignore_missing: {
- __one_of: [ false, true ]
+ __one_of: [false, true],
},
- ...commonPipelineParams
- }
+ ...commonPipelineParams,
+ },
};
// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/uppercase-processor.html
const uppercaseProcessorDefinition = {
uppercase: {
__template: {
- field: ''
+ field: '',
},
field: '',
ignore_missing: {
- __one_of: [ false, true ]
+ __one_of: [false, true],
},
- ...commonPipelineParams
- }
+ ...commonPipelineParams,
+ },
};
const processorDefinition = {
@@ -417,15 +417,13 @@ const processorDefinition = {
splitProcessorDefinition,
sortProcessorDefinition,
trimProcessorDefinition,
- uppercaseProcessorDefinition
- ]
+ uppercaseProcessorDefinition,
+ ],
};
const pipelineDefinition = {
description: '',
- processors: [
- processorDefinition
- ],
+ processors: [processorDefinition],
version: 123,
};
@@ -433,23 +431,20 @@ export const register = 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.
api.addEndpointDescription('_processor', {
- data_autocomplete_rules: processorDefinition
+ data_autocomplete_rules: processorDefinition,
});
api.addEndpointDescription('ingest.put_pipeline', {
methods: ['PUT'],
- patterns: [
- '_ingest/pipeline/{id}'
- ],
- data_autocomplete_rules: pipelineDefinition
+ patterns: ['_ingest/pipeline/{id}'],
+ data_autocomplete_rules: pipelineDefinition,
});
api.addEndpointDescription('ingest.simulate', {
data_autocomplete_rules: {
pipeline: pipelineDefinition,
- docs: [
- ]
- }
+ docs: [],
+ },
});
};
diff --git a/src/legacy/core_plugins/console/server/api_server/es_6_0/mappings.js b/src/legacy/core_plugins/console/server/api_server/es_6_0/mappings.js
index 28850dfd6de7..46f32fe58089 100644
--- a/src/legacy/core_plugins/console/server/api_server/es_6_0/mappings.js
+++ b/src/legacy/core_plugins/console/server/api_server/es_6_0/mappings.js
@@ -23,7 +23,7 @@ const BOOLEAN = {
__one_of: [true, false],
};
-export default function (api) {
+export default function(api) {
api.addEndpointDescription('put_mapping', {
priority: 10, // collides with put doc by id
data_autocomplete_rules: {
@@ -89,13 +89,7 @@ export default function (api) {
store: BOOLEAN,
index: BOOLEAN,
term_vector: {
- __one_of: [
- 'no',
- 'yes',
- 'with_offsets',
- 'with_positions',
- 'with_positions_offsets',
- ],
+ __one_of: ['no', 'yes', 'with_offsets', 'with_positions', 'with_positions_offsets'],
},
boost: 1.0,
null_value: '',
@@ -181,7 +175,7 @@ export default function (api) {
'week_date_time',
'week_date_time_no_millis',
],
- function (s) {
+ function(s) {
return ['basic_' + s, 'strict_' + s];
}
),
diff --git a/src/legacy/core_plugins/console/server/api_server/es_6_0/query/dsl.js b/src/legacy/core_plugins/console/server/api_server/es_6_0/query/dsl.js
index fd86446532ed..3ff9bed84834 100644
--- a/src/legacy/core_plugins/console/server/api_server/es_6_0/query/dsl.js
+++ b/src/legacy/core_plugins/console/server/api_server/es_6_0/query/dsl.js
@@ -30,7 +30,7 @@ import {
fuzzyTemplate,
prefixTemplate,
rangeTemplate,
- regexpTemplate
+ regexpTemplate,
} from './templates';
const matchOptions = {
cutoff_frequency: 0.001,
@@ -120,35 +120,35 @@ const SPAN_QUERIES = {
field_masking_span: {
__template: {
query: {
- SPAN_QUERY: {}
- }
+ SPAN_QUERY: {},
+ },
},
query: SPAN_QUERIES_NO_FIELD_MASK,
- field: ''
- }
+ field: '',
+ },
};
const SPAN_MULTI_QUERIES = {
wildcard: {
__template: wildcardTemplate,
- __scope_link: '.wildcard'
+ __scope_link: '.wildcard',
},
fuzzy: {
__template: fuzzyTemplate,
- __scope_link: '.fuzzy'
+ __scope_link: '.fuzzy',
},
prefix: {
__template: prefixTemplate,
- __scope_link: '.prefix'
+ __scope_link: '.prefix',
},
range: {
__template: rangeTemplate,
- __scope_link: '.range'
+ __scope_link: '.range',
},
regexp: {
__template: regexpTemplate,
- __scope_link: '.regexp'
- }
+ __scope_link: '.regexp',
+ },
};
const DECAY_FUNC_DESC = {
@@ -168,7 +168,7 @@ const DECAY_FUNC_DESC = {
const SCORING_FUNCS = {
script_score: {
__template: {
- script: '_score * doc[\'f\'].value',
+ script: "_score * doc['f'].value",
},
script: {
//populated by a global rule
@@ -244,15 +244,7 @@ export function queryDsl(api) {
'{field}': {
value: '',
flags: {
- __one_of: [
- 'ALL',
- 'ANYSTRING',
- 'COMPLEMENT',
- 'EMPTY',
- 'INTERSECTION',
- 'INTERVAL',
- 'NONE',
- ],
+ __one_of: ['ALL', 'ANYSTRING', 'COMPLEMENT', 'EMPTY', 'INTERSECTION', 'INTERVAL', 'NONE'],
},
max_determinized_states: 10000,
},
@@ -270,13 +262,7 @@ export function queryDsl(api) {
},
tie_breaker: 0.0,
type: {
- __one_of: [
- 'best_fields',
- 'most_fields',
- 'cross_fields',
- 'phrase',
- 'phrase_prefix',
- ],
+ __one_of: ['best_fields', 'most_fields', 'cross_fields', 'phrase', 'phrase_prefix'],
},
},
bool: {
@@ -519,10 +505,10 @@ export function queryDsl(api) {
span_multi: {
__template: {
match: {
- MULTI_TERM_QUERY: {}
- }
+ MULTI_TERM_QUERY: {},
+ },
},
- match: SPAN_MULTI_QUERIES
+ match: SPAN_MULTI_QUERIES,
},
span_near: {
__template: spanNearTemplate,
@@ -600,7 +586,7 @@ export function queryDsl(api) {
percolate: {
__template: {
field: '',
- document: {}
+ document: {},
},
field: '',
document: {},
@@ -611,7 +597,7 @@ export function queryDsl(api) {
type: '',
id: '',
routing: '',
- preference: ''
+ preference: '',
},
common: {
__template: {
@@ -704,7 +690,7 @@ export function queryDsl(api) {
),
script: {
__template: {
- script: '_score * doc[\'f\'].value',
+ script: "_score * doc['f'].value",
},
script: {
//populated by a global rule
@@ -714,7 +700,7 @@ export function queryDsl(api) {
__template: {
query: 'QUERY_BASE64_ENCODED',
},
- query: ''
- }
+ query: '',
+ },
});
}
diff --git a/src/legacy/core_plugins/console/server/api_server/es_6_0/query/index.js b/src/legacy/core_plugins/console/server/api_server/es_6_0/query/index.js
index cf5306ce925b..cbe4e7ed2dd5 100644
--- a/src/legacy/core_plugins/console/server/api_server/es_6_0/query/index.js
+++ b/src/legacy/core_plugins/console/server/api_server/es_6_0/query/index.js
@@ -17,4 +17,4 @@
* under the License.
*/
-export { queryDsl as default } from './dsl';
+export { queryDsl as default } from './dsl';
diff --git a/src/legacy/core_plugins/console/server/api_server/es_6_0/reindex.js b/src/legacy/core_plugins/console/server/api_server/es_6_0/reindex.js
index b7bd2c0608b6..45163d2b3c4c 100644
--- a/src/legacy/core_plugins/console/server/api_server/es_6_0/reindex.js
+++ b/src/legacy/core_plugins/console/server/api_server/es_6_0/reindex.js
@@ -17,52 +17,49 @@
* under the License.
*/
-export default function (api) {
-
+export default function(api) {
api.addEndpointDescription('reindex', {
- methods: [ 'POST' ],
- patterns: [
- '_reindex'
- ],
+ methods: ['POST'],
+ patterns: ['_reindex'],
data_autocomplete_rules: {
__template: {
- 'source': {},
- 'dest': {}
+ source: {},
+ dest: {},
},
- 'source': {
- 'index': '',
- 'type': '',
- 'query': {
- __scope_link: 'GLOBAL.query'
+ source: {
+ index: '',
+ type: '',
+ query: {
+ __scope_link: 'GLOBAL.query',
},
- 'sort': {
+ sort: {
__template: {
- 'FIELD': 'desc'
+ FIELD: 'desc',
},
- 'FIELD': { __one_of: [ 'asc', 'desc' ] }
+ FIELD: { __one_of: ['asc', 'desc'] },
},
- 'size': 1000,
- 'remote': {
+ size: 1000,
+ remote: {
__template: {
- 'host': '',
+ host: '',
},
- 'host': '',
- 'username': '',
- 'password': '',
- 'socket_timeout': '30s',
- 'connect_timeout': '30s'
- }
+ host: '',
+ username: '',
+ password: '',
+ socket_timeout: '30s',
+ connect_timeout: '30s',
+ },
},
- 'dest': {
- 'index': '',
- 'version_type': { __one_of: [ 'internal', 'external' ] },
- 'op_type': 'create',
- 'routing': { __one_of: [ 'keep', 'discard', '=SOME TEXT'] },
- 'pipeline': ''
+ dest: {
+ index: '',
+ version_type: { __one_of: ['internal', 'external'] },
+ op_type: 'create',
+ routing: { __one_of: ['keep', 'discard', '=SOME TEXT'] },
+ pipeline: '',
},
- 'conflicts': 'proceed',
- 'size': 10,
- 'script': { __scope_link: 'GLOBAL.script' },
- }
+ conflicts: 'proceed',
+ size: 10,
+ script: { __scope_link: 'GLOBAL.script' },
+ },
});
}
diff --git a/src/legacy/core_plugins/console/server/api_server/es_6_0/search.js b/src/legacy/core_plugins/console/server/api_server/es_6_0/search.js
index 71cc9626a273..19ce30d9929a 100644
--- a/src/legacy/core_plugins/console/server/api_server/es_6_0/search.js
+++ b/src/legacy/core_plugins/console/server/api_server/es_6_0/search.js
@@ -17,7 +17,7 @@
* under the License.
*/
-export default function (api) {
+export default function(api) {
api.addEndpointDescription('search', {
priority: 10, // collides with get doc by id
data_autocomplete_rules: {
@@ -129,19 +129,17 @@ export default function (api) {
docvalue_fields: ['{field}'],
collapse: {
__template: {
- 'field': 'FIELD'
- }
+ field: 'FIELD',
+ },
},
indices_boost: {
- __template: [
- { 'INDEX': 1.0 }
- ]
+ __template: [{ INDEX: 1.0 }],
},
rescore: {
__template: {
- 'query': {},
- 'window_size': 50
- }
+ query: {},
+ window_size: 50,
+ },
},
script_fields: {
__template: {
@@ -196,10 +194,7 @@ export default function (api) {
api.addEndpointDescription('search_template', {
data_autocomplete_rules: {
template: {
- __one_of: [
- { __scope_link: 'search' },
- { __scope_link: 'GLOBAL.script' },
- ],
+ __one_of: [{ __scope_link: 'search' }, { __scope_link: 'GLOBAL.script' }],
},
params: {},
},
@@ -207,10 +202,7 @@ export default function (api) {
api.addEndpointDescription('render_search_template', {
data_autocomplete_rules: {
- __one_of: [
- { source: { __scope_link: 'search' } },
- { __scope_link: 'GLOBAL.script' },
- ],
+ __one_of: [{ source: { __scope_link: 'search' } }, { __scope_link: 'GLOBAL.script' }],
params: {},
},
});
diff --git a/src/legacy/core_plugins/console/server/api_server/server.js b/src/legacy/core_plugins/console/server/api_server/server.js
index 57a53d20695a..48ed73cb3611 100644
--- a/src/legacy/core_plugins/console/server/api_server/server.js
+++ b/src/legacy/core_plugins/console/server/api_server/server.js
@@ -23,7 +23,7 @@ const KNOWN_APIS = ['es_6_0'];
export function resolveApi(senseVersion, apis, h) {
const result = {};
- _.each(apis, function (name) {
+ _.each(apis, function(name) {
{
if (KNOWN_APIS.includes(name)) {
// for now we ignore sense_version. might add it in the api name later
diff --git a/src/legacy/core_plugins/console/server/api_server/server.test.js b/src/legacy/core_plugins/console/server/api_server/server.test.js
index ea78611a6060..747689237c17 100644
--- a/src/legacy/core_plugins/console/server/api_server/server.test.js
+++ b/src/legacy/core_plugins/console/server/api_server/server.test.js
@@ -20,32 +20,32 @@ import { resolveApi } from './server';
describe('resolveApi', () => {
it('allows known APIs to be resolved', () => {
- const mockReply = jest.fn((result) => ({ type: () => result }));
+ const mockReply = jest.fn(result => ({ type: () => result }));
const result = resolveApi('Sense Version', ['es_6_0'], { response: mockReply });
expect(result).toMatchObject({
es_6_0: {
endpoints: expect.any(Object),
globals: expect.any(Object),
name: expect.any(String),
- }
+ },
});
});
it('does not resolve APIs that are not known', () => {
- const mockReply = jest.fn((result) => ({ type: () => result }));
+ const mockReply = jest.fn(result => ({ type: () => result }));
const result = resolveApi('Sense Version', ['unknown'], { response: mockReply });
expect(result).toEqual({});
});
it('handles request for apis that are known and unknown', () => {
- const mockReply = jest.fn((result) => ({ type: () => result }));
+ const mockReply = jest.fn(result => ({ type: () => result }));
const result = resolveApi('Sense Version', ['es_6_0'], { response: mockReply });
expect(result).toMatchObject({
es_6_0: {
endpoints: expect.any(Object),
globals: expect.any(Object),
name: expect.any(String),
- }
+ },
});
});
});
diff --git a/src/legacy/core_plugins/console/server/api_server/spec/index.js b/src/legacy/core_plugins/console/server/api_server/spec/index.js
index 601c5e6153e2..19f075e897db 100644
--- a/src/legacy/core_plugins/console/server/api_server/spec/index.js
+++ b/src/legacy/core_plugins/console/server/api_server/spec/index.js
@@ -48,7 +48,7 @@ function _getSpec(dirname = __dirname) {
}
export function getSpec() {
const result = _getSpec();
- extensionSpecFilePaths.forEach((extensionSpecFilePath) => {
+ extensionSpecFilePaths.forEach(extensionSpecFilePath => {
merge(result, _getSpec(extensionSpecFilePath));
});
return result;
diff --git a/src/legacy/core_plugins/console/server/proxy_config.js b/src/legacy/core_plugins/console/server/proxy_config.js
index 98bc58f5f56c..44a2769a46eb 100644
--- a/src/legacy/core_plugins/console/server/proxy_config.js
+++ b/src/legacy/core_plugins/console/server/proxy_config.js
@@ -27,21 +27,22 @@ import { WildcardMatcher } from './wildcard_matcher';
export class ProxyConfig {
constructor(config) {
config = {
- ...config
+ ...config,
};
// -----
// read "match" info
// -----
const rawMatches = {
- ...config.match
+ ...config.match,
};
- this.id = formatUrl({
- protocol: rawMatches.protocol,
- hostname: rawMatches.host,
- port: rawMatches.port,
- pathname: rawMatches.path
- }) || '*';
+ this.id =
+ formatUrl({
+ protocol: rawMatches.protocol,
+ hostname: rawMatches.host,
+ port: rawMatches.port,
+ pathname: rawMatches.path,
+ }) || '*';
this.matchers = {
protocol: new WildcardMatcher(rawMatches.protocol),
@@ -83,7 +84,7 @@ export class ProxyConfig {
return {
timeout: this.timeout,
rejectUnauthorized: this.sslAgent ? undefined : this.verifySsl,
- agent: protocol === 'https:' ? this.sslAgent : undefined
+ agent: protocol === 'https:' ? this.sslAgent : undefined,
};
}
}
diff --git a/src/legacy/core_plugins/console/server/proxy_config_collection.js b/src/legacy/core_plugins/console/server/proxy_config_collection.js
index e8bf52cc8b08..79bc057aaaf7 100644
--- a/src/legacy/core_plugins/console/server/proxy_config_collection.js
+++ b/src/legacy/core_plugins/console/server/proxy_config_collection.js
@@ -22,7 +22,6 @@ import { defaultsDeep } from 'lodash';
import { ProxyConfig } from './proxy_config';
import { parse as parseUrl } from 'url';
-
export class ProxyConfigCollection {
constructor(configs = []) {
this.configs = configs.map(settings => new ProxyConfig(settings));
diff --git a/src/legacy/core_plugins/console/server/set_headers.js b/src/legacy/core_plugins/console/server/set_headers.js
index 4b46e864e118..5ea4c214dc42 100644
--- a/src/legacy/core_plugins/console/server/set_headers.js
+++ b/src/legacy/core_plugins/console/server/set_headers.js
@@ -21,7 +21,9 @@ import { isPlainObject } from 'lodash';
export function setHeaders(originalHeaders, newHeaders) {
if (!isPlainObject(originalHeaders)) {
- throw new Error(`Expected originalHeaders to be an object, but ${typeof originalHeaders} given`);
+ throw new Error(
+ `Expected originalHeaders to be an object, but ${typeof originalHeaders} given`
+ );
}
if (!isPlainObject(newHeaders)) {
throw new Error(`Expected newHeaders to be an object, but ${typeof newHeaders} given`);
@@ -29,6 +31,6 @@ export function setHeaders(originalHeaders, newHeaders) {
return {
...originalHeaders,
- ...newHeaders
+ ...newHeaders,
};
}
diff --git a/src/legacy/core_plugins/console/server/wildcard_matcher.js b/src/legacy/core_plugins/console/server/wildcard_matcher.js
index 208ae2fc73db..b99fba9295e5 100644
--- a/src/legacy/core_plugins/console/server/wildcard_matcher.js
+++ b/src/legacy/core_plugins/console/server/wildcard_matcher.js
@@ -28,7 +28,7 @@ export class WildcardMatcher {
dot: true,
nocase: true,
matchBase: true,
- nocomment: true
+ nocomment: true,
});
}
diff --git a/src/legacy/core_plugins/elasticsearch/index.js b/src/legacy/core_plugins/elasticsearch/index.js
index f92f920d1afb..7fc00e27e5b5 100644
--- a/src/legacy/core_plugins/elasticsearch/index.js
+++ b/src/legacy/core_plugins/elasticsearch/index.js
@@ -24,7 +24,7 @@ import { Cluster } from './lib/cluster';
import { createProxy } from './lib/create_proxy';
import { handleESError } from './lib/handle_es_error';
-export default function (kibana) {
+export default function(kibana) {
let defaultVars;
return new kibana.Plugin({
@@ -40,14 +40,16 @@ export default function (kibana) {
server.newPlatform.__internals.elasticsearch.legacy.config$,
server.newPlatform.setup.core.elasticsearch.adminClient$,
server.newPlatform.setup.core.elasticsearch.dataClient$
- ).pipe(
- first(),
- map(([config, adminClusterClient, dataClusterClient]) => [
- config,
- new Cluster(adminClusterClient),
- new Cluster(dataClusterClient)
- ])
- ).toPromise();
+ )
+ .pipe(
+ first(),
+ map(([config, adminClusterClient, dataClusterClient]) => [
+ config,
+ new Cluster(adminClusterClient),
+ new Cluster(dataClusterClient),
+ ])
+ )
+ .toPromise();
defaultVars = {
esRequestTimeout: esConfig.requestTimeout.asMilliseconds(),
@@ -56,7 +58,7 @@ export default function (kibana) {
};
const clusters = new Map();
- server.expose('getCluster', (name) => {
+ server.expose('getCluster', name => {
if (name === 'admin') {
return adminCluster;
}
@@ -78,7 +80,9 @@ export default function (kibana) {
throw new Error(`cluster '${name}' already exists`);
}
- const cluster = new Cluster(server.newPlatform.setup.core.elasticsearch.createClient(name, clientConfig));
+ const cluster = new Cluster(
+ server.newPlatform.setup.core.elasticsearch.createClient(name, clientConfig)
+ );
clusters.set(name, cluster);
diff --git a/src/legacy/core_plugins/elasticsearch/lib/__tests__/ensure_es_version.js b/src/legacy/core_plugins/elasticsearch/lib/__tests__/ensure_es_version.js
index a31c7830f8d5..781d198c6623 100644
--- a/src/legacy/core_plugins/elasticsearch/lib/__tests__/ensure_es_version.js
+++ b/src/legacy/core_plugins/elasticsearch/lib/__tests__/ensure_es_version.js
@@ -31,24 +31,27 @@ describe('plugins/elasticsearch', () => {
let server;
- beforeEach(function () {
+ beforeEach(function() {
server = {
log: sinon.stub(),
logWithMetadata: sinon.stub(),
plugins: {
elasticsearch: {
- getCluster: sinon.stub().withArgs('admin').returns({ callWithInternalUser: sinon.stub() }),
+ getCluster: sinon
+ .stub()
+ .withArgs('admin')
+ .returns({ callWithInternalUser: sinon.stub() }),
status: {
- red: sinon.stub()
+ red: sinon.stub(),
},
- url: esTestConfig.getUrl()
- }
+ url: esTestConfig.getUrl(),
+ },
},
config() {
return {
- get: sinon.stub()
+ get: sinon.stub(),
};
- }
+ },
};
});
@@ -58,7 +61,7 @@ describe('plugins/elasticsearch', () => {
let i = 0;
while (versions.length) {
- const name = 'node-' + (++i);
+ const name = 'node-' + ++i;
const version = versions.shift();
const node = {
@@ -66,7 +69,7 @@ describe('plugins/elasticsearch', () => {
http: {
publish_address: 'http_address',
},
- ip: 'ip'
+ ip: 'ip',
};
if (!_.isString(version)) _.assign(node, version);
@@ -74,13 +77,17 @@ describe('plugins/elasticsearch', () => {
}
const cluster = server.plugins.elasticsearch.getCluster('admin');
- cluster.callWithInternalUser.withArgs('nodes.info', sinon.match.any).returns(Bluebird.resolve({ nodes: nodes }));
+ cluster.callWithInternalUser
+ .withArgs('nodes.info', sinon.match.any)
+ .returns(Bluebird.resolve({ nodes: nodes }));
}
function setNodeWithoutHTTP(version) {
const nodes = { 'node-without-http': { version, ip: 'ip' } };
const cluster = server.plugins.elasticsearch.getCluster('admin');
- cluster.callWithInternalUser.withArgs('nodes.info', sinon.match.any).returns(Bluebird.resolve({ nodes: nodes }));
+ cluster.callWithInternalUser
+ .withArgs('nodes.info', sinon.match.any)
+ .returns(Bluebird.resolve({ nodes: nodes }));
}
it('returns true with single a node that matches', async () => {
@@ -122,7 +129,7 @@ describe('plugins/elasticsearch', () => {
setNodes('5.1.0', '5.2.0', '5.0.0');
const ignoreVersionMismatch = true;
- const result = await ensureEsVersion(server, KIBANA_VERSION, ignoreVersionMismatch);
+ const result = await ensureEsVersion(server, KIBANA_VERSION, ignoreVersionMismatch);
expect(result).to.be(true);
});
@@ -151,11 +158,7 @@ describe('plugins/elasticsearch', () => {
});
it('fails if that single node is a client node', async () => {
- setNodes(
- '5.1.0',
- '5.2.0',
- { version: '5.0.0', attributes: { client: 'true' } },
- );
+ setNodes('5.1.0', '5.2.0', { version: '5.0.0', attributes: { client: 'true' } });
try {
await ensureEsVersion(server, KIBANA_VERSION);
} catch (e) {
diff --git a/src/legacy/core_plugins/elasticsearch/lib/__tests__/handle_es_error.js b/src/legacy/core_plugins/elasticsearch/lib/__tests__/handle_es_error.js
index 041522e9eb24..9ec4598674d5 100644
--- a/src/legacy/core_plugins/elasticsearch/lib/__tests__/handle_es_error.js
+++ b/src/legacy/core_plugins/elasticsearch/lib/__tests__/handle_es_error.js
@@ -21,14 +21,13 @@ import expect from '@kbn/expect';
import { handleESError } from '../handle_es_error';
import { errors as esErrors } from 'elasticsearch';
-describe('handleESError', function () {
-
- it('should transform elasticsearch errors into boom errors with the same status code', function () {
+describe('handleESError', function() {
+ it('should transform elasticsearch errors into boom errors with the same status code', function() {
const conflict = handleESError(new esErrors.Conflict());
expect(conflict.isBoom).to.be(true);
expect(conflict.output.statusCode).to.be(409);
- const forbidden = handleESError(new esErrors[403]);
+ const forbidden = handleESError(new esErrors[403]());
expect(forbidden.isBoom).to.be(true);
expect(forbidden.output.statusCode).to.be(403);
@@ -41,19 +40,21 @@ describe('handleESError', function () {
expect(badRequest.output.statusCode).to.be(400);
});
- it('should return an unknown error without transforming it', function () {
+ it('should return an unknown error without transforming it', function() {
const unknown = new Error('mystery error');
expect(handleESError(unknown)).to.be(unknown);
});
- it('should return a boom 503 server timeout error for ES connection errors', function () {
+ it('should return a boom 503 server timeout error for ES connection errors', function() {
expect(handleESError(new esErrors.ConnectionFault()).output.statusCode).to.be(503);
expect(handleESError(new esErrors.ServiceUnavailable()).output.statusCode).to.be(503);
expect(handleESError(new esErrors.NoConnections()).output.statusCode).to.be(503);
expect(handleESError(new esErrors.RequestTimeout()).output.statusCode).to.be(503);
});
- it('should throw an error if called with a non-error argument', function () {
- expect(handleESError).withArgs('notAnError').to.throwException();
+ it('should throw an error if called with a non-error argument', function() {
+ expect(handleESError)
+ .withArgs('notAnError')
+ .to.throwException();
});
});
diff --git a/src/legacy/core_plugins/elasticsearch/lib/__tests__/health_check.js b/src/legacy/core_plugins/elasticsearch/lib/__tests__/health_check.js
index 6ea62361b5b3..3b593c635239 100644
--- a/src/legacy/core_plugins/elasticsearch/lib/__tests__/health_check.js
+++ b/src/legacy/core_plugins/elasticsearch/lib/__tests__/health_check.js
@@ -29,7 +29,7 @@ import kibanaVersion from '../kibana_version';
const esPort = 9220;
describe('plugins/elasticsearch', () => {
- describe('lib/health_check', function () {
+ describe('lib/health_check', function() {
let health;
let plugin;
let cluster;
@@ -54,23 +54,31 @@ describe('plugins/elasticsearch', () => {
red: sinon.stub(),
green: sinon.stub(),
yellow: sinon.stub(),
- }
+ },
};
cluster = { callWithInternalUser: sinon.stub(), errors: { NoConnections } };
cluster.callWithInternalUser.withArgs('index', sinon.match.any).returns(Bluebird.resolve());
- cluster.callWithInternalUser.withArgs('mget', sinon.match.any).returns(Bluebird.resolve({ ok: true }));
- cluster.callWithInternalUser.withArgs('get', sinon.match.any).returns(Bluebird.resolve({ found: false }));
- cluster.callWithInternalUser.withArgs('search', sinon.match.any).returns(Bluebird.resolve({ hits: { hits: [] } }));
- cluster.callWithInternalUser.withArgs('nodes.info', sinon.match.any).returns(Bluebird.resolve({
- nodes: {
- 'node-01': {
- version: COMPATIBLE_VERSION_NUMBER,
- http_address: `inet[/127.0.0.1:${esPort}]`,
- ip: '127.0.0.1'
- }
- }
- }));
+ cluster.callWithInternalUser
+ .withArgs('mget', sinon.match.any)
+ .returns(Bluebird.resolve({ ok: true }));
+ cluster.callWithInternalUser
+ .withArgs('get', sinon.match.any)
+ .returns(Bluebird.resolve({ found: false }));
+ cluster.callWithInternalUser
+ .withArgs('search', sinon.match.any)
+ .returns(Bluebird.resolve({ hits: { hits: [] } }));
+ cluster.callWithInternalUser.withArgs('nodes.info', sinon.match.any).returns(
+ Bluebird.resolve({
+ nodes: {
+ 'node-01': {
+ version: COMPATIBLE_VERSION_NUMBER,
+ http_address: `inet[/127.0.0.1:${esPort}]`,
+ ip: '127.0.0.1',
+ },
+ },
+ })
+ );
// Setup the server mock
server = {
@@ -79,10 +87,10 @@ describe('plugins/elasticsearch', () => {
config: () => ({ get: sinon.stub() }),
plugins: {
elasticsearch: {
- getCluster: sinon.stub().returns(cluster)
- }
+ getCluster: sinon.stub().returns(cluster),
+ },
},
- ext: sinon.stub()
+ ext: sinon.stub(),
};
health = healthCheck(plugin, server, 0);
@@ -101,30 +109,31 @@ describe('plugins/elasticsearch', () => {
sinon.assert.calledWithExactly(server.ext, sinon.match.string, sinon.match.func);
const [, handler] = server.ext.firstCall.args;
- handler(); // this should be health.stop
+ handler(); // this should be health.stop
// ensure that the handler unregistered the timer
expect(getTimerCount()).to.be(0);
});
- it('should set the cluster green if everything is ready', function () {
+ it('should set the cluster green if everything is ready', function() {
cluster.callWithInternalUser.withArgs('ping').returns(Bluebird.resolve());
- return health.run()
- .then(function () {
- sinon.assert.calledOnce(plugin.status.yellow);
- sinon.assert.calledWithExactly(plugin.status.yellow, 'Waiting for Elasticsearch');
+ return health.run().then(function() {
+ sinon.assert.calledOnce(plugin.status.yellow);
+ sinon.assert.calledWithExactly(plugin.status.yellow, 'Waiting for Elasticsearch');
- sinon.assert.calledOnce(cluster.callWithInternalUser.withArgs('nodes.info', sinon.match.any));
- sinon.assert.notCalled(plugin.status.red);
- sinon.assert.calledOnce(plugin.status.green);
- sinon.assert.calledWithExactly(plugin.status.green, 'Ready');
- });
+ sinon.assert.calledOnce(
+ cluster.callWithInternalUser.withArgs('nodes.info', sinon.match.any)
+ );
+ sinon.assert.notCalled(plugin.status.red);
+ sinon.assert.calledOnce(plugin.status.green);
+ sinon.assert.calledWithExactly(plugin.status.green, 'Ready');
+ });
});
- describe('#waitUntilReady', function () {
- it('waits for green status', function () {
- plugin.status.once = sinon.spy(function (event, handler) {
+ describe('#waitUntilReady', function() {
+ it('waits for green status', function() {
+ plugin.status.once = sinon.spy(function(event, handler) {
expect(event).to.be('green');
setImmediate(handler);
});
@@ -133,7 +142,7 @@ describe('plugins/elasticsearch', () => {
sandbox.clock.runAll();
- return waitUntilReadyPromise.then(function () {
+ return waitUntilReadyPromise.then(function() {
sinon.assert.calledOnce(plugin.status.once);
});
});
diff --git a/src/legacy/core_plugins/elasticsearch/lib/abortable_request_handler.test.js b/src/legacy/core_plugins/elasticsearch/lib/abortable_request_handler.test.js
index 09bf701ce372..d79dd4ae4e44 100644
--- a/src/legacy/core_plugins/elasticsearch/lib/abortable_request_handler.test.js
+++ b/src/legacy/core_plugins/elasticsearch/lib/abortable_request_handler.test.js
@@ -27,8 +27,8 @@ describe('abortableRequestHandler', () => {
const eventHandlers = new Map();
const mockRequest = {
events: {
- once: jest.fn((key, fn) => eventHandlers.set(key, fn))
- }
+ once: jest.fn((key, fn) => eventHandlers.set(key, fn)),
+ },
};
const handler = jest.fn();
diff --git a/src/legacy/core_plugins/elasticsearch/lib/create_proxy.js b/src/legacy/core_plugins/elasticsearch/lib/create_proxy.js
index 266ed7bafdf9..85bc57f89e91 100644
--- a/src/legacy/core_plugins/elasticsearch/lib/create_proxy.js
+++ b/src/legacy/core_plugins/elasticsearch/lib/create_proxy.js
@@ -28,18 +28,23 @@ export function createProxy(server) {
path: '/elasticsearch/_msearch',
config: {
payload: {
- parse: 'gunzip'
- }
+ parse: 'gunzip',
+ },
},
handler: abortableRequestHandler((signal, req, h) => {
const { query, payload } = req;
- return callWithRequest(req, 'transport.request', {
- path: '/_msearch',
- method: 'POST',
- query,
- body: payload.toString('utf8')
- }, { signal }).finally(r => h.response(r));
- })
+ return callWithRequest(
+ req,
+ 'transport.request',
+ {
+ path: '/_msearch',
+ method: 'POST',
+ query,
+ body: payload.toString('utf8'),
+ },
+ { signal }
+ ).finally(r => h.response(r));
+ }),
});
server.route({
@@ -48,22 +53,27 @@ export function createProxy(server) {
config: {
validate: {
params: Joi.object().keys({
- index: Joi.string().required()
- })
- }
+ index: Joi.string().required(),
+ }),
+ },
},
handler: abortableRequestHandler(async (signal, req) => {
const { query, payload: body } = req;
try {
- return await callWithRequest(req, 'transport.request', {
- path: `/${encodeURIComponent(req.params.index)}/_search`,
- method: 'POST',
- query,
- body
- }, { signal });
+ return await callWithRequest(
+ req,
+ 'transport.request',
+ {
+ path: `/${encodeURIComponent(req.params.index)}/_search`,
+ method: 'POST',
+ query,
+ body,
+ },
+ { signal }
+ );
} catch (error) {
return JSON.parse(error.response);
}
- })
+ }),
});
}
diff --git a/src/legacy/core_plugins/elasticsearch/lib/ensure_es_version.js b/src/legacy/core_plugins/elasticsearch/lib/ensure_es_version.js
index cb3ed1886b4a..8d304cd55841 100644
--- a/src/legacy/core_plugins/elasticsearch/lib/ensure_es_version.js
+++ b/src/legacy/core_plugins/elasticsearch/lib/ensure_es_version.js
@@ -41,84 +41,85 @@ export function ensureEsVersion(server, kibanaVersion, ignoreVersionMismatch = f
server.logWithMetadata(['plugin', 'debug'], 'Checking Elasticsearch version');
return callWithInternalUser('nodes.info', {
- filterPath: [
- 'nodes.*.version',
- 'nodes.*.http.publish_address',
- 'nodes.*.ip',
- ]
- })
- .then(function (info) {
+ filterPath: ['nodes.*.version', 'nodes.*.http.publish_address', 'nodes.*.ip'],
+ }).then(function(info) {
// Aggregate incompatible ES nodes.
- const incompatibleNodes = [];
+ const incompatibleNodes = [];
- // Aggregate ES nodes which should prompt a Kibana upgrade.
- const warningNodes = [];
+ // Aggregate ES nodes which should prompt a Kibana upgrade.
+ const warningNodes = [];
- forEach(info.nodes, esNode => {
- if (!isEsCompatibleWithKibana(esNode.version, kibanaVersion)) {
+ forEach(info.nodes, esNode => {
+ if (!isEsCompatibleWithKibana(esNode.version, kibanaVersion)) {
// Exit early to avoid collecting ES nodes with newer major versions in the `warningNodes`.
- return incompatibleNodes.push(esNode);
- }
-
- // It's acceptable if ES and Kibana versions are not the same so long as
- // they are not incompatible, but we should warn about it
-
- // Ignore version qualifiers
- // https://github.com/elastic/elasticsearch/issues/36859
- const looseMismatch = coerce(esNode.version).version !== coerce(kibanaVersion).version;
- if (looseMismatch) {
- warningNodes.push(esNode);
- }
- });
+ return incompatibleNodes.push(esNode);
+ }
+
+ // It's acceptable if ES and Kibana versions are not the same so long as
+ // they are not incompatible, but we should warn about it
- function getHumanizedNodeNames(nodes) {
- return nodes.map(node => {
- const publishAddress = get(node, 'http.publish_address') ? (get(node, 'http.publish_address') + ' ') : '';
- return 'v' + node.version + ' @ ' + publishAddress + '(' + node.ip + ')';
- });
+ // Ignore version qualifiers
+ // https://github.com/elastic/elasticsearch/issues/36859
+ const looseMismatch = coerce(esNode.version).version !== coerce(kibanaVersion).version;
+ if (looseMismatch) {
+ warningNodes.push(esNode);
}
+ });
- if (warningNodes.length) {
- const simplifiedNodes = warningNodes.map(node => ({
- version: node.version,
- http: {
- publish_address: get(node, 'http.publish_address')
- },
- ip: node.ip,
- }));
-
- // Don't show the same warning over and over again.
- const warningNodeNames = getHumanizedNodeNames(simplifiedNodes).join(', ');
- if (lastWarnedNodesForServer.get(server) !== warningNodeNames) {
- lastWarnedNodesForServer.set(server, warningNodeNames);
- server.logWithMetadata(['warning'],
- `You're running Kibana ${kibanaVersion} with some different versions of ` +
+ function getHumanizedNodeNames(nodes) {
+ return nodes.map(node => {
+ const publishAddress = get(node, 'http.publish_address')
+ ? get(node, 'http.publish_address') + ' '
+ : '';
+ return 'v' + node.version + ' @ ' + publishAddress + '(' + node.ip + ')';
+ });
+ }
+
+ if (warningNodes.length) {
+ const simplifiedNodes = warningNodes.map(node => ({
+ version: node.version,
+ http: {
+ publish_address: get(node, 'http.publish_address'),
+ },
+ ip: node.ip,
+ }));
+
+ // Don't show the same warning over and over again.
+ const warningNodeNames = getHumanizedNodeNames(simplifiedNodes).join(', ');
+ if (lastWarnedNodesForServer.get(server) !== warningNodeNames) {
+ lastWarnedNodesForServer.set(server, warningNodeNames);
+ server.logWithMetadata(
+ ['warning'],
+ `You're running Kibana ${kibanaVersion} with some different versions of ` +
'Elasticsearch. Update Kibana or Elasticsearch to the same ' +
`version to prevent compatibility issues: ${warningNodeNames}`,
- {
- kibanaVersion,
- nodes: simplifiedNodes,
- });
- }
- }
-
- if (incompatibleNodes.length && !shouldIgnoreVersionMismatch(server, ignoreVersionMismatch)) {
- const incompatibleNodeNames = getHumanizedNodeNames(incompatibleNodes);
- throw new Error(
- `This version of Kibana requires Elasticsearch v` +
- `${kibanaVersion} on all nodes. I found ` +
- `the following incompatible nodes in your cluster: ${incompatibleNodeNames.join(', ')}`
+ {
+ kibanaVersion,
+ nodes: simplifiedNodes,
+ }
);
}
-
- return true;
- });
+ }
+
+ if (incompatibleNodes.length && !shouldIgnoreVersionMismatch(server, ignoreVersionMismatch)) {
+ const incompatibleNodeNames = getHumanizedNodeNames(incompatibleNodes);
+ throw new Error(
+ `This version of Kibana requires Elasticsearch v` +
+ `${kibanaVersion} on all nodes. I found ` +
+ `the following incompatible nodes in your cluster: ${incompatibleNodeNames.join(', ')}`
+ );
+ }
+
+ return true;
+ });
}
function shouldIgnoreVersionMismatch(server, ignoreVersionMismatch) {
const isDevMode = server.config().get('env.dev');
- if(!isDevMode && ignoreVersionMismatch) {
- throw new Error(`Option "elasticsearch.ignoreVersionMismatch" can only be used in development mode`);
+ if (!isDevMode && ignoreVersionMismatch) {
+ throw new Error(
+ `Option "elasticsearch.ignoreVersionMismatch" can only be used in development mode`
+ );
}
return isDevMode && ignoreVersionMismatch;
diff --git a/src/legacy/core_plugins/elasticsearch/lib/handle_es_error.js b/src/legacy/core_plugins/elasticsearch/lib/handle_es_error.js
index e64789bdff4f..fc4ff512e2bd 100644
--- a/src/legacy/core_plugins/elasticsearch/lib/handle_es_error.js
+++ b/src/legacy/core_plugins/elasticsearch/lib/handle_es_error.js
@@ -26,12 +26,17 @@ export function handleESError(error) {
throw new Error('Expected an instance of Error');
}
- if (error instanceof esErrors.ConnectionFault ||
+ if (
+ error instanceof esErrors.ConnectionFault ||
error instanceof esErrors.ServiceUnavailable ||
error instanceof esErrors.NoConnections ||
- error instanceof esErrors.RequestTimeout) {
+ error instanceof esErrors.RequestTimeout
+ ) {
return Boom.serverUnavailable(error);
- } else if (error instanceof esErrors.Conflict || _.contains(error.message, 'index_template_already_exists')) {
+ } else if (
+ error instanceof esErrors.Conflict ||
+ _.contains(error.message, 'index_template_already_exists')
+ ) {
return Boom.conflict(error);
} else if (error instanceof esErrors[403]) {
return Boom.forbidden(error);
diff --git a/src/legacy/core_plugins/elasticsearch/lib/health_check.js b/src/legacy/core_plugins/elasticsearch/lib/health_check.js
index ac8e6caab949..40053ec77454 100644
--- a/src/legacy/core_plugins/elasticsearch/lib/health_check.js
+++ b/src/legacy/core_plugins/elasticsearch/lib/health_check.js
@@ -21,11 +21,11 @@ import Bluebird from 'bluebird';
import kibanaVersion from './kibana_version';
import { ensureEsVersion } from './ensure_es_version';
-export default function (plugin, server, requestDelay, ignoreVersionMismatch) {
+export default function(plugin, server, requestDelay, ignoreVersionMismatch) {
plugin.status.yellow('Waiting for Elasticsearch');
function waitUntilReady() {
- return new Bluebird((resolve) => {
+ return new Bluebird(resolve => {
plugin.status.once('green', resolve);
});
}
@@ -36,14 +36,13 @@ export default function (plugin, server, requestDelay, ignoreVersionMismatch) {
.catch(err => plugin.status.red(err));
}
-
let timeoutId = null;
function scheduleCheck(ms) {
if (timeoutId) return;
- const myId = setTimeout(function () {
- check().finally(function () {
+ const myId = setTimeout(function() {
+ check().finally(function() {
if (timeoutId === myId) startorRestartChecking();
});
}, ms);
@@ -69,6 +68,8 @@ export default function (plugin, server, requestDelay, ignoreVersionMismatch) {
run: check,
start: startorRestartChecking,
stop: stopChecking,
- isRunning: function () { return !!timeoutId; },
+ isRunning: function() {
+ return !!timeoutId;
+ },
};
}
diff --git a/src/legacy/core_plugins/elasticsearch/lib/kibana_version.js b/src/legacy/core_plugins/elasticsearch/lib/kibana_version.js
index 80f6e4f90c89..e00c12f8271b 100644
--- a/src/legacy/core_plugins/elasticsearch/lib/kibana_version.js
+++ b/src/legacy/core_plugins/elasticsearch/lib/kibana_version.js
@@ -17,9 +17,7 @@
* under the License.
*/
-import {
- version as kibanaVersion,
-} from '../../../../../package.json';
+import { version as kibanaVersion } from '../../../../../package.json';
export default {
// Make the version stubbable to improve testability.
diff --git a/src/legacy/core_plugins/input_control_vis/index.js b/src/legacy/core_plugins/input_control_vis/index.js
index e9864aa8c394..a21b79e28fb7 100644
--- a/src/legacy/core_plugins/input_control_vis/index.js
+++ b/src/legacy/core_plugins/input_control_vis/index.js
@@ -19,14 +19,12 @@
import { resolve } from 'path';
-export default function (kibana) {
+export default function(kibana) {
return new kibana.Plugin({
uiExports: {
- visTypes: [
- 'plugins/input_control_vis/register_vis'
- ],
+ visTypes: ['plugins/input_control_vis/register_vis'],
interpreter: ['plugins/input_control_vis/input_control_fn'],
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
- }
+ },
});
}
diff --git a/src/legacy/core_plugins/input_control_vis/public/components/editor/__tests__/get_index_pattern_mock.js b/src/legacy/core_plugins/input_control_vis/public/components/editor/__tests__/get_index_pattern_mock.js
index e0f612d8bfc1..c693bf100e26 100644
--- a/src/legacy/core_plugins/input_control_vis/public/components/editor/__tests__/get_index_pattern_mock.js
+++ b/src/legacy/core_plugins/input_control_vis/public/components/editor/__tests__/get_index_pattern_mock.js
@@ -24,7 +24,7 @@ export const getIndexPatternMock = () => {
fields: [
{ name: 'keywordField', type: 'string', aggregatable: true },
{ name: 'textField', type: 'string', aggregatable: false },
- { name: 'numberField', type: 'number', aggregatable: true }
- ]
+ { name: 'numberField', type: 'number', aggregatable: true },
+ ],
});
};
diff --git a/src/legacy/core_plugins/input_control_vis/public/components/editor/__tests__/get_index_patterns_mock.js b/src/legacy/core_plugins/input_control_vis/public/components/editor/__tests__/get_index_patterns_mock.js
index d4f668b55591..76e7d4353ad4 100644
--- a/src/legacy/core_plugins/input_control_vis/public/components/editor/__tests__/get_index_patterns_mock.js
+++ b/src/legacy/core_plugins/input_control_vis/public/components/editor/__tests__/get_index_patterns_mock.js
@@ -22,14 +22,14 @@ export const getIndexPatternsMock = () => {
{
id: 'indexPattern1',
attributes: {
- title: 'indexPattern1'
- }
+ title: 'indexPattern1',
+ },
},
{
id: 'indexPattern2',
attributes: {
- title: 'indexPattern2'
- }
- }
+ title: 'indexPattern2',
+ },
+ },
]);
};
diff --git a/src/legacy/core_plugins/input_control_vis/public/components/editor/controls_tab.js b/src/legacy/core_plugins/input_control_vis/public/components/editor/controls_tab.js
index d5f58236027a..97036d7b0f5d 100644
--- a/src/legacy/core_plugins/input_control_vis/public/components/editor/controls_tab.js
+++ b/src/legacy/core_plugins/input_control_vis/public/components/editor/controls_tab.js
@@ -35,65 +35,64 @@ import {
} from '@elastic/eui';
class ControlsTabUi extends Component {
-
state = {
- type: 'list'
- }
+ type: 'list',
+ };
- getIndexPattern = async (indexPatternId) => {
+ getIndexPattern = async indexPatternId => {
return await npStart.plugins.data.indexPatterns.get(indexPatternId);
- }
+ };
- onChange = value => this.props.setValue('controls', value)
+ onChange = value => this.props.setValue('controls', value);
handleLabelChange = (controlIndex, evt) => {
const updatedControl = this.props.stateParams.controls[controlIndex];
updatedControl.label = evt.target.value;
this.onChange(setControl(this.props.stateParams.controls, controlIndex, updatedControl));
- }
+ };
handleIndexPatternChange = (controlIndex, indexPatternId) => {
const updatedControl = this.props.stateParams.controls[controlIndex];
updatedControl.indexPattern = indexPatternId;
updatedControl.fieldName = '';
this.onChange(setControl(this.props.stateParams.controls, controlIndex, updatedControl));
- }
+ };
handleFieldNameChange = (controlIndex, fieldName) => {
const updatedControl = this.props.stateParams.controls[controlIndex];
updatedControl.fieldName = fieldName;
this.onChange(setControl(this.props.stateParams.controls, controlIndex, updatedControl));
- }
+ };
handleCheckboxOptionChange = (controlIndex, optionName, evt) => {
const updatedControl = this.props.stateParams.controls[controlIndex];
updatedControl.options[optionName] = evt.target.checked;
this.onChange(setControl(this.props.stateParams.controls, controlIndex, updatedControl));
- }
+ };
handleNumberOptionChange = (controlIndex, optionName, evt) => {
const updatedControl = this.props.stateParams.controls[controlIndex];
updatedControl.options[optionName] = parseFloat(evt.target.value);
this.onChange(setControl(this.props.stateParams.controls, controlIndex, updatedControl));
- }
+ };
- handleRemoveControl = (controlIndex) => {
+ handleRemoveControl = controlIndex => {
this.onChange(removeControl(this.props.stateParams.controls, controlIndex));
- }
+ };
moveControl = (controlIndex, direction) => {
this.onChange(moveControl(this.props.stateParams.controls, controlIndex, direction));
- }
+ };
handleAddControl = () => {
this.onChange(addControl(this.props.stateParams.controls, newControl(this.state.type)));
- }
+ };
handleParentChange = (controlIndex, evt) => {
const updatedControl = this.props.stateParams.controls[controlIndex];
updatedControl.parent = evt.target.value;
this.onChange(setControl(this.props.stateParams.controls, controlIndex, updatedControl));
- }
+ };
renderControls() {
const lineageMap = getLineageMap(this.props.stateParams.controls);
@@ -101,7 +100,8 @@ class ControlsTabUi extends Component {
const parentCandidates = getParentCandidates(
this.props.stateParams.controls,
controlParams.id,
- lineageMap);
+ lineageMap
+ );
return (
-
{this.renderControls()}
-
+
this.setState({ type: evt.target.value })}
aria-label={intl.formatMessage({
id: 'inputControl.editor.controlsTab.select.controlTypeAriaLabel',
- defaultMessage: 'Select control type'
+ defaultMessage: 'Select control type',
})}
/>
-
+
-
+
-
);
}
@@ -185,7 +188,7 @@ class ControlsTabUi extends Component {
ControlsTabUi.propTypes = {
vis: PropTypes.object.isRequired,
- setValue: PropTypes.func.isRequired
+ setValue: PropTypes.func.isRequired,
};
export const ControlsTab = injectI18n(ControlsTabUi);
diff --git a/src/legacy/core_plugins/input_control_vis/public/components/editor/controls_tab.test.js b/src/legacy/core_plugins/input_control_vis/public/components/editor/controls_tab.test.js
index 45981adf9af4..28f435c27ea8 100644
--- a/src/legacy/core_plugins/input_control_vis/public/components/editor/controls_tab.test.js
+++ b/src/legacy/core_plugins/input_control_vis/public/components/editor/controls_tab.test.js
@@ -21,8 +21,8 @@ jest.mock('../../../../../core_plugins/data/public/legacy', () => ({
indexPatterns: {
indexPatterns: {
get: jest.fn(),
- }
- }
+ },
+ },
}));
jest.mock('ui/new_platform', () => ({
@@ -31,10 +31,10 @@ jest.mock('ui/new_platform', () => ({
data: {
ui: {
IndexPatternSelect: () => {
- return
;
+ },
+ },
+ },
},
},
}));
@@ -43,12 +43,10 @@ import React from 'react';
import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers';
import { findTestSubject } from '@elastic/eui/lib/test';
import { getIndexPatternMock } from './__tests__/get_index_pattern_mock';
-import {
- ControlsTab,
-} from './controls_tab';
+import { ControlsTab } from './controls_tab';
const indexPatternsMock = {
- get: getIndexPatternMock
+ get: getIndexPatternMock,
};
let props;
@@ -56,50 +54,49 @@ beforeEach(() => {
props = {
vis: {
API: {
- indexPatterns: indexPatternsMock
+ indexPatterns: indexPatternsMock,
},
},
stateParams: {
controls: [
{
- 'id': '1',
- 'indexPattern': 'indexPattern1',
- 'fieldName': 'keywordField',
- 'label': 'custom label',
- 'type': 'list',
- 'options': {
- 'type': 'terms',
- 'multiselect': true,
- 'size': 5,
- 'order': 'desc'
- }
+ id: '1',
+ indexPattern: 'indexPattern1',
+ fieldName: 'keywordField',
+ label: 'custom label',
+ type: 'list',
+ options: {
+ type: 'terms',
+ multiselect: true,
+ size: 5,
+ order: 'desc',
+ },
},
{
- 'id': '2',
- 'indexPattern': 'indexPattern1',
- 'fieldName': 'numberField',
- 'label': '',
- 'type': 'range',
- 'options': {
- 'step': 1
- }
- }
- ]
+ id: '2',
+ indexPattern: 'indexPattern1',
+ fieldName: 'numberField',
+ label: '',
+ type: 'range',
+ options: {
+ step: 1,
+ },
+ },
+ ],
},
setValue: jest.fn(),
};
});
test('renders ControlsTab', () => {
- const component = shallowWithIntl(
);
expect(component).toMatchSnapshot();
});
describe('behavior', () => {
-
test('add control button', () => {
- const component = mountWithIntl(
);
findTestSubject(component, 'inputControlEditorAddBtn').simulate('click');
@@ -112,83 +109,93 @@ describe('behavior', () => {
});
test('remove control button', () => {
- const component = mountWithIntl(
);
findTestSubject(component, 'inputControlEditorRemoveControl0').simulate('click');
- const expectedParams = ['controls', [{
- 'id': '2',
- 'indexPattern': 'indexPattern1',
- 'fieldName': 'numberField',
- 'label': '',
- 'type': 'range',
- 'options': {
- 'step': 1
- }
- }]];
+ const expectedParams = [
+ 'controls',
+ [
+ {
+ id: '2',
+ indexPattern: 'indexPattern1',
+ fieldName: 'numberField',
+ label: '',
+ type: 'range',
+ options: {
+ step: 1,
+ },
+ },
+ ],
+ ];
expect(props.setValue).toHaveBeenCalledWith(...expectedParams);
});
-
test('move down control button', () => {
- const component = mountWithIntl(
);
findTestSubject(component, 'inputControlEditorMoveDownControl0').simulate('click');
- const expectedParams = ['controls', [
- {
- 'id': '2',
- 'indexPattern': 'indexPattern1',
- 'fieldName': 'numberField',
- 'label': '',
- 'type': 'range',
- 'options': {
- 'step': 1
- }
- },
- {
- 'id': '1',
- 'indexPattern': 'indexPattern1',
- 'fieldName': 'keywordField',
- 'label': 'custom label',
- 'type': 'list',
- 'options': {
- 'type': 'terms',
- 'multiselect': true,
- 'size': 5,
- 'order': 'desc'
- }
- }
- ]];
+ const expectedParams = [
+ 'controls',
+ [
+ {
+ id: '2',
+ indexPattern: 'indexPattern1',
+ fieldName: 'numberField',
+ label: '',
+ type: 'range',
+ options: {
+ step: 1,
+ },
+ },
+ {
+ id: '1',
+ indexPattern: 'indexPattern1',
+ fieldName: 'keywordField',
+ label: 'custom label',
+ type: 'list',
+ options: {
+ type: 'terms',
+ multiselect: true,
+ size: 5,
+ order: 'desc',
+ },
+ },
+ ],
+ ];
expect(props.setValue).toHaveBeenCalledWith(...expectedParams);
});
test('move up control button', () => {
- const component = mountWithIntl(
);
findTestSubject(component, 'inputControlEditorMoveUpControl1').simulate('click');
- const expectedParams = ['controls', [
- {
- 'id': '2',
- 'indexPattern': 'indexPattern1',
- 'fieldName': 'numberField',
- 'label': '',
- 'type': 'range',
- 'options': {
- 'step': 1
- }
- },
- {
- 'id': '1',
- 'indexPattern': 'indexPattern1',
- 'fieldName': 'keywordField',
- 'label': 'custom label',
- 'type': 'list',
- 'options': {
- 'type': 'terms',
- 'multiselect': true,
- 'size': 5,
- 'order': 'desc'
- }
- }
- ]];
+ const expectedParams = [
+ 'controls',
+ [
+ {
+ id: '2',
+ indexPattern: 'indexPattern1',
+ fieldName: 'numberField',
+ label: '',
+ type: 'range',
+ options: {
+ step: 1,
+ },
+ },
+ {
+ id: '1',
+ indexPattern: 'indexPattern1',
+ fieldName: 'keywordField',
+ label: 'custom label',
+ type: 'list',
+ options: {
+ type: 'terms',
+ multiselect: true,
+ size: 5,
+ order: 'desc',
+ },
+ },
+ ],
+ ];
expect(props.setValue).toHaveBeenCalledWith(...expectedParams);
});
diff --git a/src/legacy/core_plugins/input_control_vis/public/components/editor/field_select.js b/src/legacy/core_plugins/input_control_vis/public/components/editor/field_select.js
index ce7d48a3f137..456ff17a316a 100644
--- a/src/legacy/core_plugins/input_control_vis/public/components/editor/field_select.js
+++ b/src/legacy/core_plugins/input_control_vis/public/components/editor/field_select.js
@@ -22,10 +22,7 @@ import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { injectI18n, FormattedMessage } from '@kbn/i18n/react';
-import {
- EuiFormRow,
- EuiComboBox,
-} from '@elastic/eui';
+import { EuiFormRow, EuiComboBox } from '@elastic/eui';
class FieldSelectUi extends Component {
constructor(props) {
@@ -38,7 +35,9 @@ class FieldSelectUi extends Component {
fields: [],
indexPatternId: props.indexPatternId,
};
- this.filterField = _.get(props, 'filterField', () => { return true; });
+ this.filterField = _.get(props, 'filterField', () => {
+ return true;
+ });
}
componentWillUnmount() {
@@ -55,15 +54,18 @@ class FieldSelectUi extends Component {
}
}
- loadFields = (indexPatternId) => {
- this.setState({
- isLoading: true,
- fields: [],
- indexPatternId
- }, this.debouncedLoad.bind(null, indexPatternId));
- }
+ loadFields = indexPatternId => {
+ this.setState(
+ {
+ isLoading: true,
+ fields: [],
+ indexPatternId,
+ },
+ this.debouncedLoad.bind(null, indexPatternId)
+ );
+ };
- debouncedLoad = _.debounce(async (indexPatternId) => {
+ debouncedLoad = _.debounce(async indexPatternId => {
if (!indexPatternId || indexPatternId.length === 0) {
return;
}
@@ -88,24 +90,22 @@ class FieldSelectUi extends Component {
const fieldsByTypeMap = new Map();
const fields = [];
- indexPattern.fields
- .filter(this.filterField)
- .forEach(field => {
- if (fieldsByTypeMap.has(field.type)) {
- const fieldsList = fieldsByTypeMap.get(field.type);
- fieldsList.push(field.name);
- fieldsByTypeMap.set(field.type, fieldsList);
- } else {
- fieldsByTypeMap.set(field.type, [field.name]);
- }
- });
+ indexPattern.fields.filter(this.filterField).forEach(field => {
+ if (fieldsByTypeMap.has(field.type)) {
+ const fieldsList = fieldsByTypeMap.get(field.type);
+ fieldsList.push(field.name);
+ fieldsByTypeMap.set(field.type, fieldsList);
+ } else {
+ fieldsByTypeMap.set(field.type, [field.name]);
+ }
+ });
fieldsByTypeMap.forEach((fieldsList, fieldType) => {
fields.push({
label: fieldType,
options: fieldsList.sort().map(fieldName => {
return { value: fieldName, label: fieldName };
- })
+ }),
});
});
@@ -117,13 +117,13 @@ class FieldSelectUi extends Component {
this.setState({
isLoading: false,
- fields: fields
+ fields: fields,
});
}, 300);
- onChange = (selectedOptions) => {
+ onChange = selectedOptions => {
this.props.onChange(_.get(selectedOptions, '0.value'));
- }
+ };
render() {
if (!this.props.indexPatternId || this.props.indexPatternId.trim().length === 0) {
@@ -141,12 +141,17 @@ class FieldSelectUi extends Component {
return (