-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into new-nav
- Loading branch information
Showing
441 changed files
with
12,143 additions
and
1,342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/dev/build/tasks/create_static_fs_with_node_modules_task.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import del from 'del'; | ||
import globby from 'globby'; | ||
import { resolve } from 'path'; | ||
import { generateStaticFsVolume } from '@elastic/static-fs'; | ||
|
||
async function deletePathsList(list) { | ||
for (const path of list) { | ||
await del(path); | ||
} | ||
} | ||
|
||
async function getTopLevelNodeModulesFolders(rootDir) { | ||
const nodeModulesFoldersForCwd = await globby(['**/node_modules', '!**/node_modules/**/*'], { | ||
cwd: rootDir, | ||
onlyDirectories: true, | ||
}); | ||
|
||
return nodeModulesFoldersForCwd.map(folder => resolve(rootDir, folder)); | ||
} | ||
|
||
export const CreateStaticFsWithNodeModulesTask = { | ||
description: | ||
'Creating static filesystem with node_modules, patching entryPoints and deleting node_modules folder', | ||
|
||
async run(config, log, build) { | ||
const rootDir = build.resolvePath('.'); | ||
|
||
// Get all the top node_modules folders | ||
const nodeModulesFolders = await getTopLevelNodeModulesFolders(rootDir); | ||
|
||
// Define root entry points | ||
const rootEntryPoints = [build.resolvePath('src/setup_node_env/index.js')]; | ||
|
||
// Creates the static filesystem with | ||
// every node_module we have | ||
const staticFsAddedPaths = await generateStaticFsVolume( | ||
rootDir, | ||
nodeModulesFolders, | ||
rootEntryPoints | ||
); | ||
|
||
// Delete node_modules folder | ||
await deletePathsList(staticFsAddedPaths); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/plugins/data/public/search/aggs/metrics/avg_fn.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { functionWrapper } from '../test_helpers'; | ||
import { aggAvg } from './avg_fn'; | ||
|
||
describe('agg_expression_functions', () => { | ||
describe('aggAvg', () => { | ||
const fn = functionWrapper(aggAvg()); | ||
|
||
test('required args are provided', () => { | ||
const actual = fn({ | ||
field: 'machine.os.keyword', | ||
}); | ||
expect(actual).toMatchInlineSnapshot(` | ||
Object { | ||
"type": "agg_type", | ||
"value": Object { | ||
"enabled": true, | ||
"id": undefined, | ||
"params": Object { | ||
"customLabel": undefined, | ||
"field": "machine.os.keyword", | ||
"json": undefined, | ||
}, | ||
"schema": undefined, | ||
"type": "avg", | ||
}, | ||
} | ||
`); | ||
}); | ||
|
||
test('correctly parses json string argument', () => { | ||
const actual = fn({ | ||
field: 'machine.os.keyword', | ||
json: '{ "foo": true }', | ||
}); | ||
|
||
expect(actual.value.params.json).toEqual({ foo: true }); | ||
expect(() => { | ||
fn({ | ||
field: 'machine.os.keyword', | ||
json: '/// intentionally malformed json ///', | ||
}); | ||
}).toThrowErrorMatchingInlineSnapshot(`"Unable to parse json argument string"`); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
import { ExpressionFunctionDefinition } from '../../../../../expressions/public'; | ||
import { AggExpressionType, AggExpressionFunctionArgs, METRIC_TYPES } from '../'; | ||
import { getParsedValue } from '../utils/get_parsed_value'; | ||
|
||
const fnName = 'aggAvg'; | ||
|
||
type Input = any; | ||
type AggArgs = AggExpressionFunctionArgs<typeof METRIC_TYPES.AVG>; | ||
type Output = AggExpressionType; | ||
type FunctionDefinition = ExpressionFunctionDefinition<typeof fnName, Input, AggArgs, Output>; | ||
|
||
export const aggAvg = (): FunctionDefinition => ({ | ||
name: fnName, | ||
help: i18n.translate('data.search.aggs.function.metrics.avg.help', { | ||
defaultMessage: 'Generates a serialized agg config for a Avg agg', | ||
}), | ||
type: 'agg_type', | ||
args: { | ||
id: { | ||
types: ['string'], | ||
help: i18n.translate('data.search.aggs.metrics.avg.id.help', { | ||
defaultMessage: 'ID for this aggregation', | ||
}), | ||
}, | ||
enabled: { | ||
types: ['boolean'], | ||
default: true, | ||
help: i18n.translate('data.search.aggs.metrics.avg.enabled.help', { | ||
defaultMessage: 'Specifies whether this aggregation should be enabled', | ||
}), | ||
}, | ||
schema: { | ||
types: ['string'], | ||
help: i18n.translate('data.search.aggs.metrics.avg.schema.help', { | ||
defaultMessage: 'Schema to use for this aggregation', | ||
}), | ||
}, | ||
field: { | ||
types: ['string'], | ||
required: true, | ||
help: i18n.translate('data.search.aggs.metrics.avg.field.help', { | ||
defaultMessage: 'Field to use for this aggregation', | ||
}), | ||
}, | ||
json: { | ||
types: ['string'], | ||
help: i18n.translate('data.search.aggs.metrics.avg.json.help', { | ||
defaultMessage: 'Advanced json to include when the agg is sent to Elasticsearch', | ||
}), | ||
}, | ||
customLabel: { | ||
types: ['string'], | ||
help: i18n.translate('data.search.aggs.metrics.avg.customLabel.help', { | ||
defaultMessage: 'Represents a custom label for this aggregation', | ||
}), | ||
}, | ||
}, | ||
fn: (input, args) => { | ||
const { id, enabled, schema, ...rest } = args; | ||
|
||
return { | ||
type: 'agg_type', | ||
value: { | ||
id, | ||
enabled, | ||
schema, | ||
type: METRIC_TYPES.AVG, | ||
params: { | ||
...rest, | ||
json: getParsedValue(args, 'json'), | ||
}, | ||
}, | ||
}; | ||
}, | ||
}); |
Oops, something went wrong.