From 22e66a1484a258c4150ca23c2b44305a89d80f0e Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Tue, 4 Feb 2020 18:15:48 +0100 Subject: [PATCH 01/22] Rollup TSVB integration: Add test and fix warning text (#56639) --- .../public/components/index_pattern.js | 2 + .../public/components/yes_no.js | 4 +- .../page_objects/visual_builder_page.ts | 13 +++ .../components/rollup_prompt/rollup_prompt.js | 2 +- .../test/functional/apps/rollup_job/index.js | 1 + .../test/functional/apps/rollup_job/tsvb.js | 105 ++++++++++++++++++ 6 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 x-pack/test/functional/apps/rollup_job/tsvb.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/index_pattern.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/index_pattern.js index de8469adfb8a73..f6530eb22332a8 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/index_pattern.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/index_pattern.js @@ -206,6 +206,7 @@ export const IndexPattern = ({ fields, prefix, onChange, disabled, model: _model })} > { const { name } = props; return () => { @@ -38,6 +38,7 @@ export function YesNo(props) {
{ await comboBox.clearInputField('metricsIndexPatternFieldsSelect'); diff --git a/x-pack/legacy/plugins/rollup/public/index_pattern_creation/components/rollup_prompt/rollup_prompt.js b/x-pack/legacy/plugins/rollup/public/index_pattern_creation/components/rollup_prompt/rollup_prompt.js index 7a944c5e9a5c0e..42c950f0b0d74a 100644 --- a/x-pack/legacy/plugins/rollup/public/index_pattern_creation/components/rollup_prompt/rollup_prompt.js +++ b/x-pack/legacy/plugins/rollup/public/index_pattern_creation/components/rollup_prompt/rollup_prompt.js @@ -13,7 +13,7 @@ export const RollupPrompt = () => (

Kibana's support for rollup index patterns is in beta. You might encounter issues using these patterns in saved searches, visualizations, and dashboards. They are not supported in - advanced features, such as TSVB, Timelion, and Machine Learning. + some advanced features, such as Timelion, and Machine Learning.

You can match a rollup index pattern against one rollup index and zero or more regular diff --git a/x-pack/test/functional/apps/rollup_job/index.js b/x-pack/test/functional/apps/rollup_job/index.js index 146cc4e8dbdf00..055b239058eac0 100644 --- a/x-pack/test/functional/apps/rollup_job/index.js +++ b/x-pack/test/functional/apps/rollup_job/index.js @@ -10,5 +10,6 @@ export default function({ loadTestFile }) { loadTestFile(require.resolve('./rollup_jobs')); loadTestFile(require.resolve('./hybrid_index_pattern')); + loadTestFile(require.resolve('./tsvb')); }); } diff --git a/x-pack/test/functional/apps/rollup_job/tsvb.js b/x-pack/test/functional/apps/rollup_job/tsvb.js new file mode 100644 index 00000000000000..f3782c4c916449 --- /dev/null +++ b/x-pack/test/functional/apps/rollup_job/tsvb.js @@ -0,0 +1,105 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import datemath from '@elastic/datemath'; +import expect from '@kbn/expect'; +import mockRolledUpData from './hybrid_index_helper'; + +export default function({ getService, getPageObjects }) { + const es = getService('legacyEs'); + const esArchiver = getService('esArchiver'); + const retry = getService('retry'); + const testSubjects = getService('testSubjects'); + const PageObjects = getPageObjects([ + 'common', + 'settings', + 'visualize', + 'visualBuilder', + 'timePicker', + ]); + + describe('tsvb integration', function() { + //Since rollups can only be created once with the same name (even if you delete it), + //we add the Date.now() to avoid name collision if you run the tests locally back to back. + const rollupJobName = `tsvb-test-rollup-job-${Date.now()}`; + const rollupSourceIndexName = 'rollup-source-data'; + const rollupTargetIndexName = `rollup-target-data`; + const now = new Date(); + const pastDates = [ + datemath.parse('now-1m', { forceNow: now }), + datemath.parse('now-2m', { forceNow: now }), + datemath.parse('now-3m', { forceNow: now }), + ]; + + before(async () => { + // load visualize to have an index pattern ready, otherwise visualize will redirect + await esArchiver.load('visualize/default'); + }); + + it('create rollup tsvb', async () => { + //Create data for rollup job so it doesn't fail + await es.index({ + index: rollupSourceIndexName, + body: { + '@timestamp': new Date().toISOString(), + }, + }); + + await retry.try(async () => { + //Create a rollup for kibana to recognize + await es.transport.request({ + path: `/_rollup/job/${rollupJobName}`, + method: 'PUT', + body: { + index_pattern: rollupSourceIndexName, + rollup_index: rollupTargetIndexName, + cron: '*/10 * * * * ?', + groups: { + date_histogram: { + fixed_interval: '1000ms', + field: '@timestamp', + time_zone: 'UTC', + }, + }, + timeout: '20s', + page_size: 1000, + }, + }); + }); + + await pastDates.map(async day => { + await es.index(mockRolledUpData(rollupJobName, rollupTargetIndexName, day)); + }); + + await PageObjects.visualize.navigateToNewVisualization(); + await PageObjects.visualize.clickVisualBuilder(); + await PageObjects.visualBuilder.checkVisualBuilderIsPresent(); + await PageObjects.timePicker.openQuickSelectTimeMenu(); + await testSubjects.click('superDatePickerCommonlyUsed_Last_24 hours'); + await PageObjects.visualBuilder.clickMetric(); + await PageObjects.visualBuilder.checkMetricTabIsPresent(); + await PageObjects.visualBuilder.clickPanelOptions('metric'); + await PageObjects.visualBuilder.setIndexPatternValue(rollupTargetIndexName); + await PageObjects.visualBuilder.setIntervalValue('1d'); + await PageObjects.visualBuilder.setDropLastBucket(false); + await PageObjects.common.sleep(3000); + const newValue = await PageObjects.visualBuilder.getMetricValue(); + expect(newValue).to.eql('3'); + }); + + after(async () => { + // Delete the rollup job. + await es.transport.request({ + path: `/_rollup/job/${rollupJobName}`, + method: 'DELETE', + }); + + await es.indices.delete({ index: rollupTargetIndexName }); + await es.indices.delete({ index: rollupSourceIndexName }); + await esArchiver.load('empty_kibana'); + }); + }); +} From e510484ddf880a04924921a18b0efea32427d43f Mon Sep 17 00:00:00 2001 From: Lukas Olson Date: Tue, 4 Feb 2020 10:58:43 -0700 Subject: [PATCH 02/22] [Search service] Move loadingCount to sync search strategy (#56335) * Move loadingCount to search strategy * Only register observable once Co-authored-by: Elastic Machine --- .../create_app_mount_context_search.test.ts | 50 ++++++++----------- .../search/create_app_mount_context_search.ts | 19 ++----- .../public/search/es_client/get_es_client.ts | 6 ++- .../data/public/search/search_service.ts | 10 +--- .../public/search/sync_search_strategy.ts | 17 ++++--- 5 files changed, 42 insertions(+), 60 deletions(-) diff --git a/src/plugins/data/public/search/create_app_mount_context_search.test.ts b/src/plugins/data/public/search/create_app_mount_context_search.test.ts index 15b85ee270bed1..fa7cdbcda3082b 100644 --- a/src/plugins/data/public/search/create_app_mount_context_search.test.ts +++ b/src/plugins/data/public/search/create_app_mount_context_search.test.ts @@ -18,35 +18,32 @@ */ import { createAppMountSearchContext } from './create_app_mount_context_search'; -import { from, BehaviorSubject } from 'rxjs'; +import { from } from 'rxjs'; describe('Create app mount search context', () => { it('Returns search fn when there are no strategies', () => { - const context = createAppMountSearchContext({}, new BehaviorSubject(0)); + const context = createAppMountSearchContext({}); expect(context.search).toBeDefined(); }); it(`Search throws an error when the strategy doesn't exist`, () => { - const context = createAppMountSearchContext({}, new BehaviorSubject(0)); + const context = createAppMountSearchContext({}); expect(() => context.search({}, {}, 'noexist').toPromise()).toThrowErrorMatchingInlineSnapshot( `"Strategy with name noexist does not exist"` ); }); it(`Search fn is called on appropriate strategy name`, done => { - const context = createAppMountSearchContext( - { - mysearch: search => - Promise.resolve({ - search: () => from(Promise.resolve({ percentComplete: 98 })), - }), - anothersearch: search => - Promise.resolve({ - search: () => from(Promise.resolve({ percentComplete: 0 })), - }), - }, - new BehaviorSubject(0) - ); + const context = createAppMountSearchContext({ + mysearch: search => + Promise.resolve({ + search: () => from(Promise.resolve({ percentComplete: 98 })), + }), + anothersearch: search => + Promise.resolve({ + search: () => from(Promise.resolve({ percentComplete: 0 })), + }), + }); context.search({}, {}, 'mysearch').subscribe(response => { expect(response).toEqual({ percentComplete: 98 }); @@ -55,19 +52,16 @@ describe('Create app mount search context', () => { }); it(`Search fn is called with the passed in request object`, done => { - const context = createAppMountSearchContext( - { - mysearch: search => { - return Promise.resolve({ - search: request => { - expect(request).toEqual({ greeting: 'hi' }); - return from(Promise.resolve({})); - }, - }); - }, + const context = createAppMountSearchContext({ + mysearch: search => { + return Promise.resolve({ + search: request => { + expect(request).toEqual({ greeting: 'hi' }); + return from(Promise.resolve({})); + }, + }); }, - new BehaviorSubject(0) - ); + }); context.search({ greeting: 'hi' } as any, {}, 'mysearch').subscribe( response => {}, () => {}, diff --git a/src/plugins/data/public/search/create_app_mount_context_search.ts b/src/plugins/data/public/search/create_app_mount_context_search.ts index f480b8f3e042e6..7a617e0bab8376 100644 --- a/src/plugins/data/public/search/create_app_mount_context_search.ts +++ b/src/plugins/data/public/search/create_app_mount_context_search.ts @@ -17,8 +17,8 @@ * under the License. */ -import { mergeMap, tap } from 'rxjs/operators'; -import { from, BehaviorSubject } from 'rxjs'; +import { mergeMap } from 'rxjs/operators'; +import { from } from 'rxjs'; import { ISearchAppMountContext } from './i_search_app_mount_context'; import { ISearchGeneric } from './i_search'; import { @@ -30,8 +30,7 @@ import { TStrategyTypes } from './strategy_types'; import { DEFAULT_SEARCH_STRATEGY } from '../../common/search'; export const createAppMountSearchContext = ( - searchStrategies: TSearchStrategiesMap, - loadingCount$: BehaviorSubject + searchStrategies: TSearchStrategiesMap ): ISearchAppMountContext => { const getSearchStrategy = ( strategyName?: K @@ -47,17 +46,7 @@ export const createAppMountSearchContext = ( const search: ISearchGeneric = (request, options, strategyName) => { const strategyPromise = getSearchStrategy(strategyName); - return from(strategyPromise).pipe( - mergeMap(strategy => { - loadingCount$.next(loadingCount$.getValue() + 1); - return strategy.search(request, options).pipe( - tap( - error => loadingCount$.next(loadingCount$.getValue() - 1), - complete => loadingCount$.next(loadingCount$.getValue() - 1) - ) - ); - }) - ); + return from(strategyPromise).pipe(mergeMap(strategy => strategy.search(request, options))); }; return { search }; diff --git a/src/plugins/data/public/search/es_client/get_es_client.ts b/src/plugins/data/public/search/es_client/get_es_client.ts index 6c271643ba0124..93d9d24920271e 100644 --- a/src/plugins/data/public/search/es_client/get_es_client.ts +++ b/src/plugins/data/public/search/es_client/get_es_client.ts @@ -25,8 +25,7 @@ import { BehaviorSubject } from 'rxjs'; export function getEsClient( injectedMetadata: CoreStart['injectedMetadata'], http: CoreStart['http'], - packageInfo: PackageInfo, - loadingCount$: BehaviorSubject + packageInfo: PackageInfo ) { const esRequestTimeout = injectedMetadata.getInjectedVar('esRequestTimeout') as number; const esApiVersion = injectedMetadata.getInjectedVar('esApiVersion') as string; @@ -39,6 +38,9 @@ export function getEsClient( apiVersion: esApiVersion, }); + const loadingCount$ = new BehaviorSubject(0); + http.addLoadingCountSource(loadingCount$); + return { search: wrapEsClientMethod(client, 'search', loadingCount$), msearch: wrapEsClientMethod(client, 'msearch', loadingCount$), diff --git a/src/plugins/data/public/search/search_service.ts b/src/plugins/data/public/search/search_service.ts index dad2b3d078aa0f..dd67c04f1d7bd9 100644 --- a/src/plugins/data/public/search/search_service.ts +++ b/src/plugins/data/public/search/search_service.ts @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ -import { BehaviorSubject } from 'rxjs'; import { Plugin, CoreSetup, @@ -80,22 +79,17 @@ export class SearchService implements Plugin { private contextContainer?: IContextContainer>; private esClient?: LegacyApiCaller; private search?: ISearchGeneric; - private readonly loadingCount$ = new BehaviorSubject(0); constructor(private initializerContext: PluginInitializerContext) {} public setup(core: CoreSetup, packageInfo: PackageInfo): ISearchSetup { - core.http.addLoadingCountSource(this.loadingCount$); - const search = (this.search = createAppMountSearchContext( - this.searchStrategies, - this.loadingCount$ - ).search); + const search = (this.search = createAppMountSearchContext(this.searchStrategies).search); core.application.registerMountContext<'search'>('search', () => { return { search }; }); this.contextContainer = core.context.createContextContainer(); - this.esClient = getEsClient(core.injectedMetadata, core.http, packageInfo, this.loadingCount$); + this.esClient = getEsClient(core.injectedMetadata, core.http, packageInfo); const registerSearchStrategyProvider: TRegisterSearchStrategyProvider = < T extends TStrategyTypes diff --git a/src/plugins/data/public/search/sync_search_strategy.ts b/src/plugins/data/public/search/sync_search_strategy.ts index 65fe10f39aaa04..b895a177d8608e 100644 --- a/src/plugins/data/public/search/sync_search_strategy.ts +++ b/src/plugins/data/public/search/sync_search_strategy.ts @@ -17,7 +17,7 @@ * under the License. */ -import { from } from 'rxjs'; +import { BehaviorSubject, from } from 'rxjs'; import { IKibanaSearchRequest, IKibanaSearchResponse } from '../../common/search'; import { ISearchContext } from './i_search_context'; import { ISearch, ISearchOptions } from './i_search'; @@ -31,11 +31,16 @@ export interface ISyncSearchRequest extends IKibanaSearchRequest { export const syncSearchStrategyProvider: TSearchStrategyProvider = ( context: ISearchContext -) => { +): ISearchStrategy => { + const loadingCount$ = new BehaviorSubject(0); + context.core.http.addLoadingCountSource(loadingCount$); + const search: ISearch = ( request: ISyncSearchRequest, options: ISearchOptions = {} ) => { + loadingCount$.next(loadingCount$.getValue() + 1); + const response: Promise = context.core.http.fetch({ path: `/internal/search/${request.serverStrategy}`, method: 'POST', @@ -43,12 +48,10 @@ export const syncSearchStrategyProvider: TSearchStrategyProvider loadingCount$.next(loadingCount$.getValue() - 1)); - const strategy: ISearchStrategy = { - search, + return from(response); }; - return strategy; + return { search }; }; From 885b79e76fafba23def567668b5e0b958e895c47 Mon Sep 17 00:00:00 2001 From: Xavier Mouligneau <189600+XavierM@users.noreply.github.com> Date: Tue, 4 Feb 2020 13:29:18 -0500 Subject: [PATCH 03/22] fix open close signal on detail page (#56757) --- .../pages/detection_engine/components/signals/index.tsx | 4 +++- .../detection_engine/routes/__mocks__/request_responses.ts | 2 +- .../routes/signals/open_close_signals_route.ts | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/index.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/index.tsx index e65adcf3a6920a..7eb8e07ada7620 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/index.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/index.tsx @@ -129,7 +129,9 @@ const SignalsTableComponent: React.FC = ({ dataProviders: [], indexPattern: indexPatterns, browserFields, - filters: globalFilters, + filters: isEmpty(defaultFilters) + ? globalFilters + : [...(defaultFilters ?? []), ...globalFilters], kqlQuery: globalQuery, kqlMode: globalQuery.language, start: from, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_responses.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_responses.ts index 6a42aed123fa3c..19c4279e06b032 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_responses.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_responses.ts @@ -84,7 +84,7 @@ export const typicalSetStatusSignalByIdsPayload = (): Partial => ({ - query: { range: { '@timestamp': { gte: 'now-2M', lte: 'now/M' } } }, + query: { bool: { filter: { range: { '@timestamp': { gte: 'now-2M', lte: 'now/M' } } } } }, status: 'closed', }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/signals/open_close_signals_route.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/signals/open_close_signals_route.ts index 7c49a1942ee919..4755869c3d9087 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/signals/open_close_signals_route.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/signals/open_close_signals_route.ts @@ -33,7 +33,11 @@ export const setSignalsStatusRouteDef = (server: ServerFacade): Hapi.ServerRoute queryObject = { ids: { values: signalIds } }; } if (query) { - queryObject = query; + queryObject = { + bool: { + filter: query, + }, + }; } try { return callWithRequest(request, 'updateByQuery', { From b92e8e264c91a9c8eb8cb52fd7c414d31d4ccf83 Mon Sep 17 00:00:00 2001 From: Caroline Horn <549577+cchaos@users.noreply.github.com> Date: Tue, 4 Feb 2020 13:42:27 -0500 Subject: [PATCH 04/22] Fix: Filter pill base coloring (#56761) --- src/plugins/data/public/ui/filter_bar/filter_view/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/data/public/ui/filter_bar/filter_view/index.tsx b/src/plugins/data/public/ui/filter_bar/filter_view/index.tsx index dd12789d15a9d7..ed33afeca69c29 100644 --- a/src/plugins/data/public/ui/filter_bar/filter_view/index.tsx +++ b/src/plugins/data/public/ui/filter_bar/filter_view/index.tsx @@ -57,6 +57,7 @@ export const FilterView: FC = ({ return ( Date: Tue, 4 Feb 2020 11:05:30 -0800 Subject: [PATCH 05/22] Implement UI for Create Alert form (#55232) * Updated Alert ui model, fixed form validation and small issues * Fixed error messages and validation for action params forms * Fixed typecheck error * Moved alert add/edit common fields to alert form * Fixed type checks * Refactored alert add flyout by splitting it to the form and flyout components, added some unit tests * Refactored connector add/edit flyouts and created add connector modal * Refactored add/edit flyout tests * Fixed test * Removed orig files * Removed orig file * Added unit tests for add connector modal dialog * Action Groups idea of implementation * Removed action group tabs and set only first action group as default (temporary till design will be ready for support multiple groups) * Added missing unit tests * Changed design of the email params form * Fixed actions params forms according to latest mockups * Fixed options list for available actions connectors * Fixed modal dialog update on action delete * fixed build fail * Added functionality for action types with Message field to Add variables * Added alertReducer unit tests * Added create alert functional test * Added types for Params * Some design fixes * alerts empty prompt * Fixed failing app on save alert and added possibility to hide Change trigger button * Fixed type check issues * Added connector config types * fixed type check * Fixed merge issues * Fixed type checks * Fixed functional tests and error expression message * Fixed jest tests * Review changes Co-authored-by: dave.snider@gmail.com --- .../np_ready/public/application/app.tsx | 2 +- .../builtin_action_types/email.test.tsx | 58 +- .../components/builtin_action_types/email.tsx | 307 ++++--- .../builtin_action_types/es_index.test.tsx | 19 +- .../builtin_action_types/es_index.tsx | 35 +- .../builtin_action_types/pagerduty.test.tsx | 36 +- .../builtin_action_types/pagerduty.tsx | 82 +- .../builtin_action_types/server_log.test.tsx | 26 +- .../builtin_action_types/server_log.tsx | 90 +- .../builtin_action_types/slack.test.tsx | 22 +- .../components/builtin_action_types/slack.tsx | 105 ++- .../components/builtin_action_types/types.ts | 130 +++ .../builtin_action_types/webhook.test.tsx | 22 +- .../builtin_action_types/webhook.tsx | 28 +- .../components/builtin_alert_types/index.ts | 2 +- .../threshold/expression.tsx | 153 +--- .../builtin_alert_types/threshold/index.ts | 103 +++ .../threshold/visualization.tsx | 5 +- .../application/constants/action_groups.ts | 11 - .../application/context/alerts_context.tsx | 5 +- .../public/application/lib/alert_api.test.ts | 10 +- .../action_connector_form/_index.scss | 3 + .../action_connector_form.test.tsx | 63 +- .../action_connector_form.tsx | 327 +++---- .../action_type_menu.tsx | 40 +- .../connector_add_flyout.test.tsx | 58 +- .../connector_add_flyout.tsx | 131 ++- .../connector_add_modal.test.tsx | 102 +++ .../connector_add_modal.tsx | 168 ++++ .../connector_edit_flyout.test.tsx | 2 +- .../connector_edit_flyout.tsx | 120 ++- .../connector_reducer.ts | 13 +- .../components/actions_connectors_list.tsx | 7 +- .../sections/alert_add/alert_add.test.tsx | 117 +++ .../sections/alert_add/alert_add.tsx | 759 ++-------------- .../sections/alert_add/alert_form.test.tsx | 200 ++++ .../sections/alert_add/alert_form.tsx | 853 ++++++++++++++++++ .../sections/alert_add/alert_reducer.test.ts | 163 ++++ .../sections/alert_add/alert_reducer.ts | 18 + .../components/alert_details.test.tsx | 32 + .../components/alerts_list.test.tsx | 12 +- .../alerts_list/components/alerts_list.tsx | 230 +++-- .../np_ready/public/types.ts | 25 +- .../triggers_actions_ui/public/index.scss | 3 + .../apps/triggers_actions_ui/alerts.ts | 90 +- .../apps/triggers_actions_ui/connectors.ts | 10 +- .../page_objects/triggers_actions_ui_page.ts | 24 +- 47 files changed, 3160 insertions(+), 1661 deletions(-) create mode 100644 x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/types.ts create mode 100644 x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_alert_types/threshold/index.ts delete mode 100644 x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/constants/action_groups.ts create mode 100644 x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/_index.scss create mode 100644 x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_add_modal.test.tsx create mode 100644 x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_add_modal.tsx create mode 100644 x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alert_add/alert_add.test.tsx create mode 100644 x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alert_add/alert_form.test.tsx create mode 100644 x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alert_add/alert_form.tsx create mode 100644 x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alert_add/alert_reducer.test.ts diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/app.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/app.tsx index 7d9a963c9c6b32..8bc292c58468ee 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/app.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/app.tsx @@ -48,7 +48,7 @@ export const App = (appDeps: AppDeps) => { ); }; -export const AppWithoutRouter = ({ sectionsRegex }: any) => { +export const AppWithoutRouter = ({ sectionsRegex }: { sectionsRegex: string }) => { const { capabilities } = useAppDependencies(); const canShowAlerts = hasShowAlertsCapability(capabilities); const DEFAULT_SECTION: Section = canShowAlerts ? 'alerts' : 'connectors'; diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/email.test.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/email.test.tsx index 5c924982c3536a..49a611167cf16a 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/email.test.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/email.test.tsx @@ -3,11 +3,12 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import React from 'react'; +import React, { FunctionComponent } from 'react'; import { mountWithIntl } from 'test_utils/enzyme_helpers'; import { TypeRegistry } from '../../type_registry'; import { registerBuiltInActionTypes } from './index'; -import { ActionTypeModel, ActionConnector } from '../../../types'; +import { ActionTypeModel, ActionParamsProps } from '../../../types'; +import { EmailActionParams, EmailActionConnector } from './types'; const ACTION_TYPE_ID = '.email'; let actionTypeModel: ActionTypeModel; @@ -40,43 +41,15 @@ describe('connector validation', () => { name: 'email', config: { from: 'test@test.com', - port: '2323', + port: 2323, host: 'localhost', test: 'test', }, - } as ActionConnector; + } as EmailActionConnector; expect(actionTypeModel.validateConnector(actionConnector)).toEqual({ errors: { from: [], - service: [], - port: [], - host: [], - user: [], - password: [], - }, - }); - - delete actionConnector.config.test; - actionConnector.config.host = 'elastic.co'; - actionConnector.config.port = 8080; - expect(actionTypeModel.validateConnector(actionConnector)).toEqual({ - errors: { - from: [], - service: [], - port: [], - host: [], - user: [], - password: [], - }, - }); - delete actionConnector.config.host; - delete actionConnector.config.port; - actionConnector.config.service = 'testService'; - expect(actionTypeModel.validateConnector(actionConnector)).toEqual({ - errors: { - from: [], - service: [], port: [], host: [], user: [], @@ -97,12 +70,11 @@ describe('connector validation', () => { config: { from: 'test@test.com', }, - } as ActionConnector; + } as EmailActionConnector; expect(actionTypeModel.validateConnector(actionConnector)).toEqual({ errors: { from: [], - service: ['Service is required.'], port: ['Port is required.'], host: ['Host is required.'], user: [], @@ -168,14 +140,13 @@ describe('EmailActionConnectorFields renders', () => { config: { from: 'test@test.com', }, - } as ActionConnector; + } as EmailActionConnector; const wrapper = mountWithIntl( {}} editActionSecrets={() => {}} - hasErrors={false} /> ); expect(wrapper.find('[data-test-subj="emailFromInput"]').length > 0).toBeTruthy(); @@ -198,19 +169,22 @@ describe('EmailParamsFields renders', () => { if (!actionTypeModel.actionParamsFields) { return; } - const ParamsFields = actionTypeModel.actionParamsFields; + const ParamsFields = actionTypeModel.actionParamsFields as FunctionComponent< + ActionParamsProps + >; const actionParams = { + cc: [], + bcc: [], to: ['test@test.com'], subject: 'test', message: 'test message', }; const wrapper = mountWithIntl( {}} index={0} - hasErrors={false} /> ); expect(wrapper.find('[data-test-subj="toEmailAddressInput"]').length > 0).toBeTruthy(); @@ -220,8 +194,6 @@ describe('EmailParamsFields renders', () => { .first() .prop('selectedOptions') ).toStrictEqual([{ label: 'test@test.com' }]); - expect(wrapper.find('[data-test-subj="ccEmailAddressInput"]').length > 0).toBeTruthy(); - expect(wrapper.find('[data-test-subj="bccEmailAddressInput"]').length > 0).toBeTruthy(); expect(wrapper.find('[data-test-subj="emailSubjectInput"]').length > 0).toBeTruthy(); expect(wrapper.find('[data-test-subj="emailMessageInput"]').length > 0).toBeTruthy(); }); diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/email.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/email.tsx index a6750ccf96debc..f82b2c8c88adaf 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/email.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/email.tsx @@ -3,7 +3,8 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import React, { Fragment } from 'react'; +import React, { Fragment, useState, useEffect } from 'react'; +import { FormattedMessage } from '@kbn/i18n/react'; import { EuiFieldText, EuiFlexItem, @@ -12,17 +13,22 @@ import { EuiFieldPassword, EuiComboBox, EuiTextArea, + EuiButtonEmpty, EuiSwitch, EuiFormRow, + EuiContextMenuItem, + EuiButtonIcon, + EuiContextMenuPanel, + EuiPopover, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { ActionTypeModel, ActionConnectorFieldsProps, - ActionConnector, ValidationResult, ActionParamsProps, } from '../../../types'; +import { EmailActionParams, EmailActionConnector } from './types'; export function getActionType(): ActionTypeModel { const mailformat = /^[^@\s]+@[^@\s]+$/; @@ -35,11 +41,16 @@ export function getActionType(): ActionTypeModel { defaultMessage: 'Send email from your server.', } ), - validateConnector: (action: ActionConnector): ValidationResult => { + actionTypeTitle: i18n.translate( + 'xpack.triggersActionsUI.components.builtinActionTypes.emailAction.actionTypeTitle', + { + defaultMessage: 'Send to email', + } + ), + validateConnector: (action: EmailActionConnector): ValidationResult => { const validationResult = { errors: {} }; const errors = { from: new Array(), - service: new Array(), port: new Array(), host: new Array(), user: new Array(), @@ -66,7 +77,7 @@ export function getActionType(): ActionTypeModel { ) ); } - if (!action.config.port && !action.config.service) { + if (!action.config.port) { errors.port.push( i18n.translate( 'xpack.triggersActionsUI.components.builtinActionTypes.error.requiredPortText', @@ -76,17 +87,7 @@ export function getActionType(): ActionTypeModel { ) ); } - if (!action.config.service && (!action.config.port || !action.config.host)) { - errors.service.push( - i18n.translate( - 'xpack.triggersActionsUI.components.builtinActionTypes.error.requiredServiceText', - { - defaultMessage: 'Service is required.', - } - ) - ); - } - if (!action.config.host && !action.config.service) { + if (!action.config.host) { errors.host.push( i18n.translate( 'xpack.triggersActionsUI.components.builtinActionTypes.error.requiredHostText', @@ -118,7 +119,7 @@ export function getActionType(): ActionTypeModel { } return validationResult; }, - validateParams: (actionParams: any): ValidationResult => { + validateParams: (actionParams: EmailActionParams): ValidationResult => { const validationResult = { errors: {} }; const errors = { to: new Array(), @@ -143,7 +144,7 @@ export function getActionType(): ActionTypeModel { errors.cc.push(errorText); errors.bcc.push(errorText); } - if (!actionParams.message) { + if (!actionParams.message?.length) { errors.message.push( i18n.translate( 'xpack.triggersActionsUI.components.builtinActionTypes.error.requiredMessageText', @@ -153,7 +154,7 @@ export function getActionType(): ActionTypeModel { ) ); } - if (!actionParams.subject) { + if (!actionParams.subject?.length) { errors.subject.push( i18n.translate( 'xpack.triggersActionsUI.components.builtinActionTypes.error.requiredSubjectText', @@ -170,12 +171,9 @@ export function getActionType(): ActionTypeModel { }; } -const EmailActionConnectorFields: React.FunctionComponent = ({ - action, - editActionConfig, - editActionSecrets, - errors, -}) => { +const EmailActionConnectorFields: React.FunctionComponent> = ({ action, editActionConfig, editActionSecrets, errors }) => { const { from, host, port, secure } = action.config; const { user, password } = action.secrets; @@ -265,7 +263,7 @@ const EmailActionConnectorFields: React.FunctionComponent 0 && port !== undefined} fullWidth name="port" - value={port || ''} + value={port} data-test-subj="emailPortInput" onChange={e => { editActionConfig('port', parseInt(e.target.value, 10)); @@ -365,34 +363,79 @@ const EmailActionConnectorFields: React.FunctionComponent = ({ - action, +const EmailParamsFields: React.FunctionComponent> = ({ + actionParams, editAction, index, errors, - hasErrors, + messageVariables, + defaultMessage, }) => { - const { to, cc, bcc, subject, message } = action; + const { to, cc, bcc, subject, message } = actionParams; const toOptions = to ? to.map((label: string) => ({ label })) : []; const ccOptions = cc ? cc.map((label: string) => ({ label })) : []; const bccOptions = bcc ? bcc.map((label: string) => ({ label })) : []; + const [addCC, setAddCC] = useState(false); + const [addBCC, setAddBCC] = useState(false); + const [isVariablesPopoverOpen, setIsVariablesPopoverOpen] = useState(false); + useEffect(() => { + if (defaultMessage && defaultMessage.length > 0) { + editAction('message', defaultMessage, index); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + const messageVariablesItems = messageVariables?.map((variable: string) => ( + { + editAction('message', (message ?? '').concat(` {{${variable}}}`), index); + setIsVariablesPopoverOpen(false); + }} + > + {`{{${variable}}}`} + + )); return ( 0 && to !== undefined} label={i18n.translate( 'xpack.triggersActionsUI.sections.builtinActionTypes.emailAction.recipientTextFieldLabel', { - defaultMessage: 'To', + defaultMessage: 'To:', } )} + labelAppend={ + + + {!addCC ? ( + setAddCC(true)}> + + + ) : null} + {!addBCC ? ( + setAddBCC(true)}> + + + ) : null} + + + } > 0 && to !== undefined} fullWidth data-test-subj="toEmailAddressInput" selectedOptions={toOptions} @@ -418,126 +461,164 @@ const EmailParamsFields: React.FunctionComponent = ({ }} /> - - { - const newOptions = [...ccOptions, { label: searchValue }]; - editAction( - 'cc', - newOptions.map(newOption => newOption.label), - index - ); - }} - onChange={(selectedOptions: Array<{ label: string }>) => { - editAction( - 'cc', - selectedOptions.map(selectedOption => selectedOption.label), - index - ); - }} - onBlur={() => { - if (!cc) { - editAction('cc', [], index); + error={errors.cc} + isInvalid={errors.cc.length > 0 && cc !== undefined} + label={i18n.translate( + 'xpack.triggersActionsUI.sections.builtinActionTypes.emailAction.recipientCopyTextFieldLabel', + { + defaultMessage: 'Cc:', } - }} - /> - - - + 0 && cc !== undefined} + fullWidth + data-test-subj="ccEmailAddressInput" + selectedOptions={ccOptions} + onCreateOption={(searchValue: string) => { + const newOptions = [...ccOptions, { label: searchValue }]; + editAction( + 'cc', + newOptions.map(newOption => newOption.label), + index + ); + }} + onChange={(selectedOptions: Array<{ label: string }>) => { + editAction( + 'cc', + selectedOptions.map(selectedOption => selectedOption.label), + index + ); + }} + onBlur={() => { + if (!cc) { + editAction('cc', [], index); + } + }} + /> + + ) : null} + {addBCC ? ( + { - const newOptions = [...bccOptions, { label: searchValue }]; - editAction( - 'bcc', - newOptions.map(newOption => newOption.label), - index - ); - }} - onChange={(selectedOptions: Array<{ label: string }>) => { - editAction( - 'bcc', - selectedOptions.map(selectedOption => selectedOption.label), - index - ); - }} - onBlur={() => { - if (!bcc) { - editAction('bcc', [], index); + error={errors.bcc} + isInvalid={errors.bcc.length > 0 && bcc !== undefined} + label={i18n.translate( + 'xpack.triggersActionsUI.sections.builtinActionTypes.emailAction.recipientBccTextFieldLabel', + { + defaultMessage: 'Bcc:', } - }} - /> - + )} + > + 0 && bcc !== undefined} + fullWidth + data-test-subj="bccEmailAddressInput" + selectedOptions={bccOptions} + onCreateOption={(searchValue: string) => { + const newOptions = [...bccOptions, { label: searchValue }]; + editAction( + 'bcc', + newOptions.map(newOption => newOption.label), + index + ); + }} + onChange={(selectedOptions: Array<{ label: string }>) => { + editAction( + 'bcc', + selectedOptions.map(selectedOption => selectedOption.label), + index + ); + }} + onBlur={() => { + if (!bcc) { + editAction('bcc', [], index); + } + }} + /> + + ) : null} 0 && subject !== undefined} label={i18n.translate( 'xpack.triggersActionsUI.sections.builtinActionTypes.emailAction.subjectTextFieldLabel', { - defaultMessage: 'Subject', + defaultMessage: 'Subject:', } )} > 0 && subject !== undefined} name="subject" data-test-subj="emailSubjectInput" value={subject || ''} + placeholder="Text field (placeholder)" onChange={e => { editAction('subject', e.target.value, index); }} + onBlur={() => { + if (!subject) { + editAction('subject', '', index); + } + }} /> 0 && message !== undefined} label={i18n.translate( 'xpack.triggersActionsUI.sections.builtinActionTypes.emailAction.messageTextAreaFieldLabel', { - defaultMessage: 'Message', + defaultMessage: 'Message:', } )} + labelAppend={ + setIsVariablesPopoverOpen(true)} + iconType="indexOpen" + aria-label={i18n.translate( + 'xpack.triggersActionsUI.components.builtinActionTypes.emailAction.addVariablePopoverButton', + { + defaultMessage: 'Add variable', + } + )} + /> + } + isOpen={isVariablesPopoverOpen} + closePopover={() => setIsVariablesPopoverOpen(false)} + panelPaddingSize="none" + anchorPosition="downLeft" + > + + + } > 0 && message !== undefined} value={message || ''} name="message" data-test-subj="emailMessageInput" onChange={e => { editAction('message', e.target.value, index); }} + onBlur={() => { + if (!message) { + editAction('message', '', index); + } + }} /> diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/es_index.test.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/es_index.test.tsx index b6a7c4d82aca44..d44787f0c4ed68 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/es_index.test.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/es_index.test.tsx @@ -3,11 +3,12 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import React from 'react'; +import React, { FunctionComponent } from 'react'; import { mountWithIntl } from 'test_utils/enzyme_helpers'; import { TypeRegistry } from '../../type_registry'; import { registerBuiltInActionTypes } from './index'; -import { ActionTypeModel, ActionConnector } from '../../../types'; +import { ActionTypeModel, ActionParamsProps } from '../../../types'; +import { IndexActionParams, EsIndexActionConnector } from './types'; const ACTION_TYPE_ID = '.index'; let actionTypeModel: ActionTypeModel; @@ -38,7 +39,7 @@ describe('index connector validation', () => { config: { index: 'test_es_index', }, - } as ActionConnector; + } as EsIndexActionConnector; expect(actionTypeModel.validateConnector(actionConnector)).toEqual({ errors: {}, @@ -87,14 +88,13 @@ describe('IndexActionConnectorFields renders', () => { config: { index: 'test', }, - } as ActionConnector; + } as EsIndexActionConnector; const wrapper = mountWithIntl( {}} editActionSecrets={() => {}} - hasErrors={false} /> ); expect(wrapper.find('[data-test-subj="indexInput"]').length > 0).toBeTruthy(); @@ -113,7 +113,9 @@ describe('IndexParamsFields renders', () => { if (!actionTypeModel.actionParamsFields) { return; } - const ParamsFields = actionTypeModel.actionParamsFields; + const ParamsFields = actionTypeModel.actionParamsFields as FunctionComponent< + ActionParamsProps + >; const actionParams = { index: 'test_index', refresh: false, @@ -121,11 +123,10 @@ describe('IndexParamsFields renders', () => { }; const wrapper = mountWithIntl( {}} index={0} - hasErrors={false} /> ); expect(wrapper.find('[data-test-subj="indexInput"]').length > 0).toBeTruthy(); diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/es_index.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/es_index.tsx index aa15195cdc2867..6af54d2bf15b46 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/es_index.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/es_index.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import React, { Fragment } from 'react'; -import { EuiFieldText, EuiFormRow, EuiSwitch } from '@elastic/eui'; +import { EuiFieldText, EuiFormRow, EuiSwitch, EuiSpacer } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; import { @@ -13,6 +13,7 @@ import { ValidationResult, ActionParamsProps, } from '../../../types'; +import { IndexActionParams, EsIndexActionConnector } from './types'; export function getActionType(): ActionTypeModel { return { @@ -29,17 +30,15 @@ export function getActionType(): ActionTypeModel { }, actionConnectorFields: IndexActionConnectorFields, actionParamsFields: IndexParamsFields, - validateParams: (actionParams: any): ValidationResult => { - const validationResult = { errors: {} }; - return validationResult; + validateParams: (): ValidationResult => { + return { errors: {} }; }, }; } -const IndexActionConnectorFields: React.FunctionComponent = ({ - action, - editActionConfig, -}) => { +const IndexActionConnectorFields: React.FunctionComponent> = ({ action, editActionConfig }) => { const { index } = action.config; return ( = ({ - action, +const IndexParamsFields: React.FunctionComponent> = ({ + actionParams, index, editAction, - errors, - hasErrors, }) => { - const { refresh } = action; + const { refresh } = actionParams; return ( = ({ > ) => { editAction('index', e.target.value, index); }} onBlur={() => { - if (!action.index) { + if (!actionParams.index) { editAction('index', '', index); } }} /> + { + checked={refresh || false} + onChange={e => { editAction('refresh', e.target.checked, index); }} label={ diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/pagerduty.test.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/pagerduty.test.tsx index 582315c95812a4..31a69f9fd94acd 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/pagerduty.test.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/pagerduty.test.tsx @@ -3,11 +3,17 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import React from 'react'; +import React, { FunctionComponent } from 'react'; import { mountWithIntl } from 'test_utils/enzyme_helpers'; import { TypeRegistry } from '../../type_registry'; import { registerBuiltInActionTypes } from './index'; -import { ActionTypeModel, ActionConnector } from '../../../types'; +import { ActionTypeModel, ActionParamsProps } from '../../../types'; +import { + PagerDutyActionParams, + EventActionOptions, + SeverityActionOptions, + PagerDutyActionConnector, +} from './types'; const ACTION_TYPE_ID = '.pagerduty'; let actionTypeModel: ActionTypeModel; @@ -40,7 +46,7 @@ describe('pagerduty connector validation', () => { config: { apiUrl: 'http:\\test', }, - } as ActionConnector; + } as PagerDutyActionConnector; expect(actionTypeModel.validateConnector(actionConnector)).toEqual({ errors: { @@ -66,7 +72,7 @@ describe('pagerduty connector validation', () => { config: { apiUrl: 'http:\\test', }, - } as ActionConnector; + } as PagerDutyActionConnector; expect(actionTypeModel.validateConnector(actionConnector)).toEqual({ errors: { @@ -91,7 +97,9 @@ describe('pagerduty action params validation', () => { }; expect(actionTypeModel.validateParams(actionParams)).toEqual({ - errors: {}, + errors: { + summary: [], + }, }); }); }); @@ -113,14 +121,13 @@ describe('PagerDutyActionConnectorFields renders', () => { config: { apiUrl: 'http:\\test', }, - } as ActionConnector; + } as PagerDutyActionConnector; const wrapper = mountWithIntl( {}} editActionSecrets={() => {}} - hasErrors={false} /> ); expect(wrapper.find('[data-test-subj="pagerdutyApiUrlInput"]').length > 0).toBeTruthy(); @@ -140,13 +147,15 @@ describe('PagerDutyParamsFields renders', () => { if (!actionTypeModel.actionParamsFields) { return; } - const ParamsFields = actionTypeModel.actionParamsFields; + const ParamsFields = actionTypeModel.actionParamsFields as FunctionComponent< + ActionParamsProps + >; const actionParams = { - eventAction: 'trigger', + eventAction: EventActionOptions.TRIGGER, dedupKey: 'test', summary: '2323', source: 'source', - severity: 'critical', + severity: SeverityActionOptions.CRITICAL, timestamp: '234654564654', component: 'test', group: 'group', @@ -154,11 +163,10 @@ describe('PagerDutyParamsFields renders', () => { }; const wrapper = mountWithIntl( {}} index={0} - hasErrors={false} /> ); expect(wrapper.find('[data-test-subj="severitySelect"]').length > 0).toBeTruthy(); @@ -174,6 +182,6 @@ describe('PagerDutyParamsFields renders', () => { expect(wrapper.find('[data-test-subj="componentInput"]').length > 0).toBeTruthy(); expect(wrapper.find('[data-test-subj="groupInput"]').length > 0).toBeTruthy(); expect(wrapper.find('[data-test-subj="sourceInput"]').length > 0).toBeTruthy(); - expect(wrapper.find('[data-test-subj="pagerdutyDescriptionInput"]').length > 0).toBeTruthy(); + expect(wrapper.find('[data-test-subj="pagerdutySummaryInput"]').length > 0).toBeTruthy(); }); }); diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/pagerduty.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/pagerduty.tsx index 69c7ec166df60e..3c1b1d258cfe22 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/pagerduty.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/pagerduty.tsx @@ -17,10 +17,10 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { ActionTypeModel, ActionConnectorFieldsProps, - ActionConnector, ValidationResult, ActionParamsProps, } from '../../../types'; +import { PagerDutyActionParams, PagerDutyActionConnector } from './types'; export function getActionType(): ActionTypeModel { return { @@ -32,7 +32,13 @@ export function getActionType(): ActionTypeModel { defaultMessage: 'Send an event in PagerDuty.', } ), - validateConnector: (action: ActionConnector): ValidationResult => { + actionTypeTitle: i18n.translate( + 'xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.actionTypeTitle', + { + defaultMessage: 'Send to PagerDuty', + } + ), + validateConnector: (action: PagerDutyActionConnector): ValidationResult => { const validationResult = { errors: {} }; const errors = { routingKey: new Array(), @@ -50,8 +56,22 @@ export function getActionType(): ActionTypeModel { } return validationResult; }, - validateParams: (actionParams: any): ValidationResult => { + validateParams: (actionParams: PagerDutyActionParams): ValidationResult => { const validationResult = { errors: {} }; + const errors = { + summary: new Array(), + }; + validationResult.errors = errors; + if (!actionParams.summary?.length) { + errors.summary.push( + i18n.translate( + 'xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.error.requiredSummaryText', + { + defaultMessage: 'Summary is required.', + } + ) + ); + } return validationResult; }, actionConnectorFields: PagerDutyActionConnectorFields, @@ -59,12 +79,9 @@ export function getActionType(): ActionTypeModel { }; } -const PagerDutyActionConnectorFields: React.FunctionComponent = ({ - errors, - action, - editActionConfig, - editActionSecrets, -}) => { +const PagerDutyActionConnectorFields: React.FunctionComponent> = ({ errors, action, editActionConfig, editActionSecrets }) => { const { apiUrl } = action.config; const { routingKey } = action.secrets; return ( @@ -137,14 +154,22 @@ const PagerDutyActionConnectorFields: React.FunctionComponent = ({ - action, +const PagerDutyParamsFields: React.FunctionComponent> = ({ + actionParams, editAction, index, errors, - hasErrors, }) => { - const { eventAction, dedupKey, summary, source, severity, timestamp, component, group } = action; + const { + eventAction, + dedupKey, + summary, + source, + severity, + timestamp, + component, + group, + } = actionParams; const severityOptions = [ { value: 'critical', text: 'Critical' }, { value: 'info', text: 'Info' }, @@ -332,7 +357,7 @@ const PagerDutyParamsFields: React.FunctionComponent = ({ id="pagerDutySummary" fullWidth error={errors.summary} - isInvalid={hasErrors === true && summary !== undefined} + isInvalid={errors.summary.length > 0 && summary !== undefined} label={i18n.translate( 'xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.summaryFieldLabel', { @@ -342,10 +367,10 @@ const PagerDutyParamsFields: React.FunctionComponent = ({ > 0 && summary !== undefined} name="summary" value={summary || ''} - data-test-subj="pagerdutyDescriptionInput" + data-test-subj="pagerdutySummaryInput" onChange={(e: React.ChangeEvent) => { editAction('summary', e.target.value, index); }} @@ -356,6 +381,31 @@ const PagerDutyParamsFields: React.FunctionComponent = ({ }} /> + + ) => { + editAction('class', e.target.value, index); + }} + onBlur={() => { + if (!actionParams.class) { + editAction('class', '', index); + } + }} + /> + ); }; diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/server_log.test.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/server_log.test.tsx index b79be4eef523bc..fce8f25e511314 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/server_log.test.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/server_log.test.tsx @@ -3,11 +3,12 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import React from 'react'; +import React, { FunctionComponent } from 'react'; import { mountWithIntl } from 'test_utils/enzyme_helpers'; import { TypeRegistry } from '../../type_registry'; import { registerBuiltInActionTypes } from './index'; -import { ActionTypeModel, ActionConnector } from '../../../types'; +import { ActionTypeModel, ActionConnector, ActionParamsProps } from '../../../types'; +import { ServerLogActionParams, ServerLogLevelOptions } from './types'; const ACTION_TYPE_ID = '.server-log'; let actionTypeModel: ActionTypeModel; @@ -63,18 +64,20 @@ describe('ServerLogParamsFields renders', () => { if (!actionTypeModel.actionParamsFields) { return; } - const ParamsFields = actionTypeModel.actionParamsFields; + const ParamsFields = actionTypeModel.actionParamsFields as FunctionComponent< + ActionParamsProps + >; const actionParams = { - message: 'test message', - level: 'trace', + level: ServerLogLevelOptions.TRACE, + message: 'test', }; const wrapper = mountWithIntl( {}} index={0} - hasErrors={false} + defaultMessage={'test default message'} /> ); expect(wrapper.find('[data-test-subj="loggingLevelSelect"]').length > 0).toBeTruthy(); @@ -92,18 +95,19 @@ describe('ServerLogParamsFields renders', () => { if (!actionTypeModel.actionParamsFields) { return; } - const ParamsFields = actionTypeModel.actionParamsFields; + const ParamsFields = actionTypeModel.actionParamsFields as FunctionComponent< + ActionParamsProps + >; const actionParams = { message: 'test message', - level: 'info', + level: ServerLogLevelOptions.INFO, }; const wrapper = mountWithIntl( {}} index={0} - hasErrors={false} /> ); expect(wrapper.find('[data-test-subj="loggingLevelSelect"]').length > 0).toBeTruthy(); diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/server_log.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/server_log.tsx index 885061aa819243..8d8045042cfc31 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/server_log.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/server_log.tsx @@ -3,10 +3,19 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import React, { Fragment } from 'react'; +import React, { Fragment, useEffect, useState } from 'react'; import { i18n } from '@kbn/i18n'; -import { EuiSelect, EuiTextArea, EuiFormRow } from '@elastic/eui'; +import { + EuiSelect, + EuiTextArea, + EuiFormRow, + EuiContextMenuItem, + EuiPopover, + EuiButtonIcon, + EuiContextMenuPanel, +} from '@elastic/eui'; import { ActionTypeModel, ValidationResult, ActionParamsProps } from '../../../types'; +import { ServerLogActionParams } from './types'; export function getActionType(): ActionTypeModel { return { @@ -18,16 +27,22 @@ export function getActionType(): ActionTypeModel { defaultMessage: 'Add a message to a Kibana log.', } ), + actionTypeTitle: i18n.translate( + 'xpack.triggersActionsUI.components.builtinActionTypes.serverLogAction.actionTypeTitle', + { + defaultMessage: 'Send to Server log', + } + ), validateConnector: (): ValidationResult => { return { errors: {} }; }, - validateParams: (actionParams: any): ValidationResult => { + validateParams: (actionParams: ServerLogActionParams): ValidationResult => { const validationResult = { errors: {} }; const errors = { message: new Array(), }; validationResult.errors = errors; - if (!actionParams.message || actionParams.message.length === 0) { + if (!actionParams.message?.length) { errors.message.push( i18n.translate( 'xpack.triggersActionsUI.components.builtinActionTypes.error.requiredServerLogMessageText', @@ -44,14 +59,10 @@ export function getActionType(): ActionTypeModel { }; } -export const ServerLogParamsFields: React.FunctionComponent = ({ - action, - editAction, - index, - errors, - hasErrors, -}) => { - const { message, level } = action; +export const ServerLogParamsFields: React.FunctionComponent> = ({ actionParams, editAction, index, errors, messageVariables, defaultMessage }) => { + const { message, level } = actionParams; const levelOptions = [ { value: 'trace', text: 'Trace' }, { value: 'debug', text: 'Debug' }, @@ -60,10 +71,27 @@ export const ServerLogParamsFields: React.FunctionComponent = { value: 'error', text: 'Error' }, { value: 'fatal', text: 'Fatal' }, ]; + const [isVariablesPopoverOpen, setIsVariablesPopoverOpen] = useState(false); - // Set default value 'info' for level param - editAction('level', 'info', index); - + useEffect(() => { + editAction('level', 'info', index); + if (defaultMessage && defaultMessage.length > 0) { + editAction('message', defaultMessage, index); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + const messageVariablesItems = messageVariables?.map((variable: string) => ( + { + editAction('message', (message ?? '').concat(` {{${variable}}}`), index); + setIsVariablesPopoverOpen(false); + }} + > + {`{{${variable}}}`} + + )); return ( = id="loggingMessage" fullWidth error={errors.message} - isInvalid={hasErrors && message !== undefined} + isInvalid={errors.message.length > 0 && message !== undefined} label={i18n.translate( 'xpack.triggersActionsUI.components.builtinActionTypes.serverLogAction.logMessageFieldLabel', { defaultMessage: 'Message', } )} + labelAppend={ + setIsVariablesPopoverOpen(true)} + iconType="indexOpen" + aria-label={i18n.translate( + 'xpack.triggersActionsUI.components.builtinActionTypes.serverLogAction.addVariablePopoverButton', + { + defaultMessage: 'Add variable', + } + )} + /> + } + isOpen={isVariablesPopoverOpen} + closePopover={() => setIsVariablesPopoverOpen(false)} + panelPaddingSize="none" + anchorPosition="downLeft" + > + + + } > 0 && message !== undefined} value={message || ''} name="message" data-test-subj="loggingMessageInput" onChange={e => { editAction('message', e.target.value, index); }} + onBlur={() => { + if (!message) { + editAction('message', '', index); + } + }} /> diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/slack.test.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/slack.test.tsx index 36beea4d2f2be2..e4f8599d2e46e6 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/slack.test.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/slack.test.tsx @@ -3,11 +3,12 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import React from 'react'; +import React, { FunctionComponent } from 'react'; import { mountWithIntl } from 'test_utils/enzyme_helpers'; import { TypeRegistry } from '../../type_registry'; import { registerBuiltInActionTypes } from './index'; -import { ActionTypeModel, ActionConnector } from '../../../types'; +import { ActionTypeModel, ActionParamsProps } from '../../../types'; +import { SlackActionParams, SlackActionConnector } from './types'; const ACTION_TYPE_ID = '.slack'; let actionTypeModel: ActionTypeModel; @@ -38,7 +39,7 @@ describe('slack connector validation', () => { actionTypeId: '.email', name: 'email', config: {}, - } as ActionConnector; + } as SlackActionConnector; expect(actionTypeModel.validateConnector(actionConnector)).toEqual({ errors: { @@ -54,7 +55,7 @@ describe('slack connector validation', () => { actionTypeId: '.email', name: 'email', config: {}, - } as ActionConnector; + } as SlackActionConnector; expect(actionTypeModel.validateConnector(actionConnector)).toEqual({ errors: { @@ -91,7 +92,7 @@ describe('SlackActionFields renders', () => { actionTypeId: '.email', name: 'email', config: {}, - } as ActionConnector; + } as SlackActionConnector; const wrapper = mountWithIntl( { if (!actionTypeModel.actionParamsFields) { return; } - const ParamsFields = actionTypeModel.actionParamsFields; + const ParamsFields = actionTypeModel.actionParamsFields as FunctionComponent< + ActionParamsProps + >; const actionParams = { message: 'test message', }; const wrapper = mountWithIntl( {}} index={0} - hasErrors={false} /> ); - expect(wrapper.find('[data-test-subj="slackMessageTextarea"]').length > 0).toBeTruthy(); + expect(wrapper.find('[data-test-subj="slackMessageTextArea"]').length > 0).toBeTruthy(); expect( wrapper - .find('[data-test-subj="slackMessageTextarea"]') + .find('[data-test-subj="slackMessageTextArea"]') .first() .prop('value') ).toStrictEqual('test message'); diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/slack.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/slack.tsx index 0ae51725169bf1..916715de7ae185 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/slack.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/slack.tsx @@ -3,25 +3,26 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import React, { Fragment } from 'react'; +import React, { Fragment, useState, useEffect } from 'react'; import { EuiFieldText, EuiTextArea, - EuiFlexGroup, - EuiFlexItem, EuiButtonIcon, EuiFormRow, EuiLink, + EuiPopover, + EuiContextMenuPanel, + EuiContextMenuItem, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { ActionTypeModel, ActionConnectorFieldsProps, - ActionConnector, ValidationResult, ActionParamsProps, } from '../../../types'; +import { SlackActionParams, SlackActionConnector } from './types'; export function getActionType(): ActionTypeModel { return { @@ -33,7 +34,13 @@ export function getActionType(): ActionTypeModel { defaultMessage: 'Send a message to a Slack channel or user.', } ), - validateConnector: (action: ActionConnector): ValidationResult => { + actionTypeTitle: i18n.translate( + 'xpack.triggersActionsUI.components.builtinActionTypes.slackAction.actionTypeTitle', + { + defaultMessage: 'Send to Slack', + } + ), + validateConnector: (action: SlackActionConnector): ValidationResult => { const validationResult = { errors: {} }; const errors = { webhookUrl: new Array(), @@ -51,13 +58,13 @@ export function getActionType(): ActionTypeModel { } return validationResult; }, - validateParams: (actionParams: any): ValidationResult => { + validateParams: (actionParams: SlackActionParams): ValidationResult => { const validationResult = { errors: {} }; const errors = { message: new Array(), }; validationResult.errors = errors; - if (!actionParams.message || actionParams.message.length === 0) { + if (!actionParams.message?.length) { errors.message.push( i18n.translate( 'xpack.triggersActionsUI.components.builtinActionTypes.error.requiredSlackMessageText', @@ -74,11 +81,9 @@ export function getActionType(): ActionTypeModel { }; } -const SlackActionFields: React.FunctionComponent = ({ - action, - editActionSecrets, - errors, -}) => { +const SlackActionFields: React.FunctionComponent> = ({ action, editActionSecrets, errors }) => { const { webhookUrl } = action.secrets; return ( @@ -127,47 +132,87 @@ const SlackActionFields: React.FunctionComponent = ( ); }; -const SlackParamsFields: React.FunctionComponent = ({ - action, +const SlackParamsFields: React.FunctionComponent> = ({ + actionParams, editAction, index, errors, - hasErrors, + messageVariables, + defaultMessage, }) => { - const { message } = action; - + const { message } = actionParams; + const [isVariablesPopoverOpen, setIsVariablesPopoverOpen] = useState(false); + useEffect(() => { + if (defaultMessage && defaultMessage.length > 0) { + editAction('message', defaultMessage, index); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + const messageVariablesItems = messageVariables?.map((variable: string, i: number) => ( + { + editAction('message', (message ?? '').concat(` {{${variable}}}`), index); + setIsVariablesPopoverOpen(false); + }} + > + {`{{${variable}}}`} + + )); return ( - - - window.alert('Button clicked')} - iconType="indexOpen" - aria-label="Add variable" - /> - - 0 && message !== undefined} label={i18n.translate( 'xpack.triggersActionsUI.components.builtinActionTypes.slackAction.messageTextAreaFieldLabel', { defaultMessage: 'Message', } )} + labelAppend={ + setIsVariablesPopoverOpen(true)} + iconType="indexOpen" + aria-label={i18n.translate( + 'xpack.triggersActionsUI.components.builtinActionTypes.slackAction.addVariablePopoverButton', + { + defaultMessage: 'Add variable', + } + )} + /> + } + isOpen={isVariablesPopoverOpen} + closePopover={() => setIsVariablesPopoverOpen(false)} + panelPaddingSize="none" + anchorPosition="downLeft" + > + + + } > 0 && message !== undefined} name="message" - value={message} - data-test-subj="slackMessageTextarea" + value={message || ''} + data-test-subj="slackMessageTextArea" onChange={e => { editAction('message', e.target.value, index); }} + onBlur={() => { + if (!message) { + editAction('message', '', index); + } + }} /> diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/types.ts b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/types.ts new file mode 100644 index 00000000000000..45a08b2d5263af --- /dev/null +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/types.ts @@ -0,0 +1,130 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { ActionConnector } from '../../../types'; + +export interface EmailActionParams { + to: string[]; + cc: string[]; + bcc: string[]; + subject: string; + message: string; +} + +export enum EventActionOptions { + TRIGGER = 'trigger', + RESOLVE = 'resolve', + ACKNOWLEDGE = 'acknowledge', +} + +export enum SeverityActionOptions { + CRITICAL = 'critical', + ERROR = 'error', + WARNING = 'warning', + INFO = 'info', +} + +export interface PagerDutyActionParams { + eventAction?: EventActionOptions; + dedupKey?: string; + summary?: string; + source?: string; + severity?: SeverityActionOptions; + timestamp?: string; + component?: string; + group?: string; + class?: string; +} + +export interface IndexActionParams { + index?: string; + refresh?: boolean; + executionTimeField?: string; + documents: string[]; +} + +export enum ServerLogLevelOptions { + TRACE = 'trace', + DEBUG = 'debug', + INFO = 'info', + WARN = 'warn', + ERROR = 'error', + FATAL = 'fatal', +} + +export interface ServerLogActionParams { + level?: ServerLogLevelOptions; + message: string; +} + +export interface SlackActionParams { + message: string; +} + +export interface WebhookActionParams { + body?: string; +} + +interface EmailConfig { + from: string; + host: string; + port: number; + secure?: boolean; +} + +interface EmailSecrets { + user: string; + password: string; +} + +export interface EmailActionConnector extends ActionConnector { + config: EmailConfig; + secrets: EmailSecrets; +} + +interface EsIndexConfig { + index?: string; +} + +export interface EsIndexActionConnector extends ActionConnector { + config: EsIndexConfig; +} + +interface PagerDutyConfig { + apiUrl?: string; +} + +interface PagerDutySecrets { + routingKey: string; +} + +export interface PagerDutyActionConnector extends ActionConnector { + config: PagerDutyConfig; + secrets: PagerDutySecrets; +} + +interface SlackSecrets { + webhookUrl: string; +} + +export interface SlackActionConnector extends ActionConnector { + secrets: SlackSecrets; +} + +interface WebhookConfig { + method: string; + url: string; + headers: Record; +} + +interface WebhookSecrets { + user: string; + password: string; +} + +export interface WebhookActionConnector extends ActionConnector { + config: WebhookConfig; + secrets: WebhookSecrets; +} diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/webhook.test.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/webhook.test.tsx index cd342f2e199693..5e6c0404db5324 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/webhook.test.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/webhook.test.tsx @@ -3,11 +3,12 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import React from 'react'; +import React, { FunctionComponent } from 'react'; import { mountWithIntl } from 'test_utils/enzyme_helpers'; import { TypeRegistry } from '../../type_registry'; import { registerBuiltInActionTypes } from './index'; -import { ActionTypeModel, ActionConnector } from '../../../types'; +import { ActionTypeModel, ActionParamsProps } from '../../../types'; +import { WebhookActionParams, WebhookActionConnector } from './types'; const ACTION_TYPE_ID = '.webhook'; let actionTypeModel: ActionTypeModel; @@ -41,9 +42,9 @@ describe('webhook connector validation', () => { config: { method: 'PUT', url: 'http:\\test', - headers: ['content-type: text'], + headers: { 'content-type': 'text' }, }, - } as ActionConnector; + } as WebhookActionConnector; expect(actionTypeModel.validateConnector(actionConnector)).toEqual({ errors: { @@ -66,7 +67,7 @@ describe('webhook connector validation', () => { config: { method: 'PUT', }, - } as ActionConnector; + } as WebhookActionConnector; expect(actionTypeModel.validateConnector(actionConnector)).toEqual({ errors: { @@ -109,9 +110,9 @@ describe('WebhookActionConnectorFields renders', () => { config: { method: 'PUT', url: 'http:\\test', - headers: ['content-type: text'], + headers: { 'content-type': 'text' }, }, - } as ActionConnector; + } as WebhookActionConnector; const wrapper = mountWithIntl( { if (!actionTypeModel.actionParamsFields) { return; } - const ParamsFields = actionTypeModel.actionParamsFields; + const ParamsFields = actionTypeModel.actionParamsFields as FunctionComponent< + ActionParamsProps + >; const actionParams = { body: 'test message', }; const wrapper = mountWithIntl( {}} index={0} - hasErrors={false} /> ); expect(wrapper.find('[data-test-subj="webhookBodyEditor"]').length > 0).toBeTruthy(); diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/webhook.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/webhook.tsx index 70a9a6f3d75b3a..3000191218932a 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/webhook.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/webhook.tsx @@ -27,10 +27,10 @@ import { i18n } from '@kbn/i18n'; import { ActionTypeModel, ActionConnectorFieldsProps, - ActionConnector, ValidationResult, ActionParamsProps, } from '../../../types'; +import { WebhookActionParams, WebhookActionConnector } from './types'; const HTTP_VERBS = ['post', 'put']; @@ -44,7 +44,7 @@ export function getActionType(): ActionTypeModel { defaultMessage: 'Send a request to a web service.', } ), - validateConnector: (action: ActionConnector): ValidationResult => { + validateConnector: (action: WebhookActionConnector): ValidationResult => { const validationResult = { errors: {} }; const errors = { url: new Array(), @@ -95,13 +95,13 @@ export function getActionType(): ActionTypeModel { } return validationResult; }, - validateParams: (actionParams: any): ValidationResult => { + validateParams: (actionParams: WebhookActionParams): ValidationResult => { const validationResult = { errors: {} }; const errors = { body: new Array(), }; validationResult.errors = errors; - if (!actionParams.body || actionParams.body.length === 0) { + if (!actionParams.body?.length) { errors.body.push( i18n.translate( 'xpack.triggersActionsUI.components.builtinActionTypes.error.requiredWebhookBodyText', @@ -118,12 +118,9 @@ export function getActionType(): ActionTypeModel { }; } -const WebhookActionConnectorFields: React.FunctionComponent = ({ - action, - editActionConfig, - editActionSecrets, - errors, -}) => { +const WebhookActionConnectorFields: React.FunctionComponent> = ({ action, editActionConfig, editActionSecrets, errors }) => { const [httpHeaderKey, setHttpHeaderKey] = useState(''); const [httpHeaderValue, setHttpHeaderValue] = useState(''); const [hasHeaders, setHasHeaders] = useState(false); @@ -453,14 +450,13 @@ const WebhookActionConnectorFields: React.FunctionComponent = ({ - action, +const WebhookParamsFields: React.FunctionComponent> = ({ + actionParams, editAction, index, errors, - hasErrors, }) => { - const { body } = action; + const { body } = actionParams; return ( @@ -472,13 +468,13 @@ const WebhookParamsFields: React.FunctionComponent = ({ defaultMessage: 'Body', } )} - isInvalid={hasErrors === true} + isInvalid={errors.body.length > 0 && body !== undefined} fullWidth error={errors.body} > 0 && body !== undefined} mode="json" width="100%" height="200px" diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_alert_types/index.ts b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_alert_types/index.ts index 6c5d440e47888f..436a034e060511 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_alert_types/index.ts +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_alert_types/index.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getActionType as getThresholdAlertType } from './threshold/expression'; +import { getAlertType as getThresholdAlertType } from './threshold'; import { TypeRegistry } from '../../type_registry'; import { AlertTypeModel } from '../../../types'; diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_alert_types/threshold/expression.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_alert_types/threshold/expression.tsx index 907a61677b2631..73e2e9cbf9b76d 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_alert_types/threshold/expression.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_alert_types/threshold/expression.tsx @@ -22,7 +22,7 @@ import { EuiFormRow, EuiCallOut, } from '@elastic/eui'; -import { AlertTypeModel, Alert, ValidationResult } from '../../../../types'; +import { Alert } from '../../../../types'; import { Comparator, AggregationType, GroupByType } from './types'; import { AGGREGATION_TYPES, COMPARATORS } from './constants'; import { @@ -58,99 +58,6 @@ const expressionFieldsWithValidation = [ 'timeWindowSize', ]; -const validateAlertType = (alert: Alert): ValidationResult => { - const { - index, - timeField, - aggType, - aggField, - groupBy, - termSize, - termField, - threshold, - timeWindowSize, - } = alert.params; - const validationResult = { errors: {} }; - const errors = { - aggField: new Array(), - termSize: new Array(), - termField: new Array(), - timeWindowSize: new Array(), - threshold0: new Array(), - threshold1: new Array(), - index: new Array(), - timeField: new Array(), - }; - validationResult.errors = errors; - if (!index) { - errors.index.push( - i18n.translate('xpack.triggersActionsUI.sections.addAlert.error.requiredIndexText', { - defaultMessage: 'Index is required.', - }) - ); - } - if (!timeField) { - errors.timeField.push( - i18n.translate('xpack.triggersActionsUI.sections.addAlert.error.requiredTimeFieldText', { - defaultMessage: 'Time field is required.', - }) - ); - } - if (aggType && aggregationTypes[aggType].fieldRequired && !aggField) { - errors.aggField.push( - i18n.translate('xpack.triggersActionsUI.sections.addAlert.error.requiredAggFieldText', { - defaultMessage: 'Aggregation field is required.', - }) - ); - } - if (!termSize) { - errors.termSize.push( - i18n.translate('xpack.triggersActionsUI.sections.addAlert.error.requiredTermSizedText', { - defaultMessage: 'Term size is required.', - }) - ); - } - if (groupBy && groupByTypes[groupBy].sizeRequired && !termField) { - errors.termField.push( - i18n.translate('xpack.triggersActionsUI.sections.addAlert.error.requiredtTermFieldText', { - defaultMessage: 'Term field is required.', - }) - ); - } - if (!timeWindowSize) { - errors.timeWindowSize.push( - i18n.translate('xpack.triggersActionsUI.sections.addAlert.error.requiredTimeWindowSizeText', { - defaultMessage: 'Time window size is required.', - }) - ); - } - if (threshold && threshold.length > 0 && !threshold[0]) { - errors.threshold0.push( - i18n.translate('xpack.triggersActionsUI.sections.addAlert.error.requiredThreshold0Text', { - defaultMessage: 'Threshold0, is required.', - }) - ); - } - if (threshold && threshold.length > 1 && !threshold[1]) { - errors.threshold1.push( - i18n.translate('xpack.triggersActionsUI.sections.addAlert.error.requiredThreshold1Text', { - defaultMessage: 'Threshold1 is required.', - }) - ); - } - return validationResult; -}; - -export function getActionType(): AlertTypeModel { - return { - id: 'threshold', - name: 'Index Threshold', - iconClass: 'alert', - alertParamsExpression: IndexThresholdAlertTypeExpression, - validate: validateAlertType, - }; -} - export const aggregationTypes: { [key: string]: AggregationType } = { count: { text: 'count()', @@ -275,7 +182,6 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent = setAlertParams, setAlertProperty, errors, - hasErrors, }) => { const { http } = useAppDependencies(); @@ -307,7 +213,7 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent = const [indexPopoverOpen, setIndexPopoverOpen] = useState(false); const [indexPatterns, setIndexPatterns] = useState([]); const [esFields, setEsFields] = useState>([]); - const [indexOptions, setIndexOptions] = useState([]); + const [indexOptions, setIndexOptions] = useState([]); const [timeFieldOptions, setTimeFieldOptions] = useState([firstFieldOption]); const [isIndiciesLoading, setIsIndiciesLoading] = useState(false); const [alertThresholdPopoverOpen, setAlertThresholdPopoverOpen] = useState(false); @@ -323,6 +229,13 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent = ); const hasExpressionErrors = !!Object.keys(errors).find( + errorKey => + expressionFieldsWithValidation.includes(errorKey) && + errors[errorKey].length >= 1 && + alert.params[errorKey] !== undefined + ); + + const canShowVizualization = !!Object.keys(errors).find( errorKey => expressionFieldsWithValidation.includes(errorKey) && errors[errorKey].length >= 1 ); @@ -433,7 +346,7 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent = defaultMessage="Indices to query" /> } - isInvalid={hasErrors && index !== undefined} + isInvalid={errors.index.length > 0 && index !== undefined} error={errors.index} helpText={ = fullWidth async isLoading={isIndiciesLoading} - isInvalid={hasErrors && index !== undefined} + isInvalid={errors.index.length > 0 && index !== undefined} noSuggestions={!indexOptions.length} options={indexOptions} data-test-subj="thresholdIndexesComboBox" @@ -466,8 +379,6 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent = // reset time field and expression fields if indices are deleted if (indices.length === 0) { setTimeFieldOptions([firstFieldOption]); - setAlertParams('timeFields', []); - setDefaultExpressionValues(); return; } @@ -475,7 +386,6 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent = const timeFields = getTimeFieldOptions(currentEsFields as any); setEsFields(currentEsFields); - setAlertParams('timeFields', timeFields); setTimeFieldOptions([firstFieldOption, ...timeFields]); }} onSearchChange={async search => { @@ -493,7 +403,7 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent = = defaultMessage="Time field" /> } - isInvalid={hasErrors && timeField !== undefined} + isInvalid={errors.timeField.length > 0 && timeField !== undefined} error={errors.timeField} > 0 && timeField !== undefined} fullWidth - name="watchTimeField" - data-test-subj="watchTimeFieldSelect" + name="thresholdTimeField" + data-test-subj="thresholdAlertTimeFieldSelect" value={timeField} onChange={e => { setAlertParams('timeField', e.target.value); @@ -542,6 +452,7 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent = id="indexPopover" button={ = 0 && aggField !== undefined} error={errors.aggField} > 0 && aggField !== undefined} placeholder={firstFieldOption.text} options={esFields.reduce((esFieldOptions: any[], field: any) => { if ( @@ -777,9 +688,9 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent = {groupByTypes[groupBy || DEFAULT_VALUES.GROUP_BY].sizeRequired ? ( - + 0} error={errors.termSize}> 0} value={termSize || 0} onChange={e => { const { value } = e.target; @@ -792,12 +703,12 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent = 0 && termField !== undefined} error={errors.termField} > 0 && termField !== undefined} onChange={e => { setAlertParams('termField', e.target.value); }} @@ -896,14 +807,17 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent = className="alertThresholdWatchInBetweenComparatorText" > {andThresholdText} - {hasErrors && } + {errors[`threshold${i}`].length > 0 && } ) : null} - + 0} + error={errors[`threshold${i}`]} + > 0} value={!threshold || threshold[i] === null ? 0 : threshold[i]} min={0} step={0.1} @@ -963,9 +877,12 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent = - + 0} + error={errors.timeWindowSize} + > 0} min={1} value={timeWindowSize ? parseInt(timeWindowSize, 10) : 1} onChange={e => { @@ -990,7 +907,7 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent = - {hasExpressionErrors ? null : ( + {canShowVizualization ? null : ( diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_alert_types/threshold/index.ts b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_alert_types/threshold/index.ts new file mode 100644 index 00000000000000..a0a5b05d49680f --- /dev/null +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_alert_types/threshold/index.ts @@ -0,0 +1,103 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { i18n } from '@kbn/i18n'; +import { Alert, AlertTypeModel, ValidationResult } from '../../../../types'; +import { IndexThresholdAlertTypeExpression, aggregationTypes, groupByTypes } from './expression'; + +export function getAlertType(): AlertTypeModel { + return { + id: 'threshold', + name: 'Index Threshold', + iconClass: 'alert', + alertParamsExpression: IndexThresholdAlertTypeExpression, + validate: (alert: Alert): ValidationResult => { + const { + index, + timeField, + aggType, + aggField, + groupBy, + termSize, + termField, + threshold, + timeWindowSize, + } = alert.params; + const validationResult = { errors: {} }; + const errors = { + aggField: new Array(), + termSize: new Array(), + termField: new Array(), + timeWindowSize: new Array(), + threshold0: new Array(), + threshold1: new Array(), + index: new Array(), + timeField: new Array(), + }; + validationResult.errors = errors; + if (!index || index.length === 0) { + errors.index.push( + i18n.translate('xpack.triggersActionsUI.sections.addAlert.error.requiredIndexText', { + defaultMessage: 'Index is required.', + }) + ); + } + if (!timeField) { + errors.timeField.push( + i18n.translate('xpack.triggersActionsUI.sections.addAlert.error.requiredTimeFieldText', { + defaultMessage: 'Time field is required.', + }) + ); + } + if (aggType && aggregationTypes[aggType].fieldRequired && !aggField) { + errors.aggField.push( + i18n.translate('xpack.triggersActionsUI.sections.addAlert.error.requiredAggFieldText', { + defaultMessage: 'Aggregation field is required.', + }) + ); + } + if (!termSize) { + errors.termSize.push( + i18n.translate('xpack.triggersActionsUI.sections.addAlert.error.requiredTermSizedText', { + defaultMessage: 'Term size is required.', + }) + ); + } + if (groupBy && groupByTypes[groupBy].sizeRequired && !termField) { + errors.termField.push( + i18n.translate('xpack.triggersActionsUI.sections.addAlert.error.requiredtTermFieldText', { + defaultMessage: 'Term field is required.', + }) + ); + } + if (!timeWindowSize) { + errors.timeWindowSize.push( + i18n.translate( + 'xpack.triggersActionsUI.sections.addAlert.error.requiredTimeWindowSizeText', + { + defaultMessage: 'Time window size is required.', + } + ) + ); + } + if (threshold && threshold.length > 0 && !threshold[0]) { + errors.threshold0.push( + i18n.translate('xpack.triggersActionsUI.sections.addAlert.error.requiredThreshold0Text', { + defaultMessage: 'Threshold0, is required.', + }) + ); + } + if (threshold && threshold.length > 1 && !threshold[1]) { + errors.threshold1.push( + i18n.translate('xpack.triggersActionsUI.sections.addAlert.error.requiredThreshold1Text', { + defaultMessage: 'Threshold1 is required.', + }) + ); + } + return validationResult; + }, + defaultActionMessage: 'Alert [{{ctx.metadata.name}}] has exceeded the threshold', + }; +} diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_alert_types/threshold/visualization.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_alert_types/threshold/visualization.tsx index 9ba79bba8fef6d..f91c3cf9a77084 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_alert_types/threshold/visualization.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_alert_types/threshold/visualization.tsx @@ -280,17 +280,18 @@ export const ThresholdVisualization: React.FunctionComponent = ({ alert } ) : ( } color="warning" > )} diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/constants/action_groups.ts b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/constants/action_groups.ts deleted file mode 100644 index 83a03010d55ad6..00000000000000 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/constants/action_groups.ts +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export enum ACTION_GROUPS { - ALERT = 'alert', - WARNING = 'warning', - UNACKNOWLEDGED = 'unacknowledged', -} diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/context/alerts_context.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/context/alerts_context.tsx index 06be1bb7c58516..e019319d843a8e 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/context/alerts_context.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/context/alerts_context.tsx @@ -7,8 +7,9 @@ import React, { useContext, createContext } from 'react'; export interface AlertsContextValue { - alertFlyoutVisible: boolean; - setAlertFlyoutVisibility: React.Dispatch>; + addFlyoutVisible: boolean; + setAddFlyoutVisibility: React.Dispatch>; + reloadAlerts: () => Promise; } const AlertsContext = createContext(null as any); diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/lib/alert_api.test.ts b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/lib/alert_api.test.ts index 35d1a095188dee..9e64fd86f98738 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/lib/alert_api.test.ts +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/lib/alert_api.test.ts @@ -35,6 +35,8 @@ describe('loadAlertTypes', () => { { id: 'test', name: 'Test', + actionVariables: ['var1'], + actionGroups: ['default'], }, ]; http.get.mockResolvedValueOnce(resolvedValue); @@ -300,6 +302,7 @@ describe('createAlert', () => { test('should call create alert API', async () => { const alertToCreate = { name: 'test', + consumer: 'alerting', tags: ['foo'], enabled: true, alertTypeId: 'test', @@ -309,7 +312,6 @@ describe('createAlert', () => { actions: [], params: {}, throttle: null, - consumer: '', createdAt: new Date('1970-01-01T00:00:00.000Z'), updatedAt: new Date('1970-01-01T00:00:00.000Z'), apiKey: null, @@ -331,7 +333,7 @@ describe('createAlert', () => { Array [ "/api/alert", Object { - "body": "{\\"name\\":\\"test\\",\\"tags\\":[\\"foo\\"],\\"enabled\\":true,\\"alertTypeId\\":\\"test\\",\\"schedule\\":{\\"interval\\":\\"1m\\"},\\"actions\\":[],\\"params\\":{},\\"throttle\\":null,\\"consumer\\":\\"\\",\\"createdAt\\":\\"1970-01-01T00:00:00.000Z\\",\\"updatedAt\\":\\"1970-01-01T00:00:00.000Z\\",\\"apiKey\\":null,\\"apiKeyOwner\\":null}", + "body": "{\\"name\\":\\"test\\",\\"consumer\\":\\"alerting\\",\\"tags\\":[\\"foo\\"],\\"enabled\\":true,\\"alertTypeId\\":\\"test\\",\\"schedule\\":{\\"interval\\":\\"1m\\"},\\"actions\\":[],\\"params\\":{},\\"throttle\\":null,\\"createdAt\\":\\"1970-01-01T00:00:00.000Z\\",\\"updatedAt\\":\\"1970-01-01T00:00:00.000Z\\",\\"apiKey\\":null,\\"apiKeyOwner\\":null}", }, ] `); @@ -342,6 +344,7 @@ describe('updateAlert', () => { test('should call alert update API', async () => { const alertToUpdate = { throttle: '1m', + consumer: 'alerting', name: 'test', tags: ['foo'], schedule: { @@ -349,7 +352,6 @@ describe('updateAlert', () => { }, params: {}, actions: [], - consumer: '', createdAt: new Date('1970-01-01T00:00:00.000Z'), updatedAt: new Date('1970-01-01T00:00:00.000Z'), apiKey: null, @@ -373,7 +375,7 @@ describe('updateAlert', () => { Array [ "/api/alert/123", Object { - "body": "{\\"throttle\\":\\"1m\\",\\"name\\":\\"test\\",\\"tags\\":[\\"foo\\"],\\"schedule\\":{\\"interval\\":\\"1m\\"},\\"params\\":{},\\"actions\\":[],\\"consumer\\":\\"\\",\\"createdAt\\":\\"1970-01-01T00:00:00.000Z\\",\\"updatedAt\\":\\"1970-01-01T00:00:00.000Z\\",\\"apiKey\\":null,\\"apiKeyOwner\\":null}", + "body": "{\\"throttle\\":\\"1m\\",\\"consumer\\":\\"alerting\\",\\"name\\":\\"test\\",\\"tags\\":[\\"foo\\"],\\"schedule\\":{\\"interval\\":\\"1m\\"},\\"params\\":{},\\"actions\\":[],\\"createdAt\\":\\"1970-01-01T00:00:00.000Z\\",\\"updatedAt\\":\\"1970-01-01T00:00:00.000Z\\",\\"apiKey\\":null,\\"apiKeyOwner\\":null}", }, ] `); diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/_index.scss b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/_index.scss new file mode 100644 index 00000000000000..f8fa882cd617da --- /dev/null +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/_index.scss @@ -0,0 +1,3 @@ +.actConnectorModal { + z-index: 9000; +} diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/action_connector_form.test.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/action_connector_form.test.tsx index f27f7d8c3054df..7bccf7a4328b6e 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/action_connector_form.test.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/action_connector_form.test.tsx @@ -6,9 +6,6 @@ import * as React from 'react'; import { mountWithIntl } from 'test_utils/enzyme_helpers'; import { coreMock } from '../../../../../../../../../src/core/public/mocks'; -import { ReactWrapper } from 'enzyme'; -import { act } from 'react-dom/test-utils'; -import { ActionsConnectorsContextProvider } from '../../context/actions_connectors_context'; import { actionTypeRegistryMock } from '../../action_type_registry.mock'; import { ValidationResult, ActionConnector } from '../../../types'; import { ActionConnectorForm } from './action_connector_form'; @@ -16,8 +13,7 @@ import { AppContextProvider } from '../../app_context'; const actionTypeRegistry = actionTypeRegistryMock.create(); describe('action_connector_form', () => { - let wrapper: ReactWrapper; - + let deps: any; beforeAll(async () => { const mockes = coreMock.createSetup(); const [ @@ -27,7 +23,7 @@ describe('action_connector_form', () => { application: { capabilities }, }, ] = await mockes.getStartServices(); - const deps = { + deps = { chrome, docLinks, toastNotifications: mockes.notifications.toasts, @@ -48,7 +44,9 @@ describe('action_connector_form', () => { actionTypeRegistry: actionTypeRegistry as any, alertTypeRegistry: {} as any, }; + }); + it('renders action_connector_form', () => { const actionType = { id: 'my-action-type', iconClass: 'test', @@ -71,50 +69,19 @@ describe('action_connector_form', () => { config: {}, secrets: {}, } as ActionConnector; - - await act(async () => { - wrapper = mountWithIntl( - - {}, - editFlyoutVisible: false, - setEditFlyoutVisibility: () => {}, - actionTypesIndex: { - 'my-action-type': { - id: 'my-action-type', - name: 'my-action-type-name', - enabled: true, - }, - }, - reloadConnectors: () => { - return new Promise(() => {}); - }, - }} - > - {}} - /> - - - ); - }); - - await waitForRender(wrapper); - }); - - it('renders action_connector_form', () => { + const wrapper = mountWithIntl( + + {}} + serverError={null} + errors={{ name: [] }} + /> + + ); const connectorNameField = wrapper.find('[data-test-subj="nameInput"]'); expect(connectorNameField.exists()).toBeTruthy(); expect(connectorNameField.first().prop('value')).toBe(''); }); }); - -async function waitForRender(wrapper: ReactWrapper) { - await Promise.resolve(); - await Promise.resolve(); - wrapper.update(); -} diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/action_connector_form.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/action_connector_form.tsx index 852e713b38ed74..c29064efcde35f 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/action_connector_form.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/action_connector_form.tsx @@ -3,49 +3,59 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import React, { Fragment, useState, useReducer } from 'react'; +import React, { Fragment } from 'react'; import { - EuiButton, - EuiFlexGroup, - EuiFlexItem, EuiForm, EuiCallOut, EuiLink, EuiText, EuiSpacer, - EuiButtonEmpty, - EuiFlyoutFooter, EuiFieldText, - EuiFlyoutBody, EuiFormRow, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import { createActionConnector, updateActionConnector } from '../../lib/action_connector_api'; import { useAppDependencies } from '../../app_context'; -import { connectorReducer } from './connector_reducer'; -import { useActionsConnectorsContext } from '../../context/actions_connectors_context'; +import { ReducerAction } from './connector_reducer'; import { ActionConnector, IErrorObject } from '../../../types'; -import { hasSaveActionsCapability } from '../../lib/capabilities'; + +export function validateBaseProperties(actionObject: ActionConnector) { + const validationResult = { errors: {} }; + const verrors = { + name: new Array(), + }; + validationResult.errors = verrors; + if (!actionObject.name) { + verrors.name.push( + i18n.translate( + 'xpack.triggersActionsUI.sections.actionConnectorForm.error.requiredNameText', + { + defaultMessage: 'Name is required.', + } + ) + ); + } + return validationResult; +} interface ActionConnectorProps { - initialConnector: ActionConnector; + connector: ActionConnector; + dispatch: React.Dispatch; actionTypeName: string; - setFlyoutVisibility: React.Dispatch>; + serverError: { + body: { message: string; error: string }; + } | null; + errors: IErrorObject; } export const ActionConnectorForm = ({ - initialConnector, + connector, + dispatch, actionTypeName, - setFlyoutVisibility, + serverError, + errors, }: ActionConnectorProps) => { - const { http, toastNotifications, capabilities, actionTypeRegistry } = useAppDependencies(); - - const { reloadConnectors } = useActionsConnectorsContext(); - const canSave = hasSaveActionsCapability(capabilities); - - // hooks - const [{ connector }, dispatch] = useReducer(connectorReducer, { connector: initialConnector }); + const { actionTypeRegistry } = useAppDependencies(); const setActionProperty = (key: string, value: any) => { dispatch({ command: { type: 'setProperty' }, payload: { key, value } }); @@ -59,207 +69,86 @@ export const ActionConnectorForm = ({ dispatch({ command: { type: 'setSecretsProperty' }, payload: { key, value } }); }; - const [isSaving, setIsSaving] = useState(false); - const [serverError, setServerError] = useState<{ - body: { message: string; error: string }; - } | null>(null); - - const actionTypeRegistered = actionTypeRegistry.get(initialConnector.actionTypeId); - if (!actionTypeRegistered) return null; - - function validateBaseProperties(actionObject: ActionConnector) { - const validationResult = { errors: {} }; - const errors = { - name: new Array(), - }; - validationResult.errors = errors; - if (!actionObject.name) { - errors.name.push( - i18n.translate( - 'xpack.triggersActionsUI.sections.actionConnectorForm.error.requiredNameText', - { - defaultMessage: 'Name is required.', - } - ) - ); - } - return validationResult; - } + const actionTypeRegistered = actionTypeRegistry.get(connector.actionTypeId); + if (!actionTypeRegistered) + return ( + + + +

+ + + + ), + }} + /> +

+ + + + + ); const FieldsComponent = actionTypeRegistered.actionConnectorFields; - const errors = { - ...actionTypeRegistered.validateConnector(connector).errors, - ...validateBaseProperties(connector).errors, - } as IErrorObject; - const hasErrors = !!Object.keys(errors).find(errorKey => errors[errorKey].length >= 1); - - async function onActionConnectorSave(): Promise { - let message: string; - let savedConnector: ActionConnector | undefined; - let error; - if (connector.id === undefined) { - await createActionConnector({ http, connector }) - .then(res => { - savedConnector = res; - }) - .catch(errorRes => { - error = errorRes; - }); - - message = 'Created'; - } else { - await updateActionConnector({ http, connector, id: connector.id }) - .then(res => { - savedConnector = res; - }) - .catch(errorRes => { - error = errorRes; - }); - message = 'Updated'; - } - if (error) { - return { - error, - }; - } - toastNotifications.addSuccess( - i18n.translate( - 'xpack.triggersActionsUI.sections.actionConnectorForm.updateSuccessNotificationText', - { - defaultMessage: "{message} '{connectorName}'", - values: { - message, - connectorName: savedConnector ? savedConnector.name : '', - }, - } - ) - ); - return savedConnector; - } return ( - - - - + + + } + isInvalid={errors.name.length > 0 && connector.name !== undefined} + error={errors.name} + > + 0 && connector.name !== undefined} + name="name" + placeholder="Untitled" + data-test-subj="nameInput" + value={connector.name || ''} + onChange={e => { + setActionProperty('name', e.target.value); + }} + onBlur={() => { + if (!connector.name) { + setActionProperty('name', ''); } - isInvalid={errors.name.length > 0 && connector.name !== undefined} - error={errors.name} - > - 0 && connector.name !== undefined} - name="name" - placeholder="Untitled" - data-test-subj="nameInput" - value={connector.name || ''} - onChange={e => { - setActionProperty('name', e.target.value); - }} - onBlur={() => { - if (!connector.name) { - setActionProperty('name', ''); - } - }} - /> - - - {FieldsComponent !== null ? ( - - {initialConnector.actionTypeId === null ? ( - - - -

- - - - ), - }} - /> -

-
-
- -
- ) : null} -
- ) : null} -
-
- - - - setFlyoutVisibility(false)}> - {i18n.translate( - 'xpack.triggersActionsUI.sections.actionConnectorForm.cancelButtonLabel', - { - defaultMessage: 'Cancel', - } - )} - - - {canSave ? ( - - { - setIsSaving(true); - const savedAction = await onActionConnectorSave(); - setIsSaving(false); - if (savedAction && savedAction.error) { - return setServerError(savedAction.error); - } - setFlyoutVisibility(false); - reloadConnectors(); - }} - > - - - - ) : null} - - -
+ }} + /> + + + {FieldsComponent !== null ? ( + + ) : null} + ); }; diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/action_type_menu.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/action_type_menu.tsx index 19373fda79b9e7..f89d61acb59cad 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/action_type_menu.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/action_type_menu.tsx @@ -3,18 +3,8 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import React, { Fragment } from 'react'; -import { - EuiFlexGroup, - EuiFlexItem, - EuiCard, - EuiIcon, - EuiFlexGrid, - EuiFlyoutBody, - EuiFlyoutFooter, - EuiButtonEmpty, -} from '@elastic/eui'; -import { i18n } from '@kbn/i18n'; +import React from 'react'; +import { EuiFlexItem, EuiCard, EuiIcon, EuiFlexGrid } from '@elastic/eui'; import { ActionType } from '../../../types'; import { useActionsConnectorsContext } from '../../context/actions_connectors_context'; import { useAppDependencies } from '../../app_context'; @@ -25,7 +15,7 @@ interface Props { export const ActionTypeMenu = ({ onActionTypeChange }: Props) => { const { actionTypeRegistry } = useAppDependencies(); - const { actionTypesIndex, setAddFlyoutVisibility } = useActionsConnectorsContext(); + const { actionTypesIndex } = useActionsConnectorsContext(); if (!actionTypesIndex) { return null; } @@ -45,7 +35,7 @@ export const ActionTypeMenu = ({ onActionTypeChange }: Props) => { const cardNodes = actionTypes .sort((a, b) => a.name.localeCompare(b.name)) - .map((item, index): any => { + .map((item, index) => { return ( { ); }); - return ( - - - {cardNodes} - - - - - setAddFlyoutVisibility(false)}> - {i18n.translate( - 'xpack.triggersActionsUI.sections.actionConnectorForm.cancelButtonLabel', - { - defaultMessage: 'Cancel', - } - )} - - - - - - ); + return {cardNodes}; }; diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_add_flyout.test.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_add_flyout.test.tsx index a03296c7c36792..52b9d1c0ed1bb7 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_add_flyout.test.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_add_flyout.test.tsx @@ -6,17 +6,16 @@ import * as React from 'react'; import { mountWithIntl } from 'test_utils/enzyme_helpers'; import { coreMock } from '../../../../../../../../../src/core/public/mocks'; -import { ReactWrapper } from 'enzyme'; -import { act } from 'react-dom/test-utils'; import { ConnectorAddFlyout } from './connector_add_flyout'; import { ActionsConnectorsContextProvider } from '../../context/actions_connectors_context'; import { actionTypeRegistryMock } from '../../action_type_registry.mock'; import { ValidationResult } from '../../../types'; import { AppContextProvider } from '../../app_context'; +import { AppDeps } from '../../app'; const actionTypeRegistry = actionTypeRegistryMock.create(); describe('connector_add_flyout', () => { - let wrapper: ReactWrapper; + let deps: AppDeps | null; beforeAll(async () => { const mockes = coreMock.createSetup(); @@ -27,7 +26,7 @@ describe('connector_add_flyout', () => { application: { capabilities }, }, ] = await mockes.getStartServices(); - const deps = { + deps = { chrome, docLinks, toastNotifications: mockes.notifications.toasts, @@ -48,31 +47,6 @@ describe('connector_add_flyout', () => { actionTypeRegistry: actionTypeRegistry as any, alertTypeRegistry: {} as any, }; - - await act(async () => { - wrapper = mountWithIntl( - - {}, - editFlyoutVisible: false, - setEditFlyoutVisibility: state => {}, - actionTypesIndex: { - 'my-action-type': { id: 'my-action-type', name: 'test', enabled: true }, - }, - reloadConnectors: () => { - return new Promise(() => {}); - }, - }} - > - - - - ); - }); - - await waitForRender(wrapper); }); it('renders action type menu on flyout open', () => { @@ -93,13 +67,27 @@ describe('connector_add_flyout', () => { actionTypeRegistry.get.mockReturnValueOnce(actionType); actionTypeRegistry.has.mockReturnValue(true); + const wrapper = mountWithIntl( + + {}, + editFlyoutVisible: false, + setEditFlyoutVisibility: state => {}, + actionTypesIndex: { + 'my-action-type': { id: 'my-action-type', name: 'test', enabled: true }, + }, + reloadConnectors: () => { + return new Promise(() => {}); + }, + }} + > + + + + ); expect(wrapper.find('ActionTypeMenu')).toHaveLength(1); expect(wrapper.find('[data-test-subj="my-action-type-card"]').exists()).toBeTruthy(); }); }); - -async function waitForRender(wrapper: ReactWrapper) { - await Promise.resolve(); - await Promise.resolve(); - wrapper.update(); -} diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_add_flyout.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_add_flyout.tsx index a3ec7ab4b3ab96..8a50513f158a1f 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_add_flyout.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_add_flyout.tsx @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import React, { useCallback, useState, Fragment } from 'react'; +import React, { useCallback, useState, Fragment, useReducer } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiTitle, @@ -13,21 +13,57 @@ import { EuiFlexItem, EuiIcon, EuiText, + EuiFlyoutFooter, + EuiButtonEmpty, + EuiButton, + EuiFlyoutBody, } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; import { useActionsConnectorsContext } from '../../context/actions_connectors_context'; import { ActionTypeMenu } from './action_type_menu'; -import { ActionConnectorForm } from './action_connector_form'; -import { ActionType, ActionConnector } from '../../../types'; +import { ActionConnectorForm, validateBaseProperties } from './action_connector_form'; +import { ActionType, ActionConnector, IErrorObject } from '../../../types'; import { useAppDependencies } from '../../app_context'; +import { connectorReducer } from './connector_reducer'; +import { hasSaveActionsCapability } from '../../lib/capabilities'; +import { createActionConnector } from '../../lib/action_connector_api'; export const ConnectorAddFlyout = () => { - const { actionTypeRegistry } = useAppDependencies(); - const { addFlyoutVisible, setAddFlyoutVisibility } = useActionsConnectorsContext(); + let hasErrors = false; + const { http, toastNotifications, capabilities, actionTypeRegistry } = useAppDependencies(); const [actionType, setActionType] = useState(undefined); + + // hooks + const initialConnector = { + actionTypeId: actionType?.id ?? '', + config: {}, + secrets: {}, + } as ActionConnector; + const [{ connector }, dispatch] = useReducer(connectorReducer, { connector: initialConnector }); + const setActionProperty = (key: string, value: any) => { + dispatch({ command: { type: 'setProperty' }, payload: { key, value } }); + }; + const setConnector = (value: any) => { + dispatch({ command: { type: 'setConnector' }, payload: { key: 'connector', value } }); + }; + + const { + addFlyoutVisible, + setAddFlyoutVisibility, + reloadConnectors, + } = useActionsConnectorsContext(); + const [isSaving, setIsSaving] = useState(false); + const closeFlyout = useCallback(() => { setAddFlyoutVisibility(false); setActionType(undefined); - }, [setAddFlyoutVisibility, setActionType]); + setConnector(initialConnector); + }, [setAddFlyoutVisibility, initialConnector]); + + const [serverError, setServerError] = useState<{ + body: { message: string; error: string }; + } | null>(null); + const canSave = hasSaveActionsCapability(capabilities); if (!addFlyoutVisible) { return null; @@ -35,6 +71,7 @@ export const ConnectorAddFlyout = () => { function onActionTypeChange(newActionType: ActionType) { setActionType(newActionType); + setActionProperty('actionTypeId', newActionType.id); } let currentForm; @@ -43,21 +80,45 @@ export const ConnectorAddFlyout = () => { currentForm = ; } else { actionTypeModel = actionTypeRegistry.get(actionType.id); - const initialConnector = { - actionTypeId: actionType.id, - config: {}, - secrets: {}, - } as ActionConnector; + + const errors = { + ...actionTypeModel?.validateConnector(connector).errors, + ...validateBaseProperties(connector).errors, + } as IErrorObject; + hasErrors = !!Object.keys(errors).find(errorKey => errors[errorKey].length >= 1); currentForm = ( ); } + const onActionConnectorSave = async (): Promise => + await createActionConnector({ http, connector }) + .then(savedConnector => { + toastNotifications.addSuccess( + i18n.translate( + 'xpack.triggersActionsUI.sections.addConnectorForm.updateSuccessNotificationText', + { + defaultMessage: "Created '{connectorName}'", + values: { + connectorName: savedConnector.name, + }, + } + ) + ); + return savedConnector; + }) + .catch(errorRes => { + setServerError(errorRes); + return undefined; + }); + return ( @@ -98,7 +159,49 @@ export const ConnectorAddFlyout = () => { - {currentForm} + {currentForm} + + + + + + {i18n.translate( + 'xpack.triggersActionsUI.sections.actionConnectorAdd.cancelButtonLabel', + { + defaultMessage: 'Cancel', + } + )} + + + {canSave && actionTypeModel && actionType ? ( + + { + setIsSaving(true); + const savedAction = await onActionConnectorSave(); + setIsSaving(false); + if (savedAction) { + closeFlyout(); + reloadConnectors(); + } + }} + > + + + + ) : null} + + ); }; diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_add_modal.test.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_add_modal.test.tsx new file mode 100644 index 00000000000000..cc87b16035ad32 --- /dev/null +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_add_modal.test.tsx @@ -0,0 +1,102 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import * as React from 'react'; +import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { coreMock } from '../../../../../../../../../src/core/public/mocks'; +import { ConnectorAddModal } from './connector_add_modal'; +import { ActionsConnectorsContextProvider } from '../../context/actions_connectors_context'; +import { actionTypeRegistryMock } from '../../action_type_registry.mock'; +import { ValidationResult } from '../../../types'; +import { AppContextProvider } from '../../app_context'; +import { AppDeps } from '../../app'; +const actionTypeRegistry = actionTypeRegistryMock.create(); + +describe('connector_add_modal', () => { + let deps: AppDeps | null; + + beforeAll(async () => { + const mocks = coreMock.createSetup(); + const [ + { + chrome, + docLinks, + application: { capabilities }, + }, + ] = await mocks.getStartServices(); + deps = { + chrome, + docLinks, + toastNotifications: mocks.notifications.toasts, + injectedMetadata: mocks.injectedMetadata, + http: mocks.http, + uiSettings: mocks.uiSettings, + capabilities: { + ...capabilities, + actions: { + delete: true, + save: true, + show: true, + }, + }, + legacy: { + MANAGEMENT_BREADCRUMB: { set: () => {} } as any, + }, + actionTypeRegistry: actionTypeRegistry as any, + alertTypeRegistry: {} as any, + }; + }); + it('renders connector modal form if addModalVisible is true', () => { + const actionTypeModel = { + id: 'my-action-type', + iconClass: 'test', + selectMessage: 'test', + validateConnector: (): ValidationResult => { + return { errors: {} }; + }, + validateParams: (): ValidationResult => { + const validationResult = { errors: {} }; + return validationResult; + }, + actionConnectorFields: null, + actionParamsFields: null, + }; + actionTypeRegistry.get.mockReturnValueOnce(actionTypeModel); + actionTypeRegistry.has.mockReturnValue(true); + + const actionType = { + id: 'my-action-type', + name: 'test', + enabled: true, + }; + + const wrapper = mountWithIntl( + + {}, + editFlyoutVisible: false, + setEditFlyoutVisibility: state => {}, + actionTypesIndex: { + 'my-action-type': { id: 'my-action-type', name: 'test', enabled: true }, + }, + reloadConnectors: () => { + return new Promise(() => {}); + }, + }} + > + {}} + actionType={actionType} + /> + + + ); + expect(wrapper.find('EuiModalHeader')).toHaveLength(1); + expect(wrapper.find('[data-test-subj="saveActionButtonModal"]').exists()).toBeTruthy(); + }); +}); diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_add_modal.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_add_modal.tsx new file mode 100644 index 00000000000000..2ce282e946a389 --- /dev/null +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_add_modal.tsx @@ -0,0 +1,168 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import React, { useCallback, useReducer, useState } from 'react'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { EuiTitle, EuiFlexItem, EuiIcon, EuiFlexGroup } from '@elastic/eui'; +import { + EuiModal, + EuiButton, + EuiModalHeader, + EuiModalHeaderTitle, + EuiModalBody, + EuiModalFooter, +} from '@elastic/eui'; +import { EuiButtonEmpty } from '@elastic/eui'; +import { EuiOverlayMask } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import { ActionConnectorForm, validateBaseProperties } from './action_connector_form'; +import { ActionType, ActionConnector, IErrorObject } from '../../../types'; +import { connectorReducer } from './connector_reducer'; +import { createActionConnector } from '../../lib/action_connector_api'; +import { useAppDependencies } from '../../app_context'; + +export const ConnectorAddModal = ({ + actionType, + addModalVisible, + setAddModalVisibility, + postSaveEventHandler, +}: { + actionType: ActionType; + addModalVisible: boolean; + setAddModalVisibility: React.Dispatch>; + postSaveEventHandler?: (savedAction: ActionConnector) => void; +}) => { + let hasErrors = false; + const { http, toastNotifications, actionTypeRegistry } = useAppDependencies(); + const initialConnector = { + actionTypeId: actionType.id, + config: {}, + secrets: {}, + } as ActionConnector; + const [isSaving, setIsSaving] = useState(false); + + const [{ connector }, dispatch] = useReducer(connectorReducer, { connector: initialConnector }); + const setConnector = (value: any) => { + dispatch({ command: { type: 'setConnector' }, payload: { key: 'connector', value } }); + }; + const [serverError, setServerError] = useState<{ + body: { message: string; error: string }; + } | null>(null); + + const closeModal = useCallback(() => { + setAddModalVisibility(false); + setConnector(initialConnector); + setServerError(null); + }, [initialConnector, setAddModalVisibility]); + + if (!addModalVisible) { + return null; + } + const actionTypeModel = actionTypeRegistry.get(actionType.id); + const errors = { + ...actionTypeModel?.validateConnector(connector).errors, + ...validateBaseProperties(connector).errors, + } as IErrorObject; + hasErrors = !!Object.keys(errors).find(errorKey => errors[errorKey].length >= 1); + + const onActionConnectorSave = async (): Promise => + await createActionConnector({ http, connector }) + .then(savedConnector => { + toastNotifications.addSuccess( + i18n.translate( + 'xpack.triggersActionsUI.sections.addModalConnectorForm.updateSuccessNotificationText', + { + defaultMessage: "Created '{connectorName}'", + values: { + connectorName: savedConnector.name, + }, + } + ) + ); + return savedConnector; + }) + .catch(errorRes => { + setServerError(errorRes); + return undefined; + }); + + return ( + + + + + + {actionTypeModel && actionTypeModel.iconClass ? ( + + + + ) : null} + + +

+ +

+
+
+
+
+
+ + + + + + + + {i18n.translate( + 'xpack.triggersActionsUI.sections.addModalConnectorForm.cancelButtonLabel', + { + defaultMessage: 'Cancel', + } + )} + + + { + setIsSaving(true); + const savedAction = await onActionConnectorSave(); + setIsSaving(false); + if (savedAction) { + if (postSaveEventHandler) { + postSaveEventHandler(savedAction); + } + closeModal(); + } + }} + > + + + +
+
+ ); +}; diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_edit_flyout.test.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_edit_flyout.test.tsx index 0dc38523bfab83..9687707d0876a1 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_edit_flyout.test.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_edit_flyout.test.tsx @@ -91,7 +91,7 @@ describe('connector_edit_flyout', () => { }, }} > - + ); diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_edit_flyout.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_edit_flyout.tsx index 408989609d2ec5..9c1f2ddc7f7f6d 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_edit_flyout.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_edit_flyout.tsx @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import React, { useCallback } from 'react'; +import React, { useCallback, useReducer, useState } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiTitle, @@ -12,26 +12,73 @@ import { EuiFlexGroup, EuiFlexItem, EuiIcon, + EuiFlyoutBody, + EuiFlyoutFooter, + EuiButtonEmpty, + EuiButton, } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; import { useActionsConnectorsContext } from '../../context/actions_connectors_context'; -import { ActionConnectorForm } from './action_connector_form'; +import { ActionConnectorForm, validateBaseProperties } from './action_connector_form'; import { useAppDependencies } from '../../app_context'; -import { ActionConnectorTableItem } from '../../../types'; +import { ActionConnectorTableItem, ActionConnector, IErrorObject } from '../../../types'; +import { connectorReducer } from './connector_reducer'; +import { updateActionConnector } from '../../lib/action_connector_api'; +import { hasSaveActionsCapability } from '../../lib/capabilities'; export interface ConnectorEditProps { - connector: ActionConnectorTableItem; + initialConnector: ActionConnectorTableItem; } -export const ConnectorEditFlyout = ({ connector }: ConnectorEditProps) => { - const { actionTypeRegistry } = useAppDependencies(); - const { editFlyoutVisible, setEditFlyoutVisibility } = useActionsConnectorsContext(); +export const ConnectorEditFlyout = ({ initialConnector }: ConnectorEditProps) => { + let hasErrors = false; + const { http, toastNotifications, capabilities, actionTypeRegistry } = useAppDependencies(); + const canSave = hasSaveActionsCapability(capabilities); + const { + editFlyoutVisible, + setEditFlyoutVisibility, + reloadConnectors, + } = useActionsConnectorsContext(); const closeFlyout = useCallback(() => setEditFlyoutVisibility(false), [setEditFlyoutVisibility]); + const [{ connector }, dispatch] = useReducer(connectorReducer, { + connector: { ...initialConnector, secrets: {} }, + }); + const [isSaving, setIsSaving] = useState(false); + const [serverError, setServerError] = useState<{ + body: { message: string; error: string }; + } | null>(null); if (!editFlyoutVisible) { return null; } const actionTypeModel = actionTypeRegistry.get(connector.actionTypeId); + const errors = { + ...actionTypeModel?.validateConnector(connector).errors, + ...validateBaseProperties(connector).errors, + } as IErrorObject; + hasErrors = !!Object.keys(errors).find(errorKey => errors[errorKey].length >= 1); + + const onActionConnectorSave = async (): Promise => + await updateActionConnector({ http, connector, id: connector.id }) + .then(savedConnector => { + toastNotifications.addSuccess( + i18n.translate( + 'xpack.triggersActionsUI.sections.editConnectorForm.updateSuccessNotificationText', + { + defaultMessage: "Updated '{connectorName}'", + values: { + connectorName: savedConnector.name, + }, + } + ) + ); + return savedConnector; + }) + .catch(errorRes => { + setServerError(errorRes); + return undefined; + }); return ( @@ -54,15 +101,56 @@ export const ConnectorEditFlyout = ({ connector }: ConnectorEditProps) => { - + + + + + + + + {i18n.translate( + 'xpack.triggersActionsUI.sections.editConnectorForm.cancelButtonLabel', + { + defaultMessage: 'Cancel', + } + )} + + + {canSave && actionTypeModel ? ( + + { + setIsSaving(true); + const savedAction = await onActionConnectorSave(); + setIsSaving(false); + if (savedAction) { + closeFlyout(); + reloadConnectors(); + } + }} + > + + + + ) : null} + + ); }; diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_reducer.ts b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_reducer.ts index 4a2610f965735d..4d094cd869420a 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_reducer.ts +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_reducer.ts @@ -6,7 +6,7 @@ import { isEqual } from 'lodash'; interface CommandType { - type: 'setProperty' | 'setConfigProperty' | 'setSecretsProperty'; + type: 'setConnector' | 'setProperty' | 'setConfigProperty' | 'setSecretsProperty'; } export interface ActionState { @@ -26,6 +26,17 @@ export const connectorReducer = (state: ActionState, action: ReducerAction) => { const { connector } = state; switch (command.type) { + case 'setConnector': { + const { key, value } = payload; + if (key === 'connector') { + return { + ...state, + connector: value, + }; + } else { + return state; + } + } case 'setProperty': { const { key, value } = payload; if (isEqual(connector[key], value)) { diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/actions_connectors_list/components/actions_connectors_list.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/actions_connectors_list/components/actions_connectors_list.tsx index e98c3b2c08749d..bed285f668e01f 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/actions_connectors_list/components/actions_connectors_list.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/actions_connectors_list/components/actions_connectors_list.tsx @@ -384,7 +384,12 @@ export const ActionsConnectorsList: React.FunctionComponent = () => { }} > - {editedConnectorItem ? : null} + {editedConnectorItem ? ( + + ) : null} ); diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alert_add/alert_add.test.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alert_add/alert_add.test.tsx new file mode 100644 index 00000000000000..bf94ffc73b85c9 --- /dev/null +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alert_add/alert_add.test.tsx @@ -0,0 +1,117 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import * as React from 'react'; +import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { act } from 'react-dom/test-utils'; +import { coreMock } from '../../../../../../../../../src/core/public/mocks'; +import { AlertAdd } from './alert_add'; +import { actionTypeRegistryMock } from '../../action_type_registry.mock'; +import { ValidationResult } from '../../../types'; +import { AppContextProvider } from '../../app_context'; +import { AppDeps } from '../../app'; +import { AlertsContextProvider } from '../../context/alerts_context'; +import { alertTypeRegistryMock } from '../../alert_type_registry.mock'; +import { ReactWrapper } from 'enzyme'; +const actionTypeRegistry = actionTypeRegistryMock.create(); +const alertTypeRegistry = alertTypeRegistryMock.create(); + +describe('alert_add', () => { + let deps: AppDeps | null; + let wrapper: ReactWrapper; + + beforeAll(async () => { + const mockes = coreMock.createSetup(); + const [ + { + chrome, + docLinks, + application: { capabilities }, + }, + ] = await mockes.getStartServices(); + deps = { + chrome, + docLinks, + toastNotifications: mockes.notifications.toasts, + injectedMetadata: mockes.injectedMetadata, + http: mockes.http, + uiSettings: mockes.uiSettings, + capabilities: { + ...capabilities, + alerting: { + delete: true, + save: true, + show: true, + }, + }, + legacy: { + MANAGEMENT_BREADCRUMB: { set: () => {} } as any, + }, + actionTypeRegistry: actionTypeRegistry as any, + alertTypeRegistry: alertTypeRegistry as any, + }; + const alertType = { + id: 'my-alert-type', + iconClass: 'test', + name: 'test-alert', + validate: (): ValidationResult => { + return { errors: {} }; + }, + alertParamsExpression: () => , + }; + + const actionTypeModel = { + id: 'my-action-type', + iconClass: 'test', + selectMessage: 'test', + validateConnector: (): ValidationResult => { + return { errors: {} }; + }, + validateParams: (): ValidationResult => { + const validationResult = { errors: {} }; + return validationResult; + }, + actionConnectorFields: null, + actionParamsFields: null, + }; + actionTypeRegistry.get.mockReturnValueOnce(actionTypeModel); + actionTypeRegistry.has.mockReturnValue(true); + alertTypeRegistry.list.mockReturnValue([alertType]); + alertTypeRegistry.get.mockReturnValue(alertType); + alertTypeRegistry.has.mockReturnValue(true); + actionTypeRegistry.list.mockReturnValue([actionTypeModel]); + actionTypeRegistry.has.mockReturnValue(true); + + await act(async () => { + wrapper = mountWithIntl( + + {}, + reloadAlerts: () => { + return new Promise(() => {}); + }, + }} + > + + + + ); + }); + await waitForRender(wrapper); + }); + + it('renders alert add flyout', () => { + expect(wrapper.find('[data-test-subj="addAlertFlyoutTitle"]').exists()).toBeTruthy(); + expect(wrapper.find('[data-test-subj="saveAlertButton"]').exists()).toBeTruthy(); + }); +}); + +async function waitForRender(wrapper: ReactWrapper) { + await Promise.resolve(); + await Promise.resolve(); + wrapper.update(); +} diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alert_add/alert_add.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alert_add/alert_add.tsx index f11b0b948b2a79..d73feff9380766 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alert_add/alert_add.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alert_add/alert_add.tsx @@ -3,584 +3,120 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import React, { Fragment, useState, useCallback, useReducer, useEffect } from 'react'; -import { i18n } from '@kbn/i18n'; +import React, { useCallback, useReducer, useState } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { - EuiButton, + EuiTitle, + EuiFlyoutHeader, + EuiFlyout, + EuiFlyoutFooter, EuiFlexGroup, EuiFlexItem, - EuiIcon, - EuiTitle, - EuiForm, - EuiSpacer, EuiButtonEmpty, - EuiFlyoutFooter, + EuiButton, EuiFlyoutBody, - EuiFlyoutHeader, - EuiFlyout, - EuiFieldText, - EuiFlexGrid, - EuiFormRow, - EuiComboBox, - EuiKeyPadMenuItem, - EuiTabs, - EuiTab, - EuiLink, - EuiFieldNumber, - EuiSelect, - EuiIconTip, EuiPortal, - EuiAccordion, - EuiButtonIcon, } from '@elastic/eui'; -import { useAppDependencies } from '../../app_context'; -import { createAlert } from '../../lib/alert_api'; -import { loadActionTypes, loadAllActions } from '../../lib/action_connector_api'; +import { i18n } from '@kbn/i18n'; import { useAlertsContext } from '../../context/alerts_context'; +import { Alert, AlertAction, IErrorObject } from '../../../types'; +import { AlertForm, validateBaseProperties } from './alert_form'; import { alertReducer } from './alert_reducer'; -import { - AlertTypeModel, - Alert, - IErrorObject, - ActionTypeModel, - AlertAction, - ActionTypeIndex, - ActionConnector, -} from '../../../types'; -import { ACTION_GROUPS } from '../../constants/action_groups'; -import { getTimeOptions } from '../../lib/get_time_options'; -import { SectionLoading } from '../../components/section_loading'; - -interface Props { - refreshList: () => Promise; -} - -function validateBaseProperties(alertObject: Alert) { - const validationResult = { errors: {} }; - const errors = { - name: new Array(), - interval: new Array(), - alertTypeId: new Array(), - actionConnectors: new Array(), - }; - validationResult.errors = errors; - if (!alertObject.name) { - errors.name.push( - i18n.translate('xpack.triggersActionsUI.sections.alertAdd.error.requiredNameText', { - defaultMessage: 'Name is required.', - }) - ); - } - if (!(alertObject.schedule && alertObject.schedule.interval)) { - errors.interval.push( - i18n.translate('xpack.triggersActionsUI.sections.alertAdd.error.requiredIntervalText', { - defaultMessage: 'Check interval is required.', - }) - ); - } - if (!alertObject.alertTypeId) { - errors.alertTypeId.push( - i18n.translate('xpack.triggersActionsUI.sections.alertAdd.error.requiredAlertTypeIdText', { - defaultMessage: 'Alert trigger is required.', - }) - ); - } - return validationResult; -} +import { useAppDependencies } from '../../app_context'; +import { createAlert } from '../../lib/alert_api'; -export const AlertAdd = ({ refreshList }: Props) => { +export const AlertAdd = () => { const { http, toastNotifications, alertTypeRegistry, actionTypeRegistry } = useAppDependencies(); - const initialAlert = { + const initialAlert = ({ params: {}, + consumer: 'alerting', alertTypeId: null, schedule: { interval: '1m', }, actions: [], tags: [], - }; + } as unknown) as Alert; - const { alertFlyoutVisible, setAlertFlyoutVisibility } = useAlertsContext(); - // hooks - const [alertType, setAlertType] = useState(undefined); const [{ alert }, dispatch] = useReducer(alertReducer, { alert: initialAlert }); const [isSaving, setIsSaving] = useState(false); - const [isLoadingActionTypes, setIsLoadingActionTypes] = useState(false); - const [selectedTabId, setSelectedTabId] = useState('alert'); - const [actionTypesIndex, setActionTypesIndex] = useState(undefined); - const [alertInterval, setAlertInterval] = useState(null); - const [alertIntervalUnit, setAlertIntervalUnit] = useState('m'); - const [alertThrottle, setAlertThrottle] = useState(null); - const [alertThrottleUnit, setAlertThrottleUnit] = useState(''); - const [serverError, setServerError] = useState<{ - body: { message: string; error: string }; - } | null>(null); - const [isAddActionPanelOpen, setIsAddActionPanelOpen] = useState(true); - const [connectors, setConnectors] = useState([]); - - useEffect(() => { - (async () => { - try { - setIsLoadingActionTypes(true); - const actionTypes = await loadActionTypes({ http }); - const index: ActionTypeIndex = {}; - for (const actionTypeItem of actionTypes) { - index[actionTypeItem.id] = actionTypeItem; - } - setActionTypesIndex(index); - } catch (e) { - toastNotifications.addDanger({ - title: i18n.translate( - 'xpack.triggersActionsUI.sections.alertAdd.unableToLoadActionTypesMessage', - { defaultMessage: 'Unable to load action types' } - ), - }); - } finally { - setIsLoadingActionTypes(false); - } - })(); - }, [toastNotifications, http]); - - useEffect(() => { - dispatch({ - command: { type: 'setAlert' }, - payload: { - key: 'alert', - value: { - params: {}, - alertTypeId: null, - schedule: { - interval: '1m', - }, - actions: [], - tags: [], - }, - }, - }); - }, [alertFlyoutVisible]); - - useEffect(() => { - loadConnectors(); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [alertFlyoutVisible]); - - const setAlertProperty = (key: string, value: any) => { - dispatch({ command: { type: 'setProperty' }, payload: { key, value } }); - }; - const setAlertParams = (key: string, value: any) => { - dispatch({ command: { type: 'setAlertParams' }, payload: { key, value } }); + const setAlert = (value: any) => { + dispatch({ command: { type: 'setAlert' }, payload: { key: 'alert', value } }); }; - const setActionParamsProperty = (key: string, value: any, index: number) => { - dispatch({ command: { type: 'setAlertActionParams' }, payload: { key, value, index } }); - }; - - const setActionProperty = (key: string, value: any, index: number) => { - dispatch({ command: { type: 'setAlertActionProperty' }, payload: { key, value, index } }); - }; + const { addFlyoutVisible, setAddFlyoutVisibility, reloadAlerts } = useAlertsContext(); const closeFlyout = useCallback(() => { - setAlertFlyoutVisibility(false); - setAlertType(undefined); - setIsAddActionPanelOpen(true); - setSelectedTabId('alert'); + setAddFlyoutVisibility(false); + setAlert(initialAlert); setServerError(null); - }, [setAlertFlyoutVisibility]); - - if (!alertFlyoutVisible) { - return null; - } + }, [initialAlert, setAddFlyoutVisibility]); - const tagsOptions = alert.tags ? alert.tags.map((label: string) => ({ label })) : []; + const [serverError, setServerError] = useState<{ + body: { message: string; error: string }; + } | null>(null); - async function loadConnectors() { - try { - const actionsResponse = await loadAllActions({ http }); - setConnectors(actionsResponse.data); - } catch (e) { - toastNotifications.addDanger({ - title: i18n.translate( - 'xpack.triggersActionsUI.sections.alertAdd.unableToLoadActionsMessage', - { - defaultMessage: 'Unable to load connectors', - } - ), - }); - } + if (!addFlyoutVisible) { + return null; } - const AlertParamsExpressionComponent = alertType ? alertType.alertParamsExpression : null; - + const alertType = alertTypeRegistry.get(alert.alertTypeId); const errors = { ...(alertType ? alertType.validate(alert).errors : []), ...validateBaseProperties(alert).errors, } as IErrorObject; const hasErrors = !!Object.keys(errors).find(errorKey => errors[errorKey].length >= 1); - const actionErrors = alert.actions.reduce((acc: any, alertAction: AlertAction) => { - const actionTypeConnectors = connectors.find(field => field.id === alertAction.id); - if (!actionTypeConnectors) { - return []; - } - const actionType = actionTypeRegistry.get(actionTypeConnectors.actionTypeId); - if (!actionType) { - return []; - } - const actionValidationErrors = actionType.validateParams(alertAction.params); - acc[alertAction.id] = actionValidationErrors; - return acc; - }, {}); - - const hasActionErrors = !!Object.keys(actionErrors).find(actionError => { - return !!Object.keys(actionErrors[actionError]).find((actionErrorKey: string) => { - return actionErrors[actionError][actionErrorKey].length >= 1; - }); - }); - - const tabs = [ - { - id: ACTION_GROUPS.ALERT, - name: i18n.translate('xpack.triggersActionsUI.sections.alertAdd.alertTabText', { - defaultMessage: 'Alert', - }), - }, - { - id: ACTION_GROUPS.WARNING, - name: i18n.translate('xpack.triggersActionsUI.sections.alertAdd.warningTabText', { - defaultMessage: 'Warning', - }), - }, - { - id: ACTION_GROUPS.UNACKNOWLEDGED, - name: i18n.translate('xpack.triggersActionsUI.sections.alertAdd.unacknowledgedTabText', { - defaultMessage: 'If unacknowledged', - }), - disabled: false, + const actionsErrors = alert.actions.reduce( + (acc: Record, alertAction: AlertAction) => { + const actionType = actionTypeRegistry.get(alertAction.actionTypeId); + if (!actionType) { + return { ...acc }; + } + const actionValidationErrors = actionType.validateParams(alertAction.params); + return { ...acc, [alertAction.id]: actionValidationErrors }; }, - ]; + {} + ) as Record; + + const hasActionErrors = !!Object.entries(actionsErrors) + .map(([, actionErrors]) => actionErrors) + .find((actionErrors: { errors: IErrorObject }) => { + return !!Object.keys(actionErrors.errors).find( + errorKey => actionErrors.errors[errorKey].length >= 1 + ); + }); - async function onSaveAlert(): Promise { + async function onSaveAlert(): Promise { try { const newAlert = await createAlert({ http, alert }); toastNotifications.addSuccess( - i18n.translate('xpack.triggersActionsUI.sections.alertAdd.saveSuccessNotificationText', { + i18n.translate('xpack.triggersActionsUI.sections.alertForm.saveSuccessNotificationText', { defaultMessage: "Saved '{alertName}'", values: { - alertName: newAlert.id, + alertName: newAlert.name, }, }) ); return newAlert; - } catch (error) { - return { - error, - }; - } - } - - function addActionType(actionTypeModel: ActionTypeModel) { - setIsAddActionPanelOpen(false); - const actionTypeConnectors = connectors.filter( - field => field.actionTypeId === actionTypeModel.id - ); - if (actionTypeConnectors.length > 0) { - alert.actions.push({ id: actionTypeConnectors[0].id, group: selectedTabId, params: {} }); + } catch (errorRes) { + setServerError(errorRes); + return undefined; } } - const alertTypeNodes = alertTypeRegistry.list().map(function(item, index) { - return ( - { - setAlertProperty('alertTypeId', item.id); - setAlertType(item); - }} - > - - - ); - }); - - const actionTypeNodes = actionTypeRegistry.list().map(function(item, index) { - return ( - addActionType(item)} - > - - - ); - }); - - const alertTabs = tabs.map(function(tab, index): any { - return ( - { - setSelectedTabId(tab.id); - if (!alert.actions.find((action: AlertAction) => action.group === tab.id)) { - setIsAddActionPanelOpen(true); - } else { - setIsAddActionPanelOpen(false); - } - }} - isSelected={tab.id === selectedTabId} - disabled={tab.disabled} - key={index} - > - {tab.name} - - ); - }); - - const alertTypeDetails = ( - - - - -
- -
-
-
- - { - setAlertProperty('alertTypeId', null); - setAlertType(undefined); - }} - > - - - -
- {AlertParamsExpressionComponent ? ( - - ) : null} -
- ); - - const getSelectedOptions = (actionItemId: string) => { - const val = connectors.find(connector => connector.id === actionItemId); - if (!val) { - return []; - } - return [ - { - label: val.name, - value: val.name, - id: actionItemId, - }, - ]; - }; - - const actionsListForGroup = ( - - {alert.actions.map((actionItem: AlertAction, index: number) => { - const actionConnector = connectors.find(field => field.id === actionItem.id); - if (!actionConnector) { - return null; - } - const optionsList = connectors - .filter(field => field.actionTypeId === actionConnector.actionTypeId) - .map(({ name, id }) => ({ - label: name, - key: id, - id, - })); - const actionTypeRegisterd = actionTypeRegistry.get(actionConnector.actionTypeId); - if (actionTypeRegisterd === null || actionItem.group !== selectedTabId) return null; - const ParamsFieldsComponent = actionTypeRegisterd.actionParamsFields; - const actionParamsErrors = - Object.keys(actionErrors).length > 0 ? actionErrors[actionItem.id] : []; - const hasActionParamsErrors = !!Object.keys(actionParamsErrors).find( - errorKey => actionParamsErrors[errorKey].length >= 1 - ); - return ( - - - - - - -
- -
-
-
- - } - extraAction={ - { - const updatedActions = alert.actions.filter( - (item: AlertAction) => item.id !== actionItem.id - ); - setAlertProperty('actions', updatedActions); - }} - /> - } - paddingSize="l" - > - - } - // errorKey="name" - // isShowingErrors={hasErrors} - // errors={errors} - > - { - setActionProperty('id', selectedOptions[0].id, index); - }} - isClearable={false} - /> - - - {ParamsFieldsComponent ? ( - - ) : null} -
- ); - })} - - {!isAddActionPanelOpen ? ( - setIsAddActionPanelOpen(true)} - > - - - ) : null} -
- ); - - let alertTypeArea; - if (alertType) { - alertTypeArea = {alertTypeDetails}; - } else { - alertTypeArea = ( - - -
- -
-
- - - {alertTypeNodes} - -
- ); - } - - const labelForAlertChecked = ( - <> - {' '} - - - ); - - const labelForAlertRenotify = ( - <> - {' '} - - - ); - return ( - +

{ - - - - - } - isInvalid={hasErrors && alert.name !== undefined} - error={errors.name} - > - { - setAlertProperty('name', e.target.value); - }} - onBlur={() => { - if (!alert.name) { - setAlertProperty('name', ''); - } - }} - /> - - - - - { - const newOptions = [...tagsOptions, { label: searchValue }]; - setAlertProperty( - 'tags', - newOptions.map(newOption => newOption.label) - ); - }} - onChange={(selectedOptions: Array<{ label: string }>) => { - setAlertProperty( - 'tags', - selectedOptions.map(selectedOption => selectedOption.label) - ); - }} - onBlur={() => { - if (!alert.tags) { - setAlertProperty('tags', []); - } - }} - /> - - - - - - - - - - { - const interval = - e.target.value !== '' ? parseInt(e.target.value, 10) : null; - setAlertInterval(interval); - setAlertProperty('schedule', { - interval: `${e.target.value}${alertIntervalUnit}`, - }); - }} - /> - - - { - setAlertIntervalUnit(e.target.value); - setAlertProperty('schedule', { - interval: `${alertInterval}${e.target.value}`, - }); - }} - /> - - - - - - - - - { - const throttle = - e.target.value !== '' ? parseInt(e.target.value, 10) : null; - setAlertThrottle(throttle); - setAlertProperty('throttle', `${e.target.value}${alertThrottleUnit}`); - }} - /> - - - { - setAlertThrottleUnit(e.target.value); - setAlertProperty('throttle', `${alertThrottle}${e.target.value}`); - }} - /> - - - - - - - {alertTabs} - - {alertTypeArea} - - {actionsListForGroup} - {isAddActionPanelOpen ? ( - - -
- -
-
- - - {isLoadingActionTypes ? ( - - - - ) : ( - actionTypeNodes - )} - -
- ) : null} -
+
- + {i18n.translate('xpack.triggersActionsUI.sections.alertAdd.cancelButtonLabel', { defaultMessage: 'Cancel', })} @@ -781,7 +141,7 @@ export const AlertAdd = ({ refreshList }: Props) => { { setIsSaving(true); const savedAlert = await onSaveAlert(); setIsSaving(false); - if (savedAlert && savedAlert.error) { - return setServerError(savedAlert.error); + if (savedAlert) { + closeFlyout(); + reloadAlerts(); } - closeFlyout(); - refreshList(); }} > { + let deps: AppDeps | null; + const alertType = { + id: 'my-alert-type', + iconClass: 'test', + name: 'test-alert', + validate: (): ValidationResult => { + return { errors: {} }; + }, + alertParamsExpression: () => , + }; + + const actionType = { + id: 'my-action-type', + iconClass: 'test', + selectMessage: 'test', + validateConnector: (): ValidationResult => { + return { errors: {} }; + }, + validateParams: (): ValidationResult => { + const validationResult = { errors: {} }; + return validationResult; + }, + actionConnectorFields: null, + actionParamsFields: null, + }; + beforeAll(async () => { + const mockes = coreMock.createSetup(); + const [ + { + chrome, + docLinks, + application: { capabilities }, + }, + ] = await mockes.getStartServices(); + deps = { + chrome, + docLinks, + toastNotifications: mockes.notifications.toasts, + injectedMetadata: mockes.injectedMetadata, + http: mockes.http, + uiSettings: mockes.uiSettings, + capabilities: { + ...capabilities, + siem: { + 'alerting:show': true, + 'alerting:save': true, + 'alerting:delete': false, + }, + }, + legacy: { + MANAGEMENT_BREADCRUMB: { set: () => {} } as any, + }, + actionTypeRegistry: actionTypeRegistry as any, + alertTypeRegistry: alertTypeRegistry as any, + }; + }); + + describe('alert_form create alert', () => { + let wrapper: ReactWrapper; + + beforeAll(async () => { + alertTypeRegistry.list.mockReturnValue([alertType]); + alertTypeRegistry.has.mockReturnValue(true); + actionTypeRegistry.list.mockReturnValue([actionType]); + actionTypeRegistry.has.mockReturnValue(true); + + const initialAlert = ({ + name: 'test', + params: {}, + consumer: 'alerting', + schedule: { + interval: '1m', + }, + actions: [], + tags: [], + muteAll: false, + enabled: false, + mutedInstanceIds: [], + } as unknown) as Alert; + + await act(async () => { + wrapper = mountWithIntl( + + {}} + errors={{ name: [] }} + serverError={null} + /> + + ); + }); + + await waitForRender(wrapper); + }); + + it('renders alert name', () => { + const alertNameField = wrapper.find('[data-test-subj="alertNameInput"]'); + expect(alertNameField.exists()).toBeTruthy(); + expect(alertNameField.first().prop('value')).toBe('test'); + }); + + it('renders registered selected alert type', () => { + const alertTypeSelectOptions = wrapper.find('[data-test-subj="my-alert-type-SelectOption"]'); + expect(alertTypeSelectOptions.exists()).toBeTruthy(); + }); + + it('renders registered action types', () => { + const alertTypeSelectOptions = wrapper.find( + '[data-test-subj=".server-log-ActionTypeSelectOption"]' + ); + expect(alertTypeSelectOptions.exists()).toBeFalsy(); + }); + }); + + describe('alert_form edit alert', () => { + let wrapper: ReactWrapper; + + beforeAll(async () => { + alertTypeRegistry.list.mockReturnValue([alertType]); + alertTypeRegistry.get.mockReturnValue(alertType); + alertTypeRegistry.has.mockReturnValue(true); + actionTypeRegistry.list.mockReturnValue([actionType]); + actionTypeRegistry.has.mockReturnValue(true); + + const initialAlert = ({ + name: 'test', + alertTypeId: alertType.id, + params: {}, + consumer: 'alerting', + schedule: { + interval: '1m', + }, + actions: [], + tags: [], + muteAll: false, + enabled: false, + mutedInstanceIds: [], + } as unknown) as Alert; + + await act(async () => { + wrapper = mountWithIntl( + + {}} + errors={{ name: [] }} + serverError={null} + /> + + ); + }); + + await waitForRender(wrapper); + }); + + it('renders alert name', () => { + const alertNameField = wrapper.find('[data-test-subj="alertNameInput"]'); + expect(alertNameField.exists()).toBeTruthy(); + expect(alertNameField.first().prop('value')).toBe('test'); + }); + + it('renders registered selected alert type', () => { + const alertTypeSelectOptions = wrapper.find('[data-test-subj="selectedAlertTypeTitle"]'); + expect(alertTypeSelectOptions.exists()).toBeTruthy(); + }); + + it('renders registered action types', () => { + const actionTypeSelectOptions = wrapper.find( + '[data-test-subj="my-action-type-ActionTypeSelectOption"]' + ); + expect(actionTypeSelectOptions.exists()).toBeTruthy(); + }); + }); + + async function waitForRender(wrapper: ReactWrapper) { + await Promise.resolve(); + await Promise.resolve(); + wrapper.update(); + } +}); diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alert_add/alert_form.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alert_add/alert_form.tsx new file mode 100644 index 00000000000000..78aca3ec78e666 --- /dev/null +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alert_add/alert_form.tsx @@ -0,0 +1,853 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import React, { Fragment, useState, useEffect } from 'react'; +import { i18n } from '@kbn/i18n'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { + EuiButton, + EuiFlexGroup, + EuiFlexItem, + EuiIcon, + EuiTitle, + EuiForm, + EuiSpacer, + EuiFieldText, + EuiFlexGrid, + EuiFormRow, + EuiComboBox, + EuiKeyPadMenuItem, + EuiLink, + EuiFieldNumber, + EuiSelect, + EuiIconTip, + EuiAccordion, + EuiButtonIcon, + EuiEmptyPrompt, + EuiButtonEmpty, +} from '@elastic/eui'; +import { useAppDependencies } from '../../app_context'; +import { loadAlertTypes } from '../../lib/alert_api'; +import { loadActionTypes, loadAllActions } from '../../lib/action_connector_api'; +import { AlertReducerAction } from './alert_reducer'; +import { + AlertTypeModel, + Alert, + IErrorObject, + ActionTypeModel, + AlertAction, + ActionTypeIndex, + ActionConnector, + AlertTypeIndex, +} from '../../../types'; +import { getTimeOptions } from '../../lib/get_time_options'; +import { SectionLoading } from '../../components/section_loading'; +import { ConnectorAddModal } from '../action_connector_form/connector_add_modal'; + +export function validateBaseProperties(alertObject: Alert) { + const validationResult = { errors: {} }; + const errors = { + name: new Array(), + interval: new Array(), + alertTypeId: new Array(), + actionConnectors: new Array(), + }; + validationResult.errors = errors; + if (!alertObject.name) { + errors.name.push( + i18n.translate('xpack.triggersActionsUI.sections.alertForm.error.requiredNameText', { + defaultMessage: 'Name is required.', + }) + ); + } + if (!alertObject.schedule.interval) { + errors.interval.push( + i18n.translate('xpack.triggersActionsUI.sections.alertForm.error.requiredIntervalText', { + defaultMessage: 'Check interval is required.', + }) + ); + } + if (!alertObject.alertTypeId) { + errors.alertTypeId.push( + i18n.translate('xpack.triggersActionsUI.sections.alertForm.error.requiredAlertTypeIdText', { + defaultMessage: 'Alert trigger is required.', + }) + ); + } + return validationResult; +} + +interface AlertFormProps { + alert: Alert; + canChangeTrigger?: boolean; // to hide Change trigger button + dispatch: React.Dispatch; + errors: IErrorObject; + serverError: { + body: { message: string; error: string }; + } | null; +} + +interface ActiveActionConnectorState { + actionTypeId: string; + index: number; +} + +export const AlertForm = ({ + alert, + canChangeTrigger = true, + dispatch, + errors, + serverError, +}: AlertFormProps) => { + const { http, toastNotifications, alertTypeRegistry, actionTypeRegistry } = useAppDependencies(); + const [alertTypeModel, setAlertTypeModel] = useState( + alertTypeRegistry.get(alert.alertTypeId) + ); + + const [addModalVisible, setAddModalVisibility] = useState(false); + const [isLoadingActionTypes, setIsLoadingActionTypes] = useState(false); + const [actionTypesIndex, setActionTypesIndex] = useState(undefined); + const [alertTypesIndex, setAlertTypesIndex] = useState(undefined); + const [alertInterval, setAlertInterval] = useState(null); + const [alertIntervalUnit, setAlertIntervalUnit] = useState('m'); + const [alertThrottle, setAlertThrottle] = useState(null); + const [alertThrottleUnit, setAlertThrottleUnit] = useState('m'); + const [isAddActionPanelOpen, setIsAddActionPanelOpen] = useState(true); + const [connectors, setConnectors] = useState([]); + const [defaultActionGroup, setDefaultActionGroup] = useState(undefined); + const [activeActionItem, setActiveActionItem] = useState( + undefined + ); + + // load action types + useEffect(() => { + (async () => { + try { + setIsLoadingActionTypes(true); + const actionTypes = await loadActionTypes({ http }); + const index: ActionTypeIndex = {}; + for (const actionTypeItem of actionTypes) { + index[actionTypeItem.id] = actionTypeItem; + } + setActionTypesIndex(index); + } catch (e) { + toastNotifications.addDanger({ + title: i18n.translate( + 'xpack.triggersActionsUI.sections.alertForm.unableToLoadActionTypesMessage', + { defaultMessage: 'Unable to load action types' } + ), + }); + } finally { + setIsLoadingActionTypes(false); + } + })(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + // load alert types + useEffect(() => { + (async () => { + try { + const alertTypes = await loadAlertTypes({ http }); + // temp hack of API result + alertTypes.push({ + id: 'threshold', + actionGroups: ['Alert', 'Warning', 'If unacknowledged'], + name: 'threshold', + actionVariables: ['ctx.metadata.name', 'ctx.metadata.test'], + }); + const index: AlertTypeIndex = {}; + for (const alertTypeItem of alertTypes) { + index[alertTypeItem.id] = alertTypeItem; + } + setAlertTypesIndex(index); + } catch (e) { + toastNotifications.addDanger({ + title: i18n.translate( + 'xpack.triggersActionsUI.sections.alertForm.unableToLoadAlertTypesMessage', + { defaultMessage: 'Unable to load alert types' } + ), + }); + } + })(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + useEffect(() => { + loadConnectors(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + const setAlertProperty = (key: string, value: any) => { + dispatch({ command: { type: 'setProperty' }, payload: { key, value } }); + }; + + const setAlertParams = (key: string, value: any) => { + dispatch({ command: { type: 'setAlertParams' }, payload: { key, value } }); + }; + + const setScheduleProperty = (key: string, value: any) => { + dispatch({ command: { type: 'setScheduleProperty' }, payload: { key, value } }); + }; + + const setActionParamsProperty = (key: string, value: any, index: number) => { + dispatch({ command: { type: 'setAlertActionParams' }, payload: { key, value, index } }); + }; + + const setActionProperty = (key: string, value: any, index: number) => { + dispatch({ command: { type: 'setAlertActionProperty' }, payload: { key, value, index } }); + }; + + const tagsOptions = alert.tags ? alert.tags.map((label: string) => ({ label })) : []; + + async function loadConnectors() { + try { + const actionsResponse = await loadAllActions({ http }); + setConnectors(actionsResponse.data); + } catch (e) { + toastNotifications.addDanger({ + title: i18n.translate( + 'xpack.triggersActionsUI.sections.alertForm.unableToLoadActionsMessage', + { + defaultMessage: 'Unable to load connectors', + } + ), + }); + } + } + + const actionsErrors = alert.actions.reduce( + (acc: Record, alertAction: AlertAction) => { + const actionType = actionTypeRegistry.get(alertAction.actionTypeId); + if (!actionType) { + return { ...acc }; + } + const actionValidationErrors = actionType.validateParams(alertAction.params); + return { ...acc, [alertAction.id]: actionValidationErrors }; + }, + {} + ); + + const AlertParamsExpressionComponent = alertTypeModel + ? alertTypeModel.alertParamsExpression + : null; + + function addActionType(actionTypeModel: ActionTypeModel) { + setIsAddActionPanelOpen(false); + const actionTypeConnectors = connectors.filter( + field => field.actionTypeId === actionTypeModel.id + ); + let freeConnectors; + if (actionTypeConnectors.length > 0) { + // Should we allow adding multiple actions to the same connector under the alert? + freeConnectors = actionTypeConnectors.filter( + (actionConnector: ActionConnector) => + !alert.actions.find((actionItem: AlertAction) => actionItem.id === actionConnector.id) + ); + if (freeConnectors.length > 0) { + alert.actions.push({ + id: '', + actionTypeId: actionTypeModel.id, + group: defaultActionGroup ?? 'Alert', + params: {}, + }); + setActionProperty('id', freeConnectors[0].id, alert.actions.length - 1); + } + } + if (actionTypeConnectors.length === 0 || !freeConnectors || freeConnectors.length === 0) { + // if no connectors exists or all connectors is already assigned an action under current alert + // set actionType as id to be able to create new connector within the alert form + alert.actions.push({ + id: '', + actionTypeId: actionTypeModel.id, + group: defaultActionGroup ?? 'Alert', + params: {}, + }); + setActionProperty('id', alert.actions.length, alert.actions.length - 1); + } + } + + const alertTypeNodes = alertTypeRegistry.list().map(function(item, index) { + return ( + { + setAlertProperty('alertTypeId', item.id); + setAlertTypeModel(item); + if ( + alertTypesIndex && + alertTypesIndex[item.id] && + alertTypesIndex[item.id].actionGroups.length > 0 + ) { + setDefaultActionGroup(alertTypesIndex[item.id].actionGroups[0]); + } + }} + > + + + ); + }); + + const actionTypeNodes = actionTypeRegistry.list().map(function(item, index) { + return ( + addActionType(item)} + > + + + ); + }); + + const getSelectedOptions = (actionItemId: string) => { + const val = connectors.find(connector => connector.id === actionItemId); + if (!val) { + return []; + } + return [ + { + label: val.name, + value: val.name, + id: actionItemId, + }, + ]; + }; + + const getActionTypeForm = ( + actionItem: AlertAction, + actionConnector: ActionConnector, + index: number + ) => { + const optionsList = connectors + .filter( + connectorItem => + connectorItem.actionTypeId === actionItem.actionTypeId && + (connectorItem.id === actionItem.id || + !alert.actions.find( + (existingAction: AlertAction) => + existingAction.id === connectorItem.id && existingAction.group === actionItem.group + )) + ) + .map(({ name, id }) => ({ + label: name, + key: id, + id, + })); + const actionTypeRegisterd = actionTypeRegistry.get(actionConnector.actionTypeId); + if (actionTypeRegisterd === null || actionItem.group !== defaultActionGroup) return null; + const ParamsFieldsComponent = actionTypeRegisterd.actionParamsFields; + const actionParamsErrors: { errors: IErrorObject } = + Object.keys(actionsErrors).length > 0 ? actionsErrors[actionItem.id] : { errors: {} }; + + return ( + + + + + + +
+ +
+
+
+
+ } + extraAction={ + { + const updatedActions = alert.actions.filter( + (item: AlertAction) => item.id !== actionItem.id + ); + setAlertProperty('actions', updatedActions); + setIsAddActionPanelOpen( + updatedActions.filter((item: AlertAction) => item.id !== actionItem.id).length === 0 + ); + setActiveActionItem(undefined); + }} + /> + } + paddingSize="l" + > + + + + } + labelAppend={ + { + setActiveActionItem({ actionTypeId: actionItem.actionTypeId, index }); + setAddModalVisibility(true); + }} + > + + + } + > + { + setActionProperty('id', selectedOptions[0].id, index); + }} + isClearable={false} + /> + + + + + {ParamsFieldsComponent ? ( + + ) : null} + + ); + }; + + const getAddConnectorsForm = (actionItem: AlertAction, index: number) => { + const actionTypeName = actionTypesIndex + ? actionTypesIndex[actionItem.actionTypeId].name + : actionItem.actionTypeId; + const actionTypeRegisterd = actionTypeRegistry.get(actionItem.actionTypeId); + if (actionTypeRegisterd === null || actionItem.group !== defaultActionGroup) return null; + return ( + + + + + + +
+ +
+
+
+ + } + extraAction={ + { + const updatedActions = alert.actions.filter( + (item: AlertAction) => item.id !== actionItem.id + ); + setAlertProperty('actions', updatedActions); + setIsAddActionPanelOpen( + updatedActions.filter((item: AlertAction) => item.id !== actionItem.id).length === 0 + ); + setActiveActionItem(undefined); + }} + /> + } + paddingSize="l" + > + + } + actions={[ + { + setActiveActionItem({ actionTypeId: actionItem.actionTypeId, index }); + setAddModalVisibility(true); + }} + > + + , + ]} + /> +
+ ); + }; + + const selectedGroupActions = ( + + {alert.actions.map((actionItem: AlertAction, index: number) => { + const actionConnector = connectors.find(field => field.id === actionItem.id); + // connectors doesn't exists + if (!actionConnector) { + return getAddConnectorsForm(actionItem, index); + } + return getActionTypeForm(actionItem, actionConnector, index); + })} + + {isAddActionPanelOpen === false ? ( + setIsAddActionPanelOpen(true)} + > + + + ) : null} + + ); + + const alertTypeDetails = ( + + + + +
+ +
+
+
+ {canChangeTrigger ? ( + + { + setAlertProperty('alertTypeId', null); + setAlertTypeModel(null); + }} + > + + + + ) : null} +
+ {AlertParamsExpressionComponent ? ( + + ) : null} + + {selectedGroupActions} + {isAddActionPanelOpen ? ( + + +
+ +
+
+ + + {isLoadingActionTypes ? ( + + + + ) : ( + actionTypeNodes + )} + +
+ ) : null} +
+ ); + + const labelForAlertChecked = ( + <> + {' '} + + + ); + + const labelForAlertRenotify = ( + <> + {' '} + + + ); + + return ( + + + + + } + isInvalid={errors.name.length > 0 && alert.name !== undefined} + error={errors.name} + > + 0 && alert.name !== undefined} + compressed + name="name" + data-test-subj="alertNameInput" + value={alert.name || ''} + onChange={e => { + setAlertProperty('name', e.target.value); + }} + onBlur={() => { + if (!alert.name) { + setAlertProperty('name', ''); + } + }} + /> + + + + + { + const newOptions = [...tagsOptions, { label: searchValue }]; + setAlertProperty( + 'tags', + newOptions.map(newOption => newOption.label) + ); + }} + onChange={(selectedOptions: Array<{ label: string }>) => { + setAlertProperty( + 'tags', + selectedOptions.map(selectedOption => selectedOption.label) + ); + }} + onBlur={() => { + if (!alert.tags) { + setAlertProperty('tags', []); + } + }} + /> + + + + + + + + + + { + const interval = e.target.value !== '' ? parseInt(e.target.value, 10) : null; + setAlertInterval(interval); + setScheduleProperty('interval', `${e.target.value}${alertIntervalUnit}`); + }} + /> + + + { + setAlertIntervalUnit(e.target.value); + setScheduleProperty('interval', `${alertInterval}${e.target.value}`); + }} + /> + + + + + + + + + { + const throttle = e.target.value !== '' ? parseInt(e.target.value, 10) : null; + setAlertThrottle(throttle); + setAlertProperty('throttle', `${e.target.value}${alertThrottleUnit}`); + }} + /> + + + { + setAlertThrottleUnit(e.target.value); + setAlertProperty('throttle', `${alertThrottle}${e.target.value}`); + }} + /> + + + + + + + {alertTypeModel ? ( + {alertTypeDetails} + ) : ( + + +
+ +
+
+ + + {alertTypeNodes} + +
+ )} + {actionTypesIndex && activeActionItem ? ( + { + connectors.push(savedAction); + setActionProperty('id', savedAction.id, activeActionItem.index); + }} + /> + ) : null} +
+ ); +}; diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alert_add/alert_reducer.test.ts b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alert_add/alert_reducer.test.ts new file mode 100644 index 00000000000000..bd320de1440248 --- /dev/null +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alert_add/alert_reducer.test.ts @@ -0,0 +1,163 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { alertReducer } from './alert_reducer'; +import { Alert } from '../../../types'; + +describe('alert reducer', () => { + let initialAlert: Alert; + beforeAll(() => { + initialAlert = ({ + params: {}, + consumer: 'alerting', + alertTypeId: null, + schedule: { + interval: '1m', + }, + actions: [], + tags: [], + } as unknown) as Alert; + }); + + // setAlert + test('if modified alert was reset to initial', () => { + const alert = alertReducer( + { alert: initialAlert }, + { + command: { type: 'setProperty' }, + payload: { + key: 'name', + value: 'new name', + }, + } + ); + expect(alert.alert.name).toBe('new name'); + + const updatedAlert = alertReducer( + { alert: initialAlert }, + { + command: { type: 'setAlert' }, + payload: { + key: 'alert', + value: initialAlert, + }, + } + ); + expect(updatedAlert.alert.name).toBeUndefined(); + }); + + test('if property name was changed', () => { + const updatedAlert = alertReducer( + { alert: initialAlert }, + { + command: { type: 'setProperty' }, + payload: { + key: 'name', + value: 'new name', + }, + } + ); + expect(updatedAlert.alert.name).toBe('new name'); + }); + + test('if initial schedule property was updated', () => { + const updatedAlert = alertReducer( + { alert: initialAlert }, + { + command: { type: 'setScheduleProperty' }, + payload: { + key: 'interval', + value: '10s', + }, + } + ); + expect(updatedAlert.alert.schedule.interval).toBe('10s'); + }); + + test('if alert params property was added and updated', () => { + const updatedAlert = alertReducer( + { alert: initialAlert }, + { + command: { type: 'setAlertParams' }, + payload: { + key: 'testParam', + value: 'new test params property', + }, + } + ); + expect(updatedAlert.alert.params.testParam).toBe('new test params property'); + + const updatedAlertParamsProperty = alertReducer( + { alert: updatedAlert.alert }, + { + command: { type: 'setAlertParams' }, + payload: { + key: 'testParam', + value: 'test params property updated', + }, + } + ); + expect(updatedAlertParamsProperty.alert.params.testParam).toBe('test params property updated'); + }); + + test('if alert action params property was added and updated', () => { + initialAlert.actions.push({ + id: '', + actionTypeId: 'testId', + group: 'Alert', + params: {}, + }); + const updatedAlert = alertReducer( + { alert: initialAlert }, + { + command: { type: 'setAlertActionParams' }, + payload: { + key: 'testActionParam', + value: 'new test action params property', + index: 0, + }, + } + ); + expect(updatedAlert.alert.actions[0].params.testActionParam).toBe( + 'new test action params property' + ); + + const updatedAlertActionParamsProperty = alertReducer( + { alert: updatedAlert.alert }, + { + command: { type: 'setAlertActionParams' }, + payload: { + key: 'testActionParam', + value: 'test action params property updated', + index: 0, + }, + } + ); + expect(updatedAlertActionParamsProperty.alert.actions[0].params.testActionParam).toBe( + 'test action params property updated' + ); + }); + + test('if alert action property was updated', () => { + initialAlert.actions.push({ + id: '', + actionTypeId: 'testId', + group: 'Alert', + params: {}, + }); + const updatedAlert = alertReducer( + { alert: initialAlert }, + { + command: { type: 'setAlertActionProperty' }, + payload: { + key: 'group', + value: 'Warning', + index: 0, + }, + } + ); + expect(updatedAlert.alert.actions[0].group).toBe('Warning'); + }); +}); diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alert_add/alert_reducer.ts b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alert_add/alert_reducer.ts index 9c2260f0178be8..2e56f4b026b4a0 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alert_add/alert_reducer.ts +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alert_add/alert_reducer.ts @@ -9,6 +9,7 @@ interface CommandType { type: | 'setAlert' | 'setProperty' + | 'setScheduleProperty' | 'setAlertParams' | 'setAlertActionParams' | 'setAlertActionProperty'; @@ -57,6 +58,23 @@ export const alertReducer = (state: any, action: AlertReducerAction) => { }; } } + case 'setScheduleProperty': { + const { key, value } = payload; + if (isEqual(alert.schedule[key], value)) { + return state; + } else { + return { + ...state, + alert: { + ...alert, + schedule: { + ...alert.schedule, + [key]: value, + }, + }, + }; + } + } case 'setAlertParams': { const { key, value } = payload; if (isEqual(alert.params[key], value)) { diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alert_details/components/alert_details.test.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alert_details/components/alert_details.test.tsx index 228bceb87cad7d..683aca742ac878 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alert_details/components/alert_details.test.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alert_details/components/alert_details.test.tsx @@ -43,6 +43,8 @@ describe('alert_details', () => { const alertType = { id: '.noop', name: 'No Op', + actionGroups: ['default'], + actionVariables: [], }; expect( @@ -61,6 +63,8 @@ describe('alert_details', () => { const alertType = { id: '.noop', name: 'No Op', + actionGroups: ['default'], + actionVariables: [], }; expect( @@ -86,6 +90,8 @@ describe('alert_details', () => { const alertType = { id: '.noop', name: 'No Op', + actionGroups: ['default'], + actionVariables: [], }; const actionTypes: ActionType[] = [ @@ -133,6 +139,8 @@ describe('alert_details', () => { const alertType = { id: '.noop', name: 'No Op', + actionGroups: ['default'], + actionVariables: [], }; const actionTypes: ActionType[] = [ { @@ -181,6 +189,8 @@ describe('alert_details', () => { const alertType = { id: '.noop', name: 'No Op', + actionGroups: ['default'], + actionVariables: [], }; expect( @@ -203,6 +213,8 @@ describe('alert_details', () => { const alertType = { id: '.noop', name: 'No Op', + actionGroups: ['default'], + actionVariables: [], }; expect( @@ -225,6 +237,8 @@ describe('alert_details', () => { const alertType = { id: '.noop', name: 'No Op', + actionGroups: ['default'], + actionVariables: [], }; expect( @@ -252,6 +266,8 @@ describe('enable button', () => { const alertType = { id: '.noop', name: 'No Op', + actionGroups: ['default'], + actionVariables: [], }; const enableButton = shallow( @@ -275,6 +291,8 @@ describe('enable button', () => { const alertType = { id: '.noop', name: 'No Op', + actionGroups: ['default'], + actionVariables: [], }; const enableButton = shallow( @@ -298,6 +316,8 @@ describe('enable button', () => { const alertType = { id: '.noop', name: 'No Op', + actionGroups: ['default'], + actionVariables: [], }; const disableAlert = jest.fn(); @@ -330,6 +350,8 @@ describe('enable button', () => { const alertType = { id: '.noop', name: 'No Op', + actionGroups: ['default'], + actionVariables: [], }; const enableAlert = jest.fn(); @@ -365,6 +387,8 @@ describe('mute button', () => { const alertType = { id: '.noop', name: 'No Op', + actionGroups: ['default'], + actionVariables: [], }; const enableButton = shallow( @@ -389,6 +413,8 @@ describe('mute button', () => { const alertType = { id: '.noop', name: 'No Op', + actionGroups: ['default'], + actionVariables: [], }; const enableButton = shallow( @@ -413,6 +439,8 @@ describe('mute button', () => { const alertType = { id: '.noop', name: 'No Op', + actionGroups: ['default'], + actionVariables: [], }; const muteAlert = jest.fn(); @@ -446,6 +474,8 @@ describe('mute button', () => { const alertType = { id: '.noop', name: 'No Op', + actionGroups: ['default'], + actionVariables: [], }; const unmuteAlert = jest.fn(); @@ -479,6 +509,8 @@ describe('mute button', () => { const alertType = { id: '.noop', name: 'No Op', + actionGroups: ['default'], + actionVariables: [], }; const enableButton = shallow( diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alerts_list/components/alerts_list.test.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alerts_list/components/alerts_list.test.tsx index f410fff44172fa..60435552a57592 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alerts_list/components/alerts_list.test.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alerts_list/components/alerts_list.test.tsx @@ -46,7 +46,6 @@ actionTypeRegistry.list.mockReturnValue([]); describe('alerts_list component empty', () => { let wrapper: ReactWrapper; - beforeEach(async () => { const { loadAlerts, loadAlertTypes } = jest.requireMock('../../../lib/alert_api'); const { loadActionTypes, loadAllActions } = jest.requireMock( @@ -124,14 +123,13 @@ describe('alerts_list component empty', () => { }); it('renders empty list', () => { - expect(wrapper.find('[data-test-subj="createAlertButton"]').find('EuiButton')).toHaveLength(1); + expect(wrapper.find('[data-test-subj="createFirstAlertEmptyPrompt"]').exists()).toBeTruthy(); }); - test('if click create button should render AlertAdd', () => { - wrapper - .find('[data-test-subj="createAlertButton"]') - .first() - .simulate('click'); + it('renders Create alert button', () => { + expect( + wrapper.find('[data-test-subj="createFirstAlertButton"]').find('EuiButton') + ).toHaveLength(1); expect(wrapper.find('AlertAdd')).toHaveLength(1); }); }); diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alerts_list/components/alerts_list.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alerts_list/components/alerts_list.tsx index 32de924f63e807..643816e728d1a3 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alerts_list/components/alerts_list.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alerts_list/components/alerts_list.tsx @@ -6,7 +6,7 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import React, { Fragment, useEffect, useState } from 'react'; +import React, { useEffect, useState, Fragment } from 'react'; import { EuiBasicTable, EuiButton, @@ -15,6 +15,7 @@ import { EuiFlexItem, EuiIcon, EuiSpacer, + EuiEmptyPrompt, EuiLink, } from '@elastic/eui'; import { useHistory } from 'react-router-dom'; @@ -245,100 +246,149 @@ export const AlertsList: React.FunctionComponent = () => { ); } - return ( -
- - - - - {selectedIds.length > 0 && canDelete && ( - - - setIsPerformingAction(true)} - onActionPerformed={() => { - loadAlertsData(); - setIsPerformingAction(false); - }} - /> - - - )} - - } - onChange={e => setInputText(e.target.value)} - onKeyUp={e => { - if (e.keyCode === ENTER_KEY) { - setSearchText(inputText); - } - }} - placeholder={i18n.translate( - 'xpack.triggersActionsUI.sections.alertsList.searchPlaceholderTitle', - { defaultMessage: 'Search...' } + const emptyPrompt = ( + + +

+ } + body={ +

+ +

+ } + actions={ + setAlertFlyoutVisibility(true)} + > + + + } + /> + ); + + const table = ( + + + {selectedIds.length > 0 && canDelete && ( + + + setIsPerformingAction(true)} + onActionPerformed={() => { + loadAlertsData(); + setIsPerformingAction(false); + }} /> - - - - {toolsRight.map((tool, index: number) => ( - - {tool} - - ))} - - + + + )} + + } + onChange={e => setInputText(e.target.value)} + onKeyUp={e => { + if (e.keyCode === ENTER_KEY) { + setSearchText(inputText); + } + }} + placeholder={i18n.translate( + 'xpack.triggersActionsUI.sections.alertsList.searchPlaceholderTitle', + { defaultMessage: 'Search' } + )} + /> + + + + {toolsRight.map((tool, index: number) => ( + + {tool} + + ))} + + - {/* Large to remain consistent with ActionsList table spacing */} - + {/* Large to remain consistent with ActionsList table spacing */} + - ({ - 'data-test-subj': 'alert-row', - })} - cellProps={() => ({ - 'data-test-subj': 'cell', - })} - data-test-subj="alertsList" - pagination={{ - pageIndex: page.index, - pageSize: page.size, - /* Don't display alert count until we have the alert types initialized */ - totalItemCount: - alertTypesState.isInitialized === false ? 0 : alertsState.totalItemCount, - }} - selection={ - canDelete - ? { - onSelectionChange(updatedSelectedItemsList: AlertTableItem[]) { - setSelectedIds(updatedSelectedItemsList.map(item => item.id)); - }, - } - : undefined - } - onChange={({ page: changedPage }: { page: Pagination }) => { - setPage(changedPage); - }} - /> - - - + ({ + 'data-test-subj': 'alert-row', + })} + cellProps={() => ({ + 'data-test-subj': 'cell', + })} + data-test-subj="alertsList" + pagination={{ + pageIndex: page.index, + pageSize: page.size, + /* Don't display alert count until we have the alert types initialized */ + totalItemCount: alertTypesState.isInitialized === false ? 0 : alertsState.totalItemCount, + }} + selection={ + canDelete + ? { + onSelectionChange(updatedSelectedItemsList: AlertTableItem[]) { + setSelectedIds(updatedSelectedItemsList.map(item => item.id)); + }, + } + : undefined + } + onChange={({ page: changedPage }: { page: Pagination }) => { + setPage(changedPage); + }} + /> + + ); + + return ( +
+ + {convertAlertsToTableItems(alertsState.data, alertTypesState.data).length !== 0 && table} + {convertAlertsToTableItems(alertsState.data, alertTypesState.data).length === 0 && + emptyPrompt} + + +
); }; diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/types.ts b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/types.ts index 7fb7d0bf48e4d2..1bed658940a6e5 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/types.ts +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/types.ts @@ -3,10 +3,9 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ +import { ActionType } from '../../../../../plugins/actions/common'; import { TypeRegistry } from './application/type_registry'; import { SanitizedAlert as Alert, AlertAction } from '../../../alerting/common'; -import { ActionType } from '../../../../../plugins/actions/common'; - export { Alert, AlertAction }; export { ActionType }; @@ -15,20 +14,20 @@ export type AlertTypeIndex = Record; export type ActionTypeRegistryContract = PublicMethodsOf>; export type AlertTypeRegistryContract = PublicMethodsOf>; -export interface ActionConnectorFieldsProps { - action: ActionConnector; +export interface ActionConnectorFieldsProps { + action: TActionCOnnector; editActionConfig: (property: string, value: any) => void; editActionSecrets: (property: string, value: any) => void; errors: { [key: string]: string[] }; - hasErrors?: boolean; } -export interface ActionParamsProps { - action: any; +export interface ActionParamsProps { + actionParams: TParams; index: number; editAction: (property: string, value: any, index: number) => void; errors: { [key: string]: string[] }; - hasErrors?: boolean; + messageVariables?: string[]; + defaultMessage?: string; } export interface Pagination { @@ -40,10 +39,11 @@ export interface ActionTypeModel { id: string; iconClass: string; selectMessage: string; - validateConnector: (action: ActionConnector) => ValidationResult; + actionTypeTitle?: string; + validateConnector: (connector: any) => ValidationResult; validateParams: (actionParams: any) => ValidationResult; - actionConnectorFields: React.FunctionComponent | null; - actionParamsFields: React.FunctionComponent | null; + actionConnectorFields: React.FunctionComponent | null; + actionParamsFields: any; } export interface ValidationResult { @@ -68,6 +68,8 @@ export interface ActionConnectorTableItem extends ActionConnector { export interface AlertType { id: string; name: string; + actionGroups: string[]; + actionVariables: string[]; } export type AlertWithoutId = Omit; @@ -83,6 +85,7 @@ export interface AlertTypeModel { iconClass: string; validate: (alert: Alert) => ValidationResult; alertParamsExpression: React.FunctionComponent; + defaultActionMessage?: string; } export interface IErrorObject { diff --git a/x-pack/legacy/plugins/triggers_actions_ui/public/index.scss b/x-pack/legacy/plugins/triggers_actions_ui/public/index.scss index 6faad81630b2be..810176a57f9e38 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/public/index.scss +++ b/x-pack/legacy/plugins/triggers_actions_ui/public/index.scss @@ -3,3 +3,6 @@ // Styling within the app @import '../np_ready/public/application/sections/actions_connectors_list/components/index'; + +@import '../np_ready/public/application/sections/action_connector_form/index'; + diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alerts.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alerts.ts index 0276ca81097320..84081309c18d9e 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alerts.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alerts.ts @@ -16,7 +16,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const testSubjects = getService('testSubjects'); const pageObjects = getPageObjects(['common', 'triggersActionsUI', 'header']); const supertest = getService('supertest'); - const retry = getService('retry'); + const find = getService('find'); async function createAlert() { const { body: createdAlert } = await supertest @@ -43,9 +43,52 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('alertsTab'); }); + it('should create an alert', async () => { + const alertName = generateUniqueKey(); + + await pageObjects.triggersActionsUI.clickCreateAlertButton(); + + const nameInput = await testSubjects.find('alertNameInput'); + await nameInput.click(); + await nameInput.clearValue(); + await nameInput.type(alertName); + + await testSubjects.click('threshold-SelectOption'); + + await testSubjects.click('.slack-ActionTypeSelectOption'); + await testSubjects.click('createActionConnectorButton'); + const connectorNameInput = await testSubjects.find('nameInput'); + await connectorNameInput.click(); + await connectorNameInput.clearValue(); + const connectorName = generateUniqueKey(); + await connectorNameInput.type(connectorName); + + const slackWebhookUrlInput = await testSubjects.find('slackWebhookUrlInput'); + await slackWebhookUrlInput.click(); + await slackWebhookUrlInput.clearValue(); + await slackWebhookUrlInput.type('https://test'); + + await find.clickByCssSelector('[data-test-subj="saveActionButtonModal"]:not(disabled)'); + + const loggingMessageInput = await testSubjects.find('slackMessageTextArea'); + await loggingMessageInput.click(); + await loggingMessageInput.clearValue(); + await loggingMessageInput.type('test message'); + + await testSubjects.click('slackAddVariableButton'); + const variableMenuButton = await testSubjects.find('variableMenuButton-0'); + await variableMenuButton.click(); + + await testSubjects.click('selectIndexExpression'); + + await find.clickByCssSelector('[data-test-subj="cancelSaveAlertButton"]'); + + // TODO: implement saving to the server, when threshold API will be ready + }); + it('should search for alert', async () => { const createdAlert = await createAlert(); - + await pageObjects.common.navigateToApp('triggersActions'); await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name); const searchResults = await pageObjects.triggersActionsUI.getAlertsList(); @@ -61,7 +104,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { it('should search for tags', async () => { const createdAlert = await createAlert(); - + await pageObjects.common.navigateToApp('triggersActions'); await pageObjects.triggersActionsUI.searchAlerts(`${createdAlert.name} foo`); const searchResults = await pageObjects.triggersActionsUI.getAlertsList(); @@ -77,7 +120,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { it('should disable single alert', async () => { const createdAlert = await createAlert(); - + await pageObjects.common.navigateToApp('triggersActions'); await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name); await testSubjects.click('collapsedItemActions'); @@ -95,7 +138,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { it('should re-enable single alert', async () => { const createdAlert = await createAlert(); - + await pageObjects.common.navigateToApp('triggersActions'); await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name); await testSubjects.click('collapsedItemActions'); @@ -119,7 +162,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { it('should mute single alert', async () => { const createdAlert = await createAlert(); - + await pageObjects.common.navigateToApp('triggersActions'); await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name); await testSubjects.click('collapsedItemActions'); @@ -137,7 +180,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { it('should unmute single alert', async () => { const createdAlert = await createAlert(); - + await pageObjects.common.navigateToApp('triggersActions'); await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name); await testSubjects.click('collapsedItemActions'); @@ -161,24 +204,21 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { it('should delete single alert', async () => { const createdAlert = await createAlert(); - + await pageObjects.common.navigateToApp('triggersActions'); await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name); await testSubjects.click('collapsedItemActions'); await testSubjects.click('deleteAlert'); - - await retry.try(async () => { - await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name); - - const searchResults = await pageObjects.triggersActionsUI.getAlertsList(); - expect(searchResults.length).to.eql(0); - }); + const emptyPrompt = await find.byCssSelector( + '[data-test-subj="createFirstAlertEmptyPrompt"]' + ); + expect(await emptyPrompt.elementHasClass('euiEmptyPrompt')).to.be(true); }); it('should mute all selection', async () => { const createdAlert = await createAlert(); - + await pageObjects.common.navigateToApp('triggersActions'); await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name); await testSubjects.click(`checkboxSelectRow-${createdAlert.id}`); @@ -201,7 +241,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { it('should unmute all selection', async () => { const createdAlert = await createAlert(); - + await pageObjects.common.navigateToApp('triggersActions'); await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name); await testSubjects.click(`checkboxSelectRow-${createdAlert.id}`); @@ -226,7 +266,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { it('should disable all selection', async () => { const createdAlert = await createAlert(); - + await pageObjects.common.navigateToApp('triggersActions'); await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name); await testSubjects.click(`checkboxSelectRow-${createdAlert.id}`); @@ -249,7 +289,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { it('should enable all selection', async () => { const createdAlert = await createAlert(); - + await pageObjects.common.navigateToApp('triggersActions'); await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name); await testSubjects.click(`checkboxSelectRow-${createdAlert.id}`); @@ -274,7 +314,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { it('should delete all selection', async () => { const createdAlert = await createAlert(); - + await pageObjects.common.navigateToApp('triggersActions'); await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name); await testSubjects.click(`checkboxSelectRow-${createdAlert.id}`); @@ -283,12 +323,10 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('deleteAll'); - await retry.try(async () => { - await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name); - - const searchResults = await pageObjects.triggersActionsUI.getAlertsList(); - expect(searchResults.length).to.eql(0); - }); + const emptyPrompt = await find.byCssSelector( + '[data-test-subj="createFirstAlertEmptyPrompt"]' + ); + expect(await emptyPrompt.elementHasClass('euiEmptyPrompt')).to.be(true); }); }); }; diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors.ts index d037155a29e12c..9d656b08a3abd4 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors.ts @@ -35,7 +35,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await nameInput.clearValue(); await nameInput.type(connectorName); - await find.clickByCssSelector('[data-test-subj="saveActionButton"]:not(disabled)'); + await find.clickByCssSelector('[data-test-subj="saveNewActionButton"]:not(disabled)'); const toastTitle = await pageObjects.common.closeToast(); expect(toastTitle).to.eql(`Created '${connectorName}'`); @@ -65,7 +65,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await nameInput.clearValue(); await nameInput.type(connectorName); - await find.clickByCssSelector('[data-test-subj="saveActionButton"]:not(disabled)'); + await find.clickByCssSelector('[data-test-subj="saveNewActionButton"]:not(disabled)'); await pageObjects.common.closeToast(); @@ -81,7 +81,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await nameInputToUpdate.clearValue(); await nameInputToUpdate.type(updatedConnectorName); - await find.clickByCssSelector('[data-test-subj="saveActionButton"]:not(disabled)'); + await find.clickByCssSelector('[data-test-subj="saveEditedActionButton"]:not(disabled)'); const toastTitle = await pageObjects.common.closeToast(); expect(toastTitle).to.eql(`Updated '${updatedConnectorName}'`); @@ -109,7 +109,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await nameInput.clearValue(); await nameInput.type(connectorName); - await find.clickByCssSelector('[data-test-subj="saveActionButton"]:not(disabled)'); + await find.clickByCssSelector('[data-test-subj="saveNewActionButton"]:not(disabled)'); await pageObjects.common.closeToast(); } const connectorName = generateUniqueKey(); @@ -147,7 +147,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await nameInput.clearValue(); await nameInput.type(connectorName); - await find.clickByCssSelector('[data-test-subj="saveActionButton"]:not(disabled)'); + await find.clickByCssSelector('[data-test-subj="saveNewActionButton"]:not(disabled)'); await pageObjects.common.closeToast(); } diff --git a/x-pack/test/functional_with_es_ssl/page_objects/triggers_actions_ui_page.ts b/x-pack/test/functional_with_es_ssl/page_objects/triggers_actions_ui_page.ts index ae66ac0ddddfb7..91c7fe1f97d126 100644 --- a/x-pack/test/functional_with_es_ssl/page_objects/triggers_actions_ui_page.ts +++ b/x-pack/test/functional_with_es_ssl/page_objects/triggers_actions_ui_page.ts @@ -18,11 +18,21 @@ export function TriggersActionsPageProvider({ getService }: FtrProviderContext) async getSectionHeadingText() { return await testSubjects.getVisibleText('appTitle'); }, + async clickCreateFirstConnectorButton() { + const createBtn = await find.byCssSelector('[data-test-subj="createFirstActionButton"]'); + const createBtnIsVisible = await createBtn.isDisplayed(); + if (createBtnIsVisible) { + await createBtn.click(); + } + }, async clickCreateConnectorButton() { - const createBtn = await find.byCssSelector( - '[data-test-subj="createActionButton"],[data-test-subj="createFirstActionButton"]' - ); - await createBtn.click(); + const createBtn = await find.byCssSelector('[data-test-subj="createActionButton"]'); + const createBtnIsVisible = await createBtn.isDisplayed(); + if (createBtnIsVisible) { + await createBtn.click(); + } else { + await this.clickCreateFirstConnectorButton(); + } }, async searchConnectors(searchText: string) { const searchBox = await find.byCssSelector('[data-test-subj="actionsList"] .euiFieldSearch'); @@ -109,5 +119,11 @@ export function TriggersActionsPageProvider({ getService }: FtrProviderContext) expect(valueAfter).not.to.eql(valueBefore); }); }, + async clickCreateAlertButton() { + const createBtn = await find.byCssSelector( + '[data-test-subj="createAlertButton"],[data-test-subj="createFirstAlertButton"]' + ); + await createBtn.click(); + }, }; } From 84fa97f89141ab01ba9f237ee6388c73ec8502df Mon Sep 17 00:00:00 2001 From: nnamdifrankie <56440728+nnamdifrankie@users.noreply.github.com> Date: Tue, 4 Feb 2020 14:22:30 -0500 Subject: [PATCH 06/22] [Endpoint] EMT-67: add kql support for endpoint list (#56328) [Endpoint] EMT-67: add kql support for endpoint list --- .../endpoint/server/routes/endpoints.test.ts | 65 ++++++++++++++++++- .../endpoint/server/routes/endpoints.ts | 28 +++++--- .../endpoint/endpoint_query_builders.test.ts | 59 +++++++++++++++++ .../endpoint/endpoint_query_builders.ts | 14 +++- .../apis/endpoint/endpoints.ts | 42 +++++++++++- 5 files changed, 194 insertions(+), 14 deletions(-) diff --git a/x-pack/plugins/endpoint/server/routes/endpoints.test.ts b/x-pack/plugins/endpoint/server/routes/endpoints.test.ts index be14554f128c3c..25c4225495a41a 100644 --- a/x-pack/plugins/endpoint/server/routes/endpoints.test.ts +++ b/x-pack/plugins/endpoint/server/routes/endpoints.test.ts @@ -79,7 +79,7 @@ describe('test endpoint route', () => { expect(endpointResultList.request_page_size).toEqual(10); }); - it('test find the latest of all endpoints with params', async () => { + it('test find the latest of all endpoints with paging properties', async () => { const mockRequest = httpServerMock.createKibanaRequest({ body: { paging_properties: [ @@ -112,6 +112,69 @@ describe('test endpoint route', () => { ); expect(mockScopedClient.callAsCurrentUser).toBeCalled(); + expect(mockScopedClient.callAsCurrentUser.mock.calls[0][1]?.body?.query).toEqual({ + match_all: {}, + }); + expect(routeConfig.options).toEqual({ authRequired: true }); + expect(mockResponse.ok).toBeCalled(); + const endpointResultList = mockResponse.ok.mock.calls[0][0]?.body as EndpointResultList; + expect(endpointResultList.endpoints.length).toEqual(2); + expect(endpointResultList.total).toEqual(2); + expect(endpointResultList.request_page_index).toEqual(10); + expect(endpointResultList.request_page_size).toEqual(10); + }); + + it('test find the latest of all endpoints with paging and filters properties', async () => { + const mockRequest = httpServerMock.createKibanaRequest({ + body: { + paging_properties: [ + { + page_size: 10, + }, + { + page_index: 1, + }, + ], + + filter: 'not host.ip:10.140.73.246', + }, + }); + mockScopedClient.callAsCurrentUser.mockImplementationOnce(() => + Promise.resolve((data as unknown) as SearchResponse) + ); + [routeConfig, routeHandler] = routerMock.post.mock.calls.find(([{ path }]) => + path.startsWith('/api/endpoint/endpoints') + )!; + + await routeHandler( + ({ + core: { + elasticsearch: { + dataClient: mockScopedClient, + }, + }, + } as unknown) as RequestHandlerContext, + mockRequest, + mockResponse + ); + + expect(mockScopedClient.callAsCurrentUser).toBeCalled(); + expect(mockScopedClient.callAsCurrentUser.mock.calls[0][1]?.body?.query).toEqual({ + bool: { + must_not: { + bool: { + minimum_should_match: 1, + should: [ + { + match: { + 'host.ip': '10.140.73.246', + }, + }, + ], + }, + }, + }, + }); expect(routeConfig.options).toEqual({ authRequired: true }); expect(mockResponse.ok).toBeCalled(); const endpointResultList = mockResponse.ok.mock.calls[0][0]?.body as EndpointResultList; diff --git a/x-pack/plugins/endpoint/server/routes/endpoints.ts b/x-pack/plugins/endpoint/server/routes/endpoints.ts index 24ad8e3941f5e1..054172a7f258aa 100644 --- a/x-pack/plugins/endpoint/server/routes/endpoints.ts +++ b/x-pack/plugins/endpoint/server/routes/endpoints.ts @@ -26,16 +26,26 @@ export function registerEndpointRoutes(router: IRouter, endpointAppContext: Endp validate: { body: schema.nullable( schema.object({ - paging_properties: schema.arrayOf( - schema.oneOf([ - // the number of results to return for this request per page - schema.object({ - page_size: schema.number({ defaultValue: 10, min: 1, max: 10000 }), - }), - // the index of the page to return - schema.object({ page_index: schema.number({ defaultValue: 0, min: 0 }) }), - ]) + paging_properties: schema.nullable( + schema.arrayOf( + schema.oneOf([ + /** + * the number of results to return for this request per page + */ + schema.object({ + page_size: schema.number({ defaultValue: 10, min: 1, max: 10000 }), + }), + /** + * the zero based page index of the the total number of pages of page size + */ + schema.object({ page_index: schema.number({ defaultValue: 0, min: 0 }) }), + ]) + ) ), + /** + * filter to be applied, it could be a kql expression or discrete filter to be implemented + */ + filter: schema.nullable(schema.oneOf([schema.string()])), }) ), }, diff --git a/x-pack/plugins/endpoint/server/services/endpoint/endpoint_query_builders.test.ts b/x-pack/plugins/endpoint/server/services/endpoint/endpoint_query_builders.test.ts index e453f777fbd502..bd9986ecf1f976 100644 --- a/x-pack/plugins/endpoint/server/services/endpoint/endpoint_query_builders.test.ts +++ b/x-pack/plugins/endpoint/server/services/endpoint/endpoint_query_builders.test.ts @@ -55,6 +55,65 @@ describe('query builder', () => { }); }); + describe('test query builder with kql filter', () => { + it('test default query params for all endpoints when no params or body is provided', async () => { + const mockRequest = httpServerMock.createKibanaRequest({ + body: { + filter: 'not host.ip:10.140.73.246', + }, + }); + const query = await kibanaRequestToEndpointListQuery(mockRequest, { + logFactory: loggingServiceMock.create(), + config: () => Promise.resolve(EndpointConfigSchema.validate({})), + }); + expect(query).toEqual({ + body: { + query: { + bool: { + must_not: { + bool: { + minimum_should_match: 1, + should: [ + { + match: { + 'host.ip': '10.140.73.246', + }, + }, + ], + }, + }, + }, + }, + collapse: { + field: 'host.id.keyword', + inner_hits: { + name: 'most_recent', + size: 1, + sort: [{ 'event.created': 'desc' }], + }, + }, + aggs: { + total: { + cardinality: { + field: 'host.id.keyword', + }, + }, + }, + sort: [ + { + 'event.created': { + order: 'desc', + }, + }, + ], + }, + from: 0, + size: 10, + index: 'endpoint-agent*', + } as Record); + }); + }); + describe('EndpointFetchQuery', () => { it('searches for the correct ID', () => { const mockID = 'AABBCCDD-0011-2233-AA44-DEADBEEF8899'; diff --git a/x-pack/plugins/endpoint/server/services/endpoint/endpoint_query_builders.ts b/x-pack/plugins/endpoint/server/services/endpoint/endpoint_query_builders.ts index b4f295a64b6ea0..c143b09ec453c3 100644 --- a/x-pack/plugins/endpoint/server/services/endpoint/endpoint_query_builders.ts +++ b/x-pack/plugins/endpoint/server/services/endpoint/endpoint_query_builders.ts @@ -6,6 +6,7 @@ import { KibanaRequest } from 'kibana/server'; import { EndpointAppConstants } from '../../../common/types'; import { EndpointAppContext } from '../../types'; +import { esKuery } from '../../../../../../src/plugins/data/server'; export const kibanaRequestToEndpointListQuery = async ( request: KibanaRequest, @@ -14,9 +15,7 @@ export const kibanaRequestToEndpointListQuery = async ( const pagingProperties = await getPagingProperties(request, endpointAppContext); return { body: { - query: { - match_all: {}, - }, + query: buildQueryBody(request), collapse: { field: 'host.id.keyword', inner_hits: { @@ -66,6 +65,15 @@ async function getPagingProperties( }; } +function buildQueryBody(request: KibanaRequest): Record { + if (typeof request?.body?.filter === 'string') { + return esKuery.toElasticsearchQuery(esKuery.fromKueryExpression(request.body.filter)); + } + return { + match_all: {}, + }; +} + export const kibanaRequestToEndpointFetchQuery = ( request: KibanaRequest, endpointAppContext: EndpointAppContext diff --git a/x-pack/test/api_integration/apis/endpoint/endpoints.ts b/x-pack/test/api_integration/apis/endpoint/endpoints.ts index 1c520fe92e38ee..210e9d78d7e181 100644 --- a/x-pack/test/api_integration/apis/endpoint/endpoints.ts +++ b/x-pack/test/api_integration/apis/endpoint/endpoints.ts @@ -40,7 +40,7 @@ export default function({ getService }: FtrProviderContext) { expect(body.request_page_index).to.eql(0); }); - it('endpoints api should return page based on params passed.', async () => { + it('endpoints api should return page based on paging properties passed.', async () => { const { body } = await supertest .post('/api/endpoint/endpoints') .set('kbn-xsrf', 'xxx') @@ -102,6 +102,46 @@ export default function({ getService }: FtrProviderContext) { .expect(400); expect(body.message).to.contain('Value is [0] but it must be equal to or greater than [1]'); }); + + it('endpoints api should return page based on filters passed.', async () => { + const { body } = await supertest + .post('/api/endpoint/endpoints') + .set('kbn-xsrf', 'xxx') + .send({ filter: 'not host.ip:10.101.149.26' }) + .expect(200); + expect(body.total).to.eql(2); + expect(body.endpoints.length).to.eql(2); + expect(body.request_page_size).to.eql(10); + expect(body.request_page_index).to.eql(0); + }); + + it('endpoints api should return page based on filters and paging passed.', async () => { + const notIncludedIp = '10.101.149.26'; + const { body } = await supertest + .post('/api/endpoint/endpoints') + .set('kbn-xsrf', 'xxx') + .send({ + paging_properties: [ + { + page_size: 10, + }, + { + page_index: 0, + }, + ], + filter: `not host.ip:${notIncludedIp}`, + }) + .expect(200); + expect(body.total).to.eql(2); + const resultIps: string[] = [].concat( + ...body.endpoints.map((metadata: Record) => metadata.host.ip) + ); + expect(resultIps).to.eql(['10.192.213.130', '10.70.28.129', '10.46.229.234']); + expect(resultIps).not.include.eql(notIncludedIp); + expect(body.endpoints.length).to.eql(2); + expect(body.request_page_size).to.eql(10); + expect(body.request_page_index).to.eql(0); + }); }); }); } From 16d412f8f3022db0a93aff2c4ebf82fd97a06ce2 Mon Sep 17 00:00:00 2001 From: Matthew Kime Date: Tue, 4 Feb 2020 13:38:18 -0600 Subject: [PATCH 07/22] =?UTF-8?q?Advanced=20settings=20component=20registr?= =?UTF-8?q?y=20=E2=87=92=20kibana=20platform=20plugin=20(#55940)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * advanced settings component registry to new platform --- .i18nrc.json | 1 + rfcs/text/0006_management_section_service.md | 8 -- .../advanced_settings.test.tsx.snap | 12 +-- .../settings/advanced_settings.test.tsx | 18 ++++ .../sections/settings/advanced_settings.tsx | 19 ++-- .../component_registry.test.tsx.snap | 5 - .../components/component_registry.test.tsx | 82 ----------------- .../settings/components/component_registry.ts | 83 ----------------- .../default_component_registry.test.tsx | 44 --------- .../public/views/management/management.js | 9 +- src/legacy/ui/public/management/index.d.ts | 8 -- src/legacy/ui/public/management/index.js | 6 -- .../public/new_platform/__mocks__/helpers.ts | 3 + .../new_platform/new_platform.karma_mock.js | 7 ++ .../ui/public/new_platform/new_platform.ts | 6 ++ src/plugins/advanced_settings/kibana.json | 7 ++ .../component_registry.test.tsx.snap | 3 + .../component_registry.test.tsx | 90 ++++++++++++++++++ .../component_registry/component_registry.ts | 91 +++++++++++++++++++ .../public/component_registry/index.ts | 20 ++++ .../__snapshots__/page_footer.test.tsx.snap | 0 .../component_registry}/page_footer/index.ts | 0 .../page_footer/page_footer.test.tsx | 0 .../page_footer/page_footer.ts | 0 .../__snapshots__/page_subtitle.test.tsx.snap | 0 .../page_subtitle/index.ts | 0 .../page_subtitle/page_subtitle.test.tsx | 0 .../page_subtitle/page_subtitle.ts | 0 .../__snapshots__/page_title.test.tsx.snap | 2 +- .../component_registry}/page_title/index.ts | 0 .../page_title/page_title.test.tsx | 0 .../page_title/page_title.tsx | 2 +- src/plugins/advanced_settings/public/index.ts | 27 ++++++ src/plugins/advanced_settings/public/mocks.ts | 33 +++++++ .../advanced_settings/public/plugin.ts} | 28 +++--- src/plugins/advanced_settings/public/types.ts | 27 ++++++ .../advanced_settings_service.test.tsx | 21 ++--- .../advanced_settings_service.tsx | 22 +++-- x-pack/legacy/plugins/spaces/public/legacy.ts | 5 +- .../legacy/plugins/spaces/public/plugin.tsx | 11 +-- .../translations/translations/ja-JP.json | 2 +- .../translations/translations/zh-CN.json | 2 +- 42 files changed, 399 insertions(+), 305 deletions(-) delete mode 100644 src/legacy/core_plugins/kibana/public/management/sections/settings/components/__snapshots__/component_registry.test.tsx.snap delete mode 100644 src/legacy/core_plugins/kibana/public/management/sections/settings/components/component_registry.test.tsx delete mode 100644 src/legacy/core_plugins/kibana/public/management/sections/settings/components/component_registry.ts delete mode 100644 src/legacy/core_plugins/kibana/public/management/sections/settings/components/default_component_registry.test.tsx create mode 100644 src/plugins/advanced_settings/kibana.json create mode 100644 src/plugins/advanced_settings/public/component_registry/__snapshots__/component_registry.test.tsx.snap create mode 100644 src/plugins/advanced_settings/public/component_registry/component_registry.test.tsx create mode 100644 src/plugins/advanced_settings/public/component_registry/component_registry.ts create mode 100644 src/plugins/advanced_settings/public/component_registry/index.ts rename src/{legacy/core_plugins/kibana/public/management/sections/settings/components => plugins/advanced_settings/public/component_registry}/page_footer/__snapshots__/page_footer.test.tsx.snap (100%) rename src/{legacy/core_plugins/kibana/public/management/sections/settings/components => plugins/advanced_settings/public/component_registry}/page_footer/index.ts (100%) rename src/{legacy/core_plugins/kibana/public/management/sections/settings/components => plugins/advanced_settings/public/component_registry}/page_footer/page_footer.test.tsx (100%) rename src/{legacy/core_plugins/kibana/public/management/sections/settings/components => plugins/advanced_settings/public/component_registry}/page_footer/page_footer.ts (100%) rename src/{legacy/core_plugins/kibana/public/management/sections/settings/components => plugins/advanced_settings/public/component_registry}/page_subtitle/__snapshots__/page_subtitle.test.tsx.snap (100%) rename src/{legacy/core_plugins/kibana/public/management/sections/settings/components => plugins/advanced_settings/public/component_registry}/page_subtitle/index.ts (100%) rename src/{legacy/core_plugins/kibana/public/management/sections/settings/components => plugins/advanced_settings/public/component_registry}/page_subtitle/page_subtitle.test.tsx (100%) rename src/{legacy/core_plugins/kibana/public/management/sections/settings/components => plugins/advanced_settings/public/component_registry}/page_subtitle/page_subtitle.ts (100%) rename src/{legacy/core_plugins/kibana/public/management/sections/settings/components => plugins/advanced_settings/public/component_registry}/page_title/__snapshots__/page_title.test.tsx.snap (85%) rename src/{legacy/core_plugins/kibana/public/management/sections/settings/components => plugins/advanced_settings/public/component_registry}/page_title/index.ts (100%) rename src/{legacy/core_plugins/kibana/public/management/sections/settings/components => plugins/advanced_settings/public/component_registry}/page_title/page_title.test.tsx (100%) rename src/{legacy/core_plugins/kibana/public/management/sections/settings/components => plugins/advanced_settings/public/component_registry}/page_title/page_title.tsx (91%) create mode 100644 src/plugins/advanced_settings/public/index.ts create mode 100644 src/plugins/advanced_settings/public/mocks.ts rename src/{legacy/core_plugins/kibana/public/management/sections/settings/components/default_component_registry.ts => plugins/advanced_settings/public/plugin.ts} (54%) create mode 100644 src/plugins/advanced_settings/public/types.ts diff --git a/.i18nrc.json b/.i18nrc.json index 7d7685b5c1ef1b..e0acda70cc3480 100644 --- a/.i18nrc.json +++ b/.i18nrc.json @@ -26,6 +26,7 @@ "src/legacy/core_plugins/management", "src/plugins/management" ], + "advancedSettings": "src/plugins/advanced_settings", "kibana_react": "src/legacy/core_plugins/kibana_react", "kibana-react": "src/plugins/kibana_react", "kibana_utils": "src/plugins/kibana_utils", diff --git a/rfcs/text/0006_management_section_service.md b/rfcs/text/0006_management_section_service.md index d9781e85cd8a99..1a52e85a4ff167 100644 --- a/rfcs/text/0006_management_section_service.md +++ b/rfcs/text/0006_management_section_service.md @@ -257,15 +257,7 @@ Current public contracts owned by the legacy service: ```js // ui/management/index interface API { - PAGE_TITLE_COMPONENT: string; // actually related to advanced settings? - PAGE_SUBTITLE_COMPONENT: string; // actually related to advanced settings? - PAGE_FOOTER_COMPONENT: string; // actually related to advanced settings? SidebarNav: React.FC; - registerSettingsComponent: ( - id: string, - component: string | React.FC, - allowOverride: boolean - ) => void; management: new ManagementSection(); MANAGEMENT_BREADCRUMB: { text: string; diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/__snapshots__/advanced_settings.test.tsx.snap b/src/legacy/core_plugins/kibana/public/management/sections/settings/__snapshots__/advanced_settings.test.tsx.snap index 4814432c832e2f..e76435fdb73b2d 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/settings/__snapshots__/advanced_settings.test.tsx.snap +++ b/src/legacy/core_plugins/kibana/public/management/sections/settings/__snapshots__/advanced_settings.test.tsx.snap @@ -6,7 +6,7 @@ exports[`AdvancedSettings should render read-only when saving is disabled 1`] = gutterSize="none" > - + - + @@ -139,7 +139,7 @@ exports[`AdvancedSettings should render read-only when saving is disabled 1`] = } showNoResultsMessage={true} /> - - + - + @@ -322,7 +322,7 @@ exports[`AdvancedSettings should render specific setting if given setting key 1` } showNoResultsMessage={true} /> - ({ npStart: mockConfig(), @@ -215,6 +217,22 @@ function mockConfig() { core: { uiSettings: config, }, + plugins: { + advancedSettings: { + component: { + register: jest.fn(), + get: () => { + const foo: React.ComponentType = () =>
Hello
; + foo.displayName = 'foo_component'; + return foo; + }, + componentType: { + PAGE_TITLE_COMPONENT: 'page_title_component', + PAGE_SUBTITLE_COMPONENT: 'page_subtitle_component', + }, + }, + }, + }, }; } diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/advanced_settings.tsx b/src/legacy/core_plugins/kibana/public/management/sections/settings/advanced_settings.tsx index 569ef73f2b4536..c995b391d3d2dc 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/settings/advanced_settings.tsx +++ b/src/legacy/core_plugins/kibana/public/management/sections/settings/advanced_settings.tsx @@ -31,14 +31,6 @@ import { getAriaName, toEditableConfig, DEFAULT_CATEGORY } from './lib'; import { FieldSetting, IQuery } from './types'; -import { - registerDefaultComponents, - PAGE_TITLE_COMPONENT, - PAGE_SUBTITLE_COMPONENT, - PAGE_FOOTER_COMPONENT, -} from './components/default_component_registry'; -import { getSettingsComponent } from './components/component_registry'; - interface AdvancedSettingsProps { queryText: string; enableSaving: boolean; @@ -75,8 +67,6 @@ export class AdvancedSettings extends Component diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/__snapshots__/component_registry.test.tsx.snap b/src/legacy/core_plugins/kibana/public/management/sections/settings/components/__snapshots__/component_registry.test.tsx.snap deleted file mode 100644 index 070b3870570616..00000000000000 --- a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/__snapshots__/component_registry.test.tsx.snap +++ /dev/null @@ -1,5 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`getSettingsComponent should throw an error when requesting a component that does not exist 1`] = `"Component not found with id does not exist"`; - -exports[`registerSettingsComponent should disallow registering a component with a duplicate id 1`] = `"Component with id test2 is already registered."`; diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/component_registry.test.tsx b/src/legacy/core_plugins/kibana/public/management/sections/settings/components/component_registry.test.tsx deleted file mode 100644 index 24e9e5dd3809c8..00000000000000 --- a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/component_registry.test.tsx +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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 React, { FunctionComponent } from 'react'; -import { - tryRegisterSettingsComponent, - registerSettingsComponent, - getSettingsComponent, -} from './component_registry'; - -describe('tryRegisterSettingsComponent', () => { - it('should allow a component to be registered', () => { - const component = () =>
; - expect(tryRegisterSettingsComponent('tryTest1', component)).toEqual(true); - }); - - it('should return false if the component is already registered, and not allow an override', () => { - const component = () =>
; - expect(tryRegisterSettingsComponent('tryTest2', component)).toEqual(true); - - const updatedComponent = () =>
; - expect(tryRegisterSettingsComponent('tryTest2', updatedComponent)).toEqual(false); - expect(getSettingsComponent('tryTest2')).toBe(component); - }); -}); - -describe('registerSettingsComponent', () => { - it('should allow a component to be registered', () => { - const component = () =>
; - registerSettingsComponent('test', component); - }); - - it('should disallow registering a component with a duplicate id', () => { - const component = () =>
; - registerSettingsComponent('test2', component); - expect(() => registerSettingsComponent('test2', () => )).toThrowErrorMatchingSnapshot(); - }); - - it('should allow a component to be overriden', () => { - const component = () =>
; - registerSettingsComponent('test3', component); - - const anotherComponent = () => ; - registerSettingsComponent('test3', anotherComponent, true); - - expect(getSettingsComponent('test3')).toBe(anotherComponent); - }); - - it('should set a displayName for the component', () => { - const component = () =>
; - registerSettingsComponent('display_name_component', component); - expect((component as FunctionComponent).displayName).toEqual('display_name_component'); - }); -}); - -describe('getSettingsComponent', () => { - it('should allow a component to be retrieved', () => { - const component = () =>
; - registerSettingsComponent('test4', component); - expect(getSettingsComponent('test4')).toBe(component); - }); - - it('should throw an error when requesting a component that does not exist', () => { - expect(() => getSettingsComponent('does not exist')).toThrowErrorMatchingSnapshot(); - }); -}); diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/component_registry.ts b/src/legacy/core_plugins/kibana/public/management/sections/settings/components/component_registry.ts deleted file mode 100644 index b58180c498edfe..00000000000000 --- a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/component_registry.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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 { ComponentType } from 'react'; - -type Id = string; -const registry: Record | undefined>> = {}; - -/** - * Attempts to register the provided component. - * If a component with that ID is already registered, then the registration fails. - * - * @param {*} id the id of the component to register - * @param {*} component the component - */ -export function tryRegisterSettingsComponent( - id: Id, - component: ComponentType | undefined> -) { - if (id in registry) { - return false; - } - - registerSettingsComponent(id, component); - return true; -} - -/** - * Attempts to register the provided component, with the ability to optionally allow - * the component to override an existing one. - * - * If the intent is to override, then `allowOverride` must be set to true, otherwise an exception is thrown. - * - * @param {*} id the id of the component to register - * @param {*} component the component - * @param {*} allowOverride (default: false) - optional flag to allow this component to override a previously registered component - */ -export function registerSettingsComponent( - id: Id, - component: ComponentType | undefined>, - allowOverride = false -) { - if (!allowOverride && id in registry) { - throw new Error(`Component with id ${id} is already registered.`); - } - - // Setting a display name if one does not already exist. - // This enhances the snapshots, as well as the debugging experience. - if (!component.displayName) { - component.displayName = id; - } - - registry[id] = component; -} - -/** - * Retrieve a registered component by its ID. - * If the component does not exist, then an exception is thrown. - * - * @param {*} id the ID of the component to retrieve - */ -export function getSettingsComponent(id: Id): ComponentType | undefined> { - if (!(id in registry)) { - throw new Error(`Component not found with id ${id}`); - } - return registry[id]; -} diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/default_component_registry.test.tsx b/src/legacy/core_plugins/kibana/public/management/sections/settings/components/default_component_registry.test.tsx deleted file mode 100644 index ff3f75b79baefc..00000000000000 --- a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/default_component_registry.test.tsx +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 React from 'react'; -import { registerDefaultComponents, PAGE_TITLE_COMPONENT } from './default_component_registry'; -import { getSettingsComponent, registerSettingsComponent } from './component_registry'; -import { PageTitle } from './page_title'; - -describe('default_component_registry', () => { - it('should register default components with the registry', () => { - registerDefaultComponents(); - expect(getSettingsComponent(PAGE_TITLE_COMPONENT)).toEqual(PageTitle); - }); - - it('should be able to call "registerDefaultComponents" several times without throwing', () => { - registerDefaultComponents(); - registerDefaultComponents(); - registerDefaultComponents(); - }); - - it('should not override components if they are already registered', () => { - const newComponent = () =>
; - registerSettingsComponent(PAGE_TITLE_COMPONENT, newComponent, true); - registerDefaultComponents(); - - expect(getSettingsComponent(PAGE_TITLE_COMPONENT)).toEqual(newComponent); - }); -}); diff --git a/src/legacy/core_plugins/telemetry/public/views/management/management.js b/src/legacy/core_plugins/telemetry/public/views/management/management.js index 796caf1c8cfe6d..7032775e391bb1 100644 --- a/src/legacy/core_plugins/telemetry/public/views/management/management.js +++ b/src/legacy/core_plugins/telemetry/public/views/management/management.js @@ -19,7 +19,7 @@ import React from 'react'; import routes from 'ui/routes'; -import { registerSettingsComponent, PAGE_FOOTER_COMPONENT } from 'ui/management'; +import { npSetup } from 'ui/new_platform'; import { TelemetryOptInProvider } from '../../services'; import { TelemetryForm } from '../../components'; @@ -27,6 +27,7 @@ routes.defaults(/\/management/, { resolve: { telemetryManagementSection: function(Private) { const telemetryOptInProvider = Private(TelemetryOptInProvider); + const componentRegistry = npSetup.plugins.advancedSettings.component; const Component = props => ( ); - registerSettingsComponent(PAGE_FOOTER_COMPONENT, Component, true); + componentRegistry.register( + componentRegistry.componentType.PAGE_FOOTER_COMPONENT, + Component, + true + ); }, }, }); diff --git a/src/legacy/ui/public/management/index.d.ts b/src/legacy/ui/public/management/index.d.ts index 7880e1d5d02957..529efd36623a3a 100644 --- a/src/legacy/ui/public/management/index.d.ts +++ b/src/legacy/ui/public/management/index.d.ts @@ -18,15 +18,7 @@ */ declare module 'ui/management' { - export const PAGE_TITLE_COMPONENT: string; - export const PAGE_SUBTITLE_COMPONENT: string; - export const PAGE_FOOTER_COMPONENT: string; export const SidebarNav: React.FC; - export function registerSettingsComponent( - id: string, - component: string | React.FC, - allowOverride: boolean - ): void; export const management: any; // TODO - properly provide types export const MANAGEMENT_BREADCRUMB: { text: string; diff --git a/src/legacy/ui/public/management/index.js b/src/legacy/ui/public/management/index.js index b2f1946dbc59cb..25d3678c5dbbaf 100644 --- a/src/legacy/ui/public/management/index.js +++ b/src/legacy/ui/public/management/index.js @@ -17,12 +17,6 @@ * under the License. */ -export { - PAGE_TITLE_COMPONENT, - PAGE_SUBTITLE_COMPONENT, - PAGE_FOOTER_COMPONENT, -} from '../../../core_plugins/kibana/public/management/sections/settings/components/default_component_registry'; -export { registerSettingsComponent } from '../../../core_plugins/kibana/public/management/sections/settings/components/component_registry'; export { MANAGEMENT_BREADCRUMB } from './breadcrumbs'; import { npStart } from 'ui/new_platform'; export const management = npStart.plugins.management.legacy; diff --git a/src/legacy/ui/public/new_platform/__mocks__/helpers.ts b/src/legacy/ui/public/new_platform/__mocks__/helpers.ts index 439ac9b5713dfa..cf24b0e9675fac 100644 --- a/src/legacy/ui/public/new_platform/__mocks__/helpers.ts +++ b/src/legacy/ui/public/new_platform/__mocks__/helpers.ts @@ -29,6 +29,7 @@ import { managementPluginMock } from '../../../../../plugins/management/public/m import { usageCollectionPluginMock } from '../../../../../plugins/usage_collection/public/mocks'; import { kibanaLegacyPluginMock } from '../../../../../plugins/kibana_legacy/public/mocks'; import { chartPluginMock } from '../../../../../plugins/charts/public/mocks'; +import { advancedSettingsMock } from '../../../../../plugins/advanced_settings/public/mocks'; /* eslint-enable @kbn/eslint/no-restricted-paths */ export const pluginsMock = { @@ -41,6 +42,7 @@ export const pluginsMock = { expressions: expressionsPluginMock.createSetupContract(), uiActions: uiActionsPluginMock.createSetupContract(), usageCollection: usageCollectionPluginMock.createSetupContract(), + advancedSettings: advancedSettingsMock.createSetupContract(), kibana_legacy: kibanaLegacyPluginMock.createSetupContract(), }), createStart: () => ({ @@ -52,6 +54,7 @@ export const pluginsMock = { expressions: expressionsPluginMock.createStartContract(), uiActions: uiActionsPluginMock.createStartContract(), management: managementPluginMock.createStartContract(), + advancedSettings: advancedSettingsMock.createStartContract(), kibana_legacy: kibanaLegacyPluginMock.createStartContract(), }), }; diff --git a/src/legacy/ui/public/new_platform/new_platform.karma_mock.js b/src/legacy/ui/public/new_platform/new_platform.karma_mock.js index c2c8b5a0fae7a7..7f4f67ebb06d39 100644 --- a/src/legacy/ui/public/new_platform/new_platform.karma_mock.js +++ b/src/legacy/ui/public/new_platform/new_platform.karma_mock.js @@ -20,6 +20,7 @@ import sinon from 'sinon'; import { getFieldFormatsRegistry } from '../../../../test_utils/public/stub_field_formats'; import { METRIC_TYPE } from '@kbn/analytics'; +import { ComponentRegistry } from '../../../../../src/plugins/advanced_settings/public/'; const mockObservable = () => { return { @@ -58,6 +59,12 @@ const mockCore = { export const npSetup = { core: mockCore, plugins: { + advancedSettings: { + component: { + register: sinon.fake(), + componentType: ComponentRegistry.componentType, + }, + }, usageCollection: { allowTrackUserAgent: sinon.fake(), reportUiStats: sinon.fake(), diff --git a/src/legacy/ui/public/new_platform/new_platform.ts b/src/legacy/ui/public/new_platform/new_platform.ts index 2ade98ec54efd0..62abe2eb9b5bae 100644 --- a/src/legacy/ui/public/new_platform/new_platform.ts +++ b/src/legacy/ui/public/new_platform/new_platform.ts @@ -32,6 +32,10 @@ import { DevToolsSetup, DevToolsStart } from '../../../../plugins/dev_tools/publ import { KibanaLegacySetup, KibanaLegacyStart } from '../../../../plugins/kibana_legacy/public'; import { HomePublicPluginSetup, HomePublicPluginStart } from '../../../../plugins/home/public'; import { SharePluginSetup, SharePluginStart } from '../../../../plugins/share/public'; +import { + AdvancedSettingsSetup, + AdvancedSettingsStart, +} from '../../../../plugins/advanced_settings/public'; import { ManagementSetup, ManagementStart } from '../../../../plugins/management/public'; import { BfetchPublicSetup, BfetchPublicStart } from '../../../../plugins/bfetch/public'; import { UsageCollectionSetup } from '../../../../plugins/usage_collection/public'; @@ -54,6 +58,7 @@ export interface PluginsSetup { kibana_legacy: KibanaLegacySetup; share: SharePluginSetup; usageCollection: UsageCollectionSetup; + advancedSettings: AdvancedSettingsSetup; management: ManagementSetup; } @@ -71,6 +76,7 @@ export interface PluginsStart { kibana_legacy: KibanaLegacyStart; share: SharePluginStart; management: ManagementStart; + advancedSettings: AdvancedSettingsStart; } export const npSetup = { diff --git a/src/plugins/advanced_settings/kibana.json b/src/plugins/advanced_settings/kibana.json new file mode 100644 index 00000000000000..5fc1e916ae45f8 --- /dev/null +++ b/src/plugins/advanced_settings/kibana.json @@ -0,0 +1,7 @@ +{ + "id": "advancedSettings", + "version": "kibana", + "server": false, + "ui": true, + "requiredPlugins": [] +} diff --git a/src/plugins/advanced_settings/public/component_registry/__snapshots__/component_registry.test.tsx.snap b/src/plugins/advanced_settings/public/component_registry/__snapshots__/component_registry.test.tsx.snap new file mode 100644 index 00000000000000..1d6cc882cb344d --- /dev/null +++ b/src/plugins/advanced_settings/public/component_registry/__snapshots__/component_registry.test.tsx.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ComponentRegistry register should disallow registering a component with a duplicate id 1`] = `"Component with id advanced_settings_page_title is already registered."`; diff --git a/src/plugins/advanced_settings/public/component_registry/component_registry.test.tsx b/src/plugins/advanced_settings/public/component_registry/component_registry.test.tsx new file mode 100644 index 00000000000000..3b722e9517fdb2 --- /dev/null +++ b/src/plugins/advanced_settings/public/component_registry/component_registry.test.tsx @@ -0,0 +1,90 @@ +/* + * 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 React from 'react'; +import { ComponentRegistry } from './component_registry'; + +describe('ComponentRegistry', () => { + describe('register', () => { + it('should allow a component to be registered', () => { + const component = () =>
; + new ComponentRegistry().setup.register( + ComponentRegistry.componentType.PAGE_TITLE_COMPONENT, + component + ); + }); + + it('should disallow registering a component with a duplicate id', () => { + const registry = new ComponentRegistry(); + const component = () =>
; + registry.setup.register(ComponentRegistry.componentType.PAGE_TITLE_COMPONENT, component); + expect(() => + registry.setup.register(ComponentRegistry.componentType.PAGE_TITLE_COMPONENT, () => ( + + )) + ).toThrowErrorMatchingSnapshot(); + }); + + it('should allow a component to be overriden', () => { + const registry = new ComponentRegistry(); + const component = () =>
; + registry.setup.register(ComponentRegistry.componentType.PAGE_TITLE_COMPONENT, component); + + const anotherComponent = () => ; + registry.setup.register( + ComponentRegistry.componentType.PAGE_TITLE_COMPONENT, + anotherComponent, + true + ); + + expect(registry.start.get(ComponentRegistry.componentType.PAGE_TITLE_COMPONENT)).toBe( + anotherComponent + ); + }); + }); + + describe('get', () => { + it('should allow a component to be retrieved', () => { + const registry = new ComponentRegistry(); + const component = () =>
; + registry.setup.register(ComponentRegistry.componentType.PAGE_TITLE_COMPONENT, component); + expect(registry.start.get(ComponentRegistry.componentType.PAGE_TITLE_COMPONENT)).toBe( + component + ); + }); + }); + + it('should set a displayName for the component if one does not exist', () => { + const component: React.ComponentType = () =>
; + const registry = new ComponentRegistry(); + registry.setup.register(ComponentRegistry.componentType.PAGE_TITLE_COMPONENT, component); + + expect(component.displayName).toEqual(ComponentRegistry.componentType.PAGE_TITLE_COMPONENT); + }); + + it('should not set a displayName for the component if one already exists', () => { + const component: React.ComponentType = () =>
; + component.displayName = ''; + const registry = new ComponentRegistry(); + + registry.setup.register(ComponentRegistry.componentType.PAGE_TITLE_COMPONENT, component); + + expect(component.displayName).toEqual(''); + }); +}); diff --git a/src/plugins/advanced_settings/public/component_registry/component_registry.ts b/src/plugins/advanced_settings/public/component_registry/component_registry.ts new file mode 100644 index 00000000000000..cc61798e84cb7b --- /dev/null +++ b/src/plugins/advanced_settings/public/component_registry/component_registry.ts @@ -0,0 +1,91 @@ +/* + * 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 { ComponentType } from 'react'; +import { PageTitle } from './page_title'; +import { PageSubtitle } from './page_subtitle'; +import { PageFooter } from './page_footer'; + +type Id = + | 'advanced_settings_page_title' + | 'advanced_settings_page_subtitle' + | 'advanced_settings_page_footer'; + +const componentType: { [key: string]: Id } = { + PAGE_TITLE_COMPONENT: 'advanced_settings_page_title' as Id, + PAGE_SUBTITLE_COMPONENT: 'advanced_settings_page_subtitle' as Id, + PAGE_FOOTER_COMPONENT: 'advanced_settings_page_footer' as Id, +}; + +type RegistryComponent = ComponentType | undefined>; + +export class ComponentRegistry { + static readonly componentType = componentType; + static readonly defaultRegistry: Record = { + advanced_settings_page_title: PageTitle, + advanced_settings_page_subtitle: PageSubtitle, + advanced_settings_page_footer: PageFooter, + }; + + registry: { [key in Id]?: RegistryComponent } = {}; + + /** + * Attempts to register the provided component, with the ability to optionally allow + * the component to override an existing one. + * + * If the intent is to override, then `allowOverride` must be set to true, otherwise an exception is thrown. + * + * @param {*} id the id of the component to register + * @param {*} component the component + * @param {*} allowOverride (default: false) - optional flag to allow this component to override a previously registered component + */ + private register(id: Id, component: RegistryComponent, allowOverride = false) { + if (!allowOverride && id in this.registry) { + throw new Error(`Component with id ${id} is already registered.`); + } + + // Setting a display name if one does not already exist. + // This enhances the snapshots, as well as the debugging experience. + if (!component.displayName) { + component.displayName = id; + } + + this.registry[id] = component; + } + + /** + * Retrieve a registered component by its ID. + * If the component does not exist, then an exception is thrown. + * + * @param {*} id the ID of the component to retrieve + */ + private get(id: Id): RegistryComponent { + return this.registry[id] || ComponentRegistry.defaultRegistry[id]; + } + + setup = { + componentType: ComponentRegistry.componentType, + register: this.register.bind(this), + }; + + start = { + componentType: ComponentRegistry.componentType, + get: this.get.bind(this), + }; +} diff --git a/src/plugins/advanced_settings/public/component_registry/index.ts b/src/plugins/advanced_settings/public/component_registry/index.ts new file mode 100644 index 00000000000000..79c9248e0c2a9e --- /dev/null +++ b/src/plugins/advanced_settings/public/component_registry/index.ts @@ -0,0 +1,20 @@ +/* + * 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. + */ + +export { ComponentRegistry } from './component_registry'; diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_footer/__snapshots__/page_footer.test.tsx.snap b/src/plugins/advanced_settings/public/component_registry/page_footer/__snapshots__/page_footer.test.tsx.snap similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_footer/__snapshots__/page_footer.test.tsx.snap rename to src/plugins/advanced_settings/public/component_registry/page_footer/__snapshots__/page_footer.test.tsx.snap diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_footer/index.ts b/src/plugins/advanced_settings/public/component_registry/page_footer/index.ts similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_footer/index.ts rename to src/plugins/advanced_settings/public/component_registry/page_footer/index.ts diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_footer/page_footer.test.tsx b/src/plugins/advanced_settings/public/component_registry/page_footer/page_footer.test.tsx similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_footer/page_footer.test.tsx rename to src/plugins/advanced_settings/public/component_registry/page_footer/page_footer.test.tsx diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_footer/page_footer.ts b/src/plugins/advanced_settings/public/component_registry/page_footer/page_footer.ts similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_footer/page_footer.ts rename to src/plugins/advanced_settings/public/component_registry/page_footer/page_footer.ts diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_subtitle/__snapshots__/page_subtitle.test.tsx.snap b/src/plugins/advanced_settings/public/component_registry/page_subtitle/__snapshots__/page_subtitle.test.tsx.snap similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_subtitle/__snapshots__/page_subtitle.test.tsx.snap rename to src/plugins/advanced_settings/public/component_registry/page_subtitle/__snapshots__/page_subtitle.test.tsx.snap diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_subtitle/index.ts b/src/plugins/advanced_settings/public/component_registry/page_subtitle/index.ts similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_subtitle/index.ts rename to src/plugins/advanced_settings/public/component_registry/page_subtitle/index.ts diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_subtitle/page_subtitle.test.tsx b/src/plugins/advanced_settings/public/component_registry/page_subtitle/page_subtitle.test.tsx similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_subtitle/page_subtitle.test.tsx rename to src/plugins/advanced_settings/public/component_registry/page_subtitle/page_subtitle.test.tsx diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_subtitle/page_subtitle.ts b/src/plugins/advanced_settings/public/component_registry/page_subtitle/page_subtitle.ts similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_subtitle/page_subtitle.ts rename to src/plugins/advanced_settings/public/component_registry/page_subtitle/page_subtitle.ts diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_title/__snapshots__/page_title.test.tsx.snap b/src/plugins/advanced_settings/public/component_registry/page_title/__snapshots__/page_title.test.tsx.snap similarity index 85% rename from src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_title/__snapshots__/page_title.test.tsx.snap rename to src/plugins/advanced_settings/public/component_registry/page_title/__snapshots__/page_title.test.tsx.snap index 8dd4e501067b5e..10b799a986b84d 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_title/__snapshots__/page_title.test.tsx.snap +++ b/src/plugins/advanced_settings/public/component_registry/page_title/__snapshots__/page_title.test.tsx.snap @@ -7,7 +7,7 @@ exports[`PageTitle should render normally 1`] = ` > diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_title/index.ts b/src/plugins/advanced_settings/public/component_registry/page_title/index.ts similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_title/index.ts rename to src/plugins/advanced_settings/public/component_registry/page_title/index.ts diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_title/page_title.test.tsx b/src/plugins/advanced_settings/public/component_registry/page_title/page_title.test.tsx similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_title/page_title.test.tsx rename to src/plugins/advanced_settings/public/component_registry/page_title/page_title.test.tsx diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_title/page_title.tsx b/src/plugins/advanced_settings/public/component_registry/page_title/page_title.tsx similarity index 91% rename from src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_title/page_title.tsx rename to src/plugins/advanced_settings/public/component_registry/page_title/page_title.tsx index cb807302c2380b..18d9c60d331bb9 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_title/page_title.tsx +++ b/src/plugins/advanced_settings/public/component_registry/page_title/page_title.tsx @@ -25,7 +25,7 @@ export const PageTitle = () => { return (

- +

); diff --git a/src/plugins/advanced_settings/public/index.ts b/src/plugins/advanced_settings/public/index.ts new file mode 100644 index 00000000000000..13be36e671f752 --- /dev/null +++ b/src/plugins/advanced_settings/public/index.ts @@ -0,0 +1,27 @@ +/* + * 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 { PluginInitializerContext } from 'kibana/public'; +import { AdvancedSettingsPlugin } from './plugin'; +export { AdvancedSettingsSetup, AdvancedSettingsStart } from './types'; +export { ComponentRegistry } from './component_registry'; + +export function plugin(initializerContext: PluginInitializerContext) { + return new AdvancedSettingsPlugin(); +} diff --git a/src/plugins/advanced_settings/public/mocks.ts b/src/plugins/advanced_settings/public/mocks.ts new file mode 100644 index 00000000000000..e147f57101aae1 --- /dev/null +++ b/src/plugins/advanced_settings/public/mocks.ts @@ -0,0 +1,33 @@ +/* + * 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 { ComponentRegistry } from './component_registry'; + +const register = jest.fn(); +const get = jest.fn(); +const componentType = ComponentRegistry.componentType; + +export const advancedSettingsMock = { + createSetupContract() { + return { register, componentType }; + }, + createStartContract() { + return { get, componentType }; + }, +}; diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/default_component_registry.ts b/src/plugins/advanced_settings/public/plugin.ts similarity index 54% rename from src/legacy/core_plugins/kibana/public/management/sections/settings/components/default_component_registry.ts rename to src/plugins/advanced_settings/public/plugin.ts index 80b2f2e79b9c77..692e515ca4e5ed 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/default_component_registry.ts +++ b/src/plugins/advanced_settings/public/plugin.ts @@ -17,17 +17,23 @@ * under the License. */ -import { tryRegisterSettingsComponent } from './component_registry'; -import { PageTitle } from './page_title'; -import { PageSubtitle } from './page_subtitle'; -import { PageFooter } from './page_footer'; +import { CoreSetup, CoreStart, Plugin } from 'kibana/public'; +import { ComponentRegistry } from './component_registry'; +import { AdvancedSettingsSetup, AdvancedSettingsStart } from './types'; -export const PAGE_TITLE_COMPONENT = 'advanced_settings_page_title'; -export const PAGE_SUBTITLE_COMPONENT = 'advanced_settings_page_subtitle'; -export const PAGE_FOOTER_COMPONENT = 'advanced_settings_page_footer'; +const component = new ComponentRegistry(); -export function registerDefaultComponents() { - tryRegisterSettingsComponent(PAGE_TITLE_COMPONENT, PageTitle); - tryRegisterSettingsComponent(PAGE_SUBTITLE_COMPONENT, PageSubtitle); - tryRegisterSettingsComponent(PAGE_FOOTER_COMPONENT, PageFooter); +export class AdvancedSettingsPlugin + implements Plugin { + public setup(core: CoreSetup) { + return { + component: component.setup, + }; + } + + public start(core: CoreStart) { + return { + component: component.start, + }; + } } diff --git a/src/plugins/advanced_settings/public/types.ts b/src/plugins/advanced_settings/public/types.ts new file mode 100644 index 00000000000000..a9b965c3c22dee --- /dev/null +++ b/src/plugins/advanced_settings/public/types.ts @@ -0,0 +1,27 @@ +/* + * 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 { ComponentRegistry } from './component_registry'; + +export interface AdvancedSettingsSetup { + component: ComponentRegistry['setup']; +} +export interface AdvancedSettingsStart { + component: ComponentRegistry['start']; +} diff --git a/x-pack/legacy/plugins/spaces/public/advanced_settings/advanced_settings_service.test.tsx b/x-pack/legacy/plugins/spaces/public/advanced_settings/advanced_settings_service.test.tsx index aa3c6acf262361..3c6b2332bbbdc9 100644 --- a/x-pack/legacy/plugins/spaces/public/advanced_settings/advanced_settings_service.test.tsx +++ b/x-pack/legacy/plugins/spaces/public/advanced_settings/advanced_settings_service.test.tsx @@ -5,33 +5,30 @@ */ import { AdvancedSettingsService } from './advanced_settings_service'; -jest.mock('ui/management', () => { - return { - PAGE_TITLE_COMPONENT: 'page_title_component', - PAGE_SUBTITLE_COMPONENT: 'page_subtitle_component', - }; -}); +import { advancedSettingsMock } from '../../../../../../src/plugins/advanced_settings/public/mocks'; + +const componentRegistryMock = advancedSettingsMock.createSetupContract(); describe('Advanced Settings Service', () => { describe('#setup', () => { it('registers space-aware components to augment the advanced settings screen', () => { const deps = { getActiveSpace: jest.fn().mockResolvedValue({ id: 'foo', name: 'foo-space' }), - registerSettingsComponent: jest.fn(), + componentRegistry: componentRegistryMock, }; const advancedSettingsService = new AdvancedSettingsService(); advancedSettingsService.setup(deps); - expect(deps.registerSettingsComponent).toHaveBeenCalledTimes(2); - expect(deps.registerSettingsComponent).toHaveBeenCalledWith( - 'page_title_component', + expect(deps.componentRegistry.register).toHaveBeenCalledTimes(2); + expect(deps.componentRegistry.register).toHaveBeenCalledWith( + componentRegistryMock.componentType.PAGE_TITLE_COMPONENT, expect.any(Function), true ); - expect(deps.registerSettingsComponent).toHaveBeenCalledWith( - 'page_subtitle_component', + expect(deps.componentRegistry.register).toHaveBeenCalledWith( + componentRegistryMock.componentType.PAGE_SUBTITLE_COMPONENT, expect.any(Function), true ); diff --git a/x-pack/legacy/plugins/spaces/public/advanced_settings/advanced_settings_service.tsx b/x-pack/legacy/plugins/spaces/public/advanced_settings/advanced_settings_service.tsx index 9c6c2fcc2cddac..a1552add18f2de 100644 --- a/x-pack/legacy/plugins/spaces/public/advanced_settings/advanced_settings_service.tsx +++ b/x-pack/legacy/plugins/spaces/public/advanced_settings/advanced_settings_service.tsx @@ -4,25 +4,29 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { PAGE_TITLE_COMPONENT, PAGE_SUBTITLE_COMPONENT } from 'ui/management'; import { Space } from '../../common/model/space'; import { AdvancedSettingsTitle, AdvancedSettingsSubtitle } from './components'; +import { AdvancedSettingsSetup } from '../../../../../../src/plugins/advanced_settings/public'; interface SetupDeps { getActiveSpace: () => Promise; - registerSettingsComponent: ( - id: string, - component: string | React.FC, - allowOverride: boolean - ) => void; + componentRegistry: AdvancedSettingsSetup['component']; } export class AdvancedSettingsService { - public setup({ getActiveSpace, registerSettingsComponent }: SetupDeps) { + public setup({ getActiveSpace, componentRegistry }: SetupDeps) { const PageTitle = () => ; const SubTitle = () => ; - registerSettingsComponent(PAGE_TITLE_COMPONENT, PageTitle, true); - registerSettingsComponent(PAGE_SUBTITLE_COMPONENT, SubTitle, true); + componentRegistry.register( + componentRegistry.componentType.PAGE_TITLE_COMPONENT, + PageTitle, + true + ); + componentRegistry.register( + componentRegistry.componentType.PAGE_SUBTITLE_COMPONENT, + SubTitle, + true + ); } } diff --git a/x-pack/legacy/plugins/spaces/public/legacy.ts b/x-pack/legacy/plugins/spaces/public/legacy.ts index 1dffbd26617144..200cae5498595d 100644 --- a/x-pack/legacy/plugins/spaces/public/legacy.ts +++ b/x-pack/legacy/plugins/spaces/public/legacy.ts @@ -4,7 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerSettingsComponent } from 'ui/management'; import { npSetup, npStart } from 'ui/new_platform'; import { setup as managementSetup } from '../../../../../src/legacy/core_plugins/management/public/legacy'; import { plugin } from '.'; @@ -16,9 +15,7 @@ const spacesPlugin: SpacesPlugin = plugin(); const pluginsSetup: PluginsSetup = { home: npSetup.plugins.home, management: managementSetup, - __managementLegacyCompat: { - registerSettingsComponent, - }, + advancedSettings: npSetup.plugins.advancedSettings, }; const pluginsStart: PluginsStart = { diff --git a/x-pack/legacy/plugins/spaces/public/plugin.tsx b/x-pack/legacy/plugins/spaces/public/plugin.tsx index 1ddb69a5b595cc..e6271ac3a0a702 100644 --- a/x-pack/legacy/plugins/spaces/public/plugin.tsx +++ b/x-pack/legacy/plugins/spaces/public/plugin.tsx @@ -8,6 +8,7 @@ import { CoreSetup, CoreStart, Plugin } from 'src/core/public'; import { HomePublicPluginSetup } from 'src/plugins/home/public'; import { ManagementSetup } from 'src/legacy/core_plugins/management/public'; import { ManagementStart } from 'src/plugins/management/public'; +import { AdvancedSettingsSetup } from 'src/plugins/advanced_settings/public'; import { SpacesManager } from './spaces_manager'; import { initSpacesNavControl } from './nav_control'; import { createSpacesFeatureCatalogueEntry } from './create_feature_catalogue_entry'; @@ -22,13 +23,7 @@ export interface SpacesPluginStart { export interface PluginsSetup { home?: HomePublicPluginSetup; management: ManagementSetup; - __managementLegacyCompat: { - registerSettingsComponent: ( - id: string, - component: string | React.FC, - allowOverride: boolean - ) => void; - }; + advancedSettings: AdvancedSettingsSetup; } export interface PluginsStart { @@ -53,7 +48,7 @@ export class SpacesPlugin implements Plugin this.spacesManager.getActiveSpace(), - registerSettingsComponent: plugins.__managementLegacyCompat.registerSettingsComponent, + componentRegistry: plugins.advancedSettings.component, }); if (plugins.home) { diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index abf56cd2d05b69..58d97ce263bea6 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -1624,7 +1624,7 @@ "kbn.management.settings.form.clearSearchResultText": "(検索結果を消去)", "kbn.management.settings.form.noSearchResultText": "設定が見つかりませんでした {clearSearch}", "kbn.management.settings.form.searchResultText": "検索用語により {settingsCount} 件の設定が非表示になっています {clearSearch}", - "kbn.management.settings.pageTitle": "設定", + "advancedSettings.pageTitle": "設定", "kbn.management.settings.searchBar.unableToParseQueryErrorMessage": "クエリをパースできません", "kbn.management.settings.searchBarAriaLabel": "高度な設定を検索", "kbn.management.settings.sectionLabel": "高度な設定", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index b97982b5c99dae..5d62e15be2b9f3 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -1624,7 +1624,7 @@ "kbn.management.settings.form.clearSearchResultText": "(清除搜索)", "kbn.management.settings.form.noSearchResultText": "未找到设置{clearSearch}", "kbn.management.settings.form.searchResultText": "搜索词隐藏了 {settingsCount} 个设置{clearSearch}", - "kbn.management.settings.pageTitle": "设置", + "advancedSettings.pageTitle": "设置", "kbn.management.settings.searchBar.unableToParseQueryErrorMessage": "无法解析查询", "kbn.management.settings.searchBarAriaLabel": "搜索高级设置", "kbn.management.settings.sectionLabel": "高级设置", From 74768e567ba7b66496002c401ad0a9be3b69e334 Mon Sep 17 00:00:00 2001 From: Tyler Smalley Date: Tue, 4 Feb 2020 11:49:38 -0800 Subject: [PATCH 08/22] Bumps terser-webpack-plugin to 2.3.4 (#56662) We're seeing occasional "Error: Call retries were exceeded" exception with Terser, which should be resolved by https://github.com/webpack-contrib/terser-webpack-plugin/commit/abfd9506207cf392de63a0629de82145efff2361, first included in 2.3.4 Signed-off-by: Tyler Smalley --- package.json | 2 +- packages/kbn-pm/dist/index.js | 21114 ++++++++++++++++++-------------- yarn.lock | 221 +- 3 files changed, 11897 insertions(+), 9440 deletions(-) diff --git a/package.json b/package.json index f9a3bfd99b1098..c9376e974492af 100644 --- a/package.json +++ b/package.json @@ -262,7 +262,7 @@ "style-loader": "0.23.1", "symbol-observable": "^1.2.0", "tar": "4.4.13", - "terser-webpack-plugin": "^2.1.2", + "terser-webpack-plugin": "^2.3.4", "thread-loader": "^2.1.3", "tinygradient": "0.4.3", "tinymath": "1.2.1", diff --git a/packages/kbn-pm/dist/index.js b/packages/kbn-pm/dist/index.js index 8bded9d403c215..8d17d285dce21d 100644 --- a/packages/kbn-pm/dist/index.js +++ b/packages/kbn-pm/dist/index.js @@ -94,7 +94,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _cli__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "run", function() { return _cli__WEBPACK_IMPORTED_MODULE_0__["run"]; }); -/* harmony import */ var _production__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(703); +/* harmony import */ var _production__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(705); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "buildProductionProjects", function() { return _production__WEBPACK_IMPORTED_MODULE_1__["buildProductionProjects"]; }); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "prepareExternalProjectDependencies", function() { return _production__WEBPACK_IMPORTED_MODULE_1__["prepareExternalProjectDependencies"]; }); @@ -152,7 +152,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(16); /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_3__); /* harmony import */ var _commands__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(17); -/* harmony import */ var _run__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(689); +/* harmony import */ var _run__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(690); /* harmony import */ var _utils_log__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(34); /* * Licensed to Elasticsearch B.V. under one or more contributor @@ -2507,8 +2507,8 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commands", function() { return commands; }); /* harmony import */ var _bootstrap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(18); /* harmony import */ var _clean__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(587); -/* harmony import */ var _run__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(686); -/* harmony import */ var _watch__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(687); +/* harmony import */ var _run__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(687); +/* harmony import */ var _watch__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(688); /* * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with @@ -46624,9 +46624,11 @@ function range(a, b, str) { try { var util = __webpack_require__(29); + /* istanbul ignore next */ if (typeof util.inherits !== 'function') throw ''; module.exports = util.inherits; } catch (e) { + /* istanbul ignore next */ module.exports = __webpack_require__(510); } @@ -46638,24 +46640,28 @@ try { if (typeof Object.create === 'function') { // implementation from standard node.js 'util' module module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true - } - }); + if (superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }) + } }; } else { // old school shim for old browsers module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - var TempCtor = function () {} - TempCtor.prototype = superCtor.prototype - ctor.prototype = new TempCtor() - ctor.prototype.constructor = ctor + if (superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } } } @@ -68970,7 +68976,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var del__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(588); /* harmony import */ var del__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(del__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var ora__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(675); +/* harmony import */ var ora__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(676); /* harmony import */ var ora__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(ora__WEBPACK_IMPORTED_MODULE_2__); /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(16); /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_3__); @@ -69078,13 +69084,13 @@ const CleanCommand = { const {promisify} = __webpack_require__(29); const path = __webpack_require__(16); const globby = __webpack_require__(589); -const isGlob = __webpack_require__(601); -const slash = __webpack_require__(662); -const gracefulFs = __webpack_require__(664); -const isPathCwd = __webpack_require__(668); -const isPathInside = __webpack_require__(669); -const rimraf = __webpack_require__(670); -const pMap = __webpack_require__(671); +const isGlob = __webpack_require__(606); +const slash = __webpack_require__(667); +const gracefulFs = __webpack_require__(22); +const isPathCwd = __webpack_require__(669); +const isPathInside = __webpack_require__(670); +const rimraf = __webpack_require__(671); +const pMap = __webpack_require__(672); const rimrafP = promisify(rimraf); @@ -69206,11 +69212,11 @@ module.exports.sync = (patterns, {force, dryRun, cwd = process.cwd(), ...options const fs = __webpack_require__(23); const arrayUnion = __webpack_require__(590); const merge2 = __webpack_require__(591); -const glob = __webpack_require__(502); -const fastGlob = __webpack_require__(592); -const dirGlob = __webpack_require__(658); -const gitignore = __webpack_require__(660); -const {FilterStream, UniqueStream} = __webpack_require__(663); +const glob = __webpack_require__(592); +const fastGlob = __webpack_require__(597); +const dirGlob = __webpack_require__(663); +const gitignore = __webpack_require__(665); +const {FilterStream, UniqueStream} = __webpack_require__(668); const DEFAULT_FILTER = () => false; @@ -69512,5704 +69518,7286 @@ function pauseStreams (streams, options) { /* 592 */ /***/ (function(module, exports, __webpack_require__) { -"use strict"; - -const taskManager = __webpack_require__(593); -const async_1 = __webpack_require__(621); -const stream_1 = __webpack_require__(654); -const sync_1 = __webpack_require__(655); -const settings_1 = __webpack_require__(657); -const utils = __webpack_require__(594); -function FastGlob(source, options) { - try { - assertPatternsInput(source); - } - catch (error) { - return Promise.reject(error); - } - const works = getWorks(source, async_1.default, options); - return Promise.all(works).then(utils.array.flatten); -} -(function (FastGlob) { - function sync(source, options) { - assertPatternsInput(source); - const works = getWorks(source, sync_1.default, options); - return utils.array.flatten(works); - } - FastGlob.sync = sync; - function stream(source, options) { - assertPatternsInput(source); - const works = getWorks(source, stream_1.default, options); - /** - * The stream returned by the provider cannot work with an asynchronous iterator. - * To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams. - * This affects performance (+25%). I don't see best solution right now. - */ - return utils.stream.merge(works); - } - FastGlob.stream = stream; - function generateTasks(source, options) { - assertPatternsInput(source); - const patterns = [].concat(source); - const settings = new settings_1.default(options); - return taskManager.generate(patterns, settings); - } - FastGlob.generateTasks = generateTasks; -})(FastGlob || (FastGlob = {})); -function getWorks(source, _Provider, options) { - const patterns = [].concat(source); - const settings = new settings_1.default(options); - const tasks = taskManager.generate(patterns, settings); - const provider = new _Provider(settings); - return tasks.map(provider.read, provider); -} -function assertPatternsInput(source) { - if ([].concat(source).every(isString)) { - return; - } - throw new TypeError('Patterns must be a string or an array of strings'); -} -function isString(source) { - /* tslint:disable-next-line strict-type-predicates */ - return typeof source === 'string'; -} -module.exports = FastGlob; +// Approach: +// +// 1. Get the minimatch set +// 2. For each pattern in the set, PROCESS(pattern, false) +// 3. Store matches per-set, then uniq them +// +// PROCESS(pattern, inGlobStar) +// Get the first [n] items from pattern that are all strings +// Join these together. This is PREFIX. +// If there is no more remaining, then stat(PREFIX) and +// add to matches if it succeeds. END. +// +// If inGlobStar and PREFIX is symlink and points to dir +// set ENTRIES = [] +// else readdir(PREFIX) as ENTRIES +// If fail, END +// +// with ENTRIES +// If pattern[n] is GLOBSTAR +// // handle the case where the globstar match is empty +// // by pruning it out, and testing the resulting pattern +// PROCESS(pattern[0..n] + pattern[n+1 .. $], false) +// // handle other cases. +// for ENTRY in ENTRIES (not dotfiles) +// // attach globstar + tail onto the entry +// // Mark that this entry is a globstar match +// PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true) +// +// else // not globstar +// for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot) +// Test ENTRY against pattern[n] +// If fails, continue +// If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $]) +// +// Caveat: +// Cache all stats and readdirs results to minimize syscall. Since all +// we ever care about is existence and directory-ness, we can just keep +// `true` for files, and [children,...] for directories, or `false` for +// things that don't exist. +module.exports = glob -/***/ }), -/* 593 */ -/***/ (function(module, exports, __webpack_require__) { +var fs = __webpack_require__(23) +var rp = __webpack_require__(503) +var minimatch = __webpack_require__(505) +var Minimatch = minimatch.Minimatch +var inherits = __webpack_require__(593) +var EE = __webpack_require__(379).EventEmitter +var path = __webpack_require__(16) +var assert = __webpack_require__(30) +var isAbsolute = __webpack_require__(511) +var globSync = __webpack_require__(595) +var common = __webpack_require__(596) +var alphasort = common.alphasort +var alphasorti = common.alphasorti +var setopts = common.setopts +var ownProp = common.ownProp +var inflight = __webpack_require__(514) +var util = __webpack_require__(29) +var childrenIgnored = common.childrenIgnored +var isIgnored = common.isIgnored -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const utils = __webpack_require__(594); -function generate(patterns, settings) { - const positivePatterns = getPositivePatterns(patterns); - const negativePatterns = getNegativePatternsAsPositive(patterns, settings.ignore); - /** - * When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check - * filepath directly (without read directory). - */ - const staticPatterns = !settings.caseSensitiveMatch ? [] : positivePatterns.filter(utils.pattern.isStaticPattern); - const dynamicPatterns = !settings.caseSensitiveMatch ? positivePatterns : positivePatterns.filter(utils.pattern.isDynamicPattern); - const staticTasks = convertPatternsToTasks(staticPatterns, negativePatterns, /* dynamic */ false); - const dynamicTasks = convertPatternsToTasks(dynamicPatterns, negativePatterns, /* dynamic */ true); - return staticTasks.concat(dynamicTasks); -} -exports.generate = generate; -function convertPatternsToTasks(positive, negative, dynamic) { - const positivePatternsGroup = groupPatternsByBaseDirectory(positive); - // When we have a global group – there is no reason to divide the patterns into independent tasks. - // In this case, the global task covers the rest. - if ('.' in positivePatternsGroup) { - const task = convertPatternGroupToTask('.', positive, negative, dynamic); - return [task]; - } - return convertPatternGroupsToTasks(positivePatternsGroup, negative, dynamic); -} -exports.convertPatternsToTasks = convertPatternsToTasks; -function getPositivePatterns(patterns) { - return utils.pattern.getPositivePatterns(patterns); -} -exports.getPositivePatterns = getPositivePatterns; -function getNegativePatternsAsPositive(patterns, ignore) { - const negative = utils.pattern.getNegativePatterns(patterns).concat(ignore); - const positive = negative.map(utils.pattern.convertToPositivePattern); - return positive; -} -exports.getNegativePatternsAsPositive = getNegativePatternsAsPositive; -function groupPatternsByBaseDirectory(patterns) { - return patterns.reduce((collection, pattern) => { - const base = utils.pattern.getBaseDirectory(pattern); - if (base in collection) { - collection[base].push(pattern); - } - else { - collection[base] = [pattern]; - } - return collection; - }, {}); -} -exports.groupPatternsByBaseDirectory = groupPatternsByBaseDirectory; -function convertPatternGroupsToTasks(positive, negative, dynamic) { - return Object.keys(positive).map((base) => { - return convertPatternGroupToTask(base, positive[base], negative, dynamic); - }); -} -exports.convertPatternGroupsToTasks = convertPatternGroupsToTasks; -function convertPatternGroupToTask(base, positive, negative, dynamic) { - return { - dynamic, - positive, - negative, - base, - patterns: [].concat(positive, negative.map(utils.pattern.convertToNegativePattern)) - }; -} -exports.convertPatternGroupToTask = convertPatternGroupToTask; +var once = __webpack_require__(385) +function glob (pattern, options, cb) { + if (typeof options === 'function') cb = options, options = {} + if (!options) options = {} -/***/ }), -/* 594 */ -/***/ (function(module, exports, __webpack_require__) { + if (options.sync) { + if (cb) + throw new TypeError('callback provided to sync glob') + return globSync(pattern, options) + } -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const array = __webpack_require__(595); -exports.array = array; -const errno = __webpack_require__(596); -exports.errno = errno; -const fs = __webpack_require__(597); -exports.fs = fs; -const path = __webpack_require__(598); -exports.path = path; -const pattern = __webpack_require__(599); -exports.pattern = pattern; -const stream = __webpack_require__(620); -exports.stream = stream; + return new Glob(pattern, options, cb) +} +glob.sync = globSync +var GlobSync = glob.GlobSync = globSync.GlobSync -/***/ }), -/* 595 */ -/***/ (function(module, exports, __webpack_require__) { +// old api surface +glob.glob = glob -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -function flatten(items) { - return items.reduce((collection, item) => [].concat(collection, item), []); -} -exports.flatten = flatten; +function extend (origin, add) { + if (add === null || typeof add !== 'object') { + return origin + } + var keys = Object.keys(add) + var i = keys.length + while (i--) { + origin[keys[i]] = add[keys[i]] + } + return origin +} -/***/ }), -/* 596 */ -/***/ (function(module, exports, __webpack_require__) { +glob.hasMagic = function (pattern, options_) { + var options = extend({}, options_) + options.noprocess = true -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -function isEnoentCodeError(error) { - return error.code === 'ENOENT'; -} -exports.isEnoentCodeError = isEnoentCodeError; + var g = new Glob(pattern, options) + var set = g.minimatch.set + if (!pattern) + return false -/***/ }), -/* 597 */ -/***/ (function(module, exports, __webpack_require__) { + if (set.length > 1) + return true -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -class DirentFromStats { - constructor(name, stats) { - this.name = name; - this.isBlockDevice = stats.isBlockDevice.bind(stats); - this.isCharacterDevice = stats.isCharacterDevice.bind(stats); - this.isDirectory = stats.isDirectory.bind(stats); - this.isFIFO = stats.isFIFO.bind(stats); - this.isFile = stats.isFile.bind(stats); - this.isSocket = stats.isSocket.bind(stats); - this.isSymbolicLink = stats.isSymbolicLink.bind(stats); - } -} -function createDirentFromStats(name, stats) { - return new DirentFromStats(name, stats); -} -exports.createDirentFromStats = createDirentFromStats; + for (var j = 0; j < set[0].length; j++) { + if (typeof set[0][j] !== 'string') + return true + } + return false +} -/***/ }), -/* 598 */ -/***/ (function(module, exports, __webpack_require__) { +glob.Glob = Glob +inherits(Glob, EE) +function Glob (pattern, options, cb) { + if (typeof options === 'function') { + cb = options + options = null + } -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const path = __webpack_require__(16); -/** - * Designed to work only with simple paths: `dir\\file`. - */ -function unixify(filepath) { - return filepath.replace(/\\/g, '/'); -} -exports.unixify = unixify; -function makeAbsolute(cwd, filepath) { - return path.resolve(cwd, filepath); -} -exports.makeAbsolute = makeAbsolute; + if (options && options.sync) { + if (cb) + throw new TypeError('callback provided to sync glob') + return new GlobSync(pattern, options) + } + if (!(this instanceof Glob)) + return new Glob(pattern, options, cb) -/***/ }), -/* 599 */ -/***/ (function(module, exports, __webpack_require__) { + setopts(this, pattern, options) + this._didRealPath = false -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const path = __webpack_require__(16); -const globParent = __webpack_require__(600); -const isGlob = __webpack_require__(601); -const micromatch = __webpack_require__(603); -const GLOBSTAR = '**'; -function isStaticPattern(pattern) { - return !isDynamicPattern(pattern); -} -exports.isStaticPattern = isStaticPattern; -function isDynamicPattern(pattern) { - return isGlob(pattern, { strict: false }); -} -exports.isDynamicPattern = isDynamicPattern; -function convertToPositivePattern(pattern) { - return isNegativePattern(pattern) ? pattern.slice(1) : pattern; -} -exports.convertToPositivePattern = convertToPositivePattern; -function convertToNegativePattern(pattern) { - return '!' + pattern; -} -exports.convertToNegativePattern = convertToNegativePattern; -function isNegativePattern(pattern) { - return pattern.startsWith('!') && pattern[1] !== '('; -} -exports.isNegativePattern = isNegativePattern; -function isPositivePattern(pattern) { - return !isNegativePattern(pattern); -} -exports.isPositivePattern = isPositivePattern; -function getNegativePatterns(patterns) { - return patterns.filter(isNegativePattern); -} -exports.getNegativePatterns = getNegativePatterns; -function getPositivePatterns(patterns) { - return patterns.filter(isPositivePattern); -} -exports.getPositivePatterns = getPositivePatterns; -function getBaseDirectory(pattern) { - return globParent(pattern); -} -exports.getBaseDirectory = getBaseDirectory; -function hasGlobStar(pattern) { - return pattern.indexOf(GLOBSTAR) !== -1; -} -exports.hasGlobStar = hasGlobStar; -function endsWithSlashGlobStar(pattern) { - return pattern.endsWith('/' + GLOBSTAR); -} -exports.endsWithSlashGlobStar = endsWithSlashGlobStar; -function isAffectDepthOfReadingPattern(pattern) { - const basename = path.basename(pattern); - return endsWithSlashGlobStar(pattern) || isStaticPattern(basename); -} -exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern; -function getNaiveDepth(pattern) { - const base = getBaseDirectory(pattern); - const patternDepth = pattern.split('/').length; - const patternBaseDepth = base.split('/').length; - /** - * This is a hack for pattern that has no base directory. - * - * This is related to the `*\something\*` pattern. - */ - if (base === '.') { - return patternDepth - patternBaseDepth; - } - return patternDepth - patternBaseDepth - 1; -} -exports.getNaiveDepth = getNaiveDepth; -function getMaxNaivePatternsDepth(patterns) { - return patterns.reduce((max, pattern) => { - const depth = getNaiveDepth(pattern); - return depth > max ? depth : max; - }, 0); -} -exports.getMaxNaivePatternsDepth = getMaxNaivePatternsDepth; -function makeRe(pattern, options) { - return micromatch.makeRe(pattern, options); -} -exports.makeRe = makeRe; -function convertPatternsToRe(patterns, options) { - return patterns.map((pattern) => makeRe(pattern, options)); -} -exports.convertPatternsToRe = convertPatternsToRe; -function matchAny(entry, patternsRe) { - const filepath = entry.replace(/^\.[\\\/]/, ''); - return patternsRe.some((patternRe) => patternRe.test(filepath)); -} -exports.matchAny = matchAny; + // process each pattern in the minimatch set + var n = this.minimatch.set.length + // The matches are stored as {: true,...} so that + // duplicates are automagically pruned. + // Later, we do an Object.keys() on these. + // Keep them as a list so we can fill in when nonull is set. + this.matches = new Array(n) -/***/ }), -/* 600 */ -/***/ (function(module, exports, __webpack_require__) { + if (typeof cb === 'function') { + cb = once(cb) + this.on('error', cb) + this.on('end', function (matches) { + cb(null, matches) + }) + } -"use strict"; + var self = this + this._processing = 0 + this._emitQueue = [] + this._processQueue = [] + this.paused = false -var isGlob = __webpack_require__(601); -var pathPosixDirname = __webpack_require__(16).posix.dirname; -var isWin32 = __webpack_require__(11).platform() === 'win32'; + if (this.noprocess) + return this -var slash = '/'; -var backslash = /\\/g; -var enclosure = /[\{\[].*[\/]*.*[\}\]]$/; -var globby = /(^|[^\\])([\{\[]|\([^\)]+$)/; -var escaped = /\\([\*\?\|\[\]\(\)\{\}])/g; + if (n === 0) + return done() -module.exports = function globParent(str) { - // flip windows path separators - if (isWin32 && str.indexOf(slash) < 0) { - str = str.replace(backslash, slash); + var sync = true + for (var i = 0; i < n; i ++) { + this._process(this.minimatch.set[i], i, false, done) } + sync = false - // special case for strings ending in enclosure containing path separator - if (enclosure.test(str)) { - str += slash; + function done () { + --self._processing + if (self._processing <= 0) { + if (sync) { + process.nextTick(function () { + self._finish() + }) + } else { + self._finish() + } + } } +} - // preserves full path in case of trailing path separator - str += 'a'; - - // remove path parts that are globby - do { - str = pathPosixDirname(str); - } while (isGlob(str) || globby.test(str)); +Glob.prototype._finish = function () { + assert(this instanceof Glob) + if (this.aborted) + return - // remove escape chars and return result - return str.replace(escaped, '$1'); -}; + if (this.realpath && !this._didRealpath) + return this._realpath() + common.finish(this) + this.emit('end', this.found) +} -/***/ }), -/* 601 */ -/***/ (function(module, exports, __webpack_require__) { +Glob.prototype._realpath = function () { + if (this._didRealpath) + return -/*! - * is-glob - * - * Copyright (c) 2014-2017, Jon Schlinkert. - * Released under the MIT License. - */ + this._didRealpath = true -var isExtglob = __webpack_require__(602); -var chars = { '{': '}', '(': ')', '[': ']'}; -var strictRegex = /\\(.)|(^!|\*|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\))/; -var relaxedRegex = /\\(.)|(^!|[*?{}()[\]]|\(\?)/; + var n = this.matches.length + if (n === 0) + return this._finish() -module.exports = function isGlob(str, options) { - if (typeof str !== 'string' || str === '') { - return false; - } + var self = this + for (var i = 0; i < this.matches.length; i++) + this._realpathSet(i, next) - if (isExtglob(str)) { - return true; + function next () { + if (--n === 0) + self._finish() } +} - var regex = strictRegex; - var match; +Glob.prototype._realpathSet = function (index, cb) { + var matchset = this.matches[index] + if (!matchset) + return cb() - // optionally relax regex - if (options && options.strict === false) { - regex = relaxedRegex; - } + var found = Object.keys(matchset) + var self = this + var n = found.length - while ((match = regex.exec(str))) { - if (match[2]) return true; - var idx = match.index + match[0].length; + if (n === 0) + return cb() - // if an open bracket/brace/paren is escaped, - // set the index to the next closing character - var open = match[1]; - var close = open ? chars[open] : null; - if (open && close) { - var n = str.indexOf(close, idx); - if (n !== -1) { - idx = n + 1; + var set = this.matches[index] = Object.create(null) + found.forEach(function (p, i) { + // If there's a problem with the stat, then it means that + // one or more of the links in the realpath couldn't be + // resolved. just return the abs value in that case. + p = self._makeAbs(p) + rp.realpath(p, self.realpathCache, function (er, real) { + if (!er) + set[real] = true + else if (er.syscall === 'stat') + set[p] = true + else + self.emit('error', er) // srsly wtf right here + + if (--n === 0) { + self.matches[index] = set + cb() } - } + }) + }) +} - str = str.slice(idx); - } - return false; -}; +Glob.prototype._mark = function (p) { + return common.mark(this, p) +} +Glob.prototype._makeAbs = function (f) { + return common.makeAbs(this, f) +} -/***/ }), -/* 602 */ -/***/ (function(module, exports) { +Glob.prototype.abort = function () { + this.aborted = true + this.emit('abort') +} -/*! - * is-extglob - * - * Copyright (c) 2014-2016, Jon Schlinkert. - * Licensed under the MIT License. - */ +Glob.prototype.pause = function () { + if (!this.paused) { + this.paused = true + this.emit('pause') + } +} -module.exports = function isExtglob(str) { - if (typeof str !== 'string' || str === '') { - return false; +Glob.prototype.resume = function () { + if (this.paused) { + this.emit('resume') + this.paused = false + if (this._emitQueue.length) { + var eq = this._emitQueue.slice(0) + this._emitQueue.length = 0 + for (var i = 0; i < eq.length; i ++) { + var e = eq[i] + this._emitMatch(e[0], e[1]) + } + } + if (this._processQueue.length) { + var pq = this._processQueue.slice(0) + this._processQueue.length = 0 + for (var i = 0; i < pq.length; i ++) { + var p = pq[i] + this._processing-- + this._process(p[0], p[1], p[2], p[3]) + } + } } +} - var match; - while ((match = /(\\).|([@?!+*]\(.*\))/g.exec(str))) { - if (match[2]) return true; - str = str.slice(match.index + match[0].length); +Glob.prototype._process = function (pattern, index, inGlobStar, cb) { + assert(this instanceof Glob) + assert(typeof cb === 'function') + + if (this.aborted) + return + + this._processing++ + if (this.paused) { + this._processQueue.push([pattern, index, inGlobStar, cb]) + return } - return false; -}; + //console.error('PROCESS %d', this._processing, pattern) + // Get the first [n] parts of pattern that are all strings. + var n = 0 + while (typeof pattern[n] === 'string') { + n ++ + } + // now n is the index of the first one that is *not* a string. -/***/ }), -/* 603 */ -/***/ (function(module, exports, __webpack_require__) { + // see if there's anything else + var prefix + switch (n) { + // if not, then this is rather simple + case pattern.length: + this._processSimple(pattern.join('/'), index, cb) + return -"use strict"; + case 0: + // pattern *starts* with some non-trivial item. + // going to readdir(cwd), but not include the prefix in matches. + prefix = null + break + default: + // pattern has some string bits in the front. + // whatever it starts with, whether that's 'absolute' like /foo/bar, + // or 'relative' like '../baz' + prefix = pattern.slice(0, n).join('/') + break + } -const util = __webpack_require__(29); -const braces = __webpack_require__(604); -const picomatch = __webpack_require__(614); -const utils = __webpack_require__(617); -const isEmptyString = val => typeof val === 'string' && (val === '' || val === './'); + var remain = pattern.slice(n) -/** - * Returns an array of strings that match one or more glob patterns. - * - * ```js - * const mm = require('micromatch'); - * // mm(list, patterns[, options]); - * - * console.log(mm(['a.js', 'a.txt'], ['*.js'])); - * //=> [ 'a.js' ] - * ``` - * @param {String|Array} list List of strings to match. - * @param {String|Array} patterns One or more glob patterns to use for matching. - * @param {Object} options See available [options](#options) - * @return {Array} Returns an array of matches - * @summary false - * @api public - */ + // get the list of entries. + var read + if (prefix === null) + read = '.' + else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) { + if (!prefix || !isAbsolute(prefix)) + prefix = '/' + prefix + read = prefix + } else + read = prefix -const micromatch = (list, patterns, options) => { - patterns = [].concat(patterns); - list = [].concat(list); + var abs = this._makeAbs(read) - let omit = new Set(); - let keep = new Set(); - let items = new Set(); - let negatives = 0; + //if ignored, skip _processing + if (childrenIgnored(this, read)) + return cb() - let onResult = state => { - items.add(state.output); - if (options && options.onResult) { - options.onResult(state); - } - }; + var isGlobStar = remain[0] === minimatch.GLOBSTAR + if (isGlobStar) + this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb) + else + this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb) +} - for (let i = 0; i < patterns.length; i++) { - let isMatch = picomatch(String(patterns[i]), { ...options, onResult }, true); - let negated = isMatch.state.negated || isMatch.state.negatedExtglob; - if (negated) negatives++; +Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) { + var self = this + this._readdir(abs, inGlobStar, function (er, entries) { + return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb) + }) +} - for (let item of list) { - let matched = isMatch(item, true); +Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { - let match = negated ? !matched.isMatch : matched.isMatch; - if (!match) continue; + // if the abs isn't a dir, then nothing can match! + if (!entries) + return cb() - if (negated) { - omit.add(matched.output); + // It will only match dot entries if it starts with a dot, or if + // dot is set. Stuff like @(.foo|.bar) isn't allowed. + var pn = remain[0] + var negate = !!this.minimatch.negate + var rawGlob = pn._glob + var dotOk = this.dot || rawGlob.charAt(0) === '.' + + var matchedEntries = [] + for (var i = 0; i < entries.length; i++) { + var e = entries[i] + if (e.charAt(0) !== '.' || dotOk) { + var m + if (negate && !prefix) { + m = !e.match(pn) } else { - omit.delete(matched.output); - keep.add(matched.output); + m = e.match(pn) } + if (m) + matchedEntries.push(e) } } - let result = negatives === patterns.length ? [...items] : [...keep]; - let matches = result.filter(item => !omit.has(item)); + //console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries) - if (options && matches.length === 0) { - if (options.failglob === true) { - throw new Error(`No matches found for "${patterns.join(', ')}"`); + var len = matchedEntries.length + // If there are no matched entries, then nothing matches. + if (len === 0) + return cb() + + // if this is the last remaining pattern bit, then no need for + // an additional stat *unless* the user has specified mark or + // stat explicitly. We know they exist, since readdir returned + // them. + + if (remain.length === 1 && !this.mark && !this.stat) { + if (!this.matches[index]) + this.matches[index] = Object.create(null) + + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i] + if (prefix) { + if (prefix !== '/') + e = prefix + '/' + e + else + e = prefix + e + } + + if (e.charAt(0) === '/' && !this.nomount) { + e = path.join(this.root, e) + } + this._emitMatch(index, e) } + // This was the last one, and no stats were needed + return cb() + } - if (options.nonull === true || options.nullglob === true) { - return options.unescape ? patterns.map(p => p.replace(/\\/g, '')) : patterns; + // now test all matched entries as stand-ins for that part + // of the pattern. + remain.shift() + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i] + var newPattern + if (prefix) { + if (prefix !== '/') + e = prefix + '/' + e + else + e = prefix + e } + this._process([e].concat(remain), index, inGlobStar, cb) } + cb() +} - return matches; -}; +Glob.prototype._emitMatch = function (index, e) { + if (this.aborted) + return -/** - * Backwards compatibility - */ + if (isIgnored(this, e)) + return -micromatch.match = micromatch; + if (this.paused) { + this._emitQueue.push([index, e]) + return + } -/** - * Returns a matcher function from the given glob `pattern` and `options`. - * The returned function takes a string to match as its only argument and returns - * true if the string is a match. - * - * ```js - * const mm = require('micromatch'); - * // mm.matcher(pattern[, options]); - * - * const isMatch = mm.matcher('*.!(*a)'); - * console.log(isMatch('a.a')); //=> false - * console.log(isMatch('a.b')); //=> true - * ``` - * @param {String} `pattern` Glob pattern - * @param {Object} `options` - * @return {Function} Returns a matcher function. - * @api public - */ + var abs = isAbsolute(e) ? e : this._makeAbs(e) -micromatch.matcher = (pattern, options) => picomatch(pattern, options); + if (this.mark) + e = this._mark(e) -/** - * Returns true if **any** of the given glob `patterns` match the specified `string`. - * - * ```js - * const mm = require('micromatch'); - * // mm.isMatch(string, patterns[, options]); - * - * console.log(mm.isMatch('a.a', ['b.*', '*.a'])); //=> true - * console.log(mm.isMatch('a.a', 'b.*')); //=> false - * ``` - * @param {String} str The string to test. - * @param {String|Array} patterns One or more glob patterns to use for matching. - * @param {Object} [options] See available [options](#options). - * @return {Boolean} Returns true if any patterns match `str` - * @api public - */ + if (this.absolute) + e = abs -micromatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str); + if (this.matches[index][e]) + return -/** - * Backwards compatibility - */ + if (this.nodir) { + var c = this.cache[abs] + if (c === 'DIR' || Array.isArray(c)) + return + } -micromatch.any = micromatch.isMatch; + this.matches[index][e] = true -/** - * Returns a list of strings that _**do not match any**_ of the given `patterns`. - * - * ```js - * const mm = require('micromatch'); - * // mm.not(list, patterns[, options]); - * - * console.log(mm.not(['a.a', 'b.b', 'c.c'], '*.a')); - * //=> ['b.b', 'c.c'] - * ``` - * @param {Array} `list` Array of strings to match. - * @param {String|Array} `patterns` One or more glob pattern to use for matching. - * @param {Object} `options` See available [options](#options) for changing how matches are performed - * @return {Array} Returns an array of strings that **do not match** the given patterns. - * @api public - */ + var st = this.statCache[abs] + if (st) + this.emit('stat', e, st) -micromatch.not = (list, patterns, options = {}) => { - patterns = [].concat(patterns).map(String); - let result = new Set(); - let items = []; + this.emit('match', e) +} - let onResult = state => { - if (options.onResult) options.onResult(state); - items.push(state.output); - }; +Glob.prototype._readdirInGlobStar = function (abs, cb) { + if (this.aborted) + return - let matches = micromatch(list, patterns, { ...options, onResult }); + // follow all symlinked directories forever + // just proceed as if this is a non-globstar situation + if (this.follow) + return this._readdir(abs, false, cb) - for (let item of items) { - if (!matches.includes(item)) { - result.add(item); - } - } - return [...result]; -}; + var lstatkey = 'lstat\0' + abs + var self = this + var lstatcb = inflight(lstatkey, lstatcb_) -/** - * Returns true if the given `string` contains the given pattern. Similar - * to [.isMatch](#isMatch) but the pattern can match any part of the string. - * - * ```js - * var mm = require('micromatch'); - * // mm.contains(string, pattern[, options]); - * - * console.log(mm.contains('aa/bb/cc', '*b')); - * //=> true - * console.log(mm.contains('aa/bb/cc', '*d')); - * //=> false - * ``` - * @param {String} `str` The string to match. - * @param {String|Array} `patterns` Glob pattern to use for matching. - * @param {Object} `options` See available [options](#options) for changing how matches are performed - * @return {Boolean} Returns true if the patter matches any part of `str`. - * @api public - */ + if (lstatcb) + fs.lstat(abs, lstatcb) -micromatch.contains = (str, pattern, options) => { - if (typeof str !== 'string') { - throw new TypeError(`Expected a string: "${util.inspect(str)}"`); + function lstatcb_ (er, lstat) { + if (er && er.code === 'ENOENT') + return cb() + + var isSym = lstat && lstat.isSymbolicLink() + self.symlinks[abs] = isSym + + // If it's not a symlink or a dir, then it's definitely a regular file. + // don't bother doing a readdir in that case. + if (!isSym && lstat && !lstat.isDirectory()) { + self.cache[abs] = 'FILE' + cb() + } else + self._readdir(abs, false, cb) } +} - if (Array.isArray(pattern)) { - return pattern.some(p => micromatch.contains(str, p, options)); +Glob.prototype._readdir = function (abs, inGlobStar, cb) { + if (this.aborted) + return + + cb = inflight('readdir\0'+abs+'\0'+inGlobStar, cb) + if (!cb) + return + + //console.error('RD %j %j', +inGlobStar, abs) + if (inGlobStar && !ownProp(this.symlinks, abs)) + return this._readdirInGlobStar(abs, cb) + + if (ownProp(this.cache, abs)) { + var c = this.cache[abs] + if (!c || c === 'FILE') + return cb() + + if (Array.isArray(c)) + return cb(null, c) } - if (typeof pattern === 'string') { - if (isEmptyString(str) || isEmptyString(pattern)) { - return false; - } + var self = this + fs.readdir(abs, readdirCb(this, abs, cb)) +} - if (str.includes(pattern) || (str.startsWith('./') && str.slice(2).includes(pattern))) { - return true; - } +function readdirCb (self, abs, cb) { + return function (er, entries) { + if (er) + self._readdirError(abs, er, cb) + else + self._readdirEntries(abs, entries, cb) } +} - return micromatch.isMatch(str, pattern, { ...options, contains: true }); -}; +Glob.prototype._readdirEntries = function (abs, entries, cb) { + if (this.aborted) + return -/** - * Filter the keys of the given object with the given `glob` pattern - * and `options`. Does not attempt to match nested keys. If you need this feature, - * use [glob-object][] instead. - * - * ```js - * const mm = require('micromatch'); - * // mm.matchKeys(object, patterns[, options]); - * - * const obj = { aa: 'a', ab: 'b', ac: 'c' }; - * console.log(mm.matchKeys(obj, '*b')); - * //=> { ab: 'b' } - * ``` - * @param {Object} `object` The object with keys to filter. - * @param {String|Array} `patterns` One or more glob patterns to use for matching. - * @param {Object} `options` See available [options](#options) for changing how matches are performed - * @return {Object} Returns an object with only keys that match the given patterns. - * @api public - */ - -micromatch.matchKeys = (obj, patterns, options) => { - if (!utils.isObject(obj)) { - throw new TypeError('Expected the first argument to be an object'); + // if we haven't asked to stat everything, then just + // assume that everything in there exists, so we can avoid + // having to stat it a second time. + if (!this.mark && !this.stat) { + for (var i = 0; i < entries.length; i ++) { + var e = entries[i] + if (abs === '/') + e = abs + e + else + e = abs + '/' + e + this.cache[e] = true + } } - let keys = micromatch(Object.keys(obj), patterns, options); - let res = {}; - for (let key of keys) res[key] = obj[key]; - return res; -}; - -/** - * Returns true if some of the strings in the given `list` match any of the given glob `patterns`. - * - * ```js - * const mm = require('micromatch'); - * // mm.some(list, patterns[, options]); - * - * console.log(mm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js'])); - * // true - * console.log(mm.some(['foo.js'], ['*.js', '!foo.js'])); - * // false - * ``` - * @param {String|Array} `list` The string or array of strings to test. Returns as soon as the first match is found. - * @param {String|Array} `patterns` One or more glob patterns to use for matching. - * @param {Object} `options` See available [options](#options) for changing how matches are performed - * @return {Boolean} Returns true if any patterns match `str` - * @api public - */ -micromatch.some = (list, patterns, options) => { - let items = [].concat(list); + this.cache[abs] = entries + return cb(null, entries) +} - for (let pattern of [].concat(patterns)) { - let isMatch = picomatch(String(pattern), options); - if (items.some(item => isMatch(item))) { - return true; - } - } - return false; -}; +Glob.prototype._readdirError = function (f, er, cb) { + if (this.aborted) + return -/** - * Returns true if every string in the given `list` matches - * any of the given glob `patterns`. - * - * ```js - * const mm = require('micromatch'); - * // mm.every(list, patterns[, options]); - * - * console.log(mm.every('foo.js', ['foo.js'])); - * // true - * console.log(mm.every(['foo.js', 'bar.js'], ['*.js'])); - * // true - * console.log(mm.every(['foo.js', 'bar.js'], ['*.js', '!foo.js'])); - * // false - * console.log(mm.every(['foo.js'], ['*.js', '!foo.js'])); - * // false - * ``` - * @param {String|Array} `list` The string or array of strings to test. - * @param {String|Array} `patterns` One or more glob patterns to use for matching. - * @param {Object} `options` See available [options](#options) for changing how matches are performed - * @return {Boolean} Returns true if any patterns match `str` - * @api public - */ + // handle errors, and cache the information + switch (er.code) { + case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205 + case 'ENOTDIR': // totally normal. means it *does* exist. + var abs = this._makeAbs(f) + this.cache[abs] = 'FILE' + if (abs === this.cwdAbs) { + var error = new Error(er.code + ' invalid cwd ' + this.cwd) + error.path = this.cwd + error.code = er.code + this.emit('error', error) + this.abort() + } + break -micromatch.every = (list, patterns, options) => { - let items = [].concat(list); + case 'ENOENT': // not terribly unusual + case 'ELOOP': + case 'ENAMETOOLONG': + case 'UNKNOWN': + this.cache[this._makeAbs(f)] = false + break - for (let pattern of [].concat(patterns)) { - let isMatch = picomatch(String(pattern), options); - if (!items.every(item => isMatch(item))) { - return false; - } + default: // some unusual error. Treat as failure. + this.cache[this._makeAbs(f)] = false + if (this.strict) { + this.emit('error', er) + // If the error is handled, then we abort + // if not, we threw out of here + this.abort() + } + if (!this.silent) + console.error('glob error', er) + break } - return true; -}; -/** - * Returns true if **all** of the given `patterns` match - * the specified string. - * - * ```js - * const mm = require('micromatch'); - * // mm.all(string, patterns[, options]); - * - * console.log(mm.all('foo.js', ['foo.js'])); - * // true - * - * console.log(mm.all('foo.js', ['*.js', '!foo.js'])); - * // false - * - * console.log(mm.all('foo.js', ['*.js', 'foo.js'])); - * // true - * - * console.log(mm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js'])); - * // true - * ``` - * @param {String|Array} `str` The string to test. - * @param {String|Array} `patterns` One or more glob patterns to use for matching. - * @param {Object} `options` See available [options](#options) for changing how matches are performed - * @return {Boolean} Returns true if any patterns match `str` - * @api public - */ + return cb() +} -micromatch.all = (str, patterns, options) => { - if (typeof str !== 'string') { - throw new TypeError(`Expected a string: "${util.inspect(str)}"`); - } +Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) { + var self = this + this._readdir(abs, inGlobStar, function (er, entries) { + self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb) + }) +} - return [].concat(patterns).every(p => picomatch(p, options)(str)); -}; -/** - * Returns an array of matches captured by `pattern` in `string, or `null` if the pattern did not match. - * - * ```js - * const mm = require('micromatch'); - * // mm.capture(pattern, string[, options]); - * - * console.log(mm.capture('test/*.js', 'test/foo.js')); - * //=> ['foo'] - * console.log(mm.capture('test/*.js', 'foo/bar.css')); - * //=> null - * ``` - * @param {String} `glob` Glob pattern to use for matching. - * @param {String} `input` String to match - * @param {Object} `options` See available [options](#options) for changing how matches are performed - * @return {Boolean} Returns an array of captures if the input matches the glob pattern, otherwise `null`. - * @api public - */ +Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { + //console.error('pgs2', prefix, remain[0], entries) -micromatch.capture = (glob, input, options) => { - let posix = utils.isWindows(options); - let regex = picomatch.makeRe(String(glob), { ...options, capture: true }); - let match = regex.exec(posix ? utils.toPosixSlashes(input) : input); + // no entries means not a dir, so it can never have matches + // foo.txt/** doesn't match foo.txt + if (!entries) + return cb() - if (match) { - return match.slice(1).map(v => v === void 0 ? '' : v); - } -}; + // test without the globstar, and with every child both below + // and replacing the globstar. + var remainWithoutGlobStar = remain.slice(1) + var gspref = prefix ? [ prefix ] : [] + var noGlobStar = gspref.concat(remainWithoutGlobStar) -/** - * Create a regular expression from the given glob `pattern`. - * - * ```js - * const mm = require('micromatch'); - * // mm.makeRe(pattern[, options]); - * - * console.log(mm.makeRe('*.js')); - * //=> /^(?:(\.[\\\/])?(?!\.)(?=.)[^\/]*?\.js)$/ - * ``` - * @param {String} `pattern` A glob pattern to convert to regex. - * @param {Object} `options` - * @return {RegExp} Returns a regex created from the given pattern. - * @api public - */ + // the noGlobStar pattern exits the inGlobStar state + this._process(noGlobStar, index, false, cb) -micromatch.makeRe = (...args) => picomatch.makeRe(...args); + var isSym = this.symlinks[abs] + var len = entries.length -/** - * Scan a glob pattern to separate the pattern into segments. Used - * by the [split](#split) method. - * - * ```js - * const mm = require('micromatch'); - * const state = mm.scan(pattern[, options]); - * ``` - * @param {String} `pattern` - * @param {Object} `options` - * @return {Object} Returns an object with - * @api public - */ + // If it's a symlink, and we're in a globstar, then stop + if (isSym && inGlobStar) + return cb() -micromatch.scan = (...args) => picomatch.scan(...args); + for (var i = 0; i < len; i++) { + var e = entries[i] + if (e.charAt(0) === '.' && !this.dot) + continue -/** - * Parse a glob pattern to create the source string for a regular - * expression. - * - * ```js - * const mm = require('micromatch'); - * const state = mm(pattern[, options]); - * ``` - * @param {String} `glob` - * @param {Object} `options` - * @return {Object} Returns an object with useful properties and output to be used as regex source string. - * @api public - */ + // these two cases enter the inGlobStar state + var instead = gspref.concat(entries[i], remainWithoutGlobStar) + this._process(instead, index, true, cb) -micromatch.parse = (patterns, options) => { - let res = []; - for (let pattern of [].concat(patterns || [])) { - for (let str of braces(String(pattern), options)) { - res.push(picomatch.parse(str, options)); - } + var below = gspref.concat(entries[i], remain) + this._process(below, index, true, cb) } - return res; -}; -/** - * Process the given brace `pattern`. - * - * ```js - * const { braces } = require('micromatch'); - * console.log(braces('foo/{a,b,c}/bar')); - * //=> [ 'foo/(a|b|c)/bar' ] - * - * console.log(braces('foo/{a,b,c}/bar', { expand: true })); - * //=> [ 'foo/a/bar', 'foo/b/bar', 'foo/c/bar' ] - * ``` - * @param {String} `pattern` String with brace pattern to process. - * @param {Object} `options` Any [options](#options) to change how expansion is performed. See the [braces][] library for all available options. - * @return {Array} - * @api public - */ + cb() +} -micromatch.braces = (pattern, options) => { - if (typeof pattern !== 'string') throw new TypeError('Expected a string'); - if ((options && options.nobrace === true) || !/\{.*\}/.test(pattern)) { - return [pattern]; +Glob.prototype._processSimple = function (prefix, index, cb) { + // XXX review this. Shouldn't it be doing the mounting etc + // before doing stat? kinda weird? + var self = this + this._stat(prefix, function (er, exists) { + self._processSimple2(prefix, index, er, exists, cb) + }) +} +Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) { + + //console.error('ps2', prefix, exists) + + if (!this.matches[index]) + this.matches[index] = Object.create(null) + + // If it doesn't exist, then just mark the lack of results + if (!exists) + return cb() + + if (prefix && isAbsolute(prefix) && !this.nomount) { + var trail = /[\/\\]$/.test(prefix) + if (prefix.charAt(0) === '/') { + prefix = path.join(this.root, prefix) + } else { + prefix = path.resolve(this.root, prefix) + if (trail) + prefix += '/' + } } - return braces(pattern, options); -}; -/** - * Expand braces - */ + if (process.platform === 'win32') + prefix = prefix.replace(/\\/g, '/') -micromatch.braceExpand = (pattern, options) => { - if (typeof pattern !== 'string') throw new TypeError('Expected a string'); - return micromatch.braces(pattern, { ...options, expand: true }); -}; + // Mark this as a match + this._emitMatch(index, prefix) + cb() +} -/** - * Expose micromatch - */ +// Returns either 'DIR', 'FILE', or false +Glob.prototype._stat = function (f, cb) { + var abs = this._makeAbs(f) + var needDir = f.slice(-1) === '/' -module.exports = micromatch; + if (f.length > this.maxLength) + return cb() + if (!this.stat && ownProp(this.cache, abs)) { + var c = this.cache[abs] -/***/ }), -/* 604 */ -/***/ (function(module, exports, __webpack_require__) { + if (Array.isArray(c)) + c = 'DIR' -"use strict"; + // It exists, but maybe not how we need it + if (!needDir || c === 'DIR') + return cb(null, c) + if (needDir && c === 'FILE') + return cb() -const stringify = __webpack_require__(605); -const compile = __webpack_require__(607); -const expand = __webpack_require__(611); -const parse = __webpack_require__(612); + // otherwise we have to stat, because maybe c=true + // if we know it exists, but not what it is. + } -/** - * Expand the given pattern or create a regex-compatible string. - * - * ```js - * const braces = require('braces'); - * console.log(braces('{a,b,c}', { compile: true })); //=> ['(a|b|c)'] - * console.log(braces('{a,b,c}')); //=> ['a', 'b', 'c'] - * ``` - * @param {String} `str` - * @param {Object} `options` - * @return {String} - * @api public - */ + var exists + var stat = this.statCache[abs] + if (stat !== undefined) { + if (stat === false) + return cb(null, stat) + else { + var type = stat.isDirectory() ? 'DIR' : 'FILE' + if (needDir && type === 'FILE') + return cb() + else + return cb(null, type, stat) + } + } -const braces = (input, options = {}) => { - let output = []; + var self = this + var statcb = inflight('stat\0' + abs, lstatcb_) + if (statcb) + fs.lstat(abs, statcb) - if (Array.isArray(input)) { - for (let pattern of input) { - let result = braces.create(pattern, options); - if (Array.isArray(result)) { - output.push(...result); - } else { - output.push(result); - } + function lstatcb_ (er, lstat) { + if (lstat && lstat.isSymbolicLink()) { + // If it's a symlink, then treat it as the target, unless + // the target does not exist, then treat it as a file. + return fs.stat(abs, function (er, stat) { + if (er) + self._stat2(f, abs, null, lstat, cb) + else + self._stat2(f, abs, er, stat, cb) + }) + } else { + self._stat2(f, abs, er, lstat, cb) } - } else { - output = [].concat(braces.create(input, options)); } +} - if (options && options.expand === true && options.nodupes === true) { - output = [...new Set(output)]; +Glob.prototype._stat2 = function (f, abs, er, stat, cb) { + if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { + this.statCache[abs] = false + return cb() } - return output; -}; -/** - * Parse the given `str` with the given `options`. - * - * ```js - * // braces.parse(pattern, [, options]); - * const ast = braces.parse('a/{b,c}/d'); - * console.log(ast); - * ``` - * @param {String} pattern Brace pattern to parse - * @param {Object} options - * @return {Object} Returns an AST - * @api public - */ + var needDir = f.slice(-1) === '/' + this.statCache[abs] = stat -braces.parse = (input, options = {}) => parse(input, options); + if (abs.slice(-1) === '/' && stat && !stat.isDirectory()) + return cb(null, false, stat) -/** - * Creates a braces string from an AST, or an AST node. - * - * ```js - * const braces = require('braces'); - * let ast = braces.parse('foo/{a,b}/bar'); - * console.log(stringify(ast.nodes[2])); //=> '{a,b}' - * ``` - * @param {String} `input` Brace pattern or AST. - * @param {Object} `options` - * @return {Array} Returns an array of expanded values. - * @api public - */ + var c = true + if (stat) + c = stat.isDirectory() ? 'DIR' : 'FILE' + this.cache[abs] = this.cache[abs] || c -braces.stringify = (input, options = {}) => { - if (typeof input === 'string') { - return stringify(braces.parse(input, options), options); - } - return stringify(input, options); -}; + if (needDir && c === 'FILE') + return cb() -/** - * Compiles a brace pattern into a regex-compatible, optimized string. - * This method is called by the main [braces](#braces) function by default. - * - * ```js - * const braces = require('braces'); - * console.log(braces.compile('a/{b,c}/d')); - * //=> ['a/(b|c)/d'] - * ``` - * @param {String} `input` Brace pattern or AST. - * @param {Object} `options` - * @return {Array} Returns an array of expanded values. - * @api public - */ + return cb(null, c, stat) +} -braces.compile = (input, options = {}) => { - if (typeof input === 'string') { - input = braces.parse(input, options); - } - return compile(input, options); -}; -/** - * Expands a brace pattern into an array. This method is called by the - * main [braces](#braces) function when `options.expand` is true. Before - * using this method it's recommended that you read the [performance notes](#performance)) - * and advantages of using [.compile](#compile) instead. - * - * ```js - * const braces = require('braces'); - * console.log(braces.expand('a/{b,c}/d')); - * //=> ['a/b/d', 'a/c/d']; - * ``` - * @param {String} `pattern` Brace pattern - * @param {Object} `options` - * @return {Array} Returns an array of expanded values. - * @api public - */ +/***/ }), +/* 593 */ +/***/ (function(module, exports, __webpack_require__) { -braces.expand = (input, options = {}) => { - if (typeof input === 'string') { - input = braces.parse(input, options); - } +try { + var util = __webpack_require__(29); + /* istanbul ignore next */ + if (typeof util.inherits !== 'function') throw ''; + module.exports = util.inherits; +} catch (e) { + /* istanbul ignore next */ + module.exports = __webpack_require__(594); +} - let result = expand(input, options); - // filter out empty strings if specified - if (options.noempty === true) { - result = result.filter(Boolean); - } +/***/ }), +/* 594 */ +/***/ (function(module, exports) { - // filter out duplicates if specified - if (options.nodupes === true) { - result = [...new Set(result)]; +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }) + } + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } } +} - return result; -}; -/** - * Processes a brace pattern and returns either an expanded array - * (if `options.expand` is true), a highly optimized regex-compatible string. - * This method is called by the main [braces](#braces) function. - * - * ```js - * const braces = require('braces'); - * console.log(braces.create('user-{200..300}/project-{a,b,c}-{1..10}')) - * //=> 'user-(20[0-9]|2[1-9][0-9]|300)/project-(a|b|c)-([1-9]|10)' - * ``` - * @param {String} `pattern` Brace pattern - * @param {Object} `options` - * @return {Array} Returns an array of expanded values. - * @api public - */ +/***/ }), +/* 595 */ +/***/ (function(module, exports, __webpack_require__) { -braces.create = (input, options = {}) => { - if (input === '' || input.length < 3) { - return [input]; - } +module.exports = globSync +globSync.GlobSync = GlobSync - return options.expand !== true - ? braces.compile(input, options) - : braces.expand(input, options); -}; +var fs = __webpack_require__(23) +var rp = __webpack_require__(503) +var minimatch = __webpack_require__(505) +var Minimatch = minimatch.Minimatch +var Glob = __webpack_require__(592).Glob +var util = __webpack_require__(29) +var path = __webpack_require__(16) +var assert = __webpack_require__(30) +var isAbsolute = __webpack_require__(511) +var common = __webpack_require__(596) +var alphasort = common.alphasort +var alphasorti = common.alphasorti +var setopts = common.setopts +var ownProp = common.ownProp +var childrenIgnored = common.childrenIgnored +var isIgnored = common.isIgnored -/** - * Expose "braces" - */ +function globSync (pattern, options) { + if (typeof options === 'function' || arguments.length === 3) + throw new TypeError('callback provided to sync glob\n'+ + 'See: https://github.com/isaacs/node-glob/issues/167') -module.exports = braces; + return new GlobSync(pattern, options).found +} +function GlobSync (pattern, options) { + if (!pattern) + throw new Error('must provide pattern') -/***/ }), -/* 605 */ -/***/ (function(module, exports, __webpack_require__) { + if (typeof options === 'function' || arguments.length === 3) + throw new TypeError('callback provided to sync glob\n'+ + 'See: https://github.com/isaacs/node-glob/issues/167') -"use strict"; + if (!(this instanceof GlobSync)) + return new GlobSync(pattern, options) + setopts(this, pattern, options) -const utils = __webpack_require__(606); + if (this.noprocess) + return this -module.exports = (ast, options = {}) => { - let stringify = (node, parent = {}) => { - let invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent); - let invalidNode = node.invalid === true && options.escapeInvalid === true; - let output = ''; + var n = this.minimatch.set.length + this.matches = new Array(n) + for (var i = 0; i < n; i ++) { + this._process(this.minimatch.set[i], i, false) + } + this._finish() +} - if (node.value) { - if ((invalidBlock || invalidNode) && utils.isOpenOrClose(node)) { - return '\\' + node.value; +GlobSync.prototype._finish = function () { + assert(this instanceof GlobSync) + if (this.realpath) { + var self = this + this.matches.forEach(function (matchset, index) { + var set = self.matches[index] = Object.create(null) + for (var p in matchset) { + try { + p = self._makeAbs(p) + var real = rp.realpathSync(p, self.realpathCache) + set[real] = true + } catch (er) { + if (er.syscall === 'stat') + set[self._makeAbs(p)] = true + else + throw er + } } - return node.value; - } + }) + } + common.finish(this) +} - if (node.value) { - return node.value; - } - if (node.nodes) { - for (let child of node.nodes) { - output += stringify(child); - } - } - return output; - }; +GlobSync.prototype._process = function (pattern, index, inGlobStar) { + assert(this instanceof GlobSync) - return stringify(ast); -}; + // Get the first [n] parts of pattern that are all strings. + var n = 0 + while (typeof pattern[n] === 'string') { + n ++ + } + // now n is the index of the first one that is *not* a string. + // See if there's anything else + var prefix + switch (n) { + // if not, then this is rather simple + case pattern.length: + this._processSimple(pattern.join('/'), index) + return + case 0: + // pattern *starts* with some non-trivial item. + // going to readdir(cwd), but not include the prefix in matches. + prefix = null + break -/***/ }), -/* 606 */ -/***/ (function(module, exports, __webpack_require__) { + default: + // pattern has some string bits in the front. + // whatever it starts with, whether that's 'absolute' like /foo/bar, + // or 'relative' like '../baz' + prefix = pattern.slice(0, n).join('/') + break + } -"use strict"; + var remain = pattern.slice(n) + // get the list of entries. + var read + if (prefix === null) + read = '.' + else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) { + if (!prefix || !isAbsolute(prefix)) + prefix = '/' + prefix + read = prefix + } else + read = prefix -exports.isInteger = num => { - if (typeof num === 'number') { - return Number.isInteger(num); - } - if (typeof num === 'string' && num.trim() !== '') { - return Number.isInteger(Number(num)); - } - return false; -}; + var abs = this._makeAbs(read) -/** - * Find a node of the given type - */ + //if ignored, skip processing + if (childrenIgnored(this, read)) + return -exports.find = (node, type) => node.nodes.find(node => node.type === type); + var isGlobStar = remain[0] === minimatch.GLOBSTAR + if (isGlobStar) + this._processGlobStar(prefix, read, abs, remain, index, inGlobStar) + else + this._processReaddir(prefix, read, abs, remain, index, inGlobStar) +} -/** - * Find a node of the given type - */ -exports.exceedsLimit = (min, max, step = 1, limit) => { - if (limit === false) return false; - if (!exports.isInteger(min) || !exports.isInteger(max)) return false; - return ((Number(max) - Number(min)) / Number(step)) >= limit; -}; +GlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) { + var entries = this._readdir(abs, inGlobStar) -/** - * Escape the given node with '\\' before node.value - */ + // if the abs isn't a dir, then nothing can match! + if (!entries) + return -exports.escapeNode = (block, n = 0, type) => { - let node = block.nodes[n]; - if (!node) return; + // It will only match dot entries if it starts with a dot, or if + // dot is set. Stuff like @(.foo|.bar) isn't allowed. + var pn = remain[0] + var negate = !!this.minimatch.negate + var rawGlob = pn._glob + var dotOk = this.dot || rawGlob.charAt(0) === '.' - if ((type && node.type === type) || node.type === 'open' || node.type === 'close') { - if (node.escaped !== true) { - node.value = '\\' + node.value; - node.escaped = true; + var matchedEntries = [] + for (var i = 0; i < entries.length; i++) { + var e = entries[i] + if (e.charAt(0) !== '.' || dotOk) { + var m + if (negate && !prefix) { + m = !e.match(pn) + } else { + m = e.match(pn) + } + if (m) + matchedEntries.push(e) } } -}; -/** - * Returns true if the given brace node should be enclosed in literal braces - */ + var len = matchedEntries.length + // If there are no matched entries, then nothing matches. + if (len === 0) + return -exports.encloseBrace = node => { - if (node.type !== 'brace') return false; - if ((node.commas >> 0 + node.ranges >> 0) === 0) { - node.invalid = true; - return true; - } - return false; -}; + // if this is the last remaining pattern bit, then no need for + // an additional stat *unless* the user has specified mark or + // stat explicitly. We know they exist, since readdir returned + // them. -/** - * Returns true if a brace node is invalid. - */ + if (remain.length === 1 && !this.mark && !this.stat) { + if (!this.matches[index]) + this.matches[index] = Object.create(null) -exports.isInvalidBrace = block => { - if (block.type !== 'brace') return false; - if (block.invalid === true || block.dollar) return true; - if ((block.commas >> 0 + block.ranges >> 0) === 0) { - block.invalid = true; - return true; - } - if (block.open !== true || block.close !== true) { - block.invalid = true; - return true; - } - return false; -}; + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i] + if (prefix) { + if (prefix.slice(-1) !== '/') + e = prefix + '/' + e + else + e = prefix + e + } -/** - * Returns true if a node is an open or close node - */ + if (e.charAt(0) === '/' && !this.nomount) { + e = path.join(this.root, e) + } + this._emitMatch(index, e) + } + // This was the last one, and no stats were needed + return + } -exports.isOpenOrClose = node => { - if (node.type === 'open' || node.type === 'close') { - return true; + // now test all matched entries as stand-ins for that part + // of the pattern. + remain.shift() + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i] + var newPattern + if (prefix) + newPattern = [prefix, e] + else + newPattern = [e] + this._process(newPattern.concat(remain), index, inGlobStar) } - return node.open === true || node.close === true; -}; +} -/** - * Reduce an array of text nodes. - */ -exports.reduce = nodes => nodes.reduce((acc, node) => { - if (node.type === 'text') acc.push(node.value); - if (node.type === 'range') node.type = 'text'; - return acc; -}, []); +GlobSync.prototype._emitMatch = function (index, e) { + if (isIgnored(this, e)) + return -/** - * Flatten an array - */ + var abs = this._makeAbs(e) -exports.flatten = (...args) => { - const result = []; - const flat = arr => { - for (let i = 0; i < arr.length; i++) { - let ele = arr[i]; - Array.isArray(ele) ? flat(ele, result) : ele !== void 0 && result.push(ele); - } - return result; - }; - flat(args); - return result; -}; + if (this.mark) + e = this._mark(e) + if (this.absolute) { + e = abs + } -/***/ }), -/* 607 */ -/***/ (function(module, exports, __webpack_require__) { + if (this.matches[index][e]) + return -"use strict"; + if (this.nodir) { + var c = this.cache[abs] + if (c === 'DIR' || Array.isArray(c)) + return + } + this.matches[index][e] = true -const fill = __webpack_require__(608); -const utils = __webpack_require__(606); + if (this.stat) + this._stat(e) +} -const compile = (ast, options = {}) => { - let walk = (node, parent = {}) => { - let invalidBlock = utils.isInvalidBrace(parent); - let invalidNode = node.invalid === true && options.escapeInvalid === true; - let invalid = invalidBlock === true || invalidNode === true; - let prefix = options.escapeInvalid === true ? '\\' : ''; - let output = ''; - if (node.isOpen === true) { - return prefix + node.value; - } - if (node.isClose === true) { - return prefix + node.value; - } +GlobSync.prototype._readdirInGlobStar = function (abs) { + // follow all symlinked directories forever + // just proceed as if this is a non-globstar situation + if (this.follow) + return this._readdir(abs, false) - if (node.type === 'open') { - return invalid ? (prefix + node.value) : '('; + var entries + var lstat + var stat + try { + lstat = fs.lstatSync(abs) + } catch (er) { + if (er.code === 'ENOENT') { + // lstat failed, doesn't exist + return null } + } - if (node.type === 'close') { - return invalid ? (prefix + node.value) : ')'; - } + var isSym = lstat && lstat.isSymbolicLink() + this.symlinks[abs] = isSym - if (node.type === 'comma') { - return node.prev.type === 'comma' ? '' : (invalid ? node.value : '|'); - } + // If it's not a symlink or a dir, then it's definitely a regular file. + // don't bother doing a readdir in that case. + if (!isSym && lstat && !lstat.isDirectory()) + this.cache[abs] = 'FILE' + else + entries = this._readdir(abs, false) - if (node.value) { - return node.value; - } + return entries +} - if (node.nodes && node.ranges > 0) { - let args = utils.reduce(node.nodes); - let range = fill(...args, { ...options, wrap: false, toRegex: true }); +GlobSync.prototype._readdir = function (abs, inGlobStar) { + var entries - if (range.length !== 0) { - return args.length > 1 && range.length > 1 ? `(${range})` : range; - } - } + if (inGlobStar && !ownProp(this.symlinks, abs)) + return this._readdirInGlobStar(abs) - if (node.nodes) { - for (let child of node.nodes) { - output += walk(child, node); - } - } - return output; - }; + if (ownProp(this.cache, abs)) { + var c = this.cache[abs] + if (!c || c === 'FILE') + return null - return walk(ast); -}; + if (Array.isArray(c)) + return c + } -module.exports = compile; + try { + return this._readdirEntries(abs, fs.readdirSync(abs)) + } catch (er) { + this._readdirError(abs, er) + return null + } +} +GlobSync.prototype._readdirEntries = function (abs, entries) { + // if we haven't asked to stat everything, then just + // assume that everything in there exists, so we can avoid + // having to stat it a second time. + if (!this.mark && !this.stat) { + for (var i = 0; i < entries.length; i ++) { + var e = entries[i] + if (abs === '/') + e = abs + e + else + e = abs + '/' + e + this.cache[e] = true + } + } -/***/ }), -/* 608 */ -/***/ (function(module, exports, __webpack_require__) { + this.cache[abs] = entries -"use strict"; -/*! - * fill-range - * - * Copyright (c) 2014-present, Jon Schlinkert. - * Licensed under the MIT License. - */ + // mark and cache dir-ness + return entries +} +GlobSync.prototype._readdirError = function (f, er) { + // handle errors, and cache the information + switch (er.code) { + case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205 + case 'ENOTDIR': // totally normal. means it *does* exist. + var abs = this._makeAbs(f) + this.cache[abs] = 'FILE' + if (abs === this.cwdAbs) { + var error = new Error(er.code + ' invalid cwd ' + this.cwd) + error.path = this.cwd + error.code = er.code + throw error + } + break + case 'ENOENT': // not terribly unusual + case 'ELOOP': + case 'ENAMETOOLONG': + case 'UNKNOWN': + this.cache[this._makeAbs(f)] = false + break -const util = __webpack_require__(29); -const toRegexRange = __webpack_require__(609); - -const isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val); - -const transform = toNumber => { - return value => toNumber === true ? Number(value) : String(value); -}; - -const isValidValue = value => { - return typeof value === 'number' || (typeof value === 'string' && value !== ''); -}; - -const isNumber = num => Number.isInteger(+num); - -const zeros = input => { - let value = `${input}`; - let index = -1; - if (value[0] === '-') value = value.slice(1); - if (value === '0') return false; - while (value[++index] === '0'); - return index > 0; -}; - -const stringify = (start, end, options) => { - if (typeof start === 'string' || typeof end === 'string') { - return true; + default: // some unusual error. Treat as failure. + this.cache[this._makeAbs(f)] = false + if (this.strict) + throw er + if (!this.silent) + console.error('glob error', er) + break } - return options.stringify === true; -}; +} -const pad = (input, maxLength, toNumber) => { - if (maxLength > 0) { - let dash = input[0] === '-' ? '-' : ''; - if (dash) input = input.slice(1); - input = (dash + input.padStart(dash ? maxLength - 1 : maxLength, '0')); - } - if (toNumber === false) { - return String(input); - } - return input; -}; +GlobSync.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) { -const toMaxLen = (input, maxLength) => { - let negative = input[0] === '-' ? '-' : ''; - if (negative) { - input = input.slice(1); - maxLength--; - } - while (input.length < maxLength) input = '0' + input; - return negative ? ('-' + input) : input; -}; + var entries = this._readdir(abs, inGlobStar) -const toSequence = (parts, options) => { - parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0); - parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0); + // no entries means not a dir, so it can never have matches + // foo.txt/** doesn't match foo.txt + if (!entries) + return - let prefix = options.capture ? '' : '?:'; - let positives = ''; - let negatives = ''; - let result; + // test without the globstar, and with every child both below + // and replacing the globstar. + var remainWithoutGlobStar = remain.slice(1) + var gspref = prefix ? [ prefix ] : [] + var noGlobStar = gspref.concat(remainWithoutGlobStar) - if (parts.positives.length) { - positives = parts.positives.join('|'); - } + // the noGlobStar pattern exits the inGlobStar state + this._process(noGlobStar, index, false) - if (parts.negatives.length) { - negatives = `-(${prefix}${parts.negatives.join('|')})`; - } + var len = entries.length + var isSym = this.symlinks[abs] - if (positives && negatives) { - result = `${positives}|${negatives}`; - } else { - result = positives || negatives; - } + // If it's a symlink, and we're in a globstar, then stop + if (isSym && inGlobStar) + return - if (options.wrap) { - return `(${prefix}${result})`; - } + for (var i = 0; i < len; i++) { + var e = entries[i] + if (e.charAt(0) === '.' && !this.dot) + continue - return result; -}; + // these two cases enter the inGlobStar state + var instead = gspref.concat(entries[i], remainWithoutGlobStar) + this._process(instead, index, true) -const toRange = (a, b, isNumbers, options) => { - if (isNumbers) { - return toRegexRange(a, b, { wrap: false, ...options }); + var below = gspref.concat(entries[i], remain) + this._process(below, index, true) } +} - let start = String.fromCharCode(a); - if (a === b) return start; +GlobSync.prototype._processSimple = function (prefix, index) { + // XXX review this. Shouldn't it be doing the mounting etc + // before doing stat? kinda weird? + var exists = this._stat(prefix) - let stop = String.fromCharCode(b); - return `[${start}-${stop}]`; -}; + if (!this.matches[index]) + this.matches[index] = Object.create(null) -const toRegex = (start, end, options) => { - if (Array.isArray(start)) { - let wrap = options.wrap === true; - let prefix = options.capture ? '' : '?:'; - return wrap ? `(${prefix}${start.join('|')})` : start.join('|'); + // If it doesn't exist, then just mark the lack of results + if (!exists) + return + + if (prefix && isAbsolute(prefix) && !this.nomount) { + var trail = /[\/\\]$/.test(prefix) + if (prefix.charAt(0) === '/') { + prefix = path.join(this.root, prefix) + } else { + prefix = path.resolve(this.root, prefix) + if (trail) + prefix += '/' + } } - return toRegexRange(start, end, options); -}; -const rangeError = (...args) => { - return new RangeError('Invalid range arguments: ' + util.inspect(...args)); -}; + if (process.platform === 'win32') + prefix = prefix.replace(/\\/g, '/') -const invalidRange = (start, end, options) => { - if (options.strictRanges === true) throw rangeError([start, end]); - return []; -}; + // Mark this as a match + this._emitMatch(index, prefix) +} -const invalidStep = (step, options) => { - if (options.strictRanges === true) { - throw new TypeError(`Expected step "${step}" to be a number`); - } - return []; -}; +// Returns either 'DIR', 'FILE', or false +GlobSync.prototype._stat = function (f) { + var abs = this._makeAbs(f) + var needDir = f.slice(-1) === '/' -const fillNumbers = (start, end, step = 1, options = {}) => { - let a = Number(start); - let b = Number(end); + if (f.length > this.maxLength) + return false - if (!Number.isInteger(a) || !Number.isInteger(b)) { - if (options.strictRanges === true) throw rangeError([start, end]); - return []; - } + if (!this.stat && ownProp(this.cache, abs)) { + var c = this.cache[abs] - // fix negative zero - if (a === 0) a = 0; - if (b === 0) b = 0; + if (Array.isArray(c)) + c = 'DIR' - let descending = a > b; - let startString = String(start); - let endString = String(end); - let stepString = String(step); - step = Math.max(Math.abs(step), 1); + // It exists, but maybe not how we need it + if (!needDir || c === 'DIR') + return c - let padded = zeros(startString) || zeros(endString) || zeros(stepString); - let maxLen = padded ? Math.max(startString.length, endString.length, stepString.length) : 0; - let toNumber = padded === false && stringify(start, end, options) === false; - let format = options.transform || transform(toNumber); + if (needDir && c === 'FILE') + return false - if (options.toRegex && step === 1) { - return toRange(toMaxLen(start, maxLen), toMaxLen(end, maxLen), true, options); + // otherwise we have to stat, because maybe c=true + // if we know it exists, but not what it is. } - let parts = { negatives: [], positives: [] }; - let push = num => parts[num < 0 ? 'negatives' : 'positives'].push(Math.abs(num)); - let range = []; - let index = 0; + var exists + var stat = this.statCache[abs] + if (!stat) { + var lstat + try { + lstat = fs.lstatSync(abs) + } catch (er) { + if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { + this.statCache[abs] = false + return false + } + } - while (descending ? a >= b : a <= b) { - if (options.toRegex === true && step > 1) { - push(a); + if (lstat && lstat.isSymbolicLink()) { + try { + stat = fs.statSync(abs) + } catch (er) { + stat = lstat + } } else { - range.push(pad(format(a, index), maxLen, toNumber)); + stat = lstat } - a = descending ? a - step : a + step; - index++; } - if (options.toRegex === true) { - return step > 1 - ? toSequence(parts, options) - : toRegex(range, null, { wrap: false, ...options }); - } + this.statCache[abs] = stat - return range; -}; + var c = true + if (stat) + c = stat.isDirectory() ? 'DIR' : 'FILE' -const fillLetters = (start, end, step = 1, options = {}) => { - if ((!isNumber(start) && start.length > 1) || (!isNumber(end) && end.length > 1)) { - return invalidRange(start, end, options); - } + this.cache[abs] = this.cache[abs] || c + if (needDir && c === 'FILE') + return false - let format = options.transform || (val => String.fromCharCode(val)); - let a = `${start}`.charCodeAt(0); - let b = `${end}`.charCodeAt(0); + return c +} - let descending = a > b; - let min = Math.min(a, b); - let max = Math.max(a, b); +GlobSync.prototype._mark = function (p) { + return common.mark(this, p) +} - if (options.toRegex && step === 1) { - return toRange(min, max, false, options); - } +GlobSync.prototype._makeAbs = function (f) { + return common.makeAbs(this, f) +} - let range = []; - let index = 0; - while (descending ? a >= b : a <= b) { - range.push(format(a, index)); - a = descending ? a - step : a + step; - index++; - } +/***/ }), +/* 596 */ +/***/ (function(module, exports, __webpack_require__) { - if (options.toRegex === true) { - return toRegex(range, null, { wrap: false, options }); - } +exports.alphasort = alphasort +exports.alphasorti = alphasorti +exports.setopts = setopts +exports.ownProp = ownProp +exports.makeAbs = makeAbs +exports.finish = finish +exports.mark = mark +exports.isIgnored = isIgnored +exports.childrenIgnored = childrenIgnored - return range; -}; +function ownProp (obj, field) { + return Object.prototype.hasOwnProperty.call(obj, field) +} -const fill = (start, end, step, options = {}) => { - if (end == null && isValidValue(start)) { - return [start]; - } +var path = __webpack_require__(16) +var minimatch = __webpack_require__(505) +var isAbsolute = __webpack_require__(511) +var Minimatch = minimatch.Minimatch - if (!isValidValue(start) || !isValidValue(end)) { - return invalidRange(start, end, options); +function alphasorti (a, b) { + return a.toLowerCase().localeCompare(b.toLowerCase()) +} + +function alphasort (a, b) { + return a.localeCompare(b) +} + +function setupIgnores (self, options) { + self.ignore = options.ignore || [] + + if (!Array.isArray(self.ignore)) + self.ignore = [self.ignore] + + if (self.ignore.length) { + self.ignore = self.ignore.map(ignoreMap) } +} - if (typeof step === 'function') { - return fill(start, end, 1, { transform: step }); +// ignore patterns are always in dot:true mode. +function ignoreMap (pattern) { + var gmatcher = null + if (pattern.slice(-3) === '/**') { + var gpattern = pattern.replace(/(\/\*\*)+$/, '') + gmatcher = new Minimatch(gpattern, { dot: true }) } - if (isObject(step)) { - return fill(start, end, 0, step); + return { + matcher: new Minimatch(pattern, { dot: true }), + gmatcher: gmatcher } +} - let opts = { ...options }; - if (opts.capture === true) opts.wrap = true; - step = step || opts.step || 1; +function setopts (self, pattern, options) { + if (!options) + options = {} - if (!isNumber(step)) { - if (step != null && !isObject(step)) return invalidStep(step, opts); - return fill(start, end, 1, step); + // base-matching: just use globstar for that. + if (options.matchBase && -1 === pattern.indexOf("/")) { + if (options.noglobstar) { + throw new Error("base matching requires globstar") + } + pattern = "**/" + pattern } - if (isNumber(start) && isNumber(end)) { - return fillNumbers(start, end, step, opts); - } + self.silent = !!options.silent + self.pattern = pattern + self.strict = options.strict !== false + self.realpath = !!options.realpath + self.realpathCache = options.realpathCache || Object.create(null) + self.follow = !!options.follow + self.dot = !!options.dot + self.mark = !!options.mark + self.nodir = !!options.nodir + if (self.nodir) + self.mark = true + self.sync = !!options.sync + self.nounique = !!options.nounique + self.nonull = !!options.nonull + self.nosort = !!options.nosort + self.nocase = !!options.nocase + self.stat = !!options.stat + self.noprocess = !!options.noprocess + self.absolute = !!options.absolute - return fillLetters(start, end, Math.max(Math.abs(step), 1), opts); -}; + self.maxLength = options.maxLength || Infinity + self.cache = options.cache || Object.create(null) + self.statCache = options.statCache || Object.create(null) + self.symlinks = options.symlinks || Object.create(null) -module.exports = fill; + setupIgnores(self, options) + self.changedCwd = false + var cwd = process.cwd() + if (!ownProp(options, "cwd")) + self.cwd = cwd + else { + self.cwd = path.resolve(options.cwd) + self.changedCwd = self.cwd !== cwd + } -/***/ }), -/* 609 */ -/***/ (function(module, exports, __webpack_require__) { + self.root = options.root || path.resolve(self.cwd, "/") + self.root = path.resolve(self.root) + if (process.platform === "win32") + self.root = self.root.replace(/\\/g, "/") -"use strict"; -/*! - * to-regex-range - * - * Copyright (c) 2015-present, Jon Schlinkert. - * Released under the MIT License. - */ + // TODO: is an absolute `cwd` supposed to be resolved against `root`? + // e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test') + self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd) + if (process.platform === "win32") + self.cwdAbs = self.cwdAbs.replace(/\\/g, "/") + self.nomount = !!options.nomount + // disable comments and negation in Minimatch. + // Note that they are not supported in Glob itself anyway. + options.nonegate = true + options.nocomment = true + self.minimatch = new Minimatch(pattern, options) + self.options = self.minimatch.options +} -const isNumber = __webpack_require__(610); +function finish (self) { + var nou = self.nounique + var all = nou ? [] : Object.create(null) -const toRegexRange = (min, max, options) => { - if (isNumber(min) === false) { - throw new TypeError('toRegexRange: expected the first argument to be a number'); + for (var i = 0, l = self.matches.length; i < l; i ++) { + var matches = self.matches[i] + if (!matches || Object.keys(matches).length === 0) { + if (self.nonull) { + // do like the shell, and spit out the literal glob + var literal = self.minimatch.globSet[i] + if (nou) + all.push(literal) + else + all[literal] = true + } + } else { + // had matches + var m = Object.keys(matches) + if (nou) + all.push.apply(all, m) + else + m.forEach(function (m) { + all[m] = true + }) + } } - if (max === void 0 || min === max) { - return String(min); - } + if (!nou) + all = Object.keys(all) - if (isNumber(max) === false) { - throw new TypeError('toRegexRange: expected the second argument to be a number.'); - } + if (!self.nosort) + all = all.sort(self.nocase ? alphasorti : alphasort) - let opts = { relaxZeros: true, ...options }; - if (typeof opts.strictZeros === 'boolean') { - opts.relaxZeros = opts.strictZeros === false; + // at *some* point we statted all of these + if (self.mark) { + for (var i = 0; i < all.length; i++) { + all[i] = self._mark(all[i]) + } + if (self.nodir) { + all = all.filter(function (e) { + var notDir = !(/\/$/.test(e)) + var c = self.cache[e] || self.cache[makeAbs(self, e)] + if (notDir && c) + notDir = c !== 'DIR' && !Array.isArray(c) + return notDir + }) + } } - let relax = String(opts.relaxZeros); - let shorthand = String(opts.shorthand); - let capture = String(opts.capture); - let wrap = String(opts.wrap); - let cacheKey = min + ':' + max + '=' + relax + shorthand + capture + wrap; + if (self.ignore.length) + all = all.filter(function(m) { + return !isIgnored(self, m) + }) - if (toRegexRange.cache.hasOwnProperty(cacheKey)) { - return toRegexRange.cache[cacheKey].result; - } + self.found = all +} - let a = Math.min(min, max); - let b = Math.max(min, max); +function mark (self, p) { + var abs = makeAbs(self, p) + var c = self.cache[abs] + var m = p + if (c) { + var isDir = c === 'DIR' || Array.isArray(c) + var slash = p.slice(-1) === '/' - if (Math.abs(a - b) === 1) { - let result = min + '|' + max; - if (opts.capture) { - return `(${result})`; - } - if (opts.wrap === false) { - return result; + if (isDir && !slash) + m += '/' + else if (!isDir && slash) + m = m.slice(0, -1) + + if (m !== p) { + var mabs = makeAbs(self, m) + self.statCache[mabs] = self.statCache[abs] + self.cache[mabs] = self.cache[abs] } - return `(?:${result})`; } - let isPadded = hasPadding(min) || hasPadding(max); - let state = { min, max, a, b }; - let positives = []; - let negatives = []; - - if (isPadded) { - state.isPadded = isPadded; - state.maxLen = String(state.max).length; - } + return m +} - if (a < 0) { - let newMin = b < 0 ? Math.abs(b) : 1; - negatives = splitToPatterns(newMin, Math.abs(a), state, opts); - a = state.a = 0; +// lotta situps... +function makeAbs (self, f) { + var abs = f + if (f.charAt(0) === '/') { + abs = path.join(self.root, f) + } else if (isAbsolute(f) || f === '') { + abs = f + } else if (self.changedCwd) { + abs = path.resolve(self.cwd, f) + } else { + abs = path.resolve(f) } - if (b >= 0) { - positives = splitToPatterns(a, b, state, opts); - } + if (process.platform === 'win32') + abs = abs.replace(/\\/g, '/') - state.negatives = negatives; - state.positives = positives; - state.result = collatePatterns(negatives, positives, opts); + return abs +} - if (opts.capture === true) { - state.result = `(${state.result})`; - } else if (opts.wrap !== false && (positives.length + negatives.length) > 1) { - state.result = `(?:${state.result})`; - } - toRegexRange.cache[cacheKey] = state; - return state.result; -}; +// Return true, if pattern ends with globstar '**', for the accompanying parent directory. +// Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents +function isIgnored (self, path) { + if (!self.ignore.length) + return false -function collatePatterns(neg, pos, options) { - let onlyNegative = filterPatterns(neg, pos, '-', false, options) || []; - let onlyPositive = filterPatterns(pos, neg, '', false, options) || []; - let intersected = filterPatterns(neg, pos, '-?', true, options) || []; - let subpatterns = onlyNegative.concat(intersected).concat(onlyPositive); - return subpatterns.join('|'); + return self.ignore.some(function(item) { + return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path)) + }) } -function splitToRanges(min, max) { - let nines = 1; - let zeros = 1; +function childrenIgnored (self, path) { + if (!self.ignore.length) + return false - let stop = countNines(min, nines); - let stops = new Set([max]); + return self.ignore.some(function(item) { + return !!(item.gmatcher && item.gmatcher.match(path)) + }) +} - while (min <= stop && stop <= max) { - stops.add(stop); - nines += 1; - stop = countNines(min, nines); - } - stop = countZeros(max + 1, zeros) - 1; +/***/ }), +/* 597 */ +/***/ (function(module, exports, __webpack_require__) { - while (min < stop && stop <= max) { - stops.add(stop); - zeros += 1; - stop = countZeros(max + 1, zeros) - 1; - } +"use strict"; + +const taskManager = __webpack_require__(598); +const async_1 = __webpack_require__(626); +const stream_1 = __webpack_require__(659); +const sync_1 = __webpack_require__(660); +const settings_1 = __webpack_require__(662); +const utils = __webpack_require__(599); +function FastGlob(source, options) { + try { + assertPatternsInput(source); + } + catch (error) { + return Promise.reject(error); + } + const works = getWorks(source, async_1.default, options); + return Promise.all(works).then(utils.array.flatten); +} +(function (FastGlob) { + function sync(source, options) { + assertPatternsInput(source); + const works = getWorks(source, sync_1.default, options); + return utils.array.flatten(works); + } + FastGlob.sync = sync; + function stream(source, options) { + assertPatternsInput(source); + const works = getWorks(source, stream_1.default, options); + /** + * The stream returned by the provider cannot work with an asynchronous iterator. + * To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams. + * This affects performance (+25%). I don't see best solution right now. + */ + return utils.stream.merge(works); + } + FastGlob.stream = stream; + function generateTasks(source, options) { + assertPatternsInput(source); + const patterns = [].concat(source); + const settings = new settings_1.default(options); + return taskManager.generate(patterns, settings); + } + FastGlob.generateTasks = generateTasks; +})(FastGlob || (FastGlob = {})); +function getWorks(source, _Provider, options) { + const patterns = [].concat(source); + const settings = new settings_1.default(options); + const tasks = taskManager.generate(patterns, settings); + const provider = new _Provider(settings); + return tasks.map(provider.read, provider); +} +function assertPatternsInput(source) { + if ([].concat(source).every(isString)) { + return; + } + throw new TypeError('Patterns must be a string or an array of strings'); +} +function isString(source) { + /* tslint:disable-next-line strict-type-predicates */ + return typeof source === 'string'; +} +module.exports = FastGlob; - stops = [...stops]; - stops.sort(compare); - return stops; -} -/** - * Convert a range to a regex pattern - * @param {Number} `start` - * @param {Number} `stop` - * @return {String} - */ +/***/ }), +/* 598 */ +/***/ (function(module, exports, __webpack_require__) { -function rangeToPattern(start, stop, options) { - if (start === stop) { - return { pattern: start, count: [], digits: 0 }; - } +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const utils = __webpack_require__(599); +function generate(patterns, settings) { + const positivePatterns = getPositivePatterns(patterns); + const negativePatterns = getNegativePatternsAsPositive(patterns, settings.ignore); + /** + * When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check + * filepath directly (without read directory). + */ + const staticPatterns = !settings.caseSensitiveMatch ? [] : positivePatterns.filter(utils.pattern.isStaticPattern); + const dynamicPatterns = !settings.caseSensitiveMatch ? positivePatterns : positivePatterns.filter(utils.pattern.isDynamicPattern); + const staticTasks = convertPatternsToTasks(staticPatterns, negativePatterns, /* dynamic */ false); + const dynamicTasks = convertPatternsToTasks(dynamicPatterns, negativePatterns, /* dynamic */ true); + return staticTasks.concat(dynamicTasks); +} +exports.generate = generate; +function convertPatternsToTasks(positive, negative, dynamic) { + const positivePatternsGroup = groupPatternsByBaseDirectory(positive); + // When we have a global group – there is no reason to divide the patterns into independent tasks. + // In this case, the global task covers the rest. + if ('.' in positivePatternsGroup) { + const task = convertPatternGroupToTask('.', positive, negative, dynamic); + return [task]; + } + return convertPatternGroupsToTasks(positivePatternsGroup, negative, dynamic); +} +exports.convertPatternsToTasks = convertPatternsToTasks; +function getPositivePatterns(patterns) { + return utils.pattern.getPositivePatterns(patterns); +} +exports.getPositivePatterns = getPositivePatterns; +function getNegativePatternsAsPositive(patterns, ignore) { + const negative = utils.pattern.getNegativePatterns(patterns).concat(ignore); + const positive = negative.map(utils.pattern.convertToPositivePattern); + return positive; +} +exports.getNegativePatternsAsPositive = getNegativePatternsAsPositive; +function groupPatternsByBaseDirectory(patterns) { + return patterns.reduce((collection, pattern) => { + const base = utils.pattern.getBaseDirectory(pattern); + if (base in collection) { + collection[base].push(pattern); + } + else { + collection[base] = [pattern]; + } + return collection; + }, {}); +} +exports.groupPatternsByBaseDirectory = groupPatternsByBaseDirectory; +function convertPatternGroupsToTasks(positive, negative, dynamic) { + return Object.keys(positive).map((base) => { + return convertPatternGroupToTask(base, positive[base], negative, dynamic); + }); +} +exports.convertPatternGroupsToTasks = convertPatternGroupsToTasks; +function convertPatternGroupToTask(base, positive, negative, dynamic) { + return { + dynamic, + positive, + negative, + base, + patterns: [].concat(positive, negative.map(utils.pattern.convertToNegativePattern)) + }; +} +exports.convertPatternGroupToTask = convertPatternGroupToTask; - let zipped = zip(start, stop); - let digits = zipped.length; - let pattern = ''; - let count = 0; - for (let i = 0; i < digits; i++) { - let [startDigit, stopDigit] = zipped[i]; +/***/ }), +/* 599 */ +/***/ (function(module, exports, __webpack_require__) { - if (startDigit === stopDigit) { - pattern += startDigit; +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const array = __webpack_require__(600); +exports.array = array; +const errno = __webpack_require__(601); +exports.errno = errno; +const fs = __webpack_require__(602); +exports.fs = fs; +const path = __webpack_require__(603); +exports.path = path; +const pattern = __webpack_require__(604); +exports.pattern = pattern; +const stream = __webpack_require__(625); +exports.stream = stream; - } else if (startDigit !== '0' || stopDigit !== '9') { - pattern += toCharacterClass(startDigit, stopDigit, options); - } else { - count++; - } - } +/***/ }), +/* 600 */ +/***/ (function(module, exports, __webpack_require__) { - if (count) { - pattern += options.shorthand === true ? '\\d' : '[0-9]'; - } +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +function flatten(items) { + return items.reduce((collection, item) => [].concat(collection, item), []); +} +exports.flatten = flatten; - return { pattern, count: [count], digits }; -} -function splitToPatterns(min, max, tok, options) { - let ranges = splitToRanges(min, max); - let tokens = []; - let start = min; - let prev; +/***/ }), +/* 601 */ +/***/ (function(module, exports, __webpack_require__) { - for (let i = 0; i < ranges.length; i++) { - let max = ranges[i]; - let obj = rangeToPattern(String(start), String(max), options); - let zeros = ''; +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +function isEnoentCodeError(error) { + return error.code === 'ENOENT'; +} +exports.isEnoentCodeError = isEnoentCodeError; - if (!tok.isPadded && prev && prev.pattern === obj.pattern) { - if (prev.count.length > 1) { - prev.count.pop(); - } - prev.count.push(obj.count[0]); - prev.string = prev.pattern + toQuantifier(prev.count); - start = max + 1; - continue; - } +/***/ }), +/* 602 */ +/***/ (function(module, exports, __webpack_require__) { - if (tok.isPadded) { - zeros = padZeros(max, tok, options); - } +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +class DirentFromStats { + constructor(name, stats) { + this.name = name; + this.isBlockDevice = stats.isBlockDevice.bind(stats); + this.isCharacterDevice = stats.isCharacterDevice.bind(stats); + this.isDirectory = stats.isDirectory.bind(stats); + this.isFIFO = stats.isFIFO.bind(stats); + this.isFile = stats.isFile.bind(stats); + this.isSocket = stats.isSocket.bind(stats); + this.isSymbolicLink = stats.isSymbolicLink.bind(stats); + } +} +function createDirentFromStats(name, stats) { + return new DirentFromStats(name, stats); +} +exports.createDirentFromStats = createDirentFromStats; - obj.string = zeros + obj.pattern + toQuantifier(obj.count); - tokens.push(obj); - start = max + 1; - prev = obj; - } - return tokens; -} +/***/ }), +/* 603 */ +/***/ (function(module, exports, __webpack_require__) { -function filterPatterns(arr, comparison, prefix, intersection, options) { - let result = []; +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const path = __webpack_require__(16); +/** + * Designed to work only with simple paths: `dir\\file`. + */ +function unixify(filepath) { + return filepath.replace(/\\/g, '/'); +} +exports.unixify = unixify; +function makeAbsolute(cwd, filepath) { + return path.resolve(cwd, filepath); +} +exports.makeAbsolute = makeAbsolute; - for (let ele of arr) { - let { string } = ele; - // only push if _both_ are negative... - if (!intersection && !contains(comparison, 'string', string)) { - result.push(prefix + string); - } +/***/ }), +/* 604 */ +/***/ (function(module, exports, __webpack_require__) { - // or _both_ are positive - if (intersection && contains(comparison, 'string', string)) { - result.push(prefix + string); - } - } - return result; -} +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const path = __webpack_require__(16); +const globParent = __webpack_require__(605); +const isGlob = __webpack_require__(606); +const micromatch = __webpack_require__(608); +const GLOBSTAR = '**'; +function isStaticPattern(pattern) { + return !isDynamicPattern(pattern); +} +exports.isStaticPattern = isStaticPattern; +function isDynamicPattern(pattern) { + return isGlob(pattern, { strict: false }); +} +exports.isDynamicPattern = isDynamicPattern; +function convertToPositivePattern(pattern) { + return isNegativePattern(pattern) ? pattern.slice(1) : pattern; +} +exports.convertToPositivePattern = convertToPositivePattern; +function convertToNegativePattern(pattern) { + return '!' + pattern; +} +exports.convertToNegativePattern = convertToNegativePattern; +function isNegativePattern(pattern) { + return pattern.startsWith('!') && pattern[1] !== '('; +} +exports.isNegativePattern = isNegativePattern; +function isPositivePattern(pattern) { + return !isNegativePattern(pattern); +} +exports.isPositivePattern = isPositivePattern; +function getNegativePatterns(patterns) { + return patterns.filter(isNegativePattern); +} +exports.getNegativePatterns = getNegativePatterns; +function getPositivePatterns(patterns) { + return patterns.filter(isPositivePattern); +} +exports.getPositivePatterns = getPositivePatterns; +function getBaseDirectory(pattern) { + return globParent(pattern); +} +exports.getBaseDirectory = getBaseDirectory; +function hasGlobStar(pattern) { + return pattern.indexOf(GLOBSTAR) !== -1; +} +exports.hasGlobStar = hasGlobStar; +function endsWithSlashGlobStar(pattern) { + return pattern.endsWith('/' + GLOBSTAR); +} +exports.endsWithSlashGlobStar = endsWithSlashGlobStar; +function isAffectDepthOfReadingPattern(pattern) { + const basename = path.basename(pattern); + return endsWithSlashGlobStar(pattern) || isStaticPattern(basename); +} +exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern; +function getNaiveDepth(pattern) { + const base = getBaseDirectory(pattern); + const patternDepth = pattern.split('/').length; + const patternBaseDepth = base.split('/').length; + /** + * This is a hack for pattern that has no base directory. + * + * This is related to the `*\something\*` pattern. + */ + if (base === '.') { + return patternDepth - patternBaseDepth; + } + return patternDepth - patternBaseDepth - 1; +} +exports.getNaiveDepth = getNaiveDepth; +function getMaxNaivePatternsDepth(patterns) { + return patterns.reduce((max, pattern) => { + const depth = getNaiveDepth(pattern); + return depth > max ? depth : max; + }, 0); +} +exports.getMaxNaivePatternsDepth = getMaxNaivePatternsDepth; +function makeRe(pattern, options) { + return micromatch.makeRe(pattern, options); +} +exports.makeRe = makeRe; +function convertPatternsToRe(patterns, options) { + return patterns.map((pattern) => makeRe(pattern, options)); +} +exports.convertPatternsToRe = convertPatternsToRe; +function matchAny(entry, patternsRe) { + const filepath = entry.replace(/^\.[\\\/]/, ''); + return patternsRe.some((patternRe) => patternRe.test(filepath)); +} +exports.matchAny = matchAny; -/** - * Zip strings - */ -function zip(a, b) { - let arr = []; - for (let i = 0; i < a.length; i++) arr.push([a[i], b[i]]); - return arr; -} +/***/ }), +/* 605 */ +/***/ (function(module, exports, __webpack_require__) { -function compare(a, b) { - return a > b ? 1 : b > a ? -1 : 0; -} +"use strict"; -function contains(arr, key, val) { - return arr.some(ele => ele[key] === val); -} -function countNines(min, len) { - return Number(String(min).slice(0, -len) + '9'.repeat(len)); -} +var isGlob = __webpack_require__(606); +var pathPosixDirname = __webpack_require__(16).posix.dirname; +var isWin32 = __webpack_require__(11).platform() === 'win32'; -function countZeros(integer, zeros) { - return integer - (integer % Math.pow(10, zeros)); -} +var slash = '/'; +var backslash = /\\/g; +var enclosure = /[\{\[].*[\/]*.*[\}\]]$/; +var globby = /(^|[^\\])([\{\[]|\([^\)]+$)/; +var escaped = /\\([\*\?\|\[\]\(\)\{\}])/g; -function toQuantifier(digits) { - let [start = 0, stop = ''] = digits; - if (stop || start > 1) { - return `{${start + (stop ? ',' + stop : '')}}`; +module.exports = function globParent(str) { + // flip windows path separators + if (isWin32 && str.indexOf(slash) < 0) { + str = str.replace(backslash, slash); } - return ''; -} - -function toCharacterClass(a, b, options) { - return `[${a}${(b - a === 1) ? '' : '-'}${b}]`; -} - -function hasPadding(str) { - return /^-?(0+)\d/.test(str); -} -function padZeros(value, tok, options) { - if (!tok.isPadded) { - return value; + // special case for strings ending in enclosure containing path separator + if (enclosure.test(str)) { + str += slash; } - let diff = Math.abs(tok.maxLen - String(value).length); - let relax = options.relaxZeros !== false; + // preserves full path in case of trailing path separator + str += 'a'; - switch (diff) { - case 0: - return ''; - case 1: - return relax ? '0?' : '0'; - case 2: - return relax ? '0{0,2}' : '00'; - default: { - return relax ? `0{0,${diff}}` : `0{${diff}}`; - } - } -} - -/** - * Cache - */ - -toRegexRange.cache = {}; -toRegexRange.clearCache = () => (toRegexRange.cache = {}); - -/** - * Expose `toRegexRange` - */ + // remove path parts that are globby + do { + str = pathPosixDirname(str); + } while (isGlob(str) || globby.test(str)); -module.exports = toRegexRange; + // remove escape chars and return result + return str.replace(escaped, '$1'); +}; /***/ }), -/* 610 */ +/* 606 */ /***/ (function(module, exports, __webpack_require__) { -"use strict"; /*! - * is-number + * is-glob * - * Copyright (c) 2014-present, Jon Schlinkert. + * Copyright (c) 2014-2017, Jon Schlinkert. * Released under the MIT License. */ +var isExtglob = __webpack_require__(607); +var chars = { '{': '}', '(': ')', '[': ']'}; +var strictRegex = /\\(.)|(^!|\*|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\))/; +var relaxedRegex = /\\(.)|(^!|[*?{}()[\]]|\(\?)/; - -module.exports = function(num) { - if (typeof num === 'number') { - return num - num === 0; +module.exports = function isGlob(str, options) { + if (typeof str !== 'string' || str === '') { + return false; } - if (typeof num === 'string' && num.trim() !== '') { - return Number.isFinite ? Number.isFinite(+num) : isFinite(+num); + + if (isExtglob(str)) { + return true; } - return false; -}; + var regex = strictRegex; + var match; -/***/ }), -/* 611 */ -/***/ (function(module, exports, __webpack_require__) { + // optionally relax regex + if (options && options.strict === false) { + regex = relaxedRegex; + } -"use strict"; + while ((match = regex.exec(str))) { + if (match[2]) return true; + var idx = match.index + match[0].length; + + // if an open bracket/brace/paren is escaped, + // set the index to the next closing character + var open = match[1]; + var close = open ? chars[open] : null; + if (open && close) { + var n = str.indexOf(close, idx); + if (n !== -1) { + idx = n + 1; + } + } + str = str.slice(idx); + } + return false; +}; -const fill = __webpack_require__(608); -const stringify = __webpack_require__(605); -const utils = __webpack_require__(606); -const append = (queue = '', stash = '', enclose = false) => { - let result = []; +/***/ }), +/* 607 */ +/***/ (function(module, exports) { - queue = [].concat(queue); - stash = [].concat(stash); +/*! + * is-extglob + * + * Copyright (c) 2014-2016, Jon Schlinkert. + * Licensed under the MIT License. + */ - if (!stash.length) return queue; - if (!queue.length) { - return enclose ? utils.flatten(stash).map(ele => `{${ele}}`) : stash; +module.exports = function isExtglob(str) { + if (typeof str !== 'string' || str === '') { + return false; } - for (let item of queue) { - if (Array.isArray(item)) { - for (let value of item) { - result.push(append(value, stash, enclose)); - } - } else { - for (let ele of stash) { - if (enclose === true && typeof ele === 'string') ele = `{${ele}}`; - result.push(Array.isArray(ele) ? append(item, ele, enclose) : (item + ele)); - } - } + var match; + while ((match = /(\\).|([@?!+*]\(.*\))/g.exec(str))) { + if (match[2]) return true; + str = str.slice(match.index + match[0].length); } - return utils.flatten(result); -}; -const expand = (ast, options = {}) => { - let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit; + return false; +}; - let walk = (node, parent = {}) => { - node.queue = []; - let p = parent; - let q = parent.queue; +/***/ }), +/* 608 */ +/***/ (function(module, exports, __webpack_require__) { - while (p.type !== 'brace' && p.type !== 'root' && p.parent) { - p = p.parent; - q = p.queue; - } +"use strict"; - if (node.invalid || node.dollar) { - q.push(append(q.pop(), stringify(node, options))); - return; - } - if (node.type === 'brace' && node.invalid !== true && node.nodes.length === 2) { - q.push(append(q.pop(), ['{}'])); - return; - } +const util = __webpack_require__(29); +const braces = __webpack_require__(609); +const picomatch = __webpack_require__(619); +const utils = __webpack_require__(622); +const isEmptyString = val => typeof val === 'string' && (val === '' || val === './'); - if (node.nodes && node.ranges > 0) { - let args = utils.reduce(node.nodes); +/** + * Returns an array of strings that match one or more glob patterns. + * + * ```js + * const mm = require('micromatch'); + * // mm(list, patterns[, options]); + * + * console.log(mm(['a.js', 'a.txt'], ['*.js'])); + * //=> [ 'a.js' ] + * ``` + * @param {String|Array} list List of strings to match. + * @param {String|Array} patterns One or more glob patterns to use for matching. + * @param {Object} options See available [options](#options) + * @return {Array} Returns an array of matches + * @summary false + * @api public + */ - if (utils.exceedsLimit(...args, options.step, rangeLimit)) { - throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.'); - } +const micromatch = (list, patterns, options) => { + patterns = [].concat(patterns); + list = [].concat(list); - let range = fill(...args, options); - if (range.length === 0) { - range = stringify(node, options); - } + let omit = new Set(); + let keep = new Set(); + let items = new Set(); + let negatives = 0; - q.push(append(q.pop(), range)); - node.nodes = []; - return; + let onResult = state => { + items.add(state.output); + if (options && options.onResult) { + options.onResult(state); } + }; - let enclose = utils.encloseBrace(node); - let queue = node.queue; - let block = node; - - while (block.type !== 'brace' && block.type !== 'root' && block.parent) { - block = block.parent; - queue = block.queue; - } + for (let i = 0; i < patterns.length; i++) { + let isMatch = picomatch(String(patterns[i]), { ...options, onResult }, true); + let negated = isMatch.state.negated || isMatch.state.negatedExtglob; + if (negated) negatives++; - for (let i = 0; i < node.nodes.length; i++) { - let child = node.nodes[i]; + for (let item of list) { + let matched = isMatch(item, true); - if (child.type === 'comma' && node.type === 'brace') { - if (i === 1) queue.push(''); - queue.push(''); - continue; - } + let match = negated ? !matched.isMatch : matched.isMatch; + if (!match) continue; - if (child.type === 'close') { - q.push(append(q.pop(), queue, enclose)); - continue; + if (negated) { + omit.add(matched.output); + } else { + omit.delete(matched.output); + keep.add(matched.output); } + } + } - if (child.value && child.type !== 'open') { - queue.push(append(queue.pop(), child.value)); - continue; - } + let result = negatives === patterns.length ? [...items] : [...keep]; + let matches = result.filter(item => !omit.has(item)); - if (child.nodes) { - walk(child, node); - } + if (options && matches.length === 0) { + if (options.failglob === true) { + throw new Error(`No matches found for "${patterns.join(', ')}"`); } - return queue; - }; + if (options.nonull === true || options.nullglob === true) { + return options.unescape ? patterns.map(p => p.replace(/\\/g, '')) : patterns; + } + } - return utils.flatten(walk(ast)); + return matches; }; -module.exports = expand; - - -/***/ }), -/* 612 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - +/** + * Backwards compatibility + */ -const stringify = __webpack_require__(605); +micromatch.match = micromatch; /** - * Constants + * Returns a matcher function from the given glob `pattern` and `options`. + * The returned function takes a string to match as its only argument and returns + * true if the string is a match. + * + * ```js + * const mm = require('micromatch'); + * // mm.matcher(pattern[, options]); + * + * const isMatch = mm.matcher('*.!(*a)'); + * console.log(isMatch('a.a')); //=> false + * console.log(isMatch('a.b')); //=> true + * ``` + * @param {String} `pattern` Glob pattern + * @param {Object} `options` + * @return {Function} Returns a matcher function. + * @api public */ -const { - MAX_LENGTH, - CHAR_BACKSLASH, /* \ */ - CHAR_BACKTICK, /* ` */ - CHAR_COMMA, /* , */ - CHAR_DOT, /* . */ - CHAR_LEFT_PARENTHESES, /* ( */ - CHAR_RIGHT_PARENTHESES, /* ) */ - CHAR_LEFT_CURLY_BRACE, /* { */ - CHAR_RIGHT_CURLY_BRACE, /* } */ - CHAR_LEFT_SQUARE_BRACKET, /* [ */ - CHAR_RIGHT_SQUARE_BRACKET, /* ] */ - CHAR_DOUBLE_QUOTE, /* " */ - CHAR_SINGLE_QUOTE, /* ' */ - CHAR_NO_BREAK_SPACE, - CHAR_ZERO_WIDTH_NOBREAK_SPACE -} = __webpack_require__(613); +micromatch.matcher = (pattern, options) => picomatch(pattern, options); /** - * parse + * Returns true if **any** of the given glob `patterns` match the specified `string`. + * + * ```js + * const mm = require('micromatch'); + * // mm.isMatch(string, patterns[, options]); + * + * console.log(mm.isMatch('a.a', ['b.*', '*.a'])); //=> true + * console.log(mm.isMatch('a.a', 'b.*')); //=> false + * ``` + * @param {String} str The string to test. + * @param {String|Array} patterns One or more glob patterns to use for matching. + * @param {Object} [options] See available [options](#options). + * @return {Boolean} Returns true if any patterns match `str` + * @api public */ -const parse = (input, options = {}) => { - if (typeof input !== 'string') { - throw new TypeError('Expected a string'); - } - - let opts = options || {}; - let max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH; - if (input.length > max) { - throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`); - } +micromatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str); - let ast = { type: 'root', input, nodes: [] }; - let stack = [ast]; - let block = ast; - let prev = ast; - let brackets = 0; - let length = input.length; - let index = 0; - let depth = 0; - let value; - let memo = {}; +/** + * Backwards compatibility + */ - /** - * Helpers - */ +micromatch.any = micromatch.isMatch; - const advance = () => input[index++]; - const push = node => { - if (node.type === 'text' && prev.type === 'dot') { - prev.type = 'text'; - } +/** + * Returns a list of strings that _**do not match any**_ of the given `patterns`. + * + * ```js + * const mm = require('micromatch'); + * // mm.not(list, patterns[, options]); + * + * console.log(mm.not(['a.a', 'b.b', 'c.c'], '*.a')); + * //=> ['b.b', 'c.c'] + * ``` + * @param {Array} `list` Array of strings to match. + * @param {String|Array} `patterns` One or more glob pattern to use for matching. + * @param {Object} `options` See available [options](#options) for changing how matches are performed + * @return {Array} Returns an array of strings that **do not match** the given patterns. + * @api public + */ - if (prev && prev.type === 'text' && node.type === 'text') { - prev.value += node.value; - return; - } +micromatch.not = (list, patterns, options = {}) => { + patterns = [].concat(patterns).map(String); + let result = new Set(); + let items = []; - block.nodes.push(node); - node.parent = block; - node.prev = prev; - prev = node; - return node; + let onResult = state => { + if (options.onResult) options.onResult(state); + items.push(state.output); }; - push({ type: 'bos' }); - - while (index < length) { - block = stack[stack.length - 1]; - value = advance(); - - /** - * Invalid chars - */ + let matches = micromatch(list, patterns, { ...options, onResult }); - if (value === CHAR_ZERO_WIDTH_NOBREAK_SPACE || value === CHAR_NO_BREAK_SPACE) { - continue; + for (let item of items) { + if (!matches.includes(item)) { + result.add(item); } + } + return [...result]; +}; - /** - * Escaped chars - */ +/** + * Returns true if the given `string` contains the given pattern. Similar + * to [.isMatch](#isMatch) but the pattern can match any part of the string. + * + * ```js + * var mm = require('micromatch'); + * // mm.contains(string, pattern[, options]); + * + * console.log(mm.contains('aa/bb/cc', '*b')); + * //=> true + * console.log(mm.contains('aa/bb/cc', '*d')); + * //=> false + * ``` + * @param {String} `str` The string to match. + * @param {String|Array} `patterns` Glob pattern to use for matching. + * @param {Object} `options` See available [options](#options) for changing how matches are performed + * @return {Boolean} Returns true if the patter matches any part of `str`. + * @api public + */ - if (value === CHAR_BACKSLASH) { - push({ type: 'text', value: (options.keepEscaping ? value : '') + advance() }); - continue; - } +micromatch.contains = (str, pattern, options) => { + if (typeof str !== 'string') { + throw new TypeError(`Expected a string: "${util.inspect(str)}"`); + } - /** - * Right square bracket (literal): ']' - */ + if (Array.isArray(pattern)) { + return pattern.some(p => micromatch.contains(str, p, options)); + } - if (value === CHAR_RIGHT_SQUARE_BRACKET) { - push({ type: 'text', value: '\\' + value }); - continue; + if (typeof pattern === 'string') { + if (isEmptyString(str) || isEmptyString(pattern)) { + return false; } - /** - * Left square bracket: '[' - */ - - if (value === CHAR_LEFT_SQUARE_BRACKET) { - brackets++; - - let closed = true; - let next; + if (str.includes(pattern) || (str.startsWith('./') && str.slice(2).includes(pattern))) { + return true; + } + } - while (index < length && (next = advance())) { - value += next; + return micromatch.isMatch(str, pattern, { ...options, contains: true }); +}; - if (next === CHAR_LEFT_SQUARE_BRACKET) { - brackets++; - continue; - } +/** + * Filter the keys of the given object with the given `glob` pattern + * and `options`. Does not attempt to match nested keys. If you need this feature, + * use [glob-object][] instead. + * + * ```js + * const mm = require('micromatch'); + * // mm.matchKeys(object, patterns[, options]); + * + * const obj = { aa: 'a', ab: 'b', ac: 'c' }; + * console.log(mm.matchKeys(obj, '*b')); + * //=> { ab: 'b' } + * ``` + * @param {Object} `object` The object with keys to filter. + * @param {String|Array} `patterns` One or more glob patterns to use for matching. + * @param {Object} `options` See available [options](#options) for changing how matches are performed + * @return {Object} Returns an object with only keys that match the given patterns. + * @api public + */ - if (next === CHAR_BACKSLASH) { - value += advance(); - continue; - } +micromatch.matchKeys = (obj, patterns, options) => { + if (!utils.isObject(obj)) { + throw new TypeError('Expected the first argument to be an object'); + } + let keys = micromatch(Object.keys(obj), patterns, options); + let res = {}; + for (let key of keys) res[key] = obj[key]; + return res; +}; - if (next === CHAR_RIGHT_SQUARE_BRACKET) { - brackets--; +/** + * Returns true if some of the strings in the given `list` match any of the given glob `patterns`. + * + * ```js + * const mm = require('micromatch'); + * // mm.some(list, patterns[, options]); + * + * console.log(mm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js'])); + * // true + * console.log(mm.some(['foo.js'], ['*.js', '!foo.js'])); + * // false + * ``` + * @param {String|Array} `list` The string or array of strings to test. Returns as soon as the first match is found. + * @param {String|Array} `patterns` One or more glob patterns to use for matching. + * @param {Object} `options` See available [options](#options) for changing how matches are performed + * @return {Boolean} Returns true if any patterns match `str` + * @api public + */ - if (brackets === 0) { - break; - } - } - } +micromatch.some = (list, patterns, options) => { + let items = [].concat(list); - push({ type: 'text', value }); - continue; + for (let pattern of [].concat(patterns)) { + let isMatch = picomatch(String(pattern), options); + if (items.some(item => isMatch(item))) { + return true; } + } + return false; +}; - /** - * Parentheses - */ - - if (value === CHAR_LEFT_PARENTHESES) { - block = push({ type: 'paren', nodes: [] }); - stack.push(block); - push({ type: 'text', value }); - continue; - } - - if (value === CHAR_RIGHT_PARENTHESES) { - if (block.type !== 'paren') { - push({ type: 'text', value }); - continue; - } - block = stack.pop(); - push({ type: 'text', value }); - block = stack[stack.length - 1]; - continue; - } - - /** - * Quotes: '|"|` - */ - - if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) { - let open = value; - let next; - - if (options.keepQuotes !== true) { - value = ''; - } - - while (index < length && (next = advance())) { - if (next === CHAR_BACKSLASH) { - value += next + advance(); - continue; - } - - if (next === open) { - if (options.keepQuotes === true) value += next; - break; - } - - value += next; - } - - push({ type: 'text', value }); - continue; - } - - /** - * Left curly brace: '{' - */ - - if (value === CHAR_LEFT_CURLY_BRACE) { - depth++; - - let dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true; - let brace = { - type: 'brace', - open: true, - close: false, - dollar, - depth, - commas: 0, - ranges: 0, - nodes: [] - }; - - block = push(brace); - stack.push(block); - push({ type: 'open', value }); - continue; - } - - /** - * Right curly brace: '}' - */ - - if (value === CHAR_RIGHT_CURLY_BRACE) { - if (block.type !== 'brace') { - push({ type: 'text', value }); - continue; - } - - let type = 'close'; - block = stack.pop(); - block.close = true; - - push({ type, value }); - depth--; - - block = stack[stack.length - 1]; - continue; - } - - /** - * Comma: ',' - */ - - if (value === CHAR_COMMA && depth > 0) { - if (block.ranges > 0) { - block.ranges = 0; - let open = block.nodes.shift(); - block.nodes = [open, { type: 'text', value: stringify(block) }]; - } - - push({ type: 'comma', value }); - block.commas++; - continue; - } - - /** - * Dot: '.' - */ - - if (value === CHAR_DOT && depth > 0 && block.commas === 0) { - let siblings = block.nodes; - - if (depth === 0 || siblings.length === 0) { - push({ type: 'text', value }); - continue; - } - - if (prev.type === 'dot') { - block.range = []; - prev.value += value; - prev.type = 'range'; - - if (block.nodes.length !== 3 && block.nodes.length !== 5) { - block.invalid = true; - block.ranges = 0; - prev.type = 'text'; - continue; - } - - block.ranges++; - block.args = []; - continue; - } - - if (prev.type === 'range') { - siblings.pop(); +/** + * Returns true if every string in the given `list` matches + * any of the given glob `patterns`. + * + * ```js + * const mm = require('micromatch'); + * // mm.every(list, patterns[, options]); + * + * console.log(mm.every('foo.js', ['foo.js'])); + * // true + * console.log(mm.every(['foo.js', 'bar.js'], ['*.js'])); + * // true + * console.log(mm.every(['foo.js', 'bar.js'], ['*.js', '!foo.js'])); + * // false + * console.log(mm.every(['foo.js'], ['*.js', '!foo.js'])); + * // false + * ``` + * @param {String|Array} `list` The string or array of strings to test. + * @param {String|Array} `patterns` One or more glob patterns to use for matching. + * @param {Object} `options` See available [options](#options) for changing how matches are performed + * @return {Boolean} Returns true if any patterns match `str` + * @api public + */ - let before = siblings[siblings.length - 1]; - before.value += prev.value + value; - prev = before; - block.ranges--; - continue; - } +micromatch.every = (list, patterns, options) => { + let items = [].concat(list); - push({ type: 'dot', value }); - continue; + for (let pattern of [].concat(patterns)) { + let isMatch = picomatch(String(pattern), options); + if (!items.every(item => isMatch(item))) { + return false; } - - /** - * Text - */ - - push({ type: 'text', value }); } - - // Mark imbalanced braces and brackets as invalid - do { - block = stack.pop(); - - if (block.type !== 'root') { - block.nodes.forEach(node => { - if (!node.nodes) { - if (node.type === 'open') node.isOpen = true; - if (node.type === 'close') node.isClose = true; - if (!node.nodes) node.type = 'text'; - node.invalid = true; - } - }); - - // get the location of the block on parent.nodes (block's siblings) - let parent = stack[stack.length - 1]; - let index = parent.nodes.indexOf(block); - // replace the (invalid) block with it's nodes - parent.nodes.splice(index, 1, ...block.nodes); - } - } while (stack.length > 0); - - push({ type: 'eos' }); - return ast; -}; - -module.exports = parse; - - -/***/ }), -/* 613 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -module.exports = { - MAX_LENGTH: 1024 * 64, - - // Digits - CHAR_0: '0', /* 0 */ - CHAR_9: '9', /* 9 */ - - // Alphabet chars. - CHAR_UPPERCASE_A: 'A', /* A */ - CHAR_LOWERCASE_A: 'a', /* a */ - CHAR_UPPERCASE_Z: 'Z', /* Z */ - CHAR_LOWERCASE_Z: 'z', /* z */ - - CHAR_LEFT_PARENTHESES: '(', /* ( */ - CHAR_RIGHT_PARENTHESES: ')', /* ) */ - - CHAR_ASTERISK: '*', /* * */ - - // Non-alphabetic chars. - CHAR_AMPERSAND: '&', /* & */ - CHAR_AT: '@', /* @ */ - CHAR_BACKSLASH: '\\', /* \ */ - CHAR_BACKTICK: '`', /* ` */ - CHAR_CARRIAGE_RETURN: '\r', /* \r */ - CHAR_CIRCUMFLEX_ACCENT: '^', /* ^ */ - CHAR_COLON: ':', /* : */ - CHAR_COMMA: ',', /* , */ - CHAR_DOLLAR: '$', /* . */ - CHAR_DOT: '.', /* . */ - CHAR_DOUBLE_QUOTE: '"', /* " */ - CHAR_EQUAL: '=', /* = */ - CHAR_EXCLAMATION_MARK: '!', /* ! */ - CHAR_FORM_FEED: '\f', /* \f */ - CHAR_FORWARD_SLASH: '/', /* / */ - CHAR_HASH: '#', /* # */ - CHAR_HYPHEN_MINUS: '-', /* - */ - CHAR_LEFT_ANGLE_BRACKET: '<', /* < */ - CHAR_LEFT_CURLY_BRACE: '{', /* { */ - CHAR_LEFT_SQUARE_BRACKET: '[', /* [ */ - CHAR_LINE_FEED: '\n', /* \n */ - CHAR_NO_BREAK_SPACE: '\u00A0', /* \u00A0 */ - CHAR_PERCENT: '%', /* % */ - CHAR_PLUS: '+', /* + */ - CHAR_QUESTION_MARK: '?', /* ? */ - CHAR_RIGHT_ANGLE_BRACKET: '>', /* > */ - CHAR_RIGHT_CURLY_BRACE: '}', /* } */ - CHAR_RIGHT_SQUARE_BRACKET: ']', /* ] */ - CHAR_SEMICOLON: ';', /* ; */ - CHAR_SINGLE_QUOTE: '\'', /* ' */ - CHAR_SPACE: ' ', /* */ - CHAR_TAB: '\t', /* \t */ - CHAR_UNDERSCORE: '_', /* _ */ - CHAR_VERTICAL_LINE: '|', /* | */ - CHAR_ZERO_WIDTH_NOBREAK_SPACE: '\uFEFF' /* \uFEFF */ + return true; }; - -/***/ }), -/* 614 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -module.exports = __webpack_require__(615); - - -/***/ }), -/* 615 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -const path = __webpack_require__(16); -const scan = __webpack_require__(616); -const parse = __webpack_require__(619); -const utils = __webpack_require__(617); - /** - * Creates a matcher function from one or more glob patterns. The - * returned function takes a string to match as its first argument, - * and returns true if the string is a match. The returned matcher - * function also takes a boolean as the second argument that, when true, - * returns an object with additional information. + * Returns true if **all** of the given `patterns` match + * the specified string. * * ```js - * const picomatch = require('picomatch'); - * // picomatch(glob[, options]); + * const mm = require('micromatch'); + * // mm.all(string, patterns[, options]); * - * const isMatch = picomatch('*.!(*a)'); - * console.log(isMatch('a.a')); //=> false - * console.log(isMatch('a.b')); //=> true + * console.log(mm.all('foo.js', ['foo.js'])); + * // true + * + * console.log(mm.all('foo.js', ['*.js', '!foo.js'])); + * // false + * + * console.log(mm.all('foo.js', ['*.js', 'foo.js'])); + * // true + * + * console.log(mm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js'])); + * // true * ``` - * @name picomatch - * @param {String|Array} `globs` One or more glob patterns. - * @param {Object=} `options` - * @return {Function=} Returns a matcher function. + * @param {String|Array} `str` The string to test. + * @param {String|Array} `patterns` One or more glob patterns to use for matching. + * @param {Object} `options` See available [options](#options) for changing how matches are performed + * @return {Boolean} Returns true if any patterns match `str` * @api public */ -const picomatch = (glob, options, returnState = false) => { - if (Array.isArray(glob)) { - let fns = glob.map(input => picomatch(input, options, returnState)); - return str => { - for (let isMatch of fns) { - let state = isMatch(str); - if (state) return state; - } - return false; - }; - } - - if (typeof glob !== 'string' || glob === '') { - throw new TypeError('Expected pattern to be a non-empty string'); - } - - let opts = options || {}; - let posix = utils.isWindows(options); - let regex = picomatch.makeRe(glob, options, false, true); - let state = regex.state; - delete regex.state; - - let isIgnored = () => false; - if (opts.ignore) { - let ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null }; - isIgnored = picomatch(opts.ignore, ignoreOpts, returnState); - } - - const matcher = (input, returnObject = false) => { - let { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix }); - let result = { glob, state, regex, posix, input, output, match, isMatch }; - - if (typeof opts.onResult === 'function') { - opts.onResult(result); - } - - if (isMatch === false) { - result.isMatch = false; - return returnObject ? result : false; - } - - if (isIgnored(input)) { - if (typeof opts.onIgnore === 'function') { - opts.onIgnore(result); - } - result.isMatch = false; - return returnObject ? result : false; - } - - if (typeof opts.onMatch === 'function') { - opts.onMatch(result); - } - return returnObject ? result : true; - }; - - if (returnState) { - matcher.state = state; +micromatch.all = (str, patterns, options) => { + if (typeof str !== 'string') { + throw new TypeError(`Expected a string: "${util.inspect(str)}"`); } - return matcher; + return [].concat(patterns).every(p => picomatch(p, options)(str)); }; /** - * Test `input` with the given `regex`. This is used by the main - * `picomatch()` function to test the input string. + * Returns an array of matches captured by `pattern` in `string, or `null` if the pattern did not match. * * ```js - * const picomatch = require('picomatch'); - * // picomatch.test(input, regex[, options]); + * const mm = require('micromatch'); + * // mm.capture(pattern, string[, options]); * - * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/)); - * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' } + * console.log(mm.capture('test/*.js', 'test/foo.js')); + * //=> ['foo'] + * console.log(mm.capture('test/*.js', 'foo/bar.css')); + * //=> null * ``` - * @param {String} `input` String to test. - * @param {RegExp} `regex` - * @return {Object} Returns an object with matching info. + * @param {String} `glob` Glob pattern to use for matching. + * @param {String} `input` String to match + * @param {Object} `options` See available [options](#options) for changing how matches are performed + * @return {Boolean} Returns an array of captures if the input matches the glob pattern, otherwise `null`. * @api public */ -picomatch.test = (input, regex, options, { glob, posix } = {}) => { - if (typeof input !== 'string') { - throw new TypeError('Expected input to be a string'); - } - - if (input === '') { - return { isMatch: false, output: '' }; - } - - let opts = options || {}; - let format = opts.format || (posix ? utils.toPosixSlashes : null); - let match = input === glob; - let output = (match && format) ? format(input) : input; - - if (match === false) { - output = format ? format(input) : input; - match = output === glob; - } +micromatch.capture = (glob, input, options) => { + let posix = utils.isWindows(options); + let regex = picomatch.makeRe(String(glob), { ...options, capture: true }); + let match = regex.exec(posix ? utils.toPosixSlashes(input) : input); - if (match === false || opts.capture === true) { - if (opts.matchBase === true || opts.basename === true) { - match = picomatch.matchBase(input, regex, options, posix); - } else { - match = regex.exec(output); - } + if (match) { + return match.slice(1).map(v => v === void 0 ? '' : v); } - - return { isMatch: !!match, match, output }; }; /** - * Match the basename of a filepath. + * Create a regular expression from the given glob `pattern`. * * ```js - * const picomatch = require('picomatch'); - * // picomatch.matchBase(input, glob[, options]); - * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true + * const mm = require('micromatch'); + * // mm.makeRe(pattern[, options]); + * + * console.log(mm.makeRe('*.js')); + * //=> /^(?:(\.[\\\/])?(?!\.)(?=.)[^\/]*?\.js)$/ * ``` - * @param {String} `input` String to test. - * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe). - * @return {Boolean} + * @param {String} `pattern` A glob pattern to convert to regex. + * @param {Object} `options` + * @return {RegExp} Returns a regex created from the given pattern. * @api public */ -picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) => { - let regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options); - return regex.test(path.basename(input)); -}; +micromatch.makeRe = (...args) => picomatch.makeRe(...args); /** - * Returns true if **any** of the given glob `patterns` match the specified `string`. + * Scan a glob pattern to separate the pattern into segments. Used + * by the [split](#split) method. * * ```js - * const picomatch = require('picomatch'); - * // picomatch.isMatch(string, patterns[, options]); - * - * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true - * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false + * const mm = require('micromatch'); + * const state = mm.scan(pattern[, options]); * ``` - * @param {String|Array} str The string to test. - * @param {String|Array} patterns One or more glob patterns to use for matching. - * @param {Object} [options] See available [options](#options). - * @return {Boolean} Returns true if any patterns match `str` + * @param {String} `pattern` + * @param {Object} `options` + * @return {Object} Returns an object with * @api public */ -picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str); +micromatch.scan = (...args) => picomatch.scan(...args); /** * Parse a glob pattern to create the source string for a regular * expression. * * ```js - * const picomatch = require('picomatch'); - * const result = picomatch.parse(glob[, options]); + * const mm = require('micromatch'); + * const state = mm(pattern[, options]); * ``` * @param {String} `glob` * @param {Object} `options` - * @return {Object} Returns an object with useful properties and output to be used as a regex source string. + * @return {Object} Returns an object with useful properties and output to be used as regex source string. * @api public */ -picomatch.parse = (glob, options) => parse(glob, options); +micromatch.parse = (patterns, options) => { + let res = []; + for (let pattern of [].concat(patterns || [])) { + for (let str of braces(String(pattern), options)) { + res.push(picomatch.parse(str, options)); + } + } + return res; +}; /** - * Scan a glob pattern to separate the pattern into segments. + * Process the given brace `pattern`. * * ```js - * const picomatch = require('picomatch'); - * // picomatch.scan(input[, options]); + * const { braces } = require('micromatch'); + * console.log(braces('foo/{a,b,c}/bar')); + * //=> [ 'foo/(a|b|c)/bar' ] * - * const result = picomatch.scan('!./foo/*.js'); - * console.log(result); - * // { prefix: '!./', - * // input: '!./foo/*.js', - * // base: 'foo', - * // glob: '*.js', - * // negated: true, - * // isGlob: true } + * console.log(braces('foo/{a,b,c}/bar', { expand: true })); + * //=> [ 'foo/a/bar', 'foo/b/bar', 'foo/c/bar' ] * ``` - * @param {String} `input` Glob pattern to scan. - * @param {Object} `options` - * @return {Object} Returns an object with + * @param {String} `pattern` String with brace pattern to process. + * @param {Object} `options` Any [options](#options) to change how expansion is performed. See the [braces][] library for all available options. + * @return {Array} * @api public */ -picomatch.scan = (input, options) => scan(input, options); +micromatch.braces = (pattern, options) => { + if (typeof pattern !== 'string') throw new TypeError('Expected a string'); + if ((options && options.nobrace === true) || !/\{.*\}/.test(pattern)) { + return [pattern]; + } + return braces(pattern, options); +}; /** - * Create a regular expression from a glob pattern. - * - * ```js - * const picomatch = require('picomatch'); - * // picomatch.makeRe(input[, options]); - * - * console.log(picomatch.makeRe('*.js')); - * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/ - * ``` - * @param {String} `input` A glob pattern to convert to regex. - * @param {Object} `options` - * @return {RegExp} Returns a regex created from the given pattern. - * @api public + * Expand braces */ -picomatch.makeRe = (input, options, returnOutput = false, returnState = false) => { - if (!input || typeof input !== 'string') { - throw new TypeError('Expected a non-empty string'); - } +micromatch.braceExpand = (pattern, options) => { + if (typeof pattern !== 'string') throw new TypeError('Expected a string'); + return micromatch.braces(pattern, { ...options, expand: true }); +}; - let opts = options || {}; - let prepend = opts.contains ? '' : '^'; - let append = opts.contains ? '' : '$'; - let state = { negated: false, fastpaths: true }; - let prefix = ''; - let output; +/** + * Expose micromatch + */ - if (input.startsWith('./')) { - input = input.slice(2); - prefix = state.prefix = './'; - } +module.exports = micromatch; - if (opts.fastpaths !== false && (input[0] === '.' || input[0] === '*')) { - output = parse.fastpaths(input, options); - } - if (output === void 0) { - state = picomatch.parse(input, options); - state.prefix = prefix + (state.prefix || ''); - output = state.output; - } +/***/ }), +/* 609 */ +/***/ (function(module, exports, __webpack_require__) { - if (returnOutput === true) { - return output; - } +"use strict"; - let source = `${prepend}(?:${output})${append}`; - if (state && state.negated === true) { - source = `^(?!${source}).*$`; - } - let regex = picomatch.toRegex(source, options); - if (returnState === true) { - regex.state = state; +const stringify = __webpack_require__(610); +const compile = __webpack_require__(612); +const expand = __webpack_require__(616); +const parse = __webpack_require__(617); + +/** + * Expand the given pattern or create a regex-compatible string. + * + * ```js + * const braces = require('braces'); + * console.log(braces('{a,b,c}', { compile: true })); //=> ['(a|b|c)'] + * console.log(braces('{a,b,c}')); //=> ['a', 'b', 'c'] + * ``` + * @param {String} `str` + * @param {Object} `options` + * @return {String} + * @api public + */ + +const braces = (input, options = {}) => { + let output = []; + + if (Array.isArray(input)) { + for (let pattern of input) { + let result = braces.create(pattern, options); + if (Array.isArray(result)) { + output.push(...result); + } else { + output.push(result); + } + } + } else { + output = [].concat(braces.create(input, options)); } - return regex; + if (options && options.expand === true && options.nodupes === true) { + output = [...new Set(output)]; + } + return output; }; /** - * Create a regular expression from the given regex source string. + * Parse the given `str` with the given `options`. * * ```js - * const picomatch = require('picomatch'); - * // picomatch.toRegex(source[, options]); + * // braces.parse(pattern, [, options]); + * const ast = braces.parse('a/{b,c}/d'); + * console.log(ast); + * ``` + * @param {String} pattern Brace pattern to parse + * @param {Object} options + * @return {Object} Returns an AST + * @api public + */ + +braces.parse = (input, options = {}) => parse(input, options); + +/** + * Creates a braces string from an AST, or an AST node. * - * const { output } = picomatch.parse('*.js'); - * console.log(picomatch.toRegex(output)); - * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/ + * ```js + * const braces = require('braces'); + * let ast = braces.parse('foo/{a,b}/bar'); + * console.log(stringify(ast.nodes[2])); //=> '{a,b}' * ``` - * @param {String} `source` Regular expression source string. + * @param {String} `input` Brace pattern or AST. * @param {Object} `options` - * @return {RegExp} + * @return {Array} Returns an array of expanded values. * @api public */ -picomatch.toRegex = (source, options) => { - try { - let opts = options || {}; - return new RegExp(source, opts.flags || (opts.nocase ? 'i' : '')); - } catch (err) { - if (options && options.debug === true) throw err; - return /$^/; +braces.stringify = (input, options = {}) => { + if (typeof input === 'string') { + return stringify(braces.parse(input, options), options); } + return stringify(input, options); }; /** - * Picomatch constants. - * @return {Object} + * Compiles a brace pattern into a regex-compatible, optimized string. + * This method is called by the main [braces](#braces) function by default. + * + * ```js + * const braces = require('braces'); + * console.log(braces.compile('a/{b,c}/d')); + * //=> ['a/(b|c)/d'] + * ``` + * @param {String} `input` Brace pattern or AST. + * @param {Object} `options` + * @return {Array} Returns an array of expanded values. + * @api public */ -picomatch.constants = __webpack_require__(618); +braces.compile = (input, options = {}) => { + if (typeof input === 'string') { + input = braces.parse(input, options); + } + return compile(input, options); +}; /** - * Expose "picomatch" + * Expands a brace pattern into an array. This method is called by the + * main [braces](#braces) function when `options.expand` is true. Before + * using this method it's recommended that you read the [performance notes](#performance)) + * and advantages of using [.compile](#compile) instead. + * + * ```js + * const braces = require('braces'); + * console.log(braces.expand('a/{b,c}/d')); + * //=> ['a/b/d', 'a/c/d']; + * ``` + * @param {String} `pattern` Brace pattern + * @param {Object} `options` + * @return {Array} Returns an array of expanded values. + * @api public */ -module.exports = picomatch; - - -/***/ }), -/* 616 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; +braces.expand = (input, options = {}) => { + if (typeof input === 'string') { + input = braces.parse(input, options); + } + let result = expand(input, options); -const utils = __webpack_require__(617); + // filter out empty strings if specified + if (options.noempty === true) { + result = result.filter(Boolean); + } -const { - CHAR_ASTERISK, /* * */ - CHAR_AT, /* @ */ - CHAR_BACKWARD_SLASH, /* \ */ - CHAR_COMMA, /* , */ - CHAR_DOT, /* . */ - CHAR_EXCLAMATION_MARK, /* ! */ - CHAR_FORWARD_SLASH, /* / */ - CHAR_LEFT_CURLY_BRACE, /* { */ - CHAR_LEFT_PARENTHESES, /* ( */ - CHAR_LEFT_SQUARE_BRACKET, /* [ */ - CHAR_PLUS, /* + */ - CHAR_QUESTION_MARK, /* ? */ - CHAR_RIGHT_CURLY_BRACE, /* } */ - CHAR_RIGHT_PARENTHESES, /* ) */ - CHAR_RIGHT_SQUARE_BRACKET /* ] */ -} = __webpack_require__(618); + // filter out duplicates if specified + if (options.nodupes === true) { + result = [...new Set(result)]; + } -const isPathSeparator = code => { - return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH; + return result; }; /** - * Quickly scans a glob pattern and returns an object with a handful of - * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists), - * `glob` (the actual pattern), and `negated` (true if the path starts with `!`). + * Processes a brace pattern and returns either an expanded array + * (if `options.expand` is true), a highly optimized regex-compatible string. + * This method is called by the main [braces](#braces) function. * * ```js - * const pm = require('picomatch'); - * console.log(pm.scan('foo/bar/*.js')); - * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' } + * const braces = require('braces'); + * console.log(braces.create('user-{200..300}/project-{a,b,c}-{1..10}')) + * //=> 'user-(20[0-9]|2[1-9][0-9]|300)/project-(a|b|c)-([1-9]|10)' * ``` - * @param {String} `str` + * @param {String} `pattern` Brace pattern * @param {Object} `options` - * @return {Object} Returns an object with tokens and regex source string. + * @return {Array} Returns an array of expanded values. * @api public */ -module.exports = (input, options) => { - let opts = options || {}; - let length = input.length - 1; - let index = -1; - let start = 0; - let lastIndex = 0; - let isGlob = false; - let backslashes = false; - let negated = false; - let braces = 0; - let prev; - let code; - - let braceEscaped = false; - - let eos = () => index >= length; - let advance = () => { - prev = code; - return input.charCodeAt(++index); - }; +braces.create = (input, options = {}) => { + if (input === '' || input.length < 3) { + return [input]; + } - while (index < length) { - code = advance(); - let next; + return options.expand !== true + ? braces.compile(input, options) + : braces.expand(input, options); +}; - if (code === CHAR_BACKWARD_SLASH) { - backslashes = true; - next = advance(); +/** + * Expose "braces" + */ - if (next === CHAR_LEFT_CURLY_BRACE) { - braceEscaped = true; - } - continue; - } +module.exports = braces; - if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) { - braces++; - while (!eos() && (next = advance())) { - if (next === CHAR_BACKWARD_SLASH) { - backslashes = true; - next = advance(); - continue; - } +/***/ }), +/* 610 */ +/***/ (function(module, exports, __webpack_require__) { - if (next === CHAR_LEFT_CURLY_BRACE) { - braces++; - continue; - } +"use strict"; - if (!braceEscaped && next === CHAR_DOT && (next = advance()) === CHAR_DOT) { - isGlob = true; - break; - } - if (!braceEscaped && next === CHAR_COMMA) { - isGlob = true; - break; - } +const utils = __webpack_require__(611); - if (next === CHAR_RIGHT_CURLY_BRACE) { - braces--; - if (braces === 0) { - braceEscaped = false; - break; - } - } - } - } +module.exports = (ast, options = {}) => { + let stringify = (node, parent = {}) => { + let invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent); + let invalidNode = node.invalid === true && options.escapeInvalid === true; + let output = ''; - if (code === CHAR_FORWARD_SLASH) { - if (prev === CHAR_DOT && index === (start + 1)) { - start += 2; - continue; + if (node.value) { + if ((invalidBlock || invalidNode) && utils.isOpenOrClose(node)) { + return '\\' + node.value; } - - lastIndex = index + 1; - continue; - } - - if (code === CHAR_ASTERISK) { - isGlob = true; - break; + return node.value; } - if (code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK) { - isGlob = true; - break; + if (node.value) { + return node.value; } - if (code === CHAR_LEFT_SQUARE_BRACKET) { - while (!eos() && (next = advance())) { - if (next === CHAR_BACKWARD_SLASH) { - backslashes = true; - next = advance(); - continue; - } - - if (next === CHAR_RIGHT_SQUARE_BRACKET) { - isGlob = true; - break; - } + if (node.nodes) { + for (let child of node.nodes) { + output += stringify(child); } } + return output; + }; - let isExtglobChar = code === CHAR_PLUS - || code === CHAR_AT - || code === CHAR_EXCLAMATION_MARK; - - if (isExtglobChar && input.charCodeAt(index + 1) === CHAR_LEFT_PARENTHESES) { - isGlob = true; - break; - } + return stringify(ast); +}; - if (code === CHAR_EXCLAMATION_MARK && index === start) { - negated = true; - start++; - continue; - } - if (code === CHAR_LEFT_PARENTHESES) { - while (!eos() && (next = advance())) { - if (next === CHAR_BACKWARD_SLASH) { - backslashes = true; - next = advance(); - continue; - } - if (next === CHAR_RIGHT_PARENTHESES) { - isGlob = true; - break; - } - } - } +/***/ }), +/* 611 */ +/***/ (function(module, exports, __webpack_require__) { - if (isGlob) { - break; - } - } +"use strict"; - let prefix = ''; - let orig = input; - let base = input; - let glob = ''; - if (start > 0) { - prefix = input.slice(0, start); - input = input.slice(start); - lastIndex -= start; +exports.isInteger = num => { + if (typeof num === 'number') { + return Number.isInteger(num); } - - if (base && isGlob === true && lastIndex > 0) { - base = input.slice(0, lastIndex); - glob = input.slice(lastIndex); - } else if (isGlob === true) { - base = ''; - glob = input; - } else { - base = input; + if (typeof num === 'string' && num.trim() !== '') { + return Number.isInteger(Number(num)); } + return false; +}; - if (base && base !== '' && base !== '/' && base !== input) { - if (isPathSeparator(base.charCodeAt(base.length - 1))) { - base = base.slice(0, -1); - } - } +/** + * Find a node of the given type + */ - if (opts.unescape === true) { - if (glob) glob = utils.removeBackslashes(glob); +exports.find = (node, type) => node.nodes.find(node => node.type === type); - if (base && backslashes === true) { - base = utils.removeBackslashes(base); - } - } +/** + * Find a node of the given type + */ - return { prefix, input: orig, base, glob, negated, isGlob }; +exports.exceedsLimit = (min, max, step = 1, limit) => { + if (limit === false) return false; + if (!exports.isInteger(min) || !exports.isInteger(max)) return false; + return ((Number(max) - Number(min)) / Number(step)) >= limit; }; +/** + * Escape the given node with '\\' before node.value + */ -/***/ }), -/* 617 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -const path = __webpack_require__(16); -const win32 = process.platform === 'win32'; -const { - REGEX_SPECIAL_CHARS, - REGEX_SPECIAL_CHARS_GLOBAL, - REGEX_REMOVE_BACKSLASH -} = __webpack_require__(618); +exports.escapeNode = (block, n = 0, type) => { + let node = block.nodes[n]; + if (!node) return; -exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val); -exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str); -exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str); -exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1'); -exports.toPosixSlashes = str => str.replace(/\\/g, '/'); + if ((type && node.type === type) || node.type === 'open' || node.type === 'close') { + if (node.escaped !== true) { + node.value = '\\' + node.value; + node.escaped = true; + } + } +}; -exports.removeBackslashes = str => { - return str.replace(REGEX_REMOVE_BACKSLASH, match => { - return match === '\\' ? '' : match; - }); -} +/** + * Returns true if the given brace node should be enclosed in literal braces + */ -exports.supportsLookbehinds = () => { - let segs = process.version.slice(1).split('.'); - if (segs.length === 3 && +segs[0] >= 9 || (+segs[0] === 8 && +segs[1] >= 10)) { +exports.encloseBrace = node => { + if (node.type !== 'brace') return false; + if ((node.commas >> 0 + node.ranges >> 0) === 0) { + node.invalid = true; return true; } return false; }; -exports.isWindows = options => { - if (options && typeof options.windows === 'boolean') { - return options.windows; +/** + * Returns true if a brace node is invalid. + */ + +exports.isInvalidBrace = block => { + if (block.type !== 'brace') return false; + if (block.invalid === true || block.dollar) return true; + if ((block.commas >> 0 + block.ranges >> 0) === 0) { + block.invalid = true; + return true; } - return win32 === true || path.sep === '\\'; + if (block.open !== true || block.close !== true) { + block.invalid = true; + return true; + } + return false; }; -exports.escapeLast = (input, char, lastIdx) => { - let idx = input.lastIndexOf(char, lastIdx); - if (idx === -1) return input; - if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1); - return input.slice(0, idx) + '\\' + input.slice(idx); -}; - - -/***/ }), -/* 618 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -const path = __webpack_require__(16); -const WIN_SLASH = '\\\\/'; -const WIN_NO_SLASH = `[^${WIN_SLASH}]`; - /** - * Posix glob regex + * Returns true if a node is an open or close node */ -const DOT_LITERAL = '\\.'; -const PLUS_LITERAL = '\\+'; -const QMARK_LITERAL = '\\?'; -const SLASH_LITERAL = '\\/'; -const ONE_CHAR = '(?=.)'; -const QMARK = '[^/]'; -const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`; -const START_ANCHOR = `(?:^|${SLASH_LITERAL})`; -const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`; -const NO_DOT = `(?!${DOT_LITERAL})`; -const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`; -const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`; -const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`; -const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`; -const STAR = `${QMARK}*?`; - -const POSIX_CHARS = { - DOT_LITERAL, - PLUS_LITERAL, - QMARK_LITERAL, - SLASH_LITERAL, - ONE_CHAR, - QMARK, - END_ANCHOR, - DOTS_SLASH, - NO_DOT, - NO_DOTS, - NO_DOT_SLASH, - NO_DOTS_SLASH, - QMARK_NO_DOT, - STAR, - START_ANCHOR +exports.isOpenOrClose = node => { + if (node.type === 'open' || node.type === 'close') { + return true; + } + return node.open === true || node.close === true; }; /** - * Windows glob regex + * Reduce an array of text nodes. */ -const WINDOWS_CHARS = { - ...POSIX_CHARS, - - SLASH_LITERAL: `[${WIN_SLASH}]`, - QMARK: WIN_NO_SLASH, - STAR: `${WIN_NO_SLASH}*?`, - DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`, - NO_DOT: `(?!${DOT_LITERAL})`, - NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`, - NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`, - NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`, - QMARK_NO_DOT: `[^.${WIN_SLASH}]`, - START_ANCHOR: `(?:^|[${WIN_SLASH}])`, - END_ANCHOR: `(?:[${WIN_SLASH}]|$)` -}; +exports.reduce = nodes => nodes.reduce((acc, node) => { + if (node.type === 'text') acc.push(node.value); + if (node.type === 'range') node.type = 'text'; + return acc; +}, []); /** - * POSIX Bracket Regex + * Flatten an array */ -const POSIX_REGEX_SOURCE = { - alnum: 'a-zA-Z0-9', - alpha: 'a-zA-Z', - ascii: '\\x00-\\x7F', - blank: ' \\t', - cntrl: '\\x00-\\x1F\\x7F', - digit: '0-9', - graph: '\\x21-\\x7E', - lower: 'a-z', - print: '\\x20-\\x7E ', - punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~', - space: ' \\t\\r\\n\\v\\f', - upper: 'A-Z', - word: 'A-Za-z0-9_', - xdigit: 'A-Fa-f0-9' +exports.flatten = (...args) => { + const result = []; + const flat = arr => { + for (let i = 0; i < arr.length; i++) { + let ele = arr[i]; + Array.isArray(ele) ? flat(ele, result) : ele !== void 0 && result.push(ele); + } + return result; + }; + flat(args); + return result; }; -module.exports = { - MAX_LENGTH: 1024 * 64, - POSIX_REGEX_SOURCE, - // regular expressions - REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g, - REGEX_NON_SPECIAL_CHAR: /^[^@![\].,$*+?^{}()|\\/]+/, - REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/, - REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g, - REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g, - REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g, +/***/ }), +/* 612 */ +/***/ (function(module, exports, __webpack_require__) { - // Replace globs with equivalent patterns to reduce parsing time. - REPLACEMENTS: { - '***': '*', - '**/**': '**', - '**/**/**': '**' - }, +"use strict"; - // Digits - CHAR_0: 48, /* 0 */ - CHAR_9: 57, /* 9 */ - // Alphabet chars. - CHAR_UPPERCASE_A: 65, /* A */ - CHAR_LOWERCASE_A: 97, /* a */ - CHAR_UPPERCASE_Z: 90, /* Z */ - CHAR_LOWERCASE_Z: 122, /* z */ +const fill = __webpack_require__(613); +const utils = __webpack_require__(611); - CHAR_LEFT_PARENTHESES: 40, /* ( */ - CHAR_RIGHT_PARENTHESES: 41, /* ) */ +const compile = (ast, options = {}) => { + let walk = (node, parent = {}) => { + let invalidBlock = utils.isInvalidBrace(parent); + let invalidNode = node.invalid === true && options.escapeInvalid === true; + let invalid = invalidBlock === true || invalidNode === true; + let prefix = options.escapeInvalid === true ? '\\' : ''; + let output = ''; - CHAR_ASTERISK: 42, /* * */ + if (node.isOpen === true) { + return prefix + node.value; + } + if (node.isClose === true) { + return prefix + node.value; + } - // Non-alphabetic chars. - CHAR_AMPERSAND: 38, /* & */ - CHAR_AT: 64, /* @ */ - CHAR_BACKWARD_SLASH: 92, /* \ */ - CHAR_CARRIAGE_RETURN: 13, /* \r */ - CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */ - CHAR_COLON: 58, /* : */ - CHAR_COMMA: 44, /* , */ - CHAR_DOT: 46, /* . */ - CHAR_DOUBLE_QUOTE: 34, /* " */ - CHAR_EQUAL: 61, /* = */ - CHAR_EXCLAMATION_MARK: 33, /* ! */ - CHAR_FORM_FEED: 12, /* \f */ - CHAR_FORWARD_SLASH: 47, /* / */ - CHAR_GRAVE_ACCENT: 96, /* ` */ - CHAR_HASH: 35, /* # */ - CHAR_HYPHEN_MINUS: 45, /* - */ - CHAR_LEFT_ANGLE_BRACKET: 60, /* < */ - CHAR_LEFT_CURLY_BRACE: 123, /* { */ - CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */ - CHAR_LINE_FEED: 10, /* \n */ - CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */ - CHAR_PERCENT: 37, /* % */ - CHAR_PLUS: 43, /* + */ - CHAR_QUESTION_MARK: 63, /* ? */ - CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */ - CHAR_RIGHT_CURLY_BRACE: 125, /* } */ - CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */ - CHAR_SEMICOLON: 59, /* ; */ - CHAR_SINGLE_QUOTE: 39, /* ' */ - CHAR_SPACE: 32, /* */ - CHAR_TAB: 9, /* \t */ - CHAR_UNDERSCORE: 95, /* _ */ - CHAR_VERTICAL_LINE: 124, /* | */ - CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */ + if (node.type === 'open') { + return invalid ? (prefix + node.value) : '('; + } - SEP: path.sep, + if (node.type === 'close') { + return invalid ? (prefix + node.value) : ')'; + } - /** - * Create EXTGLOB_CHARS - */ + if (node.type === 'comma') { + return node.prev.type === 'comma' ? '' : (invalid ? node.value : '|'); + } - extglobChars(chars) { - return { - '!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` }, - '?': { type: 'qmark', open: '(?:', close: ')?' }, - '+': { type: 'plus', open: '(?:', close: ')+' }, - '*': { type: 'star', open: '(?:', close: ')*' }, - '@': { type: 'at', open: '(?:', close: ')' } - }; - }, + if (node.value) { + return node.value; + } - /** - * Create GLOB_CHARS - */ + if (node.nodes && node.ranges > 0) { + let args = utils.reduce(node.nodes); + let range = fill(...args, { ...options, wrap: false, toRegex: true }); - globChars(win32) { - return win32 === true ? WINDOWS_CHARS : POSIX_CHARS; - } + if (range.length !== 0) { + return args.length > 1 && range.length > 1 ? `(${range})` : range; + } + } + + if (node.nodes) { + for (let child of node.nodes) { + output += walk(child, node); + } + } + return output; + }; + + return walk(ast); }; +module.exports = compile; + /***/ }), -/* 619 */ +/* 613 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; - - -const utils = __webpack_require__(617); -const constants = __webpack_require__(618); - -/** - * Constants +/*! + * fill-range + * + * Copyright (c) 2014-present, Jon Schlinkert. + * Licensed under the MIT License. */ -const { - MAX_LENGTH, - POSIX_REGEX_SOURCE, - REGEX_NON_SPECIAL_CHAR, - REGEX_SPECIAL_CHARS_BACKREF, - REPLACEMENTS -} = constants; -/** - * Helpers - */ -const expandRange = (args, options) => { - if (typeof options.expandRange === 'function') { - return options.expandRange(...args, options); - } +const util = __webpack_require__(29); +const toRegexRange = __webpack_require__(614); - args.sort(); - let value = `[${args.join('-')}]`; +const isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val); - try { - /* eslint-disable no-new */ - new RegExp(value); - } catch (ex) { - return args.map(v => utils.escapeRegex(v)).join('..'); - } +const transform = toNumber => { + return value => toNumber === true ? Number(value) : String(value); +}; - return value; +const isValidValue = value => { + return typeof value === 'number' || (typeof value === 'string' && value !== ''); }; -const negate = state => { - let count = 1; +const isNumber = num => Number.isInteger(+num); - while (state.peek() === '!' && (state.peek(2) !== '(' || state.peek(3) === '?')) { - state.advance(); - state.start++; - count++; +const zeros = input => { + let value = `${input}`; + let index = -1; + if (value[0] === '-') value = value.slice(1); + if (value === '0') return false; + while (value[++index] === '0'); + return index > 0; +}; + +const stringify = (start, end, options) => { + if (typeof start === 'string' || typeof end === 'string') { + return true; } + return options.stringify === true; +}; - if (count % 2 === 0) { - return false; +const pad = (input, maxLength, toNumber) => { + if (maxLength > 0) { + let dash = input[0] === '-' ? '-' : ''; + if (dash) input = input.slice(1); + input = (dash + input.padStart(dash ? maxLength - 1 : maxLength, '0')); + } + if (toNumber === false) { + return String(input); } + return input; +}; - state.negated = true; - state.start++; - return true; +const toMaxLen = (input, maxLength) => { + let negative = input[0] === '-' ? '-' : ''; + if (negative) { + input = input.slice(1); + maxLength--; + } + while (input.length < maxLength) input = '0' + input; + return negative ? ('-' + input) : input; }; -/** - * Create the message for a syntax error - */ +const toSequence = (parts, options) => { + parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0); + parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0); -const syntaxError = (type, char) => { - return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`; -}; + let prefix = options.capture ? '' : '?:'; + let positives = ''; + let negatives = ''; + let result; -/** - * Parse the given input string. - * @param {String} input - * @param {Object} options - * @return {Object} - */ + if (parts.positives.length) { + positives = parts.positives.join('|'); + } -const parse = (input, options) => { - if (typeof input !== 'string') { - throw new TypeError('Expected a string'); + if (parts.negatives.length) { + negatives = `-(${prefix}${parts.negatives.join('|')})`; } - input = REPLACEMENTS[input] || input; + if (positives && negatives) { + result = `${positives}|${negatives}`; + } else { + result = positives || negatives; + } - let opts = { ...options }; - let max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH; - let len = input.length; - if (len > max) { - throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`); + if (options.wrap) { + return `(${prefix}${result})`; } - let bos = { type: 'bos', value: '', output: opts.prepend || '' }; - let tokens = [bos]; + return result; +}; - let capture = opts.capture ? '' : '?:'; - let win32 = utils.isWindows(options); +const toRange = (a, b, isNumbers, options) => { + if (isNumbers) { + return toRegexRange(a, b, { wrap: false, ...options }); + } - // create constants based on platform, for windows or posix - const PLATFORM_CHARS = constants.globChars(win32); - const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS); + let start = String.fromCharCode(a); + if (a === b) return start; - const { - DOT_LITERAL, - PLUS_LITERAL, - SLASH_LITERAL, - ONE_CHAR, - DOTS_SLASH, - NO_DOT, - NO_DOT_SLASH, - NO_DOTS_SLASH, - QMARK, - QMARK_NO_DOT, - STAR, - START_ANCHOR - } = PLATFORM_CHARS; + let stop = String.fromCharCode(b); + return `[${start}-${stop}]`; +}; - const globstar = (opts) => { - return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`; - }; +const toRegex = (start, end, options) => { + if (Array.isArray(start)) { + let wrap = options.wrap === true; + let prefix = options.capture ? '' : '?:'; + return wrap ? `(${prefix}${start.join('|')})` : start.join('|'); + } + return toRegexRange(start, end, options); +}; - let nodot = opts.dot ? '' : NO_DOT; - let star = opts.bash === true ? globstar(opts) : STAR; - let qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT; +const rangeError = (...args) => { + return new RangeError('Invalid range arguments: ' + util.inspect(...args)); +}; - if (opts.capture) { - star = `(${star})`; - } +const invalidRange = (start, end, options) => { + if (options.strictRanges === true) throw rangeError([start, end]); + return []; +}; - // minimatch options support - if (typeof opts.noext === 'boolean') { - opts.noextglob = opts.noext; +const invalidStep = (step, options) => { + if (options.strictRanges === true) { + throw new TypeError(`Expected step "${step}" to be a number`); } + return []; +}; - let state = { - index: -1, - start: 0, - consumed: '', - output: '', - backtrack: false, - brackets: 0, - braces: 0, - parens: 0, - quotes: 0, - tokens - }; +const fillNumbers = (start, end, step = 1, options = {}) => { + let a = Number(start); + let b = Number(end); - let extglobs = []; - let stack = []; - let prev = bos; - let value; + if (!Number.isInteger(a) || !Number.isInteger(b)) { + if (options.strictRanges === true) throw rangeError([start, end]); + return []; + } - /** - * Tokenizing helpers - */ + // fix negative zero + if (a === 0) a = 0; + if (b === 0) b = 0; - const eos = () => state.index === len - 1; - const peek = state.peek = (n = 1) => input[state.index + n]; - const advance = state.advance = () => input[++state.index]; - const append = token => { - state.output += token.output != null ? token.output : token.value; - state.consumed += token.value || ''; - }; + let descending = a > b; + let startString = String(start); + let endString = String(end); + let stepString = String(step); + step = Math.max(Math.abs(step), 1); - const increment = type => { - state[type]++; - stack.push(type); - }; + let padded = zeros(startString) || zeros(endString) || zeros(stepString); + let maxLen = padded ? Math.max(startString.length, endString.length, stepString.length) : 0; + let toNumber = padded === false && stringify(start, end, options) === false; + let format = options.transform || transform(toNumber); - const decrement = type => { - state[type]--; - stack.pop(); - }; + if (options.toRegex && step === 1) { + return toRange(toMaxLen(start, maxLen), toMaxLen(end, maxLen), true, options); + } - /** - * Push tokens onto the tokens array. This helper speeds up - * tokenizing by 1) helping us avoid backtracking as much as possible, - * and 2) helping us avoid creating extra tokens when consecutive - * characters are plain text. This improves performance and simplifies - * lookbehinds. - */ + let parts = { negatives: [], positives: [] }; + let push = num => parts[num < 0 ? 'negatives' : 'positives'].push(Math.abs(num)); + let range = []; + let index = 0; - const push = tok => { - if (prev.type === 'globstar') { - let isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace'); - let isExtglob = extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'); - if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) { - state.output = state.output.slice(0, -prev.output.length); - prev.type = 'star'; - prev.value = '*'; - prev.output = star; - state.output += prev.output; - } + while (descending ? a >= b : a <= b) { + if (options.toRegex === true && step > 1) { + push(a); + } else { + range.push(pad(format(a, index), maxLen, toNumber)); } + a = descending ? a - step : a + step; + index++; + } - if (extglobs.length && tok.type !== 'paren' && !EXTGLOB_CHARS[tok.value]) { - extglobs[extglobs.length - 1].inner += tok.value; - } - - if (tok.value || tok.output) append(tok); - if (prev && prev.type === 'text' && tok.type === 'text') { - prev.value += tok.value; - return; - } + if (options.toRegex === true) { + return step > 1 + ? toSequence(parts, options) + : toRegex(range, null, { wrap: false, ...options }); + } - tok.prev = prev; - tokens.push(tok); - prev = tok; - }; + return range; +}; - const extglobOpen = (type, value) => { - let token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' }; +const fillLetters = (start, end, step = 1, options = {}) => { + if ((!isNumber(start) && start.length > 1) || (!isNumber(end) && end.length > 1)) { + return invalidRange(start, end, options); + } - token.prev = prev; - token.parens = state.parens; - token.output = state.output; - let output = (opts.capture ? '(' : '') + token.open; - push({ type, value, output: state.output ? '' : ONE_CHAR }); - push({ type: 'paren', extglob: true, value: advance(), output }); - increment('parens'); - extglobs.push(token); - }; + let format = options.transform || (val => String.fromCharCode(val)); + let a = `${start}`.charCodeAt(0); + let b = `${end}`.charCodeAt(0); - const extglobClose = token => { - let output = token.close + (opts.capture ? ')' : ''); + let descending = a > b; + let min = Math.min(a, b); + let max = Math.max(a, b); - if (token.type === 'negate') { - let extglobStar = star; + if (options.toRegex && step === 1) { + return toRange(min, max, false, options); + } - if (token.inner && token.inner.length > 1 && token.inner.includes('/')) { - extglobStar = globstar(opts); - } + let range = []; + let index = 0; - if (extglobStar !== star || eos() || /^\)+$/.test(input.slice(state.index + 1))) { - output = token.close = ')$))' + extglobStar; - } + while (descending ? a >= b : a <= b) { + range.push(format(a, index)); + a = descending ? a - step : a + step; + index++; + } - if (token.prev.type === 'bos' && eos()) { - state.negatedExtglob = true; - } - } + if (options.toRegex === true) { + return toRegex(range, null, { wrap: false, options }); + } - push({ type: 'paren', extglob: true, value, output }); - decrement('parens'); - }; + return range; +}; - if (opts.fastpaths !== false && !/(^[*!]|[/{[()\]}"])/.test(input)) { - let backslashes = false; +const fill = (start, end, step, options = {}) => { + if (end == null && isValidValue(start)) { + return [start]; + } - let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => { - if (first === '\\') { - backslashes = true; - return m; - } + if (!isValidValue(start) || !isValidValue(end)) { + return invalidRange(start, end, options); + } - if (first === '?') { - if (esc) { - return esc + first + (rest ? QMARK.repeat(rest.length) : ''); - } - if (index === 0) { - return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : ''); - } - return QMARK.repeat(chars.length); - } + if (typeof step === 'function') { + return fill(start, end, 1, { transform: step }); + } - if (first === '.') { - return DOT_LITERAL.repeat(chars.length); - } + if (isObject(step)) { + return fill(start, end, 0, step); + } - if (first === '*') { - if (esc) { - return esc + first + (rest ? star : ''); - } - return star; - } - return esc ? m : '\\' + m; - }); + let opts = { ...options }; + if (opts.capture === true) opts.wrap = true; + step = step || opts.step || 1; - if (backslashes === true) { - if (opts.unescape === true) { - output = output.replace(/\\/g, ''); - } else { - output = output.replace(/\\+/g, m => { - return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : ''); - }); - } - } + if (!isNumber(step)) { + if (step != null && !isObject(step)) return invalidStep(step, opts); + return fill(start, end, 1, step); + } - state.output = output; - return state; + if (isNumber(start) && isNumber(end)) { + return fillNumbers(start, end, step, opts); } - /** - * Tokenize input until we reach end-of-string - */ + return fillLetters(start, end, Math.max(Math.abs(step), 1), opts); +}; - while (!eos()) { - value = advance(); +module.exports = fill; - if (value === '\u0000') { - continue; - } - /** - * Escaped characters - */ +/***/ }), +/* 614 */ +/***/ (function(module, exports, __webpack_require__) { - if (value === '\\') { - let next = peek(); +"use strict"; +/*! + * to-regex-range + * + * Copyright (c) 2015-present, Jon Schlinkert. + * Released under the MIT License. + */ - if (next === '/' && opts.bash !== true) { - continue; - } - if (next === '.' || next === ';') { - continue; - } - if (!next) { - value += '\\'; - push({ type: 'text', value }); - continue; - } +const isNumber = __webpack_require__(615); - // collapse slashes to reduce potential for exploits - let match = /^\\+/.exec(input.slice(state.index + 1)); - let slashes = 0; +const toRegexRange = (min, max, options) => { + if (isNumber(min) === false) { + throw new TypeError('toRegexRange: expected the first argument to be a number'); + } - if (match && match[0].length > 2) { - slashes = match[0].length; - state.index += slashes; - if (slashes % 2 !== 0) { - value += '\\'; - } - } + if (max === void 0 || min === max) { + return String(min); + } - if (opts.unescape === true) { - value = advance() || ''; - } else { - value += advance() || ''; - } + if (isNumber(max) === false) { + throw new TypeError('toRegexRange: expected the second argument to be a number.'); + } - if (state.brackets === 0) { - push({ type: 'text', value }); - continue; - } - } + let opts = { relaxZeros: true, ...options }; + if (typeof opts.strictZeros === 'boolean') { + opts.relaxZeros = opts.strictZeros === false; + } - /** - * If we're inside a regex character class, continue - * until we reach the closing bracket. - */ + let relax = String(opts.relaxZeros); + let shorthand = String(opts.shorthand); + let capture = String(opts.capture); + let wrap = String(opts.wrap); + let cacheKey = min + ':' + max + '=' + relax + shorthand + capture + wrap; - if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) { - if (opts.posix !== false && value === ':') { - let inner = prev.value.slice(1); - if (inner.includes('[')) { - prev.posix = true; + if (toRegexRange.cache.hasOwnProperty(cacheKey)) { + return toRegexRange.cache[cacheKey].result; + } - if (inner.includes(':')) { - let idx = prev.value.lastIndexOf('['); - let pre = prev.value.slice(0, idx); - let rest = prev.value.slice(idx + 2); - let posix = POSIX_REGEX_SOURCE[rest]; - if (posix) { - prev.value = pre + posix; - state.backtrack = true; - advance(); + let a = Math.min(min, max); + let b = Math.max(min, max); - if (!bos.output && tokens.indexOf(prev) === 1) { - bos.output = ONE_CHAR; - } - continue; - } - } - } - } + if (Math.abs(a - b) === 1) { + let result = min + '|' + max; + if (opts.capture) { + return `(${result})`; + } + if (opts.wrap === false) { + return result; + } + return `(?:${result})`; + } - if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) { - value = '\\' + value; - } + let isPadded = hasPadding(min) || hasPadding(max); + let state = { min, max, a, b }; + let positives = []; + let negatives = []; - if (value === ']' && (prev.value === '[' || prev.value === '[^')) { - value = '\\' + value; - } + if (isPadded) { + state.isPadded = isPadded; + state.maxLen = String(state.max).length; + } - if (opts.posix === true && value === '!' && prev.value === '[') { - value = '^'; - } + if (a < 0) { + let newMin = b < 0 ? Math.abs(b) : 1; + negatives = splitToPatterns(newMin, Math.abs(a), state, opts); + a = state.a = 0; + } - prev.value += value; - append({ value }); - continue; - } + if (b >= 0) { + positives = splitToPatterns(a, b, state, opts); + } - /** - * If we're inside a quoted string, continue - * until we reach the closing double quote. - */ + state.negatives = negatives; + state.positives = positives; + state.result = collatePatterns(negatives, positives, opts); - if (state.quotes === 1 && value !== '"') { - value = utils.escapeRegex(value); - prev.value += value; - append({ value }); - continue; - } + if (opts.capture === true) { + state.result = `(${state.result})`; + } else if (opts.wrap !== false && (positives.length + negatives.length) > 1) { + state.result = `(?:${state.result})`; + } - /** - * Double quotes - */ + toRegexRange.cache[cacheKey] = state; + return state.result; +}; - if (value === '"') { - state.quotes = state.quotes === 1 ? 0 : 1; - if (opts.keepQuotes === true) { - push({ type: 'text', value }); - } - continue; - } +function collatePatterns(neg, pos, options) { + let onlyNegative = filterPatterns(neg, pos, '-', false, options) || []; + let onlyPositive = filterPatterns(pos, neg, '', false, options) || []; + let intersected = filterPatterns(neg, pos, '-?', true, options) || []; + let subpatterns = onlyNegative.concat(intersected).concat(onlyPositive); + return subpatterns.join('|'); +} - /** - * Parentheses - */ +function splitToRanges(min, max) { + let nines = 1; + let zeros = 1; - if (value === '(') { - push({ type: 'paren', value }); - increment('parens'); - continue; - } + let stop = countNines(min, nines); + let stops = new Set([max]); - if (value === ')') { - if (state.parens === 0 && opts.strictBrackets === true) { - throw new SyntaxError(syntaxError('opening', '(')); - } + while (min <= stop && stop <= max) { + stops.add(stop); + nines += 1; + stop = countNines(min, nines); + } - let extglob = extglobs[extglobs.length - 1]; - if (extglob && state.parens === extglob.parens + 1) { - extglobClose(extglobs.pop()); - continue; - } + stop = countZeros(max + 1, zeros) - 1; - push({ type: 'paren', value, output: state.parens ? ')' : '\\)' }); - decrement('parens'); - continue; - } + while (min < stop && stop <= max) { + stops.add(stop); + zeros += 1; + stop = countZeros(max + 1, zeros) - 1; + } - /** - * Brackets - */ + stops = [...stops]; + stops.sort(compare); + return stops; +} - if (value === '[') { - if (opts.nobracket === true || !input.slice(state.index + 1).includes(']')) { - if (opts.nobracket !== true && opts.strictBrackets === true) { - throw new SyntaxError(syntaxError('closing', ']')); - } +/** + * Convert a range to a regex pattern + * @param {Number} `start` + * @param {Number} `stop` + * @return {String} + */ - value = '\\' + value; - } else { - increment('brackets'); - } +function rangeToPattern(start, stop, options) { + if (start === stop) { + return { pattern: start, count: [], digits: 0 }; + } - push({ type: 'bracket', value }); - continue; - } + let zipped = zip(start, stop); + let digits = zipped.length; + let pattern = ''; + let count = 0; - if (value === ']') { - if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) { - push({ type: 'text', value, output: '\\' + value }); - continue; - } + for (let i = 0; i < digits; i++) { + let [startDigit, stopDigit] = zipped[i]; - if (state.brackets === 0) { - if (opts.strictBrackets === true) { - throw new SyntaxError(syntaxError('opening', '[')); - } + if (startDigit === stopDigit) { + pattern += startDigit; - push({ type: 'text', value, output: '\\' + value }); - continue; - } + } else if (startDigit !== '0' || stopDigit !== '9') { + pattern += toCharacterClass(startDigit, stopDigit, options); - decrement('brackets'); + } else { + count++; + } + } - let prevValue = prev.value.slice(1); - if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) { - value = '/' + value; - } + if (count) { + pattern += options.shorthand === true ? '\\d' : '[0-9]'; + } - prev.value += value; - append({ value }); + return { pattern, count: [count], digits }; +} - // when literal brackets are explicitly disabled - // assume we should match with a regex character class - if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) { - continue; - } +function splitToPatterns(min, max, tok, options) { + let ranges = splitToRanges(min, max); + let tokens = []; + let start = min; + let prev; - let escaped = utils.escapeRegex(prev.value); - state.output = state.output.slice(0, -prev.value.length); + for (let i = 0; i < ranges.length; i++) { + let max = ranges[i]; + let obj = rangeToPattern(String(start), String(max), options); + let zeros = ''; - // when literal brackets are explicitly enabled - // assume we should escape the brackets to match literal characters - if (opts.literalBrackets === true) { - state.output += escaped; - prev.value = escaped; - continue; + if (!tok.isPadded && prev && prev.pattern === obj.pattern) { + if (prev.count.length > 1) { + prev.count.pop(); } - // when the user specifies nothing, try to match both - prev.value = `(${capture}${escaped}|${prev.value})`; - state.output += prev.value; + prev.count.push(obj.count[0]); + prev.string = prev.pattern + toQuantifier(prev.count); + start = max + 1; continue; } - /** - * Braces - */ - - if (value === '{' && opts.nobrace !== true) { - push({ type: 'brace', value, output: '(' }); - increment('braces'); - continue; + if (tok.isPadded) { + zeros = padZeros(max, tok, options); } - if (value === '}') { - if (opts.nobrace === true || state.braces === 0) { - push({ type: 'text', value, output: '\\' + value }); - continue; - } + obj.string = zeros + obj.pattern + toQuantifier(obj.count); + tokens.push(obj); + start = max + 1; + prev = obj; + } - let output = ')'; + return tokens; +} - if (state.dots === true) { - let arr = tokens.slice(); - let range = []; +function filterPatterns(arr, comparison, prefix, intersection, options) { + let result = []; - for (let i = arr.length - 1; i >= 0; i--) { - tokens.pop(); - if (arr[i].type === 'brace') { - break; - } - if (arr[i].type !== 'dots') { - range.unshift(arr[i].value); - } - } + for (let ele of arr) { + let { string } = ele; - output = expandRange(range, opts); - state.backtrack = true; - } + // only push if _both_ are negative... + if (!intersection && !contains(comparison, 'string', string)) { + result.push(prefix + string); + } - push({ type: 'brace', value, output }); - decrement('braces'); - continue; + // or _both_ are positive + if (intersection && contains(comparison, 'string', string)) { + result.push(prefix + string); } + } + return result; +} - /** - * Pipes - */ +/** + * Zip strings + */ - if (value === '|') { - if (extglobs.length > 0) { - extglobs[extglobs.length - 1].conditions++; - } - push({ type: 'text', value }); - continue; - } +function zip(a, b) { + let arr = []; + for (let i = 0; i < a.length; i++) arr.push([a[i], b[i]]); + return arr; +} - /** - * Commas - */ +function compare(a, b) { + return a > b ? 1 : b > a ? -1 : 0; +} - if (value === ',') { - let output = value; +function contains(arr, key, val) { + return arr.some(ele => ele[key] === val); +} - if (state.braces > 0 && stack[stack.length - 1] === 'braces') { - output = '|'; - } +function countNines(min, len) { + return Number(String(min).slice(0, -len) + '9'.repeat(len)); +} - push({ type: 'comma', value, output }); - continue; - } +function countZeros(integer, zeros) { + return integer - (integer % Math.pow(10, zeros)); +} - /** - * Slashes - */ +function toQuantifier(digits) { + let [start = 0, stop = ''] = digits; + if (stop || start > 1) { + return `{${start + (stop ? ',' + stop : '')}}`; + } + return ''; +} - if (value === '/') { - // if the beginning of the glob is "./", advance the start - // to the current index, and don't add the "./" characters - // to the state. This greatly simplifies lookbehinds when - // checking for BOS characters like "!" and "." (not "./") - if (prev.type === 'dot' && state.index === 1) { - state.start = state.index + 1; - state.consumed = ''; - state.output = ''; - tokens.pop(); - prev = bos; // reset "prev" to the first token - continue; - } +function toCharacterClass(a, b, options) { + return `[${a}${(b - a === 1) ? '' : '-'}${b}]`; +} - push({ type: 'slash', value, output: SLASH_LITERAL }); - continue; - } +function hasPadding(str) { + return /^-?(0+)\d/.test(str); +} - /** - * Dots - */ +function padZeros(value, tok, options) { + if (!tok.isPadded) { + return value; + } - if (value === '.') { - if (state.braces > 0 && prev.type === 'dot') { - if (prev.value === '.') prev.output = DOT_LITERAL; - prev.type = 'dots'; - prev.output += value; - prev.value += value; - state.dots = true; - continue; - } + let diff = Math.abs(tok.maxLen - String(value).length); + let relax = options.relaxZeros !== false; - push({ type: 'dot', value, output: DOT_LITERAL }); - continue; + switch (diff) { + case 0: + return ''; + case 1: + return relax ? '0?' : '0'; + case 2: + return relax ? '0{0,2}' : '00'; + default: { + return relax ? `0{0,${diff}}` : `0{${diff}}`; } + } +} - /** - * Question marks - */ +/** + * Cache + */ - if (value === '?') { - if (prev && prev.type === 'paren') { - let next = peek(); - let output = value; +toRegexRange.cache = {}; +toRegexRange.clearCache = () => (toRegexRange.cache = {}); - if (next === '<' && !utils.supportsLookbehinds()) { - throw new Error('Node.js v10 or higher is required for regex lookbehinds'); - } +/** + * Expose `toRegexRange` + */ - if (prev.value === '(' && !/[!=<:]/.test(next) || (next === '<' && !/[!=]/.test(peek(2)))) { - output = '\\' + value; - } +module.exports = toRegexRange; - push({ type: 'text', value, output }); - continue; - } - if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { - extglobOpen('qmark', value); - continue; - } +/***/ }), +/* 615 */ +/***/ (function(module, exports, __webpack_require__) { - if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) { - push({ type: 'qmark', value, output: QMARK_NO_DOT }); - continue; - } +"use strict"; +/*! + * is-number + * + * Copyright (c) 2014-present, Jon Schlinkert. + * Released under the MIT License. + */ - push({ type: 'qmark', value, output: QMARK }); - continue; - } - /** - * Exclamation - */ - if (value === '!') { - if (opts.noextglob !== true && peek() === '(') { - if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) { - extglobOpen('negate', value); - continue; - } - } +module.exports = function(num) { + if (typeof num === 'number') { + return num - num === 0; + } + if (typeof num === 'string' && num.trim() !== '') { + return Number.isFinite ? Number.isFinite(+num) : isFinite(+num); + } + return false; +}; - if (opts.nonegate !== true && state.index === 0) { - negate(state); - continue; - } - } - /** - * Plus - */ +/***/ }), +/* 616 */ +/***/ (function(module, exports, __webpack_require__) { - if (value === '+') { - if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { - extglobOpen('plus', value); - continue; - } +"use strict"; - if (prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) { - let output = prev.extglob === true ? '\\' + value : value; - push({ type: 'plus', value, output }); - continue; - } - // use regex behavior inside parens - if (state.parens > 0 && opts.regex !== false) { - push({ type: 'plus', value }); - continue; - } +const fill = __webpack_require__(613); +const stringify = __webpack_require__(610); +const utils = __webpack_require__(611); - push({ type: 'plus', value: PLUS_LITERAL }); - continue; - } +const append = (queue = '', stash = '', enclose = false) => { + let result = []; - /** - * Plain text - */ + queue = [].concat(queue); + stash = [].concat(stash); - if (value === '@') { - if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { - push({ type: 'at', value, output: '' }); - continue; - } + if (!stash.length) return queue; + if (!queue.length) { + return enclose ? utils.flatten(stash).map(ele => `{${ele}}`) : stash; + } - push({ type: 'text', value }); - continue; + for (let item of queue) { + if (Array.isArray(item)) { + for (let value of item) { + result.push(append(value, stash, enclose)); + } + } else { + for (let ele of stash) { + if (enclose === true && typeof ele === 'string') ele = `{${ele}}`; + result.push(Array.isArray(ele) ? append(item, ele, enclose) : (item + ele)); + } } + } + return utils.flatten(result); +}; - /** - * Plain text - */ +const expand = (ast, options = {}) => { + let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit; - if (value !== '*') { - if (value === '$' || value === '^') { - value = '\\' + value; - } + let walk = (node, parent = {}) => { + node.queue = []; - let match = REGEX_NON_SPECIAL_CHAR.exec(input.slice(state.index + 1)); - if (match) { - value += match[0]; - state.index += match[0].length; - } + let p = parent; + let q = parent.queue; - push({ type: 'text', value }); - continue; + while (p.type !== 'brace' && p.type !== 'root' && p.parent) { + p = p.parent; + q = p.queue; } - /** - * Stars - */ - - if (prev && (prev.type === 'globstar' || prev.star === true)) { - prev.type = 'star'; - prev.star = true; - prev.value += value; - prev.output = star; - state.backtrack = true; - state.consumed += value; - continue; + if (node.invalid || node.dollar) { + q.push(append(q.pop(), stringify(node, options))); + return; } - if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { - extglobOpen('star', value); - continue; + if (node.type === 'brace' && node.invalid !== true && node.nodes.length === 2) { + q.push(append(q.pop(), ['{}'])); + return; } - if (prev.type === 'star') { - if (opts.noglobstar === true) { - state.consumed += value; - continue; - } - - let prior = prev.prev; - let before = prior.prev; - let isStart = prior.type === 'slash' || prior.type === 'bos'; - let afterStar = before && (before.type === 'star' || before.type === 'globstar'); + if (node.nodes && node.ranges > 0) { + let args = utils.reduce(node.nodes); - if (opts.bash === true && (!isStart || (!eos() && peek() !== '/'))) { - push({ type: 'star', value, output: '' }); - continue; + if (utils.exceedsLimit(...args, options.step, rangeLimit)) { + throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.'); } - let isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace'); - let isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren'); - if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) { - push({ type: 'star', value, output: '' }); - continue; + let range = fill(...args, options); + if (range.length === 0) { + range = stringify(node, options); } - // strip consecutive `/**/` - while (input.slice(state.index + 1, state.index + 4) === '/**') { - let after = input[state.index + 4]; - if (after && after !== '/') { - break; - } - state.consumed += '/**'; - state.index += 3; - } + q.push(append(q.pop(), range)); + node.nodes = []; + return; + } - if (prior.type === 'bos' && eos()) { - prev.type = 'globstar'; - prev.value += value; - prev.output = globstar(opts); - state.output = prev.output; - state.consumed += value; - continue; - } + let enclose = utils.encloseBrace(node); + let queue = node.queue; + let block = node; - if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) { - state.output = state.output.slice(0, -(prior.output + prev.output).length); - prior.output = '(?:' + prior.output; + while (block.type !== 'brace' && block.type !== 'root' && block.parent) { + block = block.parent; + queue = block.queue; + } - prev.type = 'globstar'; - prev.output = globstar(opts) + '|$)'; - prev.value += value; + for (let i = 0; i < node.nodes.length; i++) { + let child = node.nodes[i]; - state.output += prior.output + prev.output; - state.consumed += value; + if (child.type === 'comma' && node.type === 'brace') { + if (i === 1) queue.push(''); + queue.push(''); continue; } - let next = peek(); - if (prior.type === 'slash' && prior.prev.type !== 'bos' && next === '/') { - let end = peek(2) !== void 0 ? '|$' : ''; - - state.output = state.output.slice(0, -(prior.output + prev.output).length); - prior.output = '(?:' + prior.output; - - prev.type = 'globstar'; - prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`; - prev.value += value; - - state.output += prior.output + prev.output; - state.consumed += value + advance(); - - push({ type: 'slash', value, output: '' }); + if (child.type === 'close') { + q.push(append(q.pop(), queue, enclose)); continue; } - if (prior.type === 'bos' && next === '/') { - prev.type = 'globstar'; - prev.value += value; - prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`; - state.output = prev.output; - state.consumed += value + advance(); - push({ type: 'slash', value, output: '' }); + if (child.value && child.type !== 'open') { + queue.push(append(queue.pop(), child.value)); continue; } - // remove single star from output - state.output = state.output.slice(0, -prev.output.length); + if (child.nodes) { + walk(child, node); + } + } - // reset previous token to globstar - prev.type = 'globstar'; - prev.output = globstar(opts); - prev.value += value; + return queue; + }; - // reset output with globstar - state.output += prev.output; - state.consumed += value; - continue; - } + return utils.flatten(walk(ast)); +}; - let token = { type: 'star', value, output: star }; +module.exports = expand; - if (opts.bash === true) { - token.output = '.*?'; - if (prev.type === 'bos' || prev.type === 'slash') { - token.output = nodot + token.output; - } - push(token); - continue; - } - if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) { - token.output = value; - push(token); - continue; - } +/***/ }), +/* 617 */ +/***/ (function(module, exports, __webpack_require__) { - if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') { - if (prev.type === 'dot') { - state.output += NO_DOT_SLASH; - prev.output += NO_DOT_SLASH; +"use strict"; - } else if (opts.dot === true) { - state.output += NO_DOTS_SLASH; - prev.output += NO_DOTS_SLASH; - } else { - state.output += nodot; - prev.output += nodot; - } +const stringify = __webpack_require__(610); - if (peek() !== '*') { - state.output += ONE_CHAR; - prev.output += ONE_CHAR; - } - } +/** + * Constants + */ - push(token); - } +const { + MAX_LENGTH, + CHAR_BACKSLASH, /* \ */ + CHAR_BACKTICK, /* ` */ + CHAR_COMMA, /* , */ + CHAR_DOT, /* . */ + CHAR_LEFT_PARENTHESES, /* ( */ + CHAR_RIGHT_PARENTHESES, /* ) */ + CHAR_LEFT_CURLY_BRACE, /* { */ + CHAR_RIGHT_CURLY_BRACE, /* } */ + CHAR_LEFT_SQUARE_BRACKET, /* [ */ + CHAR_RIGHT_SQUARE_BRACKET, /* ] */ + CHAR_DOUBLE_QUOTE, /* " */ + CHAR_SINGLE_QUOTE, /* ' */ + CHAR_NO_BREAK_SPACE, + CHAR_ZERO_WIDTH_NOBREAK_SPACE +} = __webpack_require__(618); - while (state.brackets > 0) { - if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']')); - state.output = utils.escapeLast(state.output, '['); - decrement('brackets'); - } +/** + * parse + */ - while (state.parens > 0) { - if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')')); - state.output = utils.escapeLast(state.output, '('); - decrement('parens'); +const parse = (input, options = {}) => { + if (typeof input !== 'string') { + throw new TypeError('Expected a string'); } - while (state.braces > 0) { - if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}')); - state.output = utils.escapeLast(state.output, '{'); - decrement('braces'); + let opts = options || {}; + let max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH; + if (input.length > max) { + throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`); } - if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) { - push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` }); - } + let ast = { type: 'root', input, nodes: [] }; + let stack = [ast]; + let block = ast; + let prev = ast; + let brackets = 0; + let length = input.length; + let index = 0; + let depth = 0; + let value; + let memo = {}; - // rebuild the output if we had to backtrack at any point - if (state.backtrack === true) { - state.output = ''; + /** + * Helpers + */ - for (let token of state.tokens) { - state.output += token.output != null ? token.output : token.value; + const advance = () => input[index++]; + const push = node => { + if (node.type === 'text' && prev.type === 'dot') { + prev.type = 'text'; + } - if (token.suffix) { - state.output += token.suffix; - } + if (prev && prev.type === 'text' && node.type === 'text') { + prev.value += node.value; + return; } - } - return state; -}; + block.nodes.push(node); + node.parent = block; + node.prev = prev; + prev = node; + return node; + }; -/** - * Fast paths for creating regular expressions for common glob patterns. - * This can significantly speed up processing and has very little downside - * impact when none of the fast paths match. - */ + push({ type: 'bos' }); -parse.fastpaths = (input, options) => { - let opts = { ...options }; - let max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH; - let len = input.length; - if (len > max) { - throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`); - } + while (index < length) { + block = stack[stack.length - 1]; + value = advance(); - input = REPLACEMENTS[input] || input; - let win32 = utils.isWindows(options); + /** + * Invalid chars + */ - // create constants based on platform, for windows or posix - const { - DOT_LITERAL, - SLASH_LITERAL, - ONE_CHAR, - DOTS_SLASH, - NO_DOT, - NO_DOTS, - NO_DOTS_SLASH, - STAR, - START_ANCHOR - } = constants.globChars(win32); + if (value === CHAR_ZERO_WIDTH_NOBREAK_SPACE || value === CHAR_NO_BREAK_SPACE) { + continue; + } - let capture = opts.capture ? '' : '?:'; - let star = opts.bash === true ? '.*?' : STAR; - let nodot = opts.dot ? NO_DOTS : NO_DOT; - let slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT; + /** + * Escaped chars + */ - if (opts.capture) { - star = `(${star})`; - } + if (value === CHAR_BACKSLASH) { + push({ type: 'text', value: (options.keepEscaping ? value : '') + advance() }); + continue; + } - const globstar = (opts) => { - return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`; - }; + /** + * Right square bracket (literal): ']' + */ - const create = str => { - switch (str) { - case '*': - return `${nodot}${ONE_CHAR}${star}`; + if (value === CHAR_RIGHT_SQUARE_BRACKET) { + push({ type: 'text', value: '\\' + value }); + continue; + } - case '.*': - return `${DOT_LITERAL}${ONE_CHAR}${star}`; + /** + * Left square bracket: '[' + */ - case '*.*': - return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`; + if (value === CHAR_LEFT_SQUARE_BRACKET) { + brackets++; - case '*/*': - return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`; + let closed = true; + let next; - case '**': - return nodot + globstar(opts); + while (index < length && (next = advance())) { + value += next; - case '**/*': - return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`; + if (next === CHAR_LEFT_SQUARE_BRACKET) { + brackets++; + continue; + } - case '**/*.*': - return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`; + if (next === CHAR_BACKSLASH) { + value += advance(); + continue; + } - case '**/.*': - return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`; + if (next === CHAR_RIGHT_SQUARE_BRACKET) { + brackets--; - default: { - let match = /^(.*?)\.(\w+)$/.exec(str); - if (!match) return; + if (brackets === 0) { + break; + } + } + } - let source = create(match[1], options); - if (!source) return; + push({ type: 'text', value }); + continue; + } - return source + DOT_LITERAL + match[2]; + /** + * Parentheses + */ + + if (value === CHAR_LEFT_PARENTHESES) { + block = push({ type: 'paren', nodes: [] }); + stack.push(block); + push({ type: 'text', value }); + continue; + } + + if (value === CHAR_RIGHT_PARENTHESES) { + if (block.type !== 'paren') { + push({ type: 'text', value }); + continue; } + block = stack.pop(); + push({ type: 'text', value }); + block = stack[stack.length - 1]; + continue; } - }; - let output = create(input); - if (output && opts.strictSlashes !== true) { - output += `${SLASH_LITERAL}?`; - } + /** + * Quotes: '|"|` + */ - return output; -}; + if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) { + let open = value; + let next; -module.exports = parse; + if (options.keepQuotes !== true) { + value = ''; + } + while (index < length && (next = advance())) { + if (next === CHAR_BACKSLASH) { + value += next + advance(); + continue; + } -/***/ }), -/* 620 */ -/***/ (function(module, exports, __webpack_require__) { + if (next === open) { + if (options.keepQuotes === true) value += next; + break; + } -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const merge2 = __webpack_require__(591); -function merge(streams) { - const mergedStream = merge2(streams); - streams.forEach((stream) => { - stream.once('error', (err) => mergedStream.emit('error', err)); - }); - return mergedStream; -} -exports.merge = merge; + value += next; + } + push({ type: 'text', value }); + continue; + } -/***/ }), -/* 621 */ -/***/ (function(module, exports, __webpack_require__) { + /** + * Left curly brace: '{' + */ -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const stream_1 = __webpack_require__(622); -const provider_1 = __webpack_require__(649); -class ProviderAsync extends provider_1.default { - constructor() { - super(...arguments); - this._reader = new stream_1.default(this._settings); - } - read(task) { - const root = this._getRootDirectory(task); - const options = this._getReaderOptions(task); - const entries = []; - return new Promise((resolve, reject) => { - const stream = this.api(root, task, options); - stream.once('error', reject); - stream.on('data', (entry) => entries.push(options.transform(entry))); - stream.once('end', () => resolve(entries)); - }); - } - api(root, task, options) { - if (task.dynamic) { - return this._reader.dynamic(root, options); - } - return this._reader.static(task.patterns, options); - } -} -exports.default = ProviderAsync; + if (value === CHAR_LEFT_CURLY_BRACE) { + depth++; + let dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true; + let brace = { + type: 'brace', + open: true, + close: false, + dollar, + depth, + commas: 0, + ranges: 0, + nodes: [] + }; -/***/ }), -/* 622 */ -/***/ (function(module, exports, __webpack_require__) { + block = push(brace); + stack.push(block); + push({ type: 'open', value }); + continue; + } -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const stream_1 = __webpack_require__(27); -const fsStat = __webpack_require__(623); -const fsWalk = __webpack_require__(628); -const reader_1 = __webpack_require__(648); -class ReaderStream extends reader_1.default { - constructor() { - super(...arguments); - this._walkStream = fsWalk.walkStream; - this._stat = fsStat.stat; - } - dynamic(root, options) { - return this._walkStream(root, options); - } - static(patterns, options) { - const filepaths = patterns.map(this._getFullEntryPath, this); - const stream = new stream_1.PassThrough({ objectMode: true }); - stream._write = (index, _enc, done) => { - return this._getEntry(filepaths[index], patterns[index], options) - .then((entry) => { - if (entry !== null && options.entryFilter(entry)) { - stream.push(entry); - } - if (index === filepaths.length - 1) { - stream.end(); - } - done(); - }) - .catch(done); - }; - for (let i = 0; i < filepaths.length; i++) { - stream.write(i); - } - return stream; - } - _getEntry(filepath, pattern, options) { - return this._getStat(filepath) - .then((stats) => this._makeEntry(stats, pattern)) - .catch((error) => { - if (options.errorFilter(error)) { - return null; - } - throw error; - }); - } - _getStat(filepath) { - return new Promise((resolve, reject) => { - this._stat(filepath, this._fsStatSettings, (error, stats) => { - error ? reject(error) : resolve(stats); - }); - }); - } -} -exports.default = ReaderStream; + /** + * Right curly brace: '}' + */ + if (value === CHAR_RIGHT_CURLY_BRACE) { + if (block.type !== 'brace') { + push({ type: 'text', value }); + continue; + } -/***/ }), -/* 623 */ -/***/ (function(module, exports, __webpack_require__) { + let type = 'close'; + block = stack.pop(); + block.close = true; -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const async = __webpack_require__(624); -const sync = __webpack_require__(625); -const settings_1 = __webpack_require__(626); -exports.Settings = settings_1.default; -function stat(path, optionsOrSettingsOrCallback, callback) { - if (typeof optionsOrSettingsOrCallback === 'function') { - return async.read(path, getSettings(), optionsOrSettingsOrCallback); - } - async.read(path, getSettings(optionsOrSettingsOrCallback), callback); -} -exports.stat = stat; -function statSync(path, optionsOrSettings) { - const settings = getSettings(optionsOrSettings); - return sync.read(path, settings); -} -exports.statSync = statSync; -function getSettings(settingsOrOptions = {}) { - if (settingsOrOptions instanceof settings_1.default) { - return settingsOrOptions; - } - return new settings_1.default(settingsOrOptions); -} + push({ type, value }); + depth--; + block = stack[stack.length - 1]; + continue; + } -/***/ }), -/* 624 */ -/***/ (function(module, exports, __webpack_require__) { + /** + * Comma: ',' + */ -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -function read(path, settings, callback) { - settings.fs.lstat(path, (lstatError, lstat) => { - if (lstatError) { - return callFailureCallback(callback, lstatError); - } - if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) { - return callSuccessCallback(callback, lstat); - } - settings.fs.stat(path, (statError, stat) => { - if (statError) { - if (settings.throwErrorOnBrokenSymbolicLink) { - return callFailureCallback(callback, statError); - } - return callSuccessCallback(callback, lstat); - } - if (settings.markSymbolicLink) { - stat.isSymbolicLink = () => true; - } - callSuccessCallback(callback, stat); - }); - }); -} -exports.read = read; -function callFailureCallback(callback, error) { - callback(error); -} -function callSuccessCallback(callback, result) { - callback(null, result); -} + if (value === CHAR_COMMA && depth > 0) { + if (block.ranges > 0) { + block.ranges = 0; + let open = block.nodes.shift(); + block.nodes = [open, { type: 'text', value: stringify(block) }]; + } + push({ type: 'comma', value }); + block.commas++; + continue; + } -/***/ }), -/* 625 */ -/***/ (function(module, exports, __webpack_require__) { + /** + * Dot: '.' + */ -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -function read(path, settings) { - const lstat = settings.fs.lstatSync(path); - if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) { - return lstat; - } - try { - const stat = settings.fs.statSync(path); - if (settings.markSymbolicLink) { - stat.isSymbolicLink = () => true; - } - return stat; - } - catch (error) { - if (!settings.throwErrorOnBrokenSymbolicLink) { - return lstat; - } - throw error; - } -} -exports.read = read; + if (value === CHAR_DOT && depth > 0 && block.commas === 0) { + let siblings = block.nodes; + if (depth === 0 || siblings.length === 0) { + push({ type: 'text', value }); + continue; + } -/***/ }), -/* 626 */ -/***/ (function(module, exports, __webpack_require__) { + if (prev.type === 'dot') { + block.range = []; + prev.value += value; + prev.type = 'range'; -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fs = __webpack_require__(627); -class Settings { - constructor(_options = {}) { - this._options = _options; - this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true); - this.fs = fs.createFileSystemAdapter(this._options.fs); - this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false); - this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true); - } - _getValue(option, value) { - return option === undefined ? value : option; - } -} -exports.default = Settings; + if (block.nodes.length !== 3 && block.nodes.length !== 5) { + block.invalid = true; + block.ranges = 0; + prev.type = 'text'; + continue; + } + block.ranges++; + block.args = []; + continue; + } -/***/ }), -/* 627 */ -/***/ (function(module, exports, __webpack_require__) { + if (prev.type === 'range') { + siblings.pop(); -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fs = __webpack_require__(23); -exports.FILE_SYSTEM_ADAPTER = { - lstat: fs.lstat, - stat: fs.stat, - lstatSync: fs.lstatSync, - statSync: fs.statSync -}; -function createFileSystemAdapter(fsMethods) { - if (!fsMethods) { - return exports.FILE_SYSTEM_ADAPTER; - } - return Object.assign({}, exports.FILE_SYSTEM_ADAPTER, fsMethods); -} -exports.createFileSystemAdapter = createFileSystemAdapter; + let before = siblings[siblings.length - 1]; + before.value += prev.value + value; + prev = before; + block.ranges--; + continue; + } + push({ type: 'dot', value }); + continue; + } -/***/ }), -/* 628 */ -/***/ (function(module, exports, __webpack_require__) { + /** + * Text + */ -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const async_1 = __webpack_require__(629); -const stream_1 = __webpack_require__(644); -const sync_1 = __webpack_require__(645); -const settings_1 = __webpack_require__(647); -exports.Settings = settings_1.default; -function walk(dir, optionsOrSettingsOrCallback, callback) { - if (typeof optionsOrSettingsOrCallback === 'function') { - return new async_1.default(dir, getSettings()).read(optionsOrSettingsOrCallback); - } - new async_1.default(dir, getSettings(optionsOrSettingsOrCallback)).read(callback); -} -exports.walk = walk; -function walkSync(dir, optionsOrSettings) { - const settings = getSettings(optionsOrSettings); - const provider = new sync_1.default(dir, settings); - return provider.read(); -} -exports.walkSync = walkSync; -function walkStream(dir, optionsOrSettings) { - const settings = getSettings(optionsOrSettings); - const provider = new stream_1.default(dir, settings); - return provider.read(); -} -exports.walkStream = walkStream; -function getSettings(settingsOrOptions = {}) { - if (settingsOrOptions instanceof settings_1.default) { - return settingsOrOptions; - } - return new settings_1.default(settingsOrOptions); -} + push({ type: 'text', value }); + } + // Mark imbalanced braces and brackets as invalid + do { + block = stack.pop(); -/***/ }), -/* 629 */ -/***/ (function(module, exports, __webpack_require__) { + if (block.type !== 'root') { + block.nodes.forEach(node => { + if (!node.nodes) { + if (node.type === 'open') node.isOpen = true; + if (node.type === 'close') node.isClose = true; + if (!node.nodes) node.type = 'text'; + node.invalid = true; + } + }); -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const async_1 = __webpack_require__(630); -class AsyncProvider { - constructor(_root, _settings) { - this._root = _root; - this._settings = _settings; - this._reader = new async_1.default(this._root, this._settings); - this._storage = new Set(); - } - read(callback) { - this._reader.onError((error) => { - callFailureCallback(callback, error); - }); - this._reader.onEntry((entry) => { - this._storage.add(entry); - }); - this._reader.onEnd(() => { - callSuccessCallback(callback, Array.from(this._storage)); - }); - this._reader.read(); - } -} -exports.default = AsyncProvider; -function callFailureCallback(callback, error) { - callback(error); -} -function callSuccessCallback(callback, entries) { - callback(null, entries); -} + // get the location of the block on parent.nodes (block's siblings) + let parent = stack[stack.length - 1]; + let index = parent.nodes.indexOf(block); + // replace the (invalid) block with it's nodes + parent.nodes.splice(index, 1, ...block.nodes); + } + } while (stack.length > 0); + + push({ type: 'eos' }); + return ast; +}; + +module.exports = parse; /***/ }), -/* 630 */ +/* 618 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const events_1 = __webpack_require__(379); -const fsScandir = __webpack_require__(631); -const fastq = __webpack_require__(640); -const common = __webpack_require__(642); -const reader_1 = __webpack_require__(643); -class AsyncReader extends reader_1.default { - constructor(_root, _settings) { - super(_root, _settings); - this._settings = _settings; - this._scandir = fsScandir.scandir; - this._emitter = new events_1.EventEmitter(); - this._queue = fastq(this._worker.bind(this), this._settings.concurrency); - this._isFatalError = false; - this._isDestroyed = false; - this._queue.drain = () => { - if (!this._isFatalError) { - this._emitter.emit('end'); - } - }; - } - read() { - this._isFatalError = false; - this._isDestroyed = false; - setImmediate(() => { - this._pushToQueue(this._root, this._settings.basePath); - }); - return this._emitter; - } - destroy() { - if (this._isDestroyed) { - throw new Error('The reader is already destroyed'); - } - this._isDestroyed = true; - this._queue.killAndDrain(); - } - onEntry(callback) { - this._emitter.on('entry', callback); - } - onError(callback) { - this._emitter.once('error', callback); - } - onEnd(callback) { - this._emitter.once('end', callback); - } - _pushToQueue(dir, base) { - const queueItem = { dir, base }; - this._queue.push(queueItem, (error) => { - if (error) { - this._handleError(error); - } - }); - } - _worker(item, done) { - this._scandir(item.dir, this._settings.fsScandirSettings, (error, entries) => { - if (error) { - return done(error, undefined); - } - for (const entry of entries) { - this._handleEntry(entry, item.base); - } - done(null, undefined); - }); - } - _handleError(error) { - if (!common.isFatalError(this._settings, error)) { - return; - } - this._isFatalError = true; - this._isDestroyed = true; - this._emitter.emit('error', error); - } - _handleEntry(entry, base) { - if (this._isDestroyed || this._isFatalError) { - return; - } - const fullpath = entry.path; - if (base !== undefined) { - entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator); - } - if (common.isAppliedFilter(this._settings.entryFilter, entry)) { - this._emitEntry(entry); - } - if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) { - this._pushToQueue(fullpath, entry.path); - } - } - _emitEntry(entry) { - this._emitter.emit('entry', entry); - } -} -exports.default = AsyncReader; + + +module.exports = { + MAX_LENGTH: 1024 * 64, + + // Digits + CHAR_0: '0', /* 0 */ + CHAR_9: '9', /* 9 */ + + // Alphabet chars. + CHAR_UPPERCASE_A: 'A', /* A */ + CHAR_LOWERCASE_A: 'a', /* a */ + CHAR_UPPERCASE_Z: 'Z', /* Z */ + CHAR_LOWERCASE_Z: 'z', /* z */ + + CHAR_LEFT_PARENTHESES: '(', /* ( */ + CHAR_RIGHT_PARENTHESES: ')', /* ) */ + + CHAR_ASTERISK: '*', /* * */ + + // Non-alphabetic chars. + CHAR_AMPERSAND: '&', /* & */ + CHAR_AT: '@', /* @ */ + CHAR_BACKSLASH: '\\', /* \ */ + CHAR_BACKTICK: '`', /* ` */ + CHAR_CARRIAGE_RETURN: '\r', /* \r */ + CHAR_CIRCUMFLEX_ACCENT: '^', /* ^ */ + CHAR_COLON: ':', /* : */ + CHAR_COMMA: ',', /* , */ + CHAR_DOLLAR: '$', /* . */ + CHAR_DOT: '.', /* . */ + CHAR_DOUBLE_QUOTE: '"', /* " */ + CHAR_EQUAL: '=', /* = */ + CHAR_EXCLAMATION_MARK: '!', /* ! */ + CHAR_FORM_FEED: '\f', /* \f */ + CHAR_FORWARD_SLASH: '/', /* / */ + CHAR_HASH: '#', /* # */ + CHAR_HYPHEN_MINUS: '-', /* - */ + CHAR_LEFT_ANGLE_BRACKET: '<', /* < */ + CHAR_LEFT_CURLY_BRACE: '{', /* { */ + CHAR_LEFT_SQUARE_BRACKET: '[', /* [ */ + CHAR_LINE_FEED: '\n', /* \n */ + CHAR_NO_BREAK_SPACE: '\u00A0', /* \u00A0 */ + CHAR_PERCENT: '%', /* % */ + CHAR_PLUS: '+', /* + */ + CHAR_QUESTION_MARK: '?', /* ? */ + CHAR_RIGHT_ANGLE_BRACKET: '>', /* > */ + CHAR_RIGHT_CURLY_BRACE: '}', /* } */ + CHAR_RIGHT_SQUARE_BRACKET: ']', /* ] */ + CHAR_SEMICOLON: ';', /* ; */ + CHAR_SINGLE_QUOTE: '\'', /* ' */ + CHAR_SPACE: ' ', /* */ + CHAR_TAB: '\t', /* \t */ + CHAR_UNDERSCORE: '_', /* _ */ + CHAR_VERTICAL_LINE: '|', /* | */ + CHAR_ZERO_WIDTH_NOBREAK_SPACE: '\uFEFF' /* \uFEFF */ +}; /***/ }), -/* 631 */ +/* 619 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const async = __webpack_require__(632); -const sync = __webpack_require__(637); -const settings_1 = __webpack_require__(638); -exports.Settings = settings_1.default; -function scandir(path, optionsOrSettingsOrCallback, callback) { - if (typeof optionsOrSettingsOrCallback === 'function') { - return async.read(path, getSettings(), optionsOrSettingsOrCallback); - } - async.read(path, getSettings(optionsOrSettingsOrCallback), callback); -} -exports.scandir = scandir; -function scandirSync(path, optionsOrSettings) { - const settings = getSettings(optionsOrSettings); - return sync.read(path, settings); -} -exports.scandirSync = scandirSync; -function getSettings(settingsOrOptions = {}) { - if (settingsOrOptions instanceof settings_1.default) { - return settingsOrOptions; - } - return new settings_1.default(settingsOrOptions); -} + + +module.exports = __webpack_require__(620); /***/ }), -/* 632 */ +/* 620 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fsStat = __webpack_require__(623); -const rpl = __webpack_require__(633); -const constants_1 = __webpack_require__(634); -const utils = __webpack_require__(635); -function read(dir, settings, callback) { - if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) { - return readdirWithFileTypes(dir, settings, callback); - } - return readdir(dir, settings, callback); -} -exports.read = read; -function readdirWithFileTypes(dir, settings, callback) { - settings.fs.readdir(dir, { withFileTypes: true }, (readdirError, dirents) => { - if (readdirError) { - return callFailureCallback(callback, readdirError); - } - const entries = dirents.map((dirent) => ({ - dirent, - name: dirent.name, - path: `${dir}${settings.pathSegmentSeparator}${dirent.name}` - })); - if (!settings.followSymbolicLinks) { - return callSuccessCallback(callback, entries); - } - const tasks = entries.map((entry) => makeRplTaskEntry(entry, settings)); - rpl(tasks, (rplError, rplEntries) => { - if (rplError) { - return callFailureCallback(callback, rplError); - } - callSuccessCallback(callback, rplEntries); - }); - }); -} -exports.readdirWithFileTypes = readdirWithFileTypes; -function makeRplTaskEntry(entry, settings) { - return (done) => { - if (!entry.dirent.isSymbolicLink()) { - return done(null, entry); - } - settings.fs.stat(entry.path, (statError, stats) => { - if (statError) { - if (settings.throwErrorOnBrokenSymbolicLink) { - return done(statError); - } - return done(null, entry); - } - entry.dirent = utils.fs.createDirentFromStats(entry.name, stats); - return done(null, entry); - }); - }; -} -function readdir(dir, settings, callback) { - settings.fs.readdir(dir, (readdirError, names) => { - if (readdirError) { - return callFailureCallback(callback, readdirError); - } - const filepaths = names.map((name) => `${dir}${settings.pathSegmentSeparator}${name}`); - const tasks = filepaths.map((filepath) => { - return (done) => fsStat.stat(filepath, settings.fsStatSettings, done); - }); - rpl(tasks, (rplError, results) => { - if (rplError) { - return callFailureCallback(callback, rplError); - } - const entries = []; - for (let index = 0; index < names.length; index++) { - const name = names[index]; - const stats = results[index]; - const entry = { - name, - path: filepaths[index], - dirent: utils.fs.createDirentFromStats(name, stats) - }; - if (settings.stats) { - entry.stats = stats; - } - entries.push(entry); - } - callSuccessCallback(callback, entries); - }); - }); -} -exports.readdir = readdir; -function callFailureCallback(callback, error) { - callback(error); -} -function callSuccessCallback(callback, result) { - callback(null, result); -} - -/***/ }), -/* 633 */ -/***/ (function(module, exports) { -module.exports = runParallel +const path = __webpack_require__(16); +const scan = __webpack_require__(621); +const parse = __webpack_require__(624); +const utils = __webpack_require__(622); -function runParallel (tasks, cb) { - var results, pending, keys - var isSync = true +/** + * Creates a matcher function from one or more glob patterns. The + * returned function takes a string to match as its first argument, + * and returns true if the string is a match. The returned matcher + * function also takes a boolean as the second argument that, when true, + * returns an object with additional information. + * + * ```js + * const picomatch = require('picomatch'); + * // picomatch(glob[, options]); + * + * const isMatch = picomatch('*.!(*a)'); + * console.log(isMatch('a.a')); //=> false + * console.log(isMatch('a.b')); //=> true + * ``` + * @name picomatch + * @param {String|Array} `globs` One or more glob patterns. + * @param {Object=} `options` + * @return {Function=} Returns a matcher function. + * @api public + */ - if (Array.isArray(tasks)) { - results = [] - pending = tasks.length - } else { - keys = Object.keys(tasks) - results = {} - pending = keys.length +const picomatch = (glob, options, returnState = false) => { + if (Array.isArray(glob)) { + let fns = glob.map(input => picomatch(input, options, returnState)); + return str => { + for (let isMatch of fns) { + let state = isMatch(str); + if (state) return state; + } + return false; + }; } - function done (err) { - function end () { - if (cb) cb(err, results) - cb = null - } - if (isSync) process.nextTick(end) - else end() + if (typeof glob !== 'string' || glob === '') { + throw new TypeError('Expected pattern to be a non-empty string'); } - function each (i, err, result) { - results[i] = result - if (--pending === 0 || err) { - done(err) - } - } + let opts = options || {}; + let posix = utils.isWindows(options); + let regex = picomatch.makeRe(glob, options, false, true); + let state = regex.state; + delete regex.state; - if (!pending) { - // empty - done(null) - } else if (keys) { - // object - keys.forEach(function (key) { - tasks[key](function (err, result) { each(key, err, result) }) - }) - } else { - // array - tasks.forEach(function (task, i) { - task(function (err, result) { each(i, err, result) }) - }) + let isIgnored = () => false; + if (opts.ignore) { + let ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null }; + isIgnored = picomatch(opts.ignore, ignoreOpts, returnState); } - isSync = false -} + const matcher = (input, returnObject = false) => { + let { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix }); + let result = { glob, state, regex, posix, input, output, match, isMatch }; + if (typeof opts.onResult === 'function') { + opts.onResult(result); + } -/***/ }), -/* 634 */ -/***/ (function(module, exports, __webpack_require__) { + if (isMatch === false) { + result.isMatch = false; + return returnObject ? result : false; + } -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const NODE_PROCESS_VERSION_PARTS = process.versions.node.split('.'); -const MAJOR_VERSION = parseInt(NODE_PROCESS_VERSION_PARTS[0], 10); -const MINOR_VERSION = parseInt(NODE_PROCESS_VERSION_PARTS[1], 10); -/** - * IS `true` for Node.js 10.10 and greater. - */ -exports.IS_SUPPORT_READDIR_WITH_FILE_TYPES = MAJOR_VERSION > 10 || (MAJOR_VERSION === 10 && MINOR_VERSION >= 10); + if (isIgnored(input)) { + if (typeof opts.onIgnore === 'function') { + opts.onIgnore(result); + } + result.isMatch = false; + return returnObject ? result : false; + } + if (typeof opts.onMatch === 'function') { + opts.onMatch(result); + } + return returnObject ? result : true; + }; -/***/ }), -/* 635 */ -/***/ (function(module, exports, __webpack_require__) { + if (returnState) { + matcher.state = state; + } -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fs = __webpack_require__(636); -exports.fs = fs; + return matcher; +}; +/** + * Test `input` with the given `regex`. This is used by the main + * `picomatch()` function to test the input string. + * + * ```js + * const picomatch = require('picomatch'); + * // picomatch.test(input, regex[, options]); + * + * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/)); + * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' } + * ``` + * @param {String} `input` String to test. + * @param {RegExp} `regex` + * @return {Object} Returns an object with matching info. + * @api public + */ -/***/ }), -/* 636 */ -/***/ (function(module, exports, __webpack_require__) { +picomatch.test = (input, regex, options, { glob, posix } = {}) => { + if (typeof input !== 'string') { + throw new TypeError('Expected input to be a string'); + } -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -class DirentFromStats { - constructor(name, stats) { - this.name = name; - this.isBlockDevice = stats.isBlockDevice.bind(stats); - this.isCharacterDevice = stats.isCharacterDevice.bind(stats); - this.isDirectory = stats.isDirectory.bind(stats); - this.isFIFO = stats.isFIFO.bind(stats); - this.isFile = stats.isFile.bind(stats); - this.isSocket = stats.isSocket.bind(stats); - this.isSymbolicLink = stats.isSymbolicLink.bind(stats); - } -} -function createDirentFromStats(name, stats) { - return new DirentFromStats(name, stats); -} -exports.createDirentFromStats = createDirentFromStats; + if (input === '') { + return { isMatch: false, output: '' }; + } + let opts = options || {}; + let format = opts.format || (posix ? utils.toPosixSlashes : null); + let match = input === glob; + let output = (match && format) ? format(input) : input; -/***/ }), -/* 637 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fsStat = __webpack_require__(623); -const constants_1 = __webpack_require__(634); -const utils = __webpack_require__(635); -function read(dir, settings) { - if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) { - return readdirWithFileTypes(dir, settings); - } - return readdir(dir, settings); -} -exports.read = read; -function readdirWithFileTypes(dir, settings) { - const dirents = settings.fs.readdirSync(dir, { withFileTypes: true }); - return dirents.map((dirent) => { - const entry = { - dirent, - name: dirent.name, - path: `${dir}${settings.pathSegmentSeparator}${dirent.name}` - }; - if (entry.dirent.isSymbolicLink() && settings.followSymbolicLinks) { - try { - const stats = settings.fs.statSync(entry.path); - entry.dirent = utils.fs.createDirentFromStats(entry.name, stats); - } - catch (error) { - if (settings.throwErrorOnBrokenSymbolicLink) { - throw error; - } - } - } - return entry; - }); -} -exports.readdirWithFileTypes = readdirWithFileTypes; -function readdir(dir, settings) { - const names = settings.fs.readdirSync(dir); - return names.map((name) => { - const entryPath = `${dir}${settings.pathSegmentSeparator}${name}`; - const stats = fsStat.statSync(entryPath, settings.fsStatSettings); - const entry = { - name, - path: entryPath, - dirent: utils.fs.createDirentFromStats(name, stats) - }; - if (settings.stats) { - entry.stats = stats; - } - return entry; - }); -} -exports.readdir = readdir; + if (match === false) { + output = format ? format(input) : input; + match = output === glob; + } + if (match === false || opts.capture === true) { + if (opts.matchBase === true || opts.basename === true) { + match = picomatch.matchBase(input, regex, options, posix); + } else { + match = regex.exec(output); + } + } -/***/ }), -/* 638 */ -/***/ (function(module, exports, __webpack_require__) { + return { isMatch: !!match, match, output }; +}; -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const path = __webpack_require__(16); -const fsStat = __webpack_require__(623); -const fs = __webpack_require__(639); -class Settings { - constructor(_options = {}) { - this._options = _options; - this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false); - this.fs = fs.createFileSystemAdapter(this._options.fs); - this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path.sep); - this.stats = this._getValue(this._options.stats, false); - this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true); - this.fsStatSettings = new fsStat.Settings({ - followSymbolicLink: this.followSymbolicLinks, - fs: this.fs, - throwErrorOnBrokenSymbolicLink: this.throwErrorOnBrokenSymbolicLink - }); - } - _getValue(option, value) { - return option === undefined ? value : option; - } -} -exports.default = Settings; +/** + * Match the basename of a filepath. + * + * ```js + * const picomatch = require('picomatch'); + * // picomatch.matchBase(input, glob[, options]); + * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true + * ``` + * @param {String} `input` String to test. + * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe). + * @return {Boolean} + * @api public + */ +picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) => { + let regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options); + return regex.test(path.basename(input)); +}; -/***/ }), -/* 639 */ -/***/ (function(module, exports, __webpack_require__) { +/** + * Returns true if **any** of the given glob `patterns` match the specified `string`. + * + * ```js + * const picomatch = require('picomatch'); + * // picomatch.isMatch(string, patterns[, options]); + * + * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true + * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false + * ``` + * @param {String|Array} str The string to test. + * @param {String|Array} patterns One or more glob patterns to use for matching. + * @param {Object} [options] See available [options](#options). + * @return {Boolean} Returns true if any patterns match `str` + * @api public + */ -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fs = __webpack_require__(23); -exports.FILE_SYSTEM_ADAPTER = { - lstat: fs.lstat, - stat: fs.stat, - lstatSync: fs.lstatSync, - statSync: fs.statSync, - readdir: fs.readdir, - readdirSync: fs.readdirSync -}; -function createFileSystemAdapter(fsMethods) { - if (!fsMethods) { - return exports.FILE_SYSTEM_ADAPTER; - } - return Object.assign({}, exports.FILE_SYSTEM_ADAPTER, fsMethods); -} -exports.createFileSystemAdapter = createFileSystemAdapter; +picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str); +/** + * Parse a glob pattern to create the source string for a regular + * expression. + * + * ```js + * const picomatch = require('picomatch'); + * const result = picomatch.parse(glob[, options]); + * ``` + * @param {String} `glob` + * @param {Object} `options` + * @return {Object} Returns an object with useful properties and output to be used as a regex source string. + * @api public + */ -/***/ }), -/* 640 */ -/***/ (function(module, exports, __webpack_require__) { +picomatch.parse = (glob, options) => parse(glob, options); -"use strict"; +/** + * Scan a glob pattern to separate the pattern into segments. + * + * ```js + * const picomatch = require('picomatch'); + * // picomatch.scan(input[, options]); + * + * const result = picomatch.scan('!./foo/*.js'); + * console.log(result); + * // { prefix: '!./', + * // input: '!./foo/*.js', + * // base: 'foo', + * // glob: '*.js', + * // negated: true, + * // isGlob: true } + * ``` + * @param {String} `input` Glob pattern to scan. + * @param {Object} `options` + * @return {Object} Returns an object with + * @api public + */ +picomatch.scan = (input, options) => scan(input, options); -var reusify = __webpack_require__(641) +/** + * Create a regular expression from a glob pattern. + * + * ```js + * const picomatch = require('picomatch'); + * // picomatch.makeRe(input[, options]); + * + * console.log(picomatch.makeRe('*.js')); + * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/ + * ``` + * @param {String} `input` A glob pattern to convert to regex. + * @param {Object} `options` + * @return {RegExp} Returns a regex created from the given pattern. + * @api public + */ -function fastqueue (context, worker, concurrency) { - if (typeof context === 'function') { - concurrency = worker - worker = context - context = null +picomatch.makeRe = (input, options, returnOutput = false, returnState = false) => { + if (!input || typeof input !== 'string') { + throw new TypeError('Expected a non-empty string'); } - var cache = reusify(Task) - var queueHead = null - var queueTail = null - var _running = 0 + let opts = options || {}; + let prepend = opts.contains ? '' : '^'; + let append = opts.contains ? '' : '$'; + let state = { negated: false, fastpaths: true }; + let prefix = ''; + let output; - var self = { - push: push, - drain: noop, - saturated: noop, - pause: pause, - paused: false, - concurrency: concurrency, - running: running, - resume: resume, - idle: idle, - length: length, - unshift: unshift, - empty: noop, - kill: kill, - killAndDrain: killAndDrain + if (input.startsWith('./')) { + input = input.slice(2); + prefix = state.prefix = './'; } - return self - - function running () { - return _running + if (opts.fastpaths !== false && (input[0] === '.' || input[0] === '*')) { + output = parse.fastpaths(input, options); } - function pause () { - self.paused = true + if (output === void 0) { + state = picomatch.parse(input, options); + state.prefix = prefix + (state.prefix || ''); + output = state.output; } - function length () { - var current = queueHead - var counter = 0 - - while (current) { - current = current.next - counter++ - } - - return counter + if (returnOutput === true) { + return output; } - function resume () { - if (!self.paused) return - self.paused = false - for (var i = 0; i < self.concurrency; i++) { - _running++ - release() - } + let source = `${prepend}(?:${output})${append}`; + if (state && state.negated === true) { + source = `^(?!${source}).*$`; } - function idle () { - return _running === 0 && self.length() === 0 + let regex = picomatch.toRegex(source, options); + if (returnState === true) { + regex.state = state; } - function push (value, done) { - var current = cache.get() + return regex; +}; - current.context = context - current.release = release - current.value = value - current.callback = done || noop +/** + * Create a regular expression from the given regex source string. + * + * ```js + * const picomatch = require('picomatch'); + * // picomatch.toRegex(source[, options]); + * + * const { output } = picomatch.parse('*.js'); + * console.log(picomatch.toRegex(output)); + * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/ + * ``` + * @param {String} `source` Regular expression source string. + * @param {Object} `options` + * @return {RegExp} + * @api public + */ - if (_running === self.concurrency || self.paused) { - if (queueTail) { - queueTail.next = current - queueTail = current - } else { - queueHead = current - queueTail = current - self.saturated() - } - } else { - _running++ - worker.call(context, current.value, current.worked) - } +picomatch.toRegex = (source, options) => { + try { + let opts = options || {}; + return new RegExp(source, opts.flags || (opts.nocase ? 'i' : '')); + } catch (err) { + if (options && options.debug === true) throw err; + return /$^/; } +}; - function unshift (value, done) { - var current = cache.get() +/** + * Picomatch constants. + * @return {Object} + */ - current.context = context - current.release = release - current.value = value - current.callback = done || noop +picomatch.constants = __webpack_require__(623); - if (_running === self.concurrency || self.paused) { - if (queueHead) { - current.next = queueHead - queueHead = current - } else { - queueHead = current - queueTail = current - self.saturated() - } - } else { - _running++ - worker.call(context, current.value, current.worked) - } - } +/** + * Expose "picomatch" + */ - function release (holder) { - if (holder) { - cache.release(holder) - } - var next = queueHead - if (next) { - if (!self.paused) { - if (queueTail === queueHead) { - queueTail = null - } - queueHead = next.next - next.next = null - worker.call(context, next.value, next.worked) - if (queueTail === null) { - self.empty() - } - } else { - _running-- - } - } else if (--_running === 0) { - self.drain() - } - } +module.exports = picomatch; - function kill () { - queueHead = null - queueTail = null - self.drain = noop - } - function killAndDrain () { - queueHead = null - queueTail = null - self.drain() - self.drain = noop - } -} +/***/ }), +/* 621 */ +/***/ (function(module, exports, __webpack_require__) { -function noop () {} +"use strict"; -function Task () { - this.value = null - this.callback = noop - this.next = null - this.release = noop - this.context = null - var self = this +const utils = __webpack_require__(622); - this.worked = function worked (err, result) { - var callback = self.callback - self.value = null - self.callback = noop - callback.call(self.context, err, result) - self.release(self) - } -} +const { + CHAR_ASTERISK, /* * */ + CHAR_AT, /* @ */ + CHAR_BACKWARD_SLASH, /* \ */ + CHAR_COMMA, /* , */ + CHAR_DOT, /* . */ + CHAR_EXCLAMATION_MARK, /* ! */ + CHAR_FORWARD_SLASH, /* / */ + CHAR_LEFT_CURLY_BRACE, /* { */ + CHAR_LEFT_PARENTHESES, /* ( */ + CHAR_LEFT_SQUARE_BRACKET, /* [ */ + CHAR_PLUS, /* + */ + CHAR_QUESTION_MARK, /* ? */ + CHAR_RIGHT_CURLY_BRACE, /* } */ + CHAR_RIGHT_PARENTHESES, /* ) */ + CHAR_RIGHT_SQUARE_BRACKET /* ] */ +} = __webpack_require__(623); -module.exports = fastqueue +const isPathSeparator = code => { + return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH; +}; +/** + * Quickly scans a glob pattern and returns an object with a handful of + * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists), + * `glob` (the actual pattern), and `negated` (true if the path starts with `!`). + * + * ```js + * const pm = require('picomatch'); + * console.log(pm.scan('foo/bar/*.js')); + * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' } + * ``` + * @param {String} `str` + * @param {Object} `options` + * @return {Object} Returns an object with tokens and regex source string. + * @api public + */ -/***/ }), -/* 641 */ -/***/ (function(module, exports, __webpack_require__) { +module.exports = (input, options) => { + let opts = options || {}; + let length = input.length - 1; + let index = -1; + let start = 0; + let lastIndex = 0; + let isGlob = false; + let backslashes = false; + let negated = false; + let braces = 0; + let prev; + let code; -"use strict"; + let braceEscaped = false; + let eos = () => index >= length; + let advance = () => { + prev = code; + return input.charCodeAt(++index); + }; -function reusify (Constructor) { - var head = new Constructor() - var tail = head + while (index < length) { + code = advance(); + let next; - function get () { - var current = head + if (code === CHAR_BACKWARD_SLASH) { + backslashes = true; + next = advance(); - if (current.next) { - head = current.next - } else { - head = new Constructor() - tail = head + if (next === CHAR_LEFT_CURLY_BRACE) { + braceEscaped = true; + } + continue; } - current.next = null + if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) { + braces++; - return current - } + while (!eos() && (next = advance())) { + if (next === CHAR_BACKWARD_SLASH) { + backslashes = true; + next = advance(); + continue; + } - function release (obj) { - tail.next = obj - tail = obj - } + if (next === CHAR_LEFT_CURLY_BRACE) { + braces++; + continue; + } - return { - get: get, - release: release - } -} + if (!braceEscaped && next === CHAR_DOT && (next = advance()) === CHAR_DOT) { + isGlob = true; + break; + } -module.exports = reusify + if (!braceEscaped && next === CHAR_COMMA) { + isGlob = true; + break; + } + if (next === CHAR_RIGHT_CURLY_BRACE) { + braces--; + if (braces === 0) { + braceEscaped = false; + break; + } + } + } + } -/***/ }), -/* 642 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -function isFatalError(settings, error) { - if (settings.errorFilter === null) { - return true; - } - return !settings.errorFilter(error); -} -exports.isFatalError = isFatalError; -function isAppliedFilter(filter, value) { - return filter === null || filter(value); -} -exports.isAppliedFilter = isAppliedFilter; -function replacePathSegmentSeparator(filepath, separator) { - return filepath.split(/[\\\/]/).join(separator); -} -exports.replacePathSegmentSeparator = replacePathSegmentSeparator; -function joinPathSegments(a, b, separator) { - if (a === '') { - return b; - } - return a + separator + b; -} -exports.joinPathSegments = joinPathSegments; + if (code === CHAR_FORWARD_SLASH) { + if (prev === CHAR_DOT && index === (start + 1)) { + start += 2; + continue; + } + lastIndex = index + 1; + continue; + } -/***/ }), -/* 643 */ -/***/ (function(module, exports, __webpack_require__) { + if (code === CHAR_ASTERISK) { + isGlob = true; + break; + } -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const common = __webpack_require__(642); -class Reader { - constructor(_root, _settings) { - this._root = _root; - this._settings = _settings; - this._root = common.replacePathSegmentSeparator(_root, _settings.pathSegmentSeparator); - } -} -exports.default = Reader; + if (code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK) { + isGlob = true; + break; + } + if (code === CHAR_LEFT_SQUARE_BRACKET) { + while (!eos() && (next = advance())) { + if (next === CHAR_BACKWARD_SLASH) { + backslashes = true; + next = advance(); + continue; + } -/***/ }), -/* 644 */ -/***/ (function(module, exports, __webpack_require__) { + if (next === CHAR_RIGHT_SQUARE_BRACKET) { + isGlob = true; + break; + } + } + } -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const stream_1 = __webpack_require__(27); -const async_1 = __webpack_require__(630); -class StreamProvider { - constructor(_root, _settings) { - this._root = _root; - this._settings = _settings; - this._reader = new async_1.default(this._root, this._settings); - this._stream = new stream_1.Readable({ - objectMode: true, - read: () => { }, - destroy: this._reader.destroy.bind(this._reader) - }); - } - read() { - this._reader.onError((error) => { - this._stream.emit('error', error); - }); - this._reader.onEntry((entry) => { - this._stream.push(entry); - }); - this._reader.onEnd(() => { - this._stream.push(null); - }); - this._reader.read(); - return this._stream; - } -} -exports.default = StreamProvider; + let isExtglobChar = code === CHAR_PLUS + || code === CHAR_AT + || code === CHAR_EXCLAMATION_MARK; + if (isExtglobChar && input.charCodeAt(index + 1) === CHAR_LEFT_PARENTHESES) { + isGlob = true; + break; + } -/***/ }), -/* 645 */ -/***/ (function(module, exports, __webpack_require__) { + if (code === CHAR_EXCLAMATION_MARK && index === start) { + negated = true; + start++; + continue; + } -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const sync_1 = __webpack_require__(646); -class SyncProvider { - constructor(_root, _settings) { - this._root = _root; - this._settings = _settings; - this._reader = new sync_1.default(this._root, this._settings); - } - read() { - return this._reader.read(); - } -} -exports.default = SyncProvider; + if (code === CHAR_LEFT_PARENTHESES) { + while (!eos() && (next = advance())) { + if (next === CHAR_BACKWARD_SLASH) { + backslashes = true; + next = advance(); + continue; + } + if (next === CHAR_RIGHT_PARENTHESES) { + isGlob = true; + break; + } + } + } -/***/ }), -/* 646 */ -/***/ (function(module, exports, __webpack_require__) { + if (isGlob) { + break; + } + } -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fsScandir = __webpack_require__(631); -const common = __webpack_require__(642); -const reader_1 = __webpack_require__(643); -class SyncReader extends reader_1.default { - constructor() { - super(...arguments); - this._scandir = fsScandir.scandirSync; - this._storage = new Set(); - this._queue = new Set(); - } - read() { - this._pushToQueue(this._root, this._settings.basePath); - this._handleQueue(); - return Array.from(this._storage); - } - _pushToQueue(dir, base) { - this._queue.add({ dir, base }); - } - _handleQueue() { - for (const item of this._queue.values()) { - this._handleDirectory(item.dir, item.base); - } - } - _handleDirectory(dir, base) { - try { - const entries = this._scandir(dir, this._settings.fsScandirSettings); - for (const entry of entries) { - this._handleEntry(entry, base); - } - } - catch (error) { - this._handleError(error); - } - } - _handleError(error) { - if (!common.isFatalError(this._settings, error)) { - return; - } - throw error; - } - _handleEntry(entry, base) { - const fullpath = entry.path; - if (base !== undefined) { - entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator); - } - if (common.isAppliedFilter(this._settings.entryFilter, entry)) { - this._pushToStorage(entry); - } - if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) { - this._pushToQueue(fullpath, entry.path); - } - } - _pushToStorage(entry) { - this._storage.add(entry); - } -} -exports.default = SyncReader; + let prefix = ''; + let orig = input; + let base = input; + let glob = ''; + if (start > 0) { + prefix = input.slice(0, start); + input = input.slice(start); + lastIndex -= start; + } -/***/ }), -/* 647 */ -/***/ (function(module, exports, __webpack_require__) { + if (base && isGlob === true && lastIndex > 0) { + base = input.slice(0, lastIndex); + glob = input.slice(lastIndex); + } else if (isGlob === true) { + base = ''; + glob = input; + } else { + base = input; + } -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const path = __webpack_require__(16); -const fsScandir = __webpack_require__(631); -class Settings { - constructor(_options = {}) { - this._options = _options; - this.basePath = this._getValue(this._options.basePath, undefined); - this.concurrency = this._getValue(this._options.concurrency, Infinity); - this.deepFilter = this._getValue(this._options.deepFilter, null); - this.entryFilter = this._getValue(this._options.entryFilter, null); - this.errorFilter = this._getValue(this._options.errorFilter, null); - this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path.sep); - this.fsScandirSettings = new fsScandir.Settings({ - followSymbolicLinks: this._options.followSymbolicLinks, - fs: this._options.fs, - pathSegmentSeparator: this._options.pathSegmentSeparator, - stats: this._options.stats, - throwErrorOnBrokenSymbolicLink: this._options.throwErrorOnBrokenSymbolicLink - }); - } - _getValue(option, value) { - return option === undefined ? value : option; - } -} -exports.default = Settings; + if (base && base !== '' && base !== '/' && base !== input) { + if (isPathSeparator(base.charCodeAt(base.length - 1))) { + base = base.slice(0, -1); + } + } + if (opts.unescape === true) { + if (glob) glob = utils.removeBackslashes(glob); -/***/ }), -/* 648 */ -/***/ (function(module, exports, __webpack_require__) { + if (base && backslashes === true) { + base = utils.removeBackslashes(base); + } + } -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const path = __webpack_require__(16); -const fsStat = __webpack_require__(623); -const utils = __webpack_require__(594); -class Reader { - constructor(_settings) { - this._settings = _settings; - this._fsStatSettings = new fsStat.Settings({ - followSymbolicLink: this._settings.followSymbolicLinks, - fs: this._settings.fs, - throwErrorOnBrokenSymbolicLink: this._settings.followSymbolicLinks - }); - } - _getFullEntryPath(filepath) { - return path.resolve(this._settings.cwd, filepath); - } - _makeEntry(stats, pattern) { - const entry = { - name: pattern, - path: pattern, - dirent: utils.fs.createDirentFromStats(pattern, stats) - }; - if (this._settings.stats) { - entry.stats = stats; - } - return entry; - } - _isFatalError(error) { - return !utils.errno.isEnoentCodeError(error) && !this._settings.suppressErrors; - } -} -exports.default = Reader; + return { prefix, input: orig, base, glob, negated, isGlob }; +}; /***/ }), -/* 649 */ +/* 622 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const path = __webpack_require__(16); -const deep_1 = __webpack_require__(650); -const entry_1 = __webpack_require__(651); -const error_1 = __webpack_require__(652); -const entry_2 = __webpack_require__(653); -class Provider { - constructor(_settings) { - this._settings = _settings; - this.errorFilter = new error_1.default(this._settings); - this.entryFilter = new entry_1.default(this._settings, this._getMicromatchOptions()); - this.deepFilter = new deep_1.default(this._settings, this._getMicromatchOptions()); - this.entryTransformer = new entry_2.default(this._settings); - } - _getRootDirectory(task) { - return path.resolve(this._settings.cwd, task.base); - } - _getReaderOptions(task) { - const basePath = task.base === '.' ? '' : task.base; - return { - basePath, - pathSegmentSeparator: '/', - concurrency: this._settings.concurrency, - deepFilter: this.deepFilter.getFilter(basePath, task.positive, task.negative), - entryFilter: this.entryFilter.getFilter(task.positive, task.negative), - errorFilter: this.errorFilter.getFilter(), - followSymbolicLinks: this._settings.followSymbolicLinks, - fs: this._settings.fs, - stats: this._settings.stats, - throwErrorOnBrokenSymbolicLink: this._settings.throwErrorOnBrokenSymbolicLink, - transform: this.entryTransformer.getTransformer() - }; - } - _getMicromatchOptions() { - return { - dot: this._settings.dot, - matchBase: this._settings.baseNameMatch, - nobrace: !this._settings.braceExpansion, - nocase: !this._settings.caseSensitiveMatch, - noext: !this._settings.extglob, - noglobstar: !this._settings.globstar, - posix: true, - strictSlashes: false - }; - } -} -exports.default = Provider; -/***/ }), -/* 650 */ -/***/ (function(module, exports, __webpack_require__) { +const path = __webpack_require__(16); +const win32 = process.platform === 'win32'; +const { + REGEX_SPECIAL_CHARS, + REGEX_SPECIAL_CHARS_GLOBAL, + REGEX_REMOVE_BACKSLASH +} = __webpack_require__(623); -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const utils = __webpack_require__(594); -class DeepFilter { - constructor(_settings, _micromatchOptions) { - this._settings = _settings; - this._micromatchOptions = _micromatchOptions; - } - getFilter(basePath, positive, negative) { - const maxPatternDepth = this._getMaxPatternDepth(positive); - const negativeRe = this._getNegativePatternsRe(negative); - return (entry) => this._filter(basePath, entry, negativeRe, maxPatternDepth); - } - _getMaxPatternDepth(patterns) { - const globstar = patterns.some(utils.pattern.hasGlobStar); - return globstar ? Infinity : utils.pattern.getMaxNaivePatternsDepth(patterns); - } - _getNegativePatternsRe(patterns) { - const affectDepthOfReadingPatterns = patterns.filter(utils.pattern.isAffectDepthOfReadingPattern); - return utils.pattern.convertPatternsToRe(affectDepthOfReadingPatterns, this._micromatchOptions); - } - _filter(basePath, entry, negativeRe, maxPatternDepth) { - const depth = this._getEntryDepth(basePath, entry.path); - if (this._isSkippedByDeep(depth)) { - return false; - } - if (this._isSkippedByMaxPatternDepth(depth, maxPatternDepth)) { - return false; - } - if (this._isSkippedSymbolicLink(entry)) { - return false; - } - if (this._isSkippedDotDirectory(entry)) { - return false; - } - return this._isSkippedByNegativePatterns(entry, negativeRe); - } - _getEntryDepth(basePath, entryPath) { - const basePathDepth = basePath.split('/').length; - const entryPathDepth = entryPath.split('/').length; - return entryPathDepth - (basePath === '' ? 0 : basePathDepth); - } - _isSkippedByDeep(entryDepth) { - return entryDepth >= this._settings.deep; - } - _isSkippedByMaxPatternDepth(entryDepth, maxPatternDepth) { - return !this._settings.baseNameMatch && maxPatternDepth !== Infinity && entryDepth > maxPatternDepth; - } - _isSkippedSymbolicLink(entry) { - return !this._settings.followSymbolicLinks && entry.dirent.isSymbolicLink(); - } - _isSkippedDotDirectory(entry) { - return !this._settings.dot && entry.name.startsWith('.'); - } - _isSkippedByNegativePatterns(entry, negativeRe) { - return !utils.pattern.matchAny(entry.path, negativeRe); - } -} -exports.default = DeepFilter; +exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val); +exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str); +exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str); +exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1'); +exports.toPosixSlashes = str => str.replace(/\\/g, '/'); +exports.removeBackslashes = str => { + return str.replace(REGEX_REMOVE_BACKSLASH, match => { + return match === '\\' ? '' : match; + }); +} -/***/ }), -/* 651 */ -/***/ (function(module, exports, __webpack_require__) { +exports.supportsLookbehinds = () => { + let segs = process.version.slice(1).split('.'); + if (segs.length === 3 && +segs[0] >= 9 || (+segs[0] === 8 && +segs[1] >= 10)) { + return true; + } + return false; +}; -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const utils = __webpack_require__(594); -class EntryFilter { - constructor(_settings, _micromatchOptions) { - this._settings = _settings; - this._micromatchOptions = _micromatchOptions; - this.index = new Map(); - } - getFilter(positive, negative) { - const positiveRe = utils.pattern.convertPatternsToRe(positive, this._micromatchOptions); - const negativeRe = utils.pattern.convertPatternsToRe(negative, this._micromatchOptions); - return (entry) => this._filter(entry, positiveRe, negativeRe); - } - _filter(entry, positiveRe, negativeRe) { - if (this._settings.unique) { - if (this._isDuplicateEntry(entry)) { - return false; - } - this._createIndexRecord(entry); - } - if (this._onlyFileFilter(entry) || this._onlyDirectoryFilter(entry)) { - return false; - } - if (this._isSkippedByAbsoluteNegativePatterns(entry, negativeRe)) { - return false; - } - const filepath = this._settings.baseNameMatch ? entry.name : entry.path; - return this._isMatchToPatterns(filepath, positiveRe) && !this._isMatchToPatterns(entry.path, negativeRe); - } - _isDuplicateEntry(entry) { - return this.index.has(entry.path); - } - _createIndexRecord(entry) { - this.index.set(entry.path, undefined); - } - _onlyFileFilter(entry) { - return this._settings.onlyFiles && !entry.dirent.isFile(); - } - _onlyDirectoryFilter(entry) { - return this._settings.onlyDirectories && !entry.dirent.isDirectory(); - } - _isSkippedByAbsoluteNegativePatterns(entry, negativeRe) { - if (!this._settings.absolute) { - return false; - } - const fullpath = utils.path.makeAbsolute(this._settings.cwd, entry.path); - return this._isMatchToPatterns(fullpath, negativeRe); - } - _isMatchToPatterns(filepath, patternsRe) { - return utils.pattern.matchAny(filepath, patternsRe); - } -} -exports.default = EntryFilter; +exports.isWindows = options => { + if (options && typeof options.windows === 'boolean') { + return options.windows; + } + return win32 === true || path.sep === '\\'; +}; + +exports.escapeLast = (input, char, lastIdx) => { + let idx = input.lastIndexOf(char, lastIdx); + if (idx === -1) return input; + if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1); + return input.slice(0, idx) + '\\' + input.slice(idx); +}; /***/ }), -/* 652 */ +/* 623 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const utils = __webpack_require__(594); -class ErrorFilter { - constructor(_settings) { - this._settings = _settings; - } - getFilter() { - return (error) => this._isNonFatalError(error); - } - _isNonFatalError(error) { - return utils.errno.isEnoentCodeError(error) || this._settings.suppressErrors; - } -} -exports.default = ErrorFilter; + + +const path = __webpack_require__(16); +const WIN_SLASH = '\\\\/'; +const WIN_NO_SLASH = `[^${WIN_SLASH}]`; + +/** + * Posix glob regex + */ + +const DOT_LITERAL = '\\.'; +const PLUS_LITERAL = '\\+'; +const QMARK_LITERAL = '\\?'; +const SLASH_LITERAL = '\\/'; +const ONE_CHAR = '(?=.)'; +const QMARK = '[^/]'; +const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`; +const START_ANCHOR = `(?:^|${SLASH_LITERAL})`; +const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`; +const NO_DOT = `(?!${DOT_LITERAL})`; +const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`; +const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`; +const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`; +const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`; +const STAR = `${QMARK}*?`; + +const POSIX_CHARS = { + DOT_LITERAL, + PLUS_LITERAL, + QMARK_LITERAL, + SLASH_LITERAL, + ONE_CHAR, + QMARK, + END_ANCHOR, + DOTS_SLASH, + NO_DOT, + NO_DOTS, + NO_DOT_SLASH, + NO_DOTS_SLASH, + QMARK_NO_DOT, + STAR, + START_ANCHOR +}; + +/** + * Windows glob regex + */ + +const WINDOWS_CHARS = { + ...POSIX_CHARS, + + SLASH_LITERAL: `[${WIN_SLASH}]`, + QMARK: WIN_NO_SLASH, + STAR: `${WIN_NO_SLASH}*?`, + DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`, + NO_DOT: `(?!${DOT_LITERAL})`, + NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`, + NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`, + NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`, + QMARK_NO_DOT: `[^.${WIN_SLASH}]`, + START_ANCHOR: `(?:^|[${WIN_SLASH}])`, + END_ANCHOR: `(?:[${WIN_SLASH}]|$)` +}; + +/** + * POSIX Bracket Regex + */ + +const POSIX_REGEX_SOURCE = { + alnum: 'a-zA-Z0-9', + alpha: 'a-zA-Z', + ascii: '\\x00-\\x7F', + blank: ' \\t', + cntrl: '\\x00-\\x1F\\x7F', + digit: '0-9', + graph: '\\x21-\\x7E', + lower: 'a-z', + print: '\\x20-\\x7E ', + punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~', + space: ' \\t\\r\\n\\v\\f', + upper: 'A-Z', + word: 'A-Za-z0-9_', + xdigit: 'A-Fa-f0-9' +}; + +module.exports = { + MAX_LENGTH: 1024 * 64, + POSIX_REGEX_SOURCE, + + // regular expressions + REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g, + REGEX_NON_SPECIAL_CHAR: /^[^@![\].,$*+?^{}()|\\/]+/, + REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/, + REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g, + REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g, + REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g, + + // Replace globs with equivalent patterns to reduce parsing time. + REPLACEMENTS: { + '***': '*', + '**/**': '**', + '**/**/**': '**' + }, + + // Digits + CHAR_0: 48, /* 0 */ + CHAR_9: 57, /* 9 */ + + // Alphabet chars. + CHAR_UPPERCASE_A: 65, /* A */ + CHAR_LOWERCASE_A: 97, /* a */ + CHAR_UPPERCASE_Z: 90, /* Z */ + CHAR_LOWERCASE_Z: 122, /* z */ + + CHAR_LEFT_PARENTHESES: 40, /* ( */ + CHAR_RIGHT_PARENTHESES: 41, /* ) */ + + CHAR_ASTERISK: 42, /* * */ + + // Non-alphabetic chars. + CHAR_AMPERSAND: 38, /* & */ + CHAR_AT: 64, /* @ */ + CHAR_BACKWARD_SLASH: 92, /* \ */ + CHAR_CARRIAGE_RETURN: 13, /* \r */ + CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */ + CHAR_COLON: 58, /* : */ + CHAR_COMMA: 44, /* , */ + CHAR_DOT: 46, /* . */ + CHAR_DOUBLE_QUOTE: 34, /* " */ + CHAR_EQUAL: 61, /* = */ + CHAR_EXCLAMATION_MARK: 33, /* ! */ + CHAR_FORM_FEED: 12, /* \f */ + CHAR_FORWARD_SLASH: 47, /* / */ + CHAR_GRAVE_ACCENT: 96, /* ` */ + CHAR_HASH: 35, /* # */ + CHAR_HYPHEN_MINUS: 45, /* - */ + CHAR_LEFT_ANGLE_BRACKET: 60, /* < */ + CHAR_LEFT_CURLY_BRACE: 123, /* { */ + CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */ + CHAR_LINE_FEED: 10, /* \n */ + CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */ + CHAR_PERCENT: 37, /* % */ + CHAR_PLUS: 43, /* + */ + CHAR_QUESTION_MARK: 63, /* ? */ + CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */ + CHAR_RIGHT_CURLY_BRACE: 125, /* } */ + CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */ + CHAR_SEMICOLON: 59, /* ; */ + CHAR_SINGLE_QUOTE: 39, /* ' */ + CHAR_SPACE: 32, /* */ + CHAR_TAB: 9, /* \t */ + CHAR_UNDERSCORE: 95, /* _ */ + CHAR_VERTICAL_LINE: 124, /* | */ + CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */ + + SEP: path.sep, + + /** + * Create EXTGLOB_CHARS + */ + + extglobChars(chars) { + return { + '!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` }, + '?': { type: 'qmark', open: '(?:', close: ')?' }, + '+': { type: 'plus', open: '(?:', close: ')+' }, + '*': { type: 'star', open: '(?:', close: ')*' }, + '@': { type: 'at', open: '(?:', close: ')' } + }; + }, + + /** + * Create GLOB_CHARS + */ + + globChars(win32) { + return win32 === true ? WINDOWS_CHARS : POSIX_CHARS; + } +}; + + +/***/ }), +/* 624 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +const utils = __webpack_require__(622); +const constants = __webpack_require__(623); + +/** + * Constants + */ + +const { + MAX_LENGTH, + POSIX_REGEX_SOURCE, + REGEX_NON_SPECIAL_CHAR, + REGEX_SPECIAL_CHARS_BACKREF, + REPLACEMENTS +} = constants; + +/** + * Helpers + */ + +const expandRange = (args, options) => { + if (typeof options.expandRange === 'function') { + return options.expandRange(...args, options); + } + + args.sort(); + let value = `[${args.join('-')}]`; + + try { + /* eslint-disable no-new */ + new RegExp(value); + } catch (ex) { + return args.map(v => utils.escapeRegex(v)).join('..'); + } + + return value; +}; + +const negate = state => { + let count = 1; + + while (state.peek() === '!' && (state.peek(2) !== '(' || state.peek(3) === '?')) { + state.advance(); + state.start++; + count++; + } + + if (count % 2 === 0) { + return false; + } + + state.negated = true; + state.start++; + return true; +}; + +/** + * Create the message for a syntax error + */ + +const syntaxError = (type, char) => { + return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`; +}; + +/** + * Parse the given input string. + * @param {String} input + * @param {Object} options + * @return {Object} + */ + +const parse = (input, options) => { + if (typeof input !== 'string') { + throw new TypeError('Expected a string'); + } + + input = REPLACEMENTS[input] || input; + + let opts = { ...options }; + let max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH; + let len = input.length; + if (len > max) { + throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`); + } + + let bos = { type: 'bos', value: '', output: opts.prepend || '' }; + let tokens = [bos]; + + let capture = opts.capture ? '' : '?:'; + let win32 = utils.isWindows(options); + + // create constants based on platform, for windows or posix + const PLATFORM_CHARS = constants.globChars(win32); + const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS); + + const { + DOT_LITERAL, + PLUS_LITERAL, + SLASH_LITERAL, + ONE_CHAR, + DOTS_SLASH, + NO_DOT, + NO_DOT_SLASH, + NO_DOTS_SLASH, + QMARK, + QMARK_NO_DOT, + STAR, + START_ANCHOR + } = PLATFORM_CHARS; + + const globstar = (opts) => { + return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`; + }; + + let nodot = opts.dot ? '' : NO_DOT; + let star = opts.bash === true ? globstar(opts) : STAR; + let qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT; + + if (opts.capture) { + star = `(${star})`; + } + + // minimatch options support + if (typeof opts.noext === 'boolean') { + opts.noextglob = opts.noext; + } + + let state = { + index: -1, + start: 0, + consumed: '', + output: '', + backtrack: false, + brackets: 0, + braces: 0, + parens: 0, + quotes: 0, + tokens + }; + + let extglobs = []; + let stack = []; + let prev = bos; + let value; + + /** + * Tokenizing helpers + */ + + const eos = () => state.index === len - 1; + const peek = state.peek = (n = 1) => input[state.index + n]; + const advance = state.advance = () => input[++state.index]; + const append = token => { + state.output += token.output != null ? token.output : token.value; + state.consumed += token.value || ''; + }; + + const increment = type => { + state[type]++; + stack.push(type); + }; + + const decrement = type => { + state[type]--; + stack.pop(); + }; + + /** + * Push tokens onto the tokens array. This helper speeds up + * tokenizing by 1) helping us avoid backtracking as much as possible, + * and 2) helping us avoid creating extra tokens when consecutive + * characters are plain text. This improves performance and simplifies + * lookbehinds. + */ + + const push = tok => { + if (prev.type === 'globstar') { + let isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace'); + let isExtglob = extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'); + if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) { + state.output = state.output.slice(0, -prev.output.length); + prev.type = 'star'; + prev.value = '*'; + prev.output = star; + state.output += prev.output; + } + } + + if (extglobs.length && tok.type !== 'paren' && !EXTGLOB_CHARS[tok.value]) { + extglobs[extglobs.length - 1].inner += tok.value; + } + + if (tok.value || tok.output) append(tok); + if (prev && prev.type === 'text' && tok.type === 'text') { + prev.value += tok.value; + return; + } + + tok.prev = prev; + tokens.push(tok); + prev = tok; + }; + + const extglobOpen = (type, value) => { + let token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' }; + + token.prev = prev; + token.parens = state.parens; + token.output = state.output; + let output = (opts.capture ? '(' : '') + token.open; + + push({ type, value, output: state.output ? '' : ONE_CHAR }); + push({ type: 'paren', extglob: true, value: advance(), output }); + increment('parens'); + extglobs.push(token); + }; + + const extglobClose = token => { + let output = token.close + (opts.capture ? ')' : ''); + + if (token.type === 'negate') { + let extglobStar = star; + + if (token.inner && token.inner.length > 1 && token.inner.includes('/')) { + extglobStar = globstar(opts); + } + + if (extglobStar !== star || eos() || /^\)+$/.test(input.slice(state.index + 1))) { + output = token.close = ')$))' + extglobStar; + } + + if (token.prev.type === 'bos' && eos()) { + state.negatedExtglob = true; + } + } + + push({ type: 'paren', extglob: true, value, output }); + decrement('parens'); + }; + + if (opts.fastpaths !== false && !/(^[*!]|[/{[()\]}"])/.test(input)) { + let backslashes = false; + + let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => { + if (first === '\\') { + backslashes = true; + return m; + } + + if (first === '?') { + if (esc) { + return esc + first + (rest ? QMARK.repeat(rest.length) : ''); + } + if (index === 0) { + return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : ''); + } + return QMARK.repeat(chars.length); + } + + if (first === '.') { + return DOT_LITERAL.repeat(chars.length); + } + + if (first === '*') { + if (esc) { + return esc + first + (rest ? star : ''); + } + return star; + } + return esc ? m : '\\' + m; + }); + + if (backslashes === true) { + if (opts.unescape === true) { + output = output.replace(/\\/g, ''); + } else { + output = output.replace(/\\+/g, m => { + return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : ''); + }); + } + } + + state.output = output; + return state; + } + + /** + * Tokenize input until we reach end-of-string + */ + + while (!eos()) { + value = advance(); + + if (value === '\u0000') { + continue; + } + + /** + * Escaped characters + */ + + if (value === '\\') { + let next = peek(); + + if (next === '/' && opts.bash !== true) { + continue; + } + + if (next === '.' || next === ';') { + continue; + } + + if (!next) { + value += '\\'; + push({ type: 'text', value }); + continue; + } + + // collapse slashes to reduce potential for exploits + let match = /^\\+/.exec(input.slice(state.index + 1)); + let slashes = 0; + + if (match && match[0].length > 2) { + slashes = match[0].length; + state.index += slashes; + if (slashes % 2 !== 0) { + value += '\\'; + } + } + + if (opts.unescape === true) { + value = advance() || ''; + } else { + value += advance() || ''; + } + + if (state.brackets === 0) { + push({ type: 'text', value }); + continue; + } + } + + /** + * If we're inside a regex character class, continue + * until we reach the closing bracket. + */ + + if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) { + if (opts.posix !== false && value === ':') { + let inner = prev.value.slice(1); + if (inner.includes('[')) { + prev.posix = true; + + if (inner.includes(':')) { + let idx = prev.value.lastIndexOf('['); + let pre = prev.value.slice(0, idx); + let rest = prev.value.slice(idx + 2); + let posix = POSIX_REGEX_SOURCE[rest]; + if (posix) { + prev.value = pre + posix; + state.backtrack = true; + advance(); + + if (!bos.output && tokens.indexOf(prev) === 1) { + bos.output = ONE_CHAR; + } + continue; + } + } + } + } + + if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) { + value = '\\' + value; + } + + if (value === ']' && (prev.value === '[' || prev.value === '[^')) { + value = '\\' + value; + } + + if (opts.posix === true && value === '!' && prev.value === '[') { + value = '^'; + } + + prev.value += value; + append({ value }); + continue; + } + + /** + * If we're inside a quoted string, continue + * until we reach the closing double quote. + */ + + if (state.quotes === 1 && value !== '"') { + value = utils.escapeRegex(value); + prev.value += value; + append({ value }); + continue; + } + + /** + * Double quotes + */ + + if (value === '"') { + state.quotes = state.quotes === 1 ? 0 : 1; + if (opts.keepQuotes === true) { + push({ type: 'text', value }); + } + continue; + } + + /** + * Parentheses + */ + + if (value === '(') { + push({ type: 'paren', value }); + increment('parens'); + continue; + } + + if (value === ')') { + if (state.parens === 0 && opts.strictBrackets === true) { + throw new SyntaxError(syntaxError('opening', '(')); + } + + let extglob = extglobs[extglobs.length - 1]; + if (extglob && state.parens === extglob.parens + 1) { + extglobClose(extglobs.pop()); + continue; + } + + push({ type: 'paren', value, output: state.parens ? ')' : '\\)' }); + decrement('parens'); + continue; + } + + /** + * Brackets + */ + + if (value === '[') { + if (opts.nobracket === true || !input.slice(state.index + 1).includes(']')) { + if (opts.nobracket !== true && opts.strictBrackets === true) { + throw new SyntaxError(syntaxError('closing', ']')); + } + + value = '\\' + value; + } else { + increment('brackets'); + } + + push({ type: 'bracket', value }); + continue; + } + + if (value === ']') { + if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) { + push({ type: 'text', value, output: '\\' + value }); + continue; + } + + if (state.brackets === 0) { + if (opts.strictBrackets === true) { + throw new SyntaxError(syntaxError('opening', '[')); + } + + push({ type: 'text', value, output: '\\' + value }); + continue; + } + + decrement('brackets'); + + let prevValue = prev.value.slice(1); + if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) { + value = '/' + value; + } + + prev.value += value; + append({ value }); + + // when literal brackets are explicitly disabled + // assume we should match with a regex character class + if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) { + continue; + } + + let escaped = utils.escapeRegex(prev.value); + state.output = state.output.slice(0, -prev.value.length); + + // when literal brackets are explicitly enabled + // assume we should escape the brackets to match literal characters + if (opts.literalBrackets === true) { + state.output += escaped; + prev.value = escaped; + continue; + } + + // when the user specifies nothing, try to match both + prev.value = `(${capture}${escaped}|${prev.value})`; + state.output += prev.value; + continue; + } + + /** + * Braces + */ + + if (value === '{' && opts.nobrace !== true) { + push({ type: 'brace', value, output: '(' }); + increment('braces'); + continue; + } + + if (value === '}') { + if (opts.nobrace === true || state.braces === 0) { + push({ type: 'text', value, output: '\\' + value }); + continue; + } + + let output = ')'; + + if (state.dots === true) { + let arr = tokens.slice(); + let range = []; + + for (let i = arr.length - 1; i >= 0; i--) { + tokens.pop(); + if (arr[i].type === 'brace') { + break; + } + if (arr[i].type !== 'dots') { + range.unshift(arr[i].value); + } + } + + output = expandRange(range, opts); + state.backtrack = true; + } + + push({ type: 'brace', value, output }); + decrement('braces'); + continue; + } + + /** + * Pipes + */ + + if (value === '|') { + if (extglobs.length > 0) { + extglobs[extglobs.length - 1].conditions++; + } + push({ type: 'text', value }); + continue; + } + + /** + * Commas + */ + + if (value === ',') { + let output = value; + + if (state.braces > 0 && stack[stack.length - 1] === 'braces') { + output = '|'; + } + + push({ type: 'comma', value, output }); + continue; + } + + /** + * Slashes + */ + + if (value === '/') { + // if the beginning of the glob is "./", advance the start + // to the current index, and don't add the "./" characters + // to the state. This greatly simplifies lookbehinds when + // checking for BOS characters like "!" and "." (not "./") + if (prev.type === 'dot' && state.index === 1) { + state.start = state.index + 1; + state.consumed = ''; + state.output = ''; + tokens.pop(); + prev = bos; // reset "prev" to the first token + continue; + } + + push({ type: 'slash', value, output: SLASH_LITERAL }); + continue; + } + + /** + * Dots + */ + + if (value === '.') { + if (state.braces > 0 && prev.type === 'dot') { + if (prev.value === '.') prev.output = DOT_LITERAL; + prev.type = 'dots'; + prev.output += value; + prev.value += value; + state.dots = true; + continue; + } + + push({ type: 'dot', value, output: DOT_LITERAL }); + continue; + } + + /** + * Question marks + */ + + if (value === '?') { + if (prev && prev.type === 'paren') { + let next = peek(); + let output = value; + + if (next === '<' && !utils.supportsLookbehinds()) { + throw new Error('Node.js v10 or higher is required for regex lookbehinds'); + } + + if (prev.value === '(' && !/[!=<:]/.test(next) || (next === '<' && !/[!=]/.test(peek(2)))) { + output = '\\' + value; + } + + push({ type: 'text', value, output }); + continue; + } + + if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { + extglobOpen('qmark', value); + continue; + } + + if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) { + push({ type: 'qmark', value, output: QMARK_NO_DOT }); + continue; + } + + push({ type: 'qmark', value, output: QMARK }); + continue; + } + + /** + * Exclamation + */ + + if (value === '!') { + if (opts.noextglob !== true && peek() === '(') { + if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) { + extglobOpen('negate', value); + continue; + } + } + + if (opts.nonegate !== true && state.index === 0) { + negate(state); + continue; + } + } + + /** + * Plus + */ + + if (value === '+') { + if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { + extglobOpen('plus', value); + continue; + } + + if (prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) { + let output = prev.extglob === true ? '\\' + value : value; + push({ type: 'plus', value, output }); + continue; + } + + // use regex behavior inside parens + if (state.parens > 0 && opts.regex !== false) { + push({ type: 'plus', value }); + continue; + } + + push({ type: 'plus', value: PLUS_LITERAL }); + continue; + } + + /** + * Plain text + */ + + if (value === '@') { + if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { + push({ type: 'at', value, output: '' }); + continue; + } + + push({ type: 'text', value }); + continue; + } + + /** + * Plain text + */ + + if (value !== '*') { + if (value === '$' || value === '^') { + value = '\\' + value; + } + + let match = REGEX_NON_SPECIAL_CHAR.exec(input.slice(state.index + 1)); + if (match) { + value += match[0]; + state.index += match[0].length; + } + + push({ type: 'text', value }); + continue; + } + + /** + * Stars + */ + + if (prev && (prev.type === 'globstar' || prev.star === true)) { + prev.type = 'star'; + prev.star = true; + prev.value += value; + prev.output = star; + state.backtrack = true; + state.consumed += value; + continue; + } + + if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { + extglobOpen('star', value); + continue; + } + + if (prev.type === 'star') { + if (opts.noglobstar === true) { + state.consumed += value; + continue; + } + + let prior = prev.prev; + let before = prior.prev; + let isStart = prior.type === 'slash' || prior.type === 'bos'; + let afterStar = before && (before.type === 'star' || before.type === 'globstar'); + + if (opts.bash === true && (!isStart || (!eos() && peek() !== '/'))) { + push({ type: 'star', value, output: '' }); + continue; + } + + let isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace'); + let isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren'); + if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) { + push({ type: 'star', value, output: '' }); + continue; + } + + // strip consecutive `/**/` + while (input.slice(state.index + 1, state.index + 4) === '/**') { + let after = input[state.index + 4]; + if (after && after !== '/') { + break; + } + state.consumed += '/**'; + state.index += 3; + } + + if (prior.type === 'bos' && eos()) { + prev.type = 'globstar'; + prev.value += value; + prev.output = globstar(opts); + state.output = prev.output; + state.consumed += value; + continue; + } + + if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) { + state.output = state.output.slice(0, -(prior.output + prev.output).length); + prior.output = '(?:' + prior.output; + + prev.type = 'globstar'; + prev.output = globstar(opts) + '|$)'; + prev.value += value; + + state.output += prior.output + prev.output; + state.consumed += value; + continue; + } + + let next = peek(); + if (prior.type === 'slash' && prior.prev.type !== 'bos' && next === '/') { + let end = peek(2) !== void 0 ? '|$' : ''; + + state.output = state.output.slice(0, -(prior.output + prev.output).length); + prior.output = '(?:' + prior.output; + + prev.type = 'globstar'; + prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`; + prev.value += value; + + state.output += prior.output + prev.output; + state.consumed += value + advance(); + + push({ type: 'slash', value, output: '' }); + continue; + } + + if (prior.type === 'bos' && next === '/') { + prev.type = 'globstar'; + prev.value += value; + prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`; + state.output = prev.output; + state.consumed += value + advance(); + push({ type: 'slash', value, output: '' }); + continue; + } + + // remove single star from output + state.output = state.output.slice(0, -prev.output.length); + + // reset previous token to globstar + prev.type = 'globstar'; + prev.output = globstar(opts); + prev.value += value; + + // reset output with globstar + state.output += prev.output; + state.consumed += value; + continue; + } + + let token = { type: 'star', value, output: star }; + + if (opts.bash === true) { + token.output = '.*?'; + if (prev.type === 'bos' || prev.type === 'slash') { + token.output = nodot + token.output; + } + push(token); + continue; + } + + if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) { + token.output = value; + push(token); + continue; + } + + if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') { + if (prev.type === 'dot') { + state.output += NO_DOT_SLASH; + prev.output += NO_DOT_SLASH; + + } else if (opts.dot === true) { + state.output += NO_DOTS_SLASH; + prev.output += NO_DOTS_SLASH; + + } else { + state.output += nodot; + prev.output += nodot; + } + + if (peek() !== '*') { + state.output += ONE_CHAR; + prev.output += ONE_CHAR; + } + } + + push(token); + } + + while (state.brackets > 0) { + if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']')); + state.output = utils.escapeLast(state.output, '['); + decrement('brackets'); + } + + while (state.parens > 0) { + if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')')); + state.output = utils.escapeLast(state.output, '('); + decrement('parens'); + } + + while (state.braces > 0) { + if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}')); + state.output = utils.escapeLast(state.output, '{'); + decrement('braces'); + } + + if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) { + push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` }); + } + + // rebuild the output if we had to backtrack at any point + if (state.backtrack === true) { + state.output = ''; + + for (let token of state.tokens) { + state.output += token.output != null ? token.output : token.value; + + if (token.suffix) { + state.output += token.suffix; + } + } + } + + return state; +}; + +/** + * Fast paths for creating regular expressions for common glob patterns. + * This can significantly speed up processing and has very little downside + * impact when none of the fast paths match. + */ + +parse.fastpaths = (input, options) => { + let opts = { ...options }; + let max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH; + let len = input.length; + if (len > max) { + throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`); + } + + input = REPLACEMENTS[input] || input; + let win32 = utils.isWindows(options); + + // create constants based on platform, for windows or posix + const { + DOT_LITERAL, + SLASH_LITERAL, + ONE_CHAR, + DOTS_SLASH, + NO_DOT, + NO_DOTS, + NO_DOTS_SLASH, + STAR, + START_ANCHOR + } = constants.globChars(win32); + + let capture = opts.capture ? '' : '?:'; + let star = opts.bash === true ? '.*?' : STAR; + let nodot = opts.dot ? NO_DOTS : NO_DOT; + let slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT; + + if (opts.capture) { + star = `(${star})`; + } + + const globstar = (opts) => { + return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`; + }; + + const create = str => { + switch (str) { + case '*': + return `${nodot}${ONE_CHAR}${star}`; + + case '.*': + return `${DOT_LITERAL}${ONE_CHAR}${star}`; + + case '*.*': + return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`; + + case '*/*': + return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`; + + case '**': + return nodot + globstar(opts); + + case '**/*': + return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`; + + case '**/*.*': + return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`; + + case '**/.*': + return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`; + + default: { + let match = /^(.*?)\.(\w+)$/.exec(str); + if (!match) return; + + let source = create(match[1], options); + if (!source) return; + + return source + DOT_LITERAL + match[2]; + } + } + }; + + let output = create(input); + if (output && opts.strictSlashes !== true) { + output += `${SLASH_LITERAL}?`; + } + + return output; +}; + +module.exports = parse; + + +/***/ }), +/* 625 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const merge2 = __webpack_require__(591); +function merge(streams) { + const mergedStream = merge2(streams); + streams.forEach((stream) => { + stream.once('error', (err) => mergedStream.emit('error', err)); + }); + return mergedStream; +} +exports.merge = merge; + + +/***/ }), +/* 626 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const stream_1 = __webpack_require__(627); +const provider_1 = __webpack_require__(654); +class ProviderAsync extends provider_1.default { + constructor() { + super(...arguments); + this._reader = new stream_1.default(this._settings); + } + read(task) { + const root = this._getRootDirectory(task); + const options = this._getReaderOptions(task); + const entries = []; + return new Promise((resolve, reject) => { + const stream = this.api(root, task, options); + stream.once('error', reject); + stream.on('data', (entry) => entries.push(options.transform(entry))); + stream.once('end', () => resolve(entries)); + }); + } + api(root, task, options) { + if (task.dynamic) { + return this._reader.dynamic(root, options); + } + return this._reader.static(task.patterns, options); + } +} +exports.default = ProviderAsync; + + +/***/ }), +/* 627 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const stream_1 = __webpack_require__(27); +const fsStat = __webpack_require__(628); +const fsWalk = __webpack_require__(633); +const reader_1 = __webpack_require__(653); +class ReaderStream extends reader_1.default { + constructor() { + super(...arguments); + this._walkStream = fsWalk.walkStream; + this._stat = fsStat.stat; + } + dynamic(root, options) { + return this._walkStream(root, options); + } + static(patterns, options) { + const filepaths = patterns.map(this._getFullEntryPath, this); + const stream = new stream_1.PassThrough({ objectMode: true }); + stream._write = (index, _enc, done) => { + return this._getEntry(filepaths[index], patterns[index], options) + .then((entry) => { + if (entry !== null && options.entryFilter(entry)) { + stream.push(entry); + } + if (index === filepaths.length - 1) { + stream.end(); + } + done(); + }) + .catch(done); + }; + for (let i = 0; i < filepaths.length; i++) { + stream.write(i); + } + return stream; + } + _getEntry(filepath, pattern, options) { + return this._getStat(filepath) + .then((stats) => this._makeEntry(stats, pattern)) + .catch((error) => { + if (options.errorFilter(error)) { + return null; + } + throw error; + }); + } + _getStat(filepath) { + return new Promise((resolve, reject) => { + this._stat(filepath, this._fsStatSettings, (error, stats) => { + error ? reject(error) : resolve(stats); + }); + }); + } +} +exports.default = ReaderStream; + + +/***/ }), +/* 628 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const async = __webpack_require__(629); +const sync = __webpack_require__(630); +const settings_1 = __webpack_require__(631); +exports.Settings = settings_1.default; +function stat(path, optionsOrSettingsOrCallback, callback) { + if (typeof optionsOrSettingsOrCallback === 'function') { + return async.read(path, getSettings(), optionsOrSettingsOrCallback); + } + async.read(path, getSettings(optionsOrSettingsOrCallback), callback); +} +exports.stat = stat; +function statSync(path, optionsOrSettings) { + const settings = getSettings(optionsOrSettings); + return sync.read(path, settings); +} +exports.statSync = statSync; +function getSettings(settingsOrOptions = {}) { + if (settingsOrOptions instanceof settings_1.default) { + return settingsOrOptions; + } + return new settings_1.default(settingsOrOptions); +} + + +/***/ }), +/* 629 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +function read(path, settings, callback) { + settings.fs.lstat(path, (lstatError, lstat) => { + if (lstatError) { + return callFailureCallback(callback, lstatError); + } + if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) { + return callSuccessCallback(callback, lstat); + } + settings.fs.stat(path, (statError, stat) => { + if (statError) { + if (settings.throwErrorOnBrokenSymbolicLink) { + return callFailureCallback(callback, statError); + } + return callSuccessCallback(callback, lstat); + } + if (settings.markSymbolicLink) { + stat.isSymbolicLink = () => true; + } + callSuccessCallback(callback, stat); + }); + }); +} +exports.read = read; +function callFailureCallback(callback, error) { + callback(error); +} +function callSuccessCallback(callback, result) { + callback(null, result); +} + + +/***/ }), +/* 630 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +function read(path, settings) { + const lstat = settings.fs.lstatSync(path); + if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) { + return lstat; + } + try { + const stat = settings.fs.statSync(path); + if (settings.markSymbolicLink) { + stat.isSymbolicLink = () => true; + } + return stat; + } + catch (error) { + if (!settings.throwErrorOnBrokenSymbolicLink) { + return lstat; + } + throw error; + } +} +exports.read = read; + + +/***/ }), +/* 631 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const fs = __webpack_require__(632); +class Settings { + constructor(_options = {}) { + this._options = _options; + this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true); + this.fs = fs.createFileSystemAdapter(this._options.fs); + this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false); + this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true); + } + _getValue(option, value) { + return option === undefined ? value : option; + } +} +exports.default = Settings; + + +/***/ }), +/* 632 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const fs = __webpack_require__(23); +exports.FILE_SYSTEM_ADAPTER = { + lstat: fs.lstat, + stat: fs.stat, + lstatSync: fs.lstatSync, + statSync: fs.statSync +}; +function createFileSystemAdapter(fsMethods) { + if (!fsMethods) { + return exports.FILE_SYSTEM_ADAPTER; + } + return Object.assign({}, exports.FILE_SYSTEM_ADAPTER, fsMethods); +} +exports.createFileSystemAdapter = createFileSystemAdapter; + + +/***/ }), +/* 633 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const async_1 = __webpack_require__(634); +const stream_1 = __webpack_require__(649); +const sync_1 = __webpack_require__(650); +const settings_1 = __webpack_require__(652); +exports.Settings = settings_1.default; +function walk(dir, optionsOrSettingsOrCallback, callback) { + if (typeof optionsOrSettingsOrCallback === 'function') { + return new async_1.default(dir, getSettings()).read(optionsOrSettingsOrCallback); + } + new async_1.default(dir, getSettings(optionsOrSettingsOrCallback)).read(callback); +} +exports.walk = walk; +function walkSync(dir, optionsOrSettings) { + const settings = getSettings(optionsOrSettings); + const provider = new sync_1.default(dir, settings); + return provider.read(); +} +exports.walkSync = walkSync; +function walkStream(dir, optionsOrSettings) { + const settings = getSettings(optionsOrSettings); + const provider = new stream_1.default(dir, settings); + return provider.read(); +} +exports.walkStream = walkStream; +function getSettings(settingsOrOptions = {}) { + if (settingsOrOptions instanceof settings_1.default) { + return settingsOrOptions; + } + return new settings_1.default(settingsOrOptions); +} + + +/***/ }), +/* 634 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const async_1 = __webpack_require__(635); +class AsyncProvider { + constructor(_root, _settings) { + this._root = _root; + this._settings = _settings; + this._reader = new async_1.default(this._root, this._settings); + this._storage = new Set(); + } + read(callback) { + this._reader.onError((error) => { + callFailureCallback(callback, error); + }); + this._reader.onEntry((entry) => { + this._storage.add(entry); + }); + this._reader.onEnd(() => { + callSuccessCallback(callback, Array.from(this._storage)); + }); + this._reader.read(); + } +} +exports.default = AsyncProvider; +function callFailureCallback(callback, error) { + callback(error); +} +function callSuccessCallback(callback, entries) { + callback(null, entries); +} + + +/***/ }), +/* 635 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const events_1 = __webpack_require__(379); +const fsScandir = __webpack_require__(636); +const fastq = __webpack_require__(645); +const common = __webpack_require__(647); +const reader_1 = __webpack_require__(648); +class AsyncReader extends reader_1.default { + constructor(_root, _settings) { + super(_root, _settings); + this._settings = _settings; + this._scandir = fsScandir.scandir; + this._emitter = new events_1.EventEmitter(); + this._queue = fastq(this._worker.bind(this), this._settings.concurrency); + this._isFatalError = false; + this._isDestroyed = false; + this._queue.drain = () => { + if (!this._isFatalError) { + this._emitter.emit('end'); + } + }; + } + read() { + this._isFatalError = false; + this._isDestroyed = false; + setImmediate(() => { + this._pushToQueue(this._root, this._settings.basePath); + }); + return this._emitter; + } + destroy() { + if (this._isDestroyed) { + throw new Error('The reader is already destroyed'); + } + this._isDestroyed = true; + this._queue.killAndDrain(); + } + onEntry(callback) { + this._emitter.on('entry', callback); + } + onError(callback) { + this._emitter.once('error', callback); + } + onEnd(callback) { + this._emitter.once('end', callback); + } + _pushToQueue(dir, base) { + const queueItem = { dir, base }; + this._queue.push(queueItem, (error) => { + if (error) { + this._handleError(error); + } + }); + } + _worker(item, done) { + this._scandir(item.dir, this._settings.fsScandirSettings, (error, entries) => { + if (error) { + return done(error, undefined); + } + for (const entry of entries) { + this._handleEntry(entry, item.base); + } + done(null, undefined); + }); + } + _handleError(error) { + if (!common.isFatalError(this._settings, error)) { + return; + } + this._isFatalError = true; + this._isDestroyed = true; + this._emitter.emit('error', error); + } + _handleEntry(entry, base) { + if (this._isDestroyed || this._isFatalError) { + return; + } + const fullpath = entry.path; + if (base !== undefined) { + entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator); + } + if (common.isAppliedFilter(this._settings.entryFilter, entry)) { + this._emitEntry(entry); + } + if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) { + this._pushToQueue(fullpath, entry.path); + } + } + _emitEntry(entry) { + this._emitter.emit('entry', entry); + } +} +exports.default = AsyncReader; + + +/***/ }), +/* 636 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const async = __webpack_require__(637); +const sync = __webpack_require__(642); +const settings_1 = __webpack_require__(643); +exports.Settings = settings_1.default; +function scandir(path, optionsOrSettingsOrCallback, callback) { + if (typeof optionsOrSettingsOrCallback === 'function') { + return async.read(path, getSettings(), optionsOrSettingsOrCallback); + } + async.read(path, getSettings(optionsOrSettingsOrCallback), callback); +} +exports.scandir = scandir; +function scandirSync(path, optionsOrSettings) { + const settings = getSettings(optionsOrSettings); + return sync.read(path, settings); +} +exports.scandirSync = scandirSync; +function getSettings(settingsOrOptions = {}) { + if (settingsOrOptions instanceof settings_1.default) { + return settingsOrOptions; + } + return new settings_1.default(settingsOrOptions); +} + + +/***/ }), +/* 637 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const fsStat = __webpack_require__(628); +const rpl = __webpack_require__(638); +const constants_1 = __webpack_require__(639); +const utils = __webpack_require__(640); +function read(dir, settings, callback) { + if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) { + return readdirWithFileTypes(dir, settings, callback); + } + return readdir(dir, settings, callback); +} +exports.read = read; +function readdirWithFileTypes(dir, settings, callback) { + settings.fs.readdir(dir, { withFileTypes: true }, (readdirError, dirents) => { + if (readdirError) { + return callFailureCallback(callback, readdirError); + } + const entries = dirents.map((dirent) => ({ + dirent, + name: dirent.name, + path: `${dir}${settings.pathSegmentSeparator}${dirent.name}` + })); + if (!settings.followSymbolicLinks) { + return callSuccessCallback(callback, entries); + } + const tasks = entries.map((entry) => makeRplTaskEntry(entry, settings)); + rpl(tasks, (rplError, rplEntries) => { + if (rplError) { + return callFailureCallback(callback, rplError); + } + callSuccessCallback(callback, rplEntries); + }); + }); +} +exports.readdirWithFileTypes = readdirWithFileTypes; +function makeRplTaskEntry(entry, settings) { + return (done) => { + if (!entry.dirent.isSymbolicLink()) { + return done(null, entry); + } + settings.fs.stat(entry.path, (statError, stats) => { + if (statError) { + if (settings.throwErrorOnBrokenSymbolicLink) { + return done(statError); + } + return done(null, entry); + } + entry.dirent = utils.fs.createDirentFromStats(entry.name, stats); + return done(null, entry); + }); + }; +} +function readdir(dir, settings, callback) { + settings.fs.readdir(dir, (readdirError, names) => { + if (readdirError) { + return callFailureCallback(callback, readdirError); + } + const filepaths = names.map((name) => `${dir}${settings.pathSegmentSeparator}${name}`); + const tasks = filepaths.map((filepath) => { + return (done) => fsStat.stat(filepath, settings.fsStatSettings, done); + }); + rpl(tasks, (rplError, results) => { + if (rplError) { + return callFailureCallback(callback, rplError); + } + const entries = []; + for (let index = 0; index < names.length; index++) { + const name = names[index]; + const stats = results[index]; + const entry = { + name, + path: filepaths[index], + dirent: utils.fs.createDirentFromStats(name, stats) + }; + if (settings.stats) { + entry.stats = stats; + } + entries.push(entry); + } + callSuccessCallback(callback, entries); + }); + }); +} +exports.readdir = readdir; +function callFailureCallback(callback, error) { + callback(error); +} +function callSuccessCallback(callback, result) { + callback(null, result); +} + + +/***/ }), +/* 638 */ +/***/ (function(module, exports) { + +module.exports = runParallel + +function runParallel (tasks, cb) { + var results, pending, keys + var isSync = true + + if (Array.isArray(tasks)) { + results = [] + pending = tasks.length + } else { + keys = Object.keys(tasks) + results = {} + pending = keys.length + } + + function done (err) { + function end () { + if (cb) cb(err, results) + cb = null + } + if (isSync) process.nextTick(end) + else end() + } + + function each (i, err, result) { + results[i] = result + if (--pending === 0 || err) { + done(err) + } + } + + if (!pending) { + // empty + done(null) + } else if (keys) { + // object + keys.forEach(function (key) { + tasks[key](function (err, result) { each(key, err, result) }) + }) + } else { + // array + tasks.forEach(function (task, i) { + task(function (err, result) { each(i, err, result) }) + }) + } + + isSync = false +} + + +/***/ }), +/* 639 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const NODE_PROCESS_VERSION_PARTS = process.versions.node.split('.'); +const MAJOR_VERSION = parseInt(NODE_PROCESS_VERSION_PARTS[0], 10); +const MINOR_VERSION = parseInt(NODE_PROCESS_VERSION_PARTS[1], 10); +/** + * IS `true` for Node.js 10.10 and greater. + */ +exports.IS_SUPPORT_READDIR_WITH_FILE_TYPES = MAJOR_VERSION > 10 || (MAJOR_VERSION === 10 && MINOR_VERSION >= 10); + + +/***/ }), +/* 640 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const fs = __webpack_require__(641); +exports.fs = fs; + + +/***/ }), +/* 641 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +class DirentFromStats { + constructor(name, stats) { + this.name = name; + this.isBlockDevice = stats.isBlockDevice.bind(stats); + this.isCharacterDevice = stats.isCharacterDevice.bind(stats); + this.isDirectory = stats.isDirectory.bind(stats); + this.isFIFO = stats.isFIFO.bind(stats); + this.isFile = stats.isFile.bind(stats); + this.isSocket = stats.isSocket.bind(stats); + this.isSymbolicLink = stats.isSymbolicLink.bind(stats); + } +} +function createDirentFromStats(name, stats) { + return new DirentFromStats(name, stats); +} +exports.createDirentFromStats = createDirentFromStats; + + +/***/ }), +/* 642 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const fsStat = __webpack_require__(628); +const constants_1 = __webpack_require__(639); +const utils = __webpack_require__(640); +function read(dir, settings) { + if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) { + return readdirWithFileTypes(dir, settings); + } + return readdir(dir, settings); +} +exports.read = read; +function readdirWithFileTypes(dir, settings) { + const dirents = settings.fs.readdirSync(dir, { withFileTypes: true }); + return dirents.map((dirent) => { + const entry = { + dirent, + name: dirent.name, + path: `${dir}${settings.pathSegmentSeparator}${dirent.name}` + }; + if (entry.dirent.isSymbolicLink() && settings.followSymbolicLinks) { + try { + const stats = settings.fs.statSync(entry.path); + entry.dirent = utils.fs.createDirentFromStats(entry.name, stats); + } + catch (error) { + if (settings.throwErrorOnBrokenSymbolicLink) { + throw error; + } + } + } + return entry; + }); +} +exports.readdirWithFileTypes = readdirWithFileTypes; +function readdir(dir, settings) { + const names = settings.fs.readdirSync(dir); + return names.map((name) => { + const entryPath = `${dir}${settings.pathSegmentSeparator}${name}`; + const stats = fsStat.statSync(entryPath, settings.fsStatSettings); + const entry = { + name, + path: entryPath, + dirent: utils.fs.createDirentFromStats(name, stats) + }; + if (settings.stats) { + entry.stats = stats; + } + return entry; + }); +} +exports.readdir = readdir; + + +/***/ }), +/* 643 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const path = __webpack_require__(16); +const fsStat = __webpack_require__(628); +const fs = __webpack_require__(644); +class Settings { + constructor(_options = {}) { + this._options = _options; + this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false); + this.fs = fs.createFileSystemAdapter(this._options.fs); + this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path.sep); + this.stats = this._getValue(this._options.stats, false); + this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true); + this.fsStatSettings = new fsStat.Settings({ + followSymbolicLink: this.followSymbolicLinks, + fs: this.fs, + throwErrorOnBrokenSymbolicLink: this.throwErrorOnBrokenSymbolicLink + }); + } + _getValue(option, value) { + return option === undefined ? value : option; + } +} +exports.default = Settings; + + +/***/ }), +/* 644 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const fs = __webpack_require__(23); +exports.FILE_SYSTEM_ADAPTER = { + lstat: fs.lstat, + stat: fs.stat, + lstatSync: fs.lstatSync, + statSync: fs.statSync, + readdir: fs.readdir, + readdirSync: fs.readdirSync +}; +function createFileSystemAdapter(fsMethods) { + if (!fsMethods) { + return exports.FILE_SYSTEM_ADAPTER; + } + return Object.assign({}, exports.FILE_SYSTEM_ADAPTER, fsMethods); +} +exports.createFileSystemAdapter = createFileSystemAdapter; + + +/***/ }), +/* 645 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var reusify = __webpack_require__(646) + +function fastqueue (context, worker, concurrency) { + if (typeof context === 'function') { + concurrency = worker + worker = context + context = null + } + + var cache = reusify(Task) + var queueHead = null + var queueTail = null + var _running = 0 + + var self = { + push: push, + drain: noop, + saturated: noop, + pause: pause, + paused: false, + concurrency: concurrency, + running: running, + resume: resume, + idle: idle, + length: length, + unshift: unshift, + empty: noop, + kill: kill, + killAndDrain: killAndDrain + } + + return self + + function running () { + return _running + } + + function pause () { + self.paused = true + } + + function length () { + var current = queueHead + var counter = 0 + + while (current) { + current = current.next + counter++ + } + + return counter + } + + function resume () { + if (!self.paused) return + self.paused = false + for (var i = 0; i < self.concurrency; i++) { + _running++ + release() + } + } + + function idle () { + return _running === 0 && self.length() === 0 + } + + function push (value, done) { + var current = cache.get() + + current.context = context + current.release = release + current.value = value + current.callback = done || noop + + if (_running === self.concurrency || self.paused) { + if (queueTail) { + queueTail.next = current + queueTail = current + } else { + queueHead = current + queueTail = current + self.saturated() + } + } else { + _running++ + worker.call(context, current.value, current.worked) + } + } + + function unshift (value, done) { + var current = cache.get() + + current.context = context + current.release = release + current.value = value + current.callback = done || noop + + if (_running === self.concurrency || self.paused) { + if (queueHead) { + current.next = queueHead + queueHead = current + } else { + queueHead = current + queueTail = current + self.saturated() + } + } else { + _running++ + worker.call(context, current.value, current.worked) + } + } + + function release (holder) { + if (holder) { + cache.release(holder) + } + var next = queueHead + if (next) { + if (!self.paused) { + if (queueTail === queueHead) { + queueTail = null + } + queueHead = next.next + next.next = null + worker.call(context, next.value, next.worked) + if (queueTail === null) { + self.empty() + } + } else { + _running-- + } + } else if (--_running === 0) { + self.drain() + } + } + + function kill () { + queueHead = null + queueTail = null + self.drain = noop + } + + function killAndDrain () { + queueHead = null + queueTail = null + self.drain() + self.drain = noop + } +} + +function noop () {} + +function Task () { + this.value = null + this.callback = noop + this.next = null + this.release = noop + this.context = null + + var self = this + + this.worked = function worked (err, result) { + var callback = self.callback + self.value = null + self.callback = noop + callback.call(self.context, err, result) + self.release(self) + } +} + +module.exports = fastqueue + + +/***/ }), +/* 646 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function reusify (Constructor) { + var head = new Constructor() + var tail = head + + function get () { + var current = head + + if (current.next) { + head = current.next + } else { + head = new Constructor() + tail = head + } + + current.next = null + + return current + } + + function release (obj) { + tail.next = obj + tail = obj + } + + return { + get: get, + release: release + } +} + +module.exports = reusify + + +/***/ }), +/* 647 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +function isFatalError(settings, error) { + if (settings.errorFilter === null) { + return true; + } + return !settings.errorFilter(error); +} +exports.isFatalError = isFatalError; +function isAppliedFilter(filter, value) { + return filter === null || filter(value); +} +exports.isAppliedFilter = isAppliedFilter; +function replacePathSegmentSeparator(filepath, separator) { + return filepath.split(/[\\\/]/).join(separator); +} +exports.replacePathSegmentSeparator = replacePathSegmentSeparator; +function joinPathSegments(a, b, separator) { + if (a === '') { + return b; + } + return a + separator + b; +} +exports.joinPathSegments = joinPathSegments; + + +/***/ }), +/* 648 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const common = __webpack_require__(647); +class Reader { + constructor(_root, _settings) { + this._root = _root; + this._settings = _settings; + this._root = common.replacePathSegmentSeparator(_root, _settings.pathSegmentSeparator); + } +} +exports.default = Reader; + + +/***/ }), +/* 649 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const stream_1 = __webpack_require__(27); +const async_1 = __webpack_require__(635); +class StreamProvider { + constructor(_root, _settings) { + this._root = _root; + this._settings = _settings; + this._reader = new async_1.default(this._root, this._settings); + this._stream = new stream_1.Readable({ + objectMode: true, + read: () => { }, + destroy: this._reader.destroy.bind(this._reader) + }); + } + read() { + this._reader.onError((error) => { + this._stream.emit('error', error); + }); + this._reader.onEntry((entry) => { + this._stream.push(entry); + }); + this._reader.onEnd(() => { + this._stream.push(null); + }); + this._reader.read(); + return this._stream; + } +} +exports.default = StreamProvider; + + +/***/ }), +/* 650 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const sync_1 = __webpack_require__(651); +class SyncProvider { + constructor(_root, _settings) { + this._root = _root; + this._settings = _settings; + this._reader = new sync_1.default(this._root, this._settings); + } + read() { + return this._reader.read(); + } +} +exports.default = SyncProvider; + + +/***/ }), +/* 651 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const fsScandir = __webpack_require__(636); +const common = __webpack_require__(647); +const reader_1 = __webpack_require__(648); +class SyncReader extends reader_1.default { + constructor() { + super(...arguments); + this._scandir = fsScandir.scandirSync; + this._storage = new Set(); + this._queue = new Set(); + } + read() { + this._pushToQueue(this._root, this._settings.basePath); + this._handleQueue(); + return Array.from(this._storage); + } + _pushToQueue(dir, base) { + this._queue.add({ dir, base }); + } + _handleQueue() { + for (const item of this._queue.values()) { + this._handleDirectory(item.dir, item.base); + } + } + _handleDirectory(dir, base) { + try { + const entries = this._scandir(dir, this._settings.fsScandirSettings); + for (const entry of entries) { + this._handleEntry(entry, base); + } + } + catch (error) { + this._handleError(error); + } + } + _handleError(error) { + if (!common.isFatalError(this._settings, error)) { + return; + } + throw error; + } + _handleEntry(entry, base) { + const fullpath = entry.path; + if (base !== undefined) { + entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator); + } + if (common.isAppliedFilter(this._settings.entryFilter, entry)) { + this._pushToStorage(entry); + } + if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) { + this._pushToQueue(fullpath, entry.path); + } + } + _pushToStorage(entry) { + this._storage.add(entry); + } +} +exports.default = SyncReader; + + +/***/ }), +/* 652 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const path = __webpack_require__(16); +const fsScandir = __webpack_require__(636); +class Settings { + constructor(_options = {}) { + this._options = _options; + this.basePath = this._getValue(this._options.basePath, undefined); + this.concurrency = this._getValue(this._options.concurrency, Infinity); + this.deepFilter = this._getValue(this._options.deepFilter, null); + this.entryFilter = this._getValue(this._options.entryFilter, null); + this.errorFilter = this._getValue(this._options.errorFilter, null); + this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path.sep); + this.fsScandirSettings = new fsScandir.Settings({ + followSymbolicLinks: this._options.followSymbolicLinks, + fs: this._options.fs, + pathSegmentSeparator: this._options.pathSegmentSeparator, + stats: this._options.stats, + throwErrorOnBrokenSymbolicLink: this._options.throwErrorOnBrokenSymbolicLink + }); + } + _getValue(option, value) { + return option === undefined ? value : option; + } +} +exports.default = Settings; + + +/***/ }), +/* 653 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const path = __webpack_require__(16); +const fsStat = __webpack_require__(628); +const utils = __webpack_require__(599); +class Reader { + constructor(_settings) { + this._settings = _settings; + this._fsStatSettings = new fsStat.Settings({ + followSymbolicLink: this._settings.followSymbolicLinks, + fs: this._settings.fs, + throwErrorOnBrokenSymbolicLink: this._settings.followSymbolicLinks + }); + } + _getFullEntryPath(filepath) { + return path.resolve(this._settings.cwd, filepath); + } + _makeEntry(stats, pattern) { + const entry = { + name: pattern, + path: pattern, + dirent: utils.fs.createDirentFromStats(pattern, stats) + }; + if (this._settings.stats) { + entry.stats = stats; + } + return entry; + } + _isFatalError(error) { + return !utils.errno.isEnoentCodeError(error) && !this._settings.suppressErrors; + } +} +exports.default = Reader; /***/ }), -/* 653 */ +/* 654 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const path = __webpack_require__(16); +const deep_1 = __webpack_require__(655); +const entry_1 = __webpack_require__(656); +const error_1 = __webpack_require__(657); +const entry_2 = __webpack_require__(658); +class Provider { + constructor(_settings) { + this._settings = _settings; + this.errorFilter = new error_1.default(this._settings); + this.entryFilter = new entry_1.default(this._settings, this._getMicromatchOptions()); + this.deepFilter = new deep_1.default(this._settings, this._getMicromatchOptions()); + this.entryTransformer = new entry_2.default(this._settings); + } + _getRootDirectory(task) { + return path.resolve(this._settings.cwd, task.base); + } + _getReaderOptions(task) { + const basePath = task.base === '.' ? '' : task.base; + return { + basePath, + pathSegmentSeparator: '/', + concurrency: this._settings.concurrency, + deepFilter: this.deepFilter.getFilter(basePath, task.positive, task.negative), + entryFilter: this.entryFilter.getFilter(task.positive, task.negative), + errorFilter: this.errorFilter.getFilter(), + followSymbolicLinks: this._settings.followSymbolicLinks, + fs: this._settings.fs, + stats: this._settings.stats, + throwErrorOnBrokenSymbolicLink: this._settings.throwErrorOnBrokenSymbolicLink, + transform: this.entryTransformer.getTransformer() + }; + } + _getMicromatchOptions() { + return { + dot: this._settings.dot, + matchBase: this._settings.baseNameMatch, + nobrace: !this._settings.braceExpansion, + nocase: !this._settings.caseSensitiveMatch, + noext: !this._settings.extglob, + noglobstar: !this._settings.globstar, + posix: true, + strictSlashes: false + }; + } +} +exports.default = Provider; + + +/***/ }), +/* 655 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const utils = __webpack_require__(599); +class DeepFilter { + constructor(_settings, _micromatchOptions) { + this._settings = _settings; + this._micromatchOptions = _micromatchOptions; + } + getFilter(basePath, positive, negative) { + const maxPatternDepth = this._getMaxPatternDepth(positive); + const negativeRe = this._getNegativePatternsRe(negative); + return (entry) => this._filter(basePath, entry, negativeRe, maxPatternDepth); + } + _getMaxPatternDepth(patterns) { + const globstar = patterns.some(utils.pattern.hasGlobStar); + return globstar ? Infinity : utils.pattern.getMaxNaivePatternsDepth(patterns); + } + _getNegativePatternsRe(patterns) { + const affectDepthOfReadingPatterns = patterns.filter(utils.pattern.isAffectDepthOfReadingPattern); + return utils.pattern.convertPatternsToRe(affectDepthOfReadingPatterns, this._micromatchOptions); + } + _filter(basePath, entry, negativeRe, maxPatternDepth) { + const depth = this._getEntryDepth(basePath, entry.path); + if (this._isSkippedByDeep(depth)) { + return false; + } + if (this._isSkippedByMaxPatternDepth(depth, maxPatternDepth)) { + return false; + } + if (this._isSkippedSymbolicLink(entry)) { + return false; + } + if (this._isSkippedDotDirectory(entry)) { + return false; + } + return this._isSkippedByNegativePatterns(entry, negativeRe); + } + _getEntryDepth(basePath, entryPath) { + const basePathDepth = basePath.split('/').length; + const entryPathDepth = entryPath.split('/').length; + return entryPathDepth - (basePath === '' ? 0 : basePathDepth); + } + _isSkippedByDeep(entryDepth) { + return entryDepth >= this._settings.deep; + } + _isSkippedByMaxPatternDepth(entryDepth, maxPatternDepth) { + return !this._settings.baseNameMatch && maxPatternDepth !== Infinity && entryDepth > maxPatternDepth; + } + _isSkippedSymbolicLink(entry) { + return !this._settings.followSymbolicLinks && entry.dirent.isSymbolicLink(); + } + _isSkippedDotDirectory(entry) { + return !this._settings.dot && entry.name.startsWith('.'); + } + _isSkippedByNegativePatterns(entry, negativeRe) { + return !utils.pattern.matchAny(entry.path, negativeRe); + } +} +exports.default = DeepFilter; + + +/***/ }), +/* 656 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const utils = __webpack_require__(599); +class EntryFilter { + constructor(_settings, _micromatchOptions) { + this._settings = _settings; + this._micromatchOptions = _micromatchOptions; + this.index = new Map(); + } + getFilter(positive, negative) { + const positiveRe = utils.pattern.convertPatternsToRe(positive, this._micromatchOptions); + const negativeRe = utils.pattern.convertPatternsToRe(negative, this._micromatchOptions); + return (entry) => this._filter(entry, positiveRe, negativeRe); + } + _filter(entry, positiveRe, negativeRe) { + if (this._settings.unique) { + if (this._isDuplicateEntry(entry)) { + return false; + } + this._createIndexRecord(entry); + } + if (this._onlyFileFilter(entry) || this._onlyDirectoryFilter(entry)) { + return false; + } + if (this._isSkippedByAbsoluteNegativePatterns(entry, negativeRe)) { + return false; + } + const filepath = this._settings.baseNameMatch ? entry.name : entry.path; + return this._isMatchToPatterns(filepath, positiveRe) && !this._isMatchToPatterns(entry.path, negativeRe); + } + _isDuplicateEntry(entry) { + return this.index.has(entry.path); + } + _createIndexRecord(entry) { + this.index.set(entry.path, undefined); + } + _onlyFileFilter(entry) { + return this._settings.onlyFiles && !entry.dirent.isFile(); + } + _onlyDirectoryFilter(entry) { + return this._settings.onlyDirectories && !entry.dirent.isDirectory(); + } + _isSkippedByAbsoluteNegativePatterns(entry, negativeRe) { + if (!this._settings.absolute) { + return false; + } + const fullpath = utils.path.makeAbsolute(this._settings.cwd, entry.path); + return this._isMatchToPatterns(fullpath, negativeRe); + } + _isMatchToPatterns(filepath, patternsRe) { + return utils.pattern.matchAny(filepath, patternsRe); + } +} +exports.default = EntryFilter; + + +/***/ }), +/* 657 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const utils = __webpack_require__(599); +class ErrorFilter { + constructor(_settings) { + this._settings = _settings; + } + getFilter() { + return (error) => this._isNonFatalError(error); + } + _isNonFatalError(error) { + return utils.errno.isEnoentCodeError(error) || this._settings.suppressErrors; + } +} +exports.default = ErrorFilter; + + +/***/ }), +/* 658 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const utils = __webpack_require__(594); +const utils = __webpack_require__(599); class EntryTransformer { constructor(_settings) { this._settings = _settings; @@ -75236,2515 +76824,3068 @@ exports.default = EntryTransformer; /***/ }), -/* 654 */ +/* 659 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const stream_1 = __webpack_require__(27); +const stream_2 = __webpack_require__(627); +const provider_1 = __webpack_require__(654); +class ProviderStream extends provider_1.default { + constructor() { + super(...arguments); + this._reader = new stream_2.default(this._settings); + } + read(task) { + const root = this._getRootDirectory(task); + const options = this._getReaderOptions(task); + const source = this.api(root, task, options); + const dest = new stream_1.Readable({ objectMode: true, read: () => { } }); + source + .once('error', (error) => dest.emit('error', error)) + .on('data', (entry) => dest.emit('data', options.transform(entry))) + .once('end', () => dest.emit('end')); + return dest; + } + api(root, task, options) { + if (task.dynamic) { + return this._reader.dynamic(root, options); + } + return this._reader.static(task.patterns, options); + } +} +exports.default = ProviderStream; + + +/***/ }), +/* 660 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const sync_1 = __webpack_require__(661); +const provider_1 = __webpack_require__(654); +class ProviderSync extends provider_1.default { + constructor() { + super(...arguments); + this._reader = new sync_1.default(this._settings); + } + read(task) { + const root = this._getRootDirectory(task); + const options = this._getReaderOptions(task); + const entries = this.api(root, task, options); + return entries.map(options.transform); + } + api(root, task, options) { + if (task.dynamic) { + return this._reader.dynamic(root, options); + } + return this._reader.static(task.patterns, options); + } +} +exports.default = ProviderSync; + + +/***/ }), +/* 661 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const fsStat = __webpack_require__(628); +const fsWalk = __webpack_require__(633); +const reader_1 = __webpack_require__(653); +class ReaderSync extends reader_1.default { + constructor() { + super(...arguments); + this._walkSync = fsWalk.walkSync; + this._statSync = fsStat.statSync; + } + dynamic(root, options) { + return this._walkSync(root, options); + } + static(patterns, options) { + const entries = []; + for (const pattern of patterns) { + const filepath = this._getFullEntryPath(pattern); + const entry = this._getEntry(filepath, pattern, options); + if (entry === null || !options.entryFilter(entry)) { + continue; + } + entries.push(entry); + } + return entries; + } + _getEntry(filepath, pattern, options) { + try { + const stats = this._getStat(filepath); + return this._makeEntry(stats, pattern); + } + catch (error) { + if (options.errorFilter(error)) { + return null; + } + throw error; + } + } + _getStat(filepath) { + return this._statSync(filepath, this._fsStatSettings); + } +} +exports.default = ReaderSync; + + +/***/ }), +/* 662 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const fs = __webpack_require__(23); +const os = __webpack_require__(11); +const CPU_COUNT = os.cpus().length; +exports.DEFAULT_FILE_SYSTEM_ADAPTER = { + lstat: fs.lstat, + lstatSync: fs.lstatSync, + stat: fs.stat, + statSync: fs.statSync, + readdir: fs.readdir, + readdirSync: fs.readdirSync +}; +// tslint:enable no-redundant-jsdoc +class Settings { + constructor(_options = {}) { + this._options = _options; + this.absolute = this._getValue(this._options.absolute, false); + this.baseNameMatch = this._getValue(this._options.baseNameMatch, false); + this.braceExpansion = this._getValue(this._options.braceExpansion, true); + this.caseSensitiveMatch = this._getValue(this._options.caseSensitiveMatch, true); + this.concurrency = this._getValue(this._options.concurrency, CPU_COUNT); + this.cwd = this._getValue(this._options.cwd, process.cwd()); + this.deep = this._getValue(this._options.deep, Infinity); + this.dot = this._getValue(this._options.dot, false); + this.extglob = this._getValue(this._options.extglob, true); + this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, true); + this.fs = this._getFileSystemMethods(this._options.fs); + this.globstar = this._getValue(this._options.globstar, true); + this.ignore = this._getValue(this._options.ignore, []); + this.markDirectories = this._getValue(this._options.markDirectories, false); + this.objectMode = this._getValue(this._options.objectMode, false); + this.onlyDirectories = this._getValue(this._options.onlyDirectories, false); + this.onlyFiles = this._getValue(this._options.onlyFiles, true); + this.stats = this._getValue(this._options.stats, false); + this.suppressErrors = this._getValue(this._options.suppressErrors, false); + this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, false); + this.unique = this._getValue(this._options.unique, true); + if (this.onlyDirectories) { + this.onlyFiles = false; + } + if (this.stats) { + this.objectMode = true; + } + } + _getValue(option, value) { + return option === undefined ? value : option; + } + _getFileSystemMethods(methods = {}) { + return Object.assign({}, exports.DEFAULT_FILE_SYSTEM_ADAPTER, methods); + } +} +exports.default = Settings; + + +/***/ }), +/* 663 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +const path = __webpack_require__(16); +const pathType = __webpack_require__(664); + +const getExtensions = extensions => extensions.length > 1 ? `{${extensions.join(',')}}` : extensions[0]; + +const getPath = (filepath, cwd) => { + const pth = filepath[0] === '!' ? filepath.slice(1) : filepath; + return path.isAbsolute(pth) ? pth : path.join(cwd, pth); +}; + +const addExtensions = (file, extensions) => { + if (path.extname(file)) { + return `**/${file}`; + } + + return `**/${file}.${getExtensions(extensions)}`; +}; + +const getGlob = (directory, options) => { + if (options.files && !Array.isArray(options.files)) { + throw new TypeError(`Expected \`files\` to be of type \`Array\` but received type \`${typeof options.files}\``); + } + + if (options.extensions && !Array.isArray(options.extensions)) { + throw new TypeError(`Expected \`extensions\` to be of type \`Array\` but received type \`${typeof options.extensions}\``); + } + + if (options.files && options.extensions) { + return options.files.map(x => path.posix.join(directory, addExtensions(x, options.extensions))); + } + + if (options.files) { + return options.files.map(x => path.posix.join(directory, `**/${x}`)); + } + + if (options.extensions) { + return [path.posix.join(directory, `**/*.${getExtensions(options.extensions)}`)]; + } + + return [path.posix.join(directory, '**')]; +}; + +module.exports = async (input, options) => { + options = { + cwd: process.cwd(), + ...options + }; + + if (typeof options.cwd !== 'string') { + throw new TypeError(`Expected \`cwd\` to be of type \`string\` but received type \`${typeof options.cwd}\``); + } + + const globs = await Promise.all([].concat(input).map(async x => { + const isDirectory = await pathType.isDirectory(getPath(x, options.cwd)); + return isDirectory ? getGlob(x, options) : x; + })); + + return [].concat.apply([], globs); // eslint-disable-line prefer-spread +}; + +module.exports.sync = (input, options) => { + options = { + cwd: process.cwd(), + ...options + }; + + if (typeof options.cwd !== 'string') { + throw new TypeError(`Expected \`cwd\` to be of type \`string\` but received type \`${typeof options.cwd}\``); + } + + const globs = [].concat(input).map(x => pathType.isDirectorySync(getPath(x, options.cwd)) ? getGlob(x, options) : x); + + return [].concat.apply([], globs); // eslint-disable-line prefer-spread +}; + + +/***/ }), +/* 664 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +const {promisify} = __webpack_require__(29); +const fs = __webpack_require__(23); + +async function isType(fsStatType, statsMethodName, filePath) { + if (typeof filePath !== 'string') { + throw new TypeError(`Expected a string, got ${typeof filePath}`); + } + + try { + const stats = await promisify(fs[fsStatType])(filePath); + return stats[statsMethodName](); + } catch (error) { + if (error.code === 'ENOENT') { + return false; + } + + throw error; + } +} + +function isTypeSync(fsStatType, statsMethodName, filePath) { + if (typeof filePath !== 'string') { + throw new TypeError(`Expected a string, got ${typeof filePath}`); + } + + try { + return fs[fsStatType](filePath)[statsMethodName](); + } catch (error) { + if (error.code === 'ENOENT') { + return false; + } + + throw error; + } +} + +exports.isFile = isType.bind(null, 'stat', 'isFile'); +exports.isDirectory = isType.bind(null, 'stat', 'isDirectory'); +exports.isSymlink = isType.bind(null, 'lstat', 'isSymbolicLink'); +exports.isFileSync = isTypeSync.bind(null, 'statSync', 'isFile'); +exports.isDirectorySync = isTypeSync.bind(null, 'statSync', 'isDirectory'); +exports.isSymlinkSync = isTypeSync.bind(null, 'lstatSync', 'isSymbolicLink'); + + +/***/ }), +/* 665 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const stream_1 = __webpack_require__(27); -const stream_2 = __webpack_require__(622); -const provider_1 = __webpack_require__(649); -class ProviderStream extends provider_1.default { - constructor() { - super(...arguments); - this._reader = new stream_2.default(this._settings); - } - read(task) { - const root = this._getRootDirectory(task); - const options = this._getReaderOptions(task); - const source = this.api(root, task, options); - const dest = new stream_1.Readable({ objectMode: true, read: () => { } }); - source - .once('error', (error) => dest.emit('error', error)) - .on('data', (entry) => dest.emit('data', options.transform(entry))) - .once('end', () => dest.emit('end')); - return dest; - } - api(root, task, options) { - if (task.dynamic) { - return this._reader.dynamic(root, options); - } - return this._reader.static(task.patterns, options); - } -} -exports.default = ProviderStream; + +const {promisify} = __webpack_require__(29); +const fs = __webpack_require__(23); +const path = __webpack_require__(16); +const fastGlob = __webpack_require__(597); +const gitIgnore = __webpack_require__(666); +const slash = __webpack_require__(667); + +const DEFAULT_IGNORE = [ + '**/node_modules/**', + '**/flow-typed/**', + '**/coverage/**', + '**/.git' +]; + +const readFileP = promisify(fs.readFile); + +const mapGitIgnorePatternTo = base => ignore => { + if (ignore.startsWith('!')) { + return '!' + path.posix.join(base, ignore.slice(1)); + } + + return path.posix.join(base, ignore); +}; + +const parseGitIgnore = (content, options) => { + const base = slash(path.relative(options.cwd, path.dirname(options.fileName))); + + return content + .split(/\r?\n/) + .filter(Boolean) + .filter(line => !line.startsWith('#')) + .map(mapGitIgnorePatternTo(base)); +}; + +const reduceIgnore = files => { + return files.reduce((ignores, file) => { + ignores.add(parseGitIgnore(file.content, { + cwd: file.cwd, + fileName: file.filePath + })); + return ignores; + }, gitIgnore()); +}; + +const ensureAbsolutePathForCwd = (cwd, p) => { + if (path.isAbsolute(p)) { + if (p.startsWith(cwd)) { + return p; + } + + throw new Error(`Path ${p} is not in cwd ${cwd}`); + } + + return path.join(cwd, p); +}; + +const getIsIgnoredPredecate = (ignores, cwd) => { + return p => ignores.ignores(slash(path.relative(cwd, ensureAbsolutePathForCwd(cwd, p)))); +}; + +const getFile = async (file, cwd) => { + const filePath = path.join(cwd, file); + const content = await readFileP(filePath, 'utf8'); + + return { + cwd, + filePath, + content + }; +}; + +const getFileSync = (file, cwd) => { + const filePath = path.join(cwd, file); + const content = fs.readFileSync(filePath, 'utf8'); + + return { + cwd, + filePath, + content + }; +}; + +const normalizeOptions = ({ + ignore = [], + cwd = process.cwd() +} = {}) => { + return {ignore, cwd}; +}; + +module.exports = async options => { + options = normalizeOptions(options); + + const paths = await fastGlob('**/.gitignore', { + ignore: DEFAULT_IGNORE.concat(options.ignore), + cwd: options.cwd + }); + + const files = await Promise.all(paths.map(file => getFile(file, options.cwd))); + const ignores = reduceIgnore(files); + + return getIsIgnoredPredecate(ignores, options.cwd); +}; + +module.exports.sync = options => { + options = normalizeOptions(options); + + const paths = fastGlob.sync('**/.gitignore', { + ignore: DEFAULT_IGNORE.concat(options.ignore), + cwd: options.cwd + }); + + const files = paths.map(file => getFileSync(file, options.cwd)); + const ignores = reduceIgnore(files); + + return getIsIgnoredPredecate(ignores, options.cwd); +}; /***/ }), -/* 655 */ -/***/ (function(module, exports, __webpack_require__) { +/* 666 */ +/***/ (function(module, exports) { -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const sync_1 = __webpack_require__(656); -const provider_1 = __webpack_require__(649); -class ProviderSync extends provider_1.default { - constructor() { - super(...arguments); - this._reader = new sync_1.default(this._settings); - } - read(task) { - const root = this._getRootDirectory(task); - const options = this._getReaderOptions(task); - const entries = this.api(root, task, options); - return entries.map(options.transform); - } - api(root, task, options) { - if (task.dynamic) { - return this._reader.dynamic(root, options); - } - return this._reader.static(task.patterns, options); - } -} -exports.default = ProviderSync; +// A simple implementation of make-array +function makeArray (subject) { + return Array.isArray(subject) + ? subject + : [subject] +} + +const REGEX_TEST_BLANK_LINE = /^\s+$/ +const REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/ +const REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/ +const REGEX_SPLITALL_CRLF = /\r?\n/g +// /foo, +// ./foo, +// ../foo, +// . +// .. +const REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/ + +const SLASH = '/' +const KEY_IGNORE = typeof Symbol !== 'undefined' + ? Symbol.for('node-ignore') + /* istanbul ignore next */ + : 'node-ignore' + +const define = (object, key, value) => + Object.defineProperty(object, key, {value}) + +const REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g + +// Sanitize the range of a regular expression +// The cases are complicated, see test cases for details +const sanitizeRange = range => range.replace( + REGEX_REGEXP_RANGE, + (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) + ? match + // Invalid range (out of order) which is ok for gitignore rules but + // fatal for JavaScript regular expression, so eliminate it. + : '' +) + +// > If the pattern ends with a slash, +// > it is removed for the purpose of the following description, +// > but it would only find a match with a directory. +// > In other words, foo/ will match a directory foo and paths underneath it, +// > but will not match a regular file or a symbolic link foo +// > (this is consistent with the way how pathspec works in general in Git). +// '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`' +// -> ignore-rules will not deal with it, because it costs extra `fs.stat` call +// you could use option `mark: true` with `glob` + +// '`foo/`' should not continue with the '`..`' +const DEFAULT_REPLACER_PREFIX = [ + + // > Trailing spaces are ignored unless they are quoted with backslash ("\") + [ + // (a\ ) -> (a ) + // (a ) -> (a) + // (a \ ) -> (a ) + /\\?\s+$/, + match => match.indexOf('\\') === 0 + ? ' ' + : '' + ], + + // replace (\ ) with ' ' + [ + /\\\s/g, + () => ' ' + ], + + // Escape metacharacters + // which is written down by users but means special for regular expressions. + + // > There are 12 characters with special meanings: + // > - the backslash \, + // > - the caret ^, + // > - the dollar sign $, + // > - the period or dot ., + // > - the vertical bar or pipe symbol |, + // > - the question mark ?, + // > - the asterisk or star *, + // > - the plus sign +, + // > - the opening parenthesis (, + // > - the closing parenthesis ), + // > - and the opening square bracket [, + // > - the opening curly brace {, + // > These special characters are often called "metacharacters". + [ + /[\\^$.|*+(){]/g, + match => `\\${match}` + ], + + [ + // > [abc] matches any character inside the brackets + // > (in this case a, b, or c); + /\[([^\]/]*)($|\])/g, + (match, p1, p2) => p2 === ']' + ? `[${sanitizeRange(p1)}]` + : `\\${match}` + ], + + [ + // > a question mark (?) matches a single character + /(?!\\)\?/g, + () => '[^/]' + ], + + // leading slash + [ + + // > A leading slash matches the beginning of the pathname. + // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c". + // A leading slash matches the beginning of the pathname + /^\//, + () => '^' + ], + + // replace special metacharacter slash after the leading slash + [ + /\//g, + () => '\\/' + ], + + [ + // > A leading "**" followed by a slash means match in all directories. + // > For example, "**/foo" matches file or directory "foo" anywhere, + // > the same as pattern "foo". + // > "**/foo/bar" matches file or directory "bar" anywhere that is directly + // > under directory "foo". + // Notice that the '*'s have been replaced as '\\*' + /^\^*\\\*\\\*\\\//, + + // '**/foo' <-> 'foo' + () => '^(?:.*\\/)?' + ] +] + +const DEFAULT_REPLACER_SUFFIX = [ + // starting + [ + // there will be no leading '/' + // (which has been replaced by section "leading slash") + // If starts with '**', adding a '^' to the regular expression also works + /^(?=[^^])/, + function startingReplacer () { + return !/\/(?!$)/.test(this) + // > If the pattern does not contain a slash /, + // > Git treats it as a shell glob pattern + // Actually, if there is only a trailing slash, + // git also treats it as a shell glob pattern + ? '(?:^|\\/)' + + // > Otherwise, Git treats the pattern as a shell glob suitable for + // > consumption by fnmatch(3) + : '^' + } + ], + + // two globstars + [ + // Use lookahead assertions so that we could match more than one `'/**'` + /\\\/\\\*\\\*(?=\\\/|$)/g, + + // Zero, one or several directories + // should not use '*', or it will be replaced by the next replacer + + // Check if it is not the last `'/**'` + (_, index, str) => index + 6 < str.length + + // case: /**/ + // > A slash followed by two consecutive asterisks then a slash matches + // > zero or more directories. + // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on. + // '/**/' + ? '(?:\\/[^\\/]+)*' + + // case: /** + // > A trailing `"/**"` matches everything inside. + + // #21: everything inside but it should not include the current folder + : '\\/.+' + ], + + // intermediate wildcards + [ + // Never replace escaped '*' + // ignore rule '\*' will match the path '*' + + // 'abc.*/' -> go + // 'abc.*' -> skip this rule + /(^|[^\\]+)\\\*(?=.+)/g, + + // '*.js' matches '.js' + // '*.js' doesn't match 'abc' + (_, p1) => `${p1}[^\\/]*` + ], + + // trailing wildcard + [ + /(\^|\\\/)?\\\*$/, + (_, p1) => { + const prefix = p1 + // '\^': + // '/*' does not match '' + // '/*' does not match everything + + // '\\\/': + // 'abc/*' does not match 'abc/' + ? `${p1}[^/]+` + + // 'a*' matches 'a' + // 'a*' matches 'aa' + : '[^/]*' + + return `${prefix}(?=$|\\/$)` + } + ], + + [ + // unescape + /\\\\\\/g, + () => '\\' + ] +] + +const POSITIVE_REPLACERS = [ + ...DEFAULT_REPLACER_PREFIX, + + // 'f' + // matches + // - /f(end) + // - /f/ + // - (start)f(end) + // - (start)f/ + // doesn't match + // - oof + // - foo + // pseudo: + // -> (^|/)f(/|$) + + // ending + [ + // 'js' will not match 'js.' + // 'ab' will not match 'abc' + /(?:[^*/])$/, + + // 'js*' will not match 'a.js' + // 'js/' will not match 'a.js' + // 'js' will match 'a.js' and 'a.js/' + match => `${match}(?=$|\\/)` + ], + + ...DEFAULT_REPLACER_SUFFIX +] + +const NEGATIVE_REPLACERS = [ + ...DEFAULT_REPLACER_PREFIX, + + // #24, #38 + // The MISSING rule of [gitignore docs](https://git-scm.com/docs/gitignore) + // A negative pattern without a trailing wildcard should not + // re-include the things inside that directory. + + // eg: + // ['node_modules/*', '!node_modules'] + // should ignore `node_modules/a.js` + [ + /(?:[^*])$/, + match => `${match}(?=$|\\/$)` + ], + + ...DEFAULT_REPLACER_SUFFIX +] + +// A simple cache, because an ignore rule only has only one certain meaning +const regexCache = Object.create(null) + +// @param {pattern} +const makeRegex = (pattern, negative, ignorecase) => { + const r = regexCache[pattern] + if (r) { + return r + } + + const replacers = negative + ? NEGATIVE_REPLACERS + : POSITIVE_REPLACERS + + const source = replacers.reduce( + (prev, current) => prev.replace(current[0], current[1].bind(pattern)), + pattern + ) + + return regexCache[pattern] = ignorecase + ? new RegExp(source, 'i') + : new RegExp(source) +} + +const isString = subject => typeof subject === 'string' + +// > A blank line matches no files, so it can serve as a separator for readability. +const checkPattern = pattern => pattern + && isString(pattern) + && !REGEX_TEST_BLANK_LINE.test(pattern) + + // > A line starting with # serves as a comment. + && pattern.indexOf('#') !== 0 + +const splitPattern = pattern => pattern.split(REGEX_SPLITALL_CRLF) + +class IgnoreRule { + constructor ( + origin, + pattern, + negative, + regex + ) { + this.origin = origin + this.pattern = pattern + this.negative = negative + this.regex = regex + } +} + +const createRule = (pattern, ignorecase) => { + const origin = pattern + let negative = false + + // > An optional prefix "!" which negates the pattern; + if (pattern.indexOf('!') === 0) { + negative = true + pattern = pattern.substr(1) + } + pattern = pattern + // > Put a backslash ("\") in front of the first "!" for patterns that + // > begin with a literal "!", for example, `"\!important!.txt"`. + .replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, '!') + // > Put a backslash ("\") in front of the first hash for patterns that + // > begin with a hash. + .replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, '#') -/***/ }), -/* 656 */ -/***/ (function(module, exports, __webpack_require__) { + const regex = makeRegex(pattern, negative, ignorecase) -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fsStat = __webpack_require__(623); -const fsWalk = __webpack_require__(628); -const reader_1 = __webpack_require__(648); -class ReaderSync extends reader_1.default { - constructor() { - super(...arguments); - this._walkSync = fsWalk.walkSync; - this._statSync = fsStat.statSync; - } - dynamic(root, options) { - return this._walkSync(root, options); - } - static(patterns, options) { - const entries = []; - for (const pattern of patterns) { - const filepath = this._getFullEntryPath(pattern); - const entry = this._getEntry(filepath, pattern, options); - if (entry === null || !options.entryFilter(entry)) { - continue; - } - entries.push(entry); - } - return entries; - } - _getEntry(filepath, pattern, options) { - try { - const stats = this._getStat(filepath); - return this._makeEntry(stats, pattern); - } - catch (error) { - if (options.errorFilter(error)) { - return null; - } - throw error; - } - } - _getStat(filepath) { - return this._statSync(filepath, this._fsStatSettings); - } -} -exports.default = ReaderSync; + return new IgnoreRule( + origin, + pattern, + negative, + regex + ) +} +const throwError = (message, Ctor) => { + throw new Ctor(message) +} -/***/ }), -/* 657 */ -/***/ (function(module, exports, __webpack_require__) { +const checkPath = (path, originalPath, doThrow) => { + if (!isString(path)) { + return doThrow( + `path must be a string, but got \`${originalPath}\``, + TypeError + ) + } -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fs = __webpack_require__(23); -const os = __webpack_require__(11); -const CPU_COUNT = os.cpus().length; -exports.DEFAULT_FILE_SYSTEM_ADAPTER = { - lstat: fs.lstat, - lstatSync: fs.lstatSync, - stat: fs.stat, - statSync: fs.statSync, - readdir: fs.readdir, - readdirSync: fs.readdirSync -}; -// tslint:enable no-redundant-jsdoc -class Settings { - constructor(_options = {}) { - this._options = _options; - this.absolute = this._getValue(this._options.absolute, false); - this.baseNameMatch = this._getValue(this._options.baseNameMatch, false); - this.braceExpansion = this._getValue(this._options.braceExpansion, true); - this.caseSensitiveMatch = this._getValue(this._options.caseSensitiveMatch, true); - this.concurrency = this._getValue(this._options.concurrency, CPU_COUNT); - this.cwd = this._getValue(this._options.cwd, process.cwd()); - this.deep = this._getValue(this._options.deep, Infinity); - this.dot = this._getValue(this._options.dot, false); - this.extglob = this._getValue(this._options.extglob, true); - this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, true); - this.fs = this._getFileSystemMethods(this._options.fs); - this.globstar = this._getValue(this._options.globstar, true); - this.ignore = this._getValue(this._options.ignore, []); - this.markDirectories = this._getValue(this._options.markDirectories, false); - this.objectMode = this._getValue(this._options.objectMode, false); - this.onlyDirectories = this._getValue(this._options.onlyDirectories, false); - this.onlyFiles = this._getValue(this._options.onlyFiles, true); - this.stats = this._getValue(this._options.stats, false); - this.suppressErrors = this._getValue(this._options.suppressErrors, false); - this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, false); - this.unique = this._getValue(this._options.unique, true); - if (this.onlyDirectories) { - this.onlyFiles = false; - } - if (this.stats) { - this.objectMode = true; - } - } - _getValue(option, value) { - return option === undefined ? value : option; - } - _getFileSystemMethods(methods = {}) { - return Object.assign({}, exports.DEFAULT_FILE_SYSTEM_ADAPTER, methods); - } -} -exports.default = Settings; + // We don't know if we should ignore '', so throw + if (!path) { + return doThrow(`path must not be empty`, TypeError) + } + // Check if it is a relative path + if (checkPath.isNotRelative(path)) { + const r = '`path.relative()`d' + return doThrow( + `path should be a ${r} string, but got "${originalPath}"`, + RangeError + ) + } -/***/ }), -/* 658 */ -/***/ (function(module, exports, __webpack_require__) { + return true +} -"use strict"; +const isNotRelative = path => REGEX_TEST_INVALID_PATH.test(path) -const path = __webpack_require__(16); -const pathType = __webpack_require__(659); +checkPath.isNotRelative = isNotRelative +checkPath.convert = p => p -const getExtensions = extensions => extensions.length > 1 ? `{${extensions.join(',')}}` : extensions[0]; +class Ignore { + constructor ({ + ignorecase = true + } = {}) { + this._rules = [] + this._ignorecase = ignorecase + define(this, KEY_IGNORE, true) + this._initCache() + } -const getPath = (filepath, cwd) => { - const pth = filepath[0] === '!' ? filepath.slice(1) : filepath; - return path.isAbsolute(pth) ? pth : path.join(cwd, pth); -}; + _initCache () { + this._ignoreCache = Object.create(null) + this._testCache = Object.create(null) + } -const addExtensions = (file, extensions) => { - if (path.extname(file)) { - return `**/${file}`; - } + _addPattern (pattern) { + // #32 + if (pattern && pattern[KEY_IGNORE]) { + this._rules = this._rules.concat(pattern._rules) + this._added = true + return + } - return `**/${file}.${getExtensions(extensions)}`; -}; + if (checkPattern(pattern)) { + const rule = createRule(pattern, this._ignorecase) + this._added = true + this._rules.push(rule) + } + } -const getGlob = (directory, options) => { - if (options.files && !Array.isArray(options.files)) { - throw new TypeError(`Expected \`files\` to be of type \`Array\` but received type \`${typeof options.files}\``); - } + // @param {Array | string | Ignore} pattern + add (pattern) { + this._added = false - if (options.extensions && !Array.isArray(options.extensions)) { - throw new TypeError(`Expected \`extensions\` to be of type \`Array\` but received type \`${typeof options.extensions}\``); - } + makeArray( + isString(pattern) + ? splitPattern(pattern) + : pattern + ).forEach(this._addPattern, this) - if (options.files && options.extensions) { - return options.files.map(x => path.posix.join(directory, addExtensions(x, options.extensions))); - } + // Some rules have just added to the ignore, + // making the behavior changed. + if (this._added) { + this._initCache() + } - if (options.files) { - return options.files.map(x => path.posix.join(directory, `**/${x}`)); - } + return this + } - if (options.extensions) { - return [path.posix.join(directory, `**/*.${getExtensions(options.extensions)}`)]; - } + // legacy + addPattern (pattern) { + return this.add(pattern) + } - return [path.posix.join(directory, '**')]; -}; + // | ignored : unignored + // negative | 0:0 | 0:1 | 1:0 | 1:1 + // -------- | ------- | ------- | ------- | -------- + // 0 | TEST | TEST | SKIP | X + // 1 | TESTIF | SKIP | TEST | X -module.exports = async (input, options) => { - options = { - cwd: process.cwd(), - ...options - }; + // - SKIP: always skip + // - TEST: always test + // - TESTIF: only test if checkUnignored + // - X: that never happen - if (typeof options.cwd !== 'string') { - throw new TypeError(`Expected \`cwd\` to be of type \`string\` but received type \`${typeof options.cwd}\``); - } + // @param {boolean} whether should check if the path is unignored, + // setting `checkUnignored` to `false` could reduce additional + // path matching. - const globs = await Promise.all([].concat(input).map(async x => { - const isDirectory = await pathType.isDirectory(getPath(x, options.cwd)); - return isDirectory ? getGlob(x, options) : x; - })); + // @returns {TestResult} true if a file is ignored + _testOne (path, checkUnignored) { + let ignored = false + let unignored = false - return [].concat.apply([], globs); // eslint-disable-line prefer-spread -}; + this._rules.forEach(rule => { + const {negative} = rule + if ( + unignored === negative && ignored !== unignored + || negative && !ignored && !unignored && !checkUnignored + ) { + return + } -module.exports.sync = (input, options) => { - options = { - cwd: process.cwd(), - ...options - }; + const matched = rule.regex.test(path) - if (typeof options.cwd !== 'string') { - throw new TypeError(`Expected \`cwd\` to be of type \`string\` but received type \`${typeof options.cwd}\``); - } + if (matched) { + ignored = !negative + unignored = negative + } + }) - const globs = [].concat(input).map(x => pathType.isDirectorySync(getPath(x, options.cwd)) ? getGlob(x, options) : x); + return { + ignored, + unignored + } + } - return [].concat.apply([], globs); // eslint-disable-line prefer-spread -}; + // @returns {TestResult} + _test (originalPath, cache, checkUnignored, slices) { + const path = originalPath + // Supports nullable path + && checkPath.convert(originalPath) + checkPath(path, originalPath, throwError) -/***/ }), -/* 659 */ -/***/ (function(module, exports, __webpack_require__) { + return this._t(path, cache, checkUnignored, slices) + } -"use strict"; + _t (path, cache, checkUnignored, slices) { + if (path in cache) { + return cache[path] + } -const {promisify} = __webpack_require__(29); -const fs = __webpack_require__(23); + if (!slices) { + // path/to/a.js + // ['path', 'to', 'a.js'] + slices = path.split(SLASH) + } -async function isType(fsStatType, statsMethodName, filePath) { - if (typeof filePath !== 'string') { - throw new TypeError(`Expected a string, got ${typeof filePath}`); - } + slices.pop() - try { - const stats = await promisify(fs[fsStatType])(filePath); - return stats[statsMethodName](); - } catch (error) { - if (error.code === 'ENOENT') { - return false; - } + // If the path has no parent directory, just test it + if (!slices.length) { + return cache[path] = this._testOne(path, checkUnignored) + } - throw error; - } -} + const parent = this._t( + slices.join(SLASH) + SLASH, + cache, + checkUnignored, + slices + ) -function isTypeSync(fsStatType, statsMethodName, filePath) { - if (typeof filePath !== 'string') { - throw new TypeError(`Expected a string, got ${typeof filePath}`); - } + // If the path contains a parent directory, check the parent first + return cache[path] = parent.ignored + // > It is not possible to re-include a file if a parent directory of + // > that file is excluded. + ? parent + : this._testOne(path, checkUnignored) + } - try { - return fs[fsStatType](filePath)[statsMethodName](); - } catch (error) { - if (error.code === 'ENOENT') { - return false; - } + ignores (path) { + return this._test(path, this._ignoreCache, false).ignored + } - throw error; - } + createFilter () { + return path => !this.ignores(path) + } + + filter (paths) { + return makeArray(paths).filter(this.createFilter()) + } + + // @returns {TestResult} + test (path) { + return this._test(path, this._testCache, true) + } } -exports.isFile = isType.bind(null, 'stat', 'isFile'); -exports.isDirectory = isType.bind(null, 'stat', 'isDirectory'); -exports.isSymlink = isType.bind(null, 'lstat', 'isSymbolicLink'); -exports.isFileSync = isTypeSync.bind(null, 'statSync', 'isFile'); -exports.isDirectorySync = isTypeSync.bind(null, 'statSync', 'isDirectory'); -exports.isSymlinkSync = isTypeSync.bind(null, 'lstatSync', 'isSymbolicLink'); +const factory = options => new Ignore(options) +const returnFalse = () => false -/***/ }), -/* 660 */ -/***/ (function(module, exports, __webpack_require__) { +const isPathValid = path => + checkPath(path && checkPath.convert(path), path, returnFalse) -"use strict"; +factory.isPathValid = isPathValid -const {promisify} = __webpack_require__(29); -const fs = __webpack_require__(23); -const path = __webpack_require__(16); -const fastGlob = __webpack_require__(592); -const gitIgnore = __webpack_require__(661); -const slash = __webpack_require__(662); +// Fixes typescript +factory.default = factory -const DEFAULT_IGNORE = [ - '**/node_modules/**', - '**/flow-typed/**', - '**/coverage/**', - '**/.git' -]; +module.exports = factory -const readFileP = promisify(fs.readFile); +// Windows +// -------------------------------------------------------------- +/* istanbul ignore if */ +if ( + // Detect `process` so that it can run in browsers. + typeof process !== 'undefined' + && ( + process.env && process.env.IGNORE_TEST_WIN32 + || process.platform === 'win32' + ) +) { + /* eslint no-control-regex: "off" */ + const makePosix = str => /^\\\\\?\\/.test(str) + || /["<>|\u0000-\u001F]+/u.test(str) + ? str + : str.replace(/\\/g, '/') -const mapGitIgnorePatternTo = base => ignore => { - if (ignore.startsWith('!')) { - return '!' + path.posix.join(base, ignore.slice(1)); - } + checkPath.convert = makePosix - return path.posix.join(base, ignore); -}; + // 'C:\\foo' <- 'C:\\foo' has been converted to 'C:/' + // 'd:\\foo' + const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i + checkPath.isNotRelative = path => + REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path) + || isNotRelative(path) +} -const parseGitIgnore = (content, options) => { - const base = slash(path.relative(options.cwd, path.dirname(options.fileName))); - return content - .split(/\r?\n/) - .filter(Boolean) - .filter(line => !line.startsWith('#')) - .map(mapGitIgnorePatternTo(base)); -}; +/***/ }), +/* 667 */ +/***/ (function(module, exports, __webpack_require__) { -const reduceIgnore = files => { - return files.reduce((ignores, file) => { - ignores.add(parseGitIgnore(file.content, { - cwd: file.cwd, - fileName: file.filePath - })); - return ignores; - }, gitIgnore()); -}; +"use strict"; -const ensureAbsolutePathForCwd = (cwd, p) => { - if (path.isAbsolute(p)) { - if (p.startsWith(cwd)) { - return p; - } +module.exports = path => { + const isExtendedLengthPath = /^\\\\\?\\/.test(path); + const hasNonAscii = /[^\u0000-\u0080]+/.test(path); // eslint-disable-line no-control-regex - throw new Error(`Path ${p} is not in cwd ${cwd}`); + if (isExtendedLengthPath || hasNonAscii) { + return path; } - return path.join(cwd, p); -}; - -const getIsIgnoredPredecate = (ignores, cwd) => { - return p => ignores.ignores(slash(path.relative(cwd, ensureAbsolutePathForCwd(cwd, p)))); + return path.replace(/\\/g, '/'); }; -const getFile = async (file, cwd) => { - const filePath = path.join(cwd, file); - const content = await readFileP(filePath, 'utf8'); - - return { - cwd, - filePath, - content - }; -}; -const getFileSync = (file, cwd) => { - const filePath = path.join(cwd, file); - const content = fs.readFileSync(filePath, 'utf8'); +/***/ }), +/* 668 */ +/***/ (function(module, exports, __webpack_require__) { - return { - cwd, - filePath, - content - }; -}; +"use strict"; -const normalizeOptions = ({ - ignore = [], - cwd = process.cwd() -} = {}) => { - return {ignore, cwd}; -}; +const {Transform} = __webpack_require__(27); -module.exports = async options => { - options = normalizeOptions(options); +class ObjectTransform extends Transform { + constructor() { + super({ + objectMode: true + }); + } +} - const paths = await fastGlob('**/.gitignore', { - ignore: DEFAULT_IGNORE.concat(options.ignore), - cwd: options.cwd - }); +class FilterStream extends ObjectTransform { + constructor(filter) { + super(); + this._filter = filter; + } - const files = await Promise.all(paths.map(file => getFile(file, options.cwd))); - const ignores = reduceIgnore(files); + _transform(data, encoding, callback) { + if (this._filter(data)) { + this.push(data); + } - return getIsIgnoredPredecate(ignores, options.cwd); -}; + callback(); + } +} -module.exports.sync = options => { - options = normalizeOptions(options); +class UniqueStream extends ObjectTransform { + constructor() { + super(); + this._pushed = new Set(); + } - const paths = fastGlob.sync('**/.gitignore', { - ignore: DEFAULT_IGNORE.concat(options.ignore), - cwd: options.cwd - }); + _transform(data, encoding, callback) { + if (!this._pushed.has(data)) { + this.push(data); + this._pushed.add(data); + } - const files = paths.map(file => getFileSync(file, options.cwd)); - const ignores = reduceIgnore(files); + callback(); + } +} - return getIsIgnoredPredecate(ignores, options.cwd); +module.exports = { + FilterStream, + UniqueStream }; /***/ }), -/* 661 */ -/***/ (function(module, exports) { +/* 669 */ +/***/ (function(module, exports, __webpack_require__) { -// A simple implementation of make-array -function makeArray (subject) { - return Array.isArray(subject) - ? subject - : [subject] -} +"use strict"; -const REGEX_TEST_BLANK_LINE = /^\s+$/ -const REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/ -const REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/ -const REGEX_SPLITALL_CRLF = /\r?\n/g -// /foo, -// ./foo, -// ../foo, -// . -// .. -const REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/ +const path = __webpack_require__(16); -const SLASH = '/' -const KEY_IGNORE = typeof Symbol !== 'undefined' - ? Symbol.for('node-ignore') - /* istanbul ignore next */ - : 'node-ignore' +module.exports = path_ => { + let cwd = process.cwd(); -const define = (object, key, value) => - Object.defineProperty(object, key, {value}) + path_ = path.resolve(path_); -const REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g + if (process.platform === 'win32') { + cwd = cwd.toLowerCase(); + path_ = path_.toLowerCase(); + } -// Sanitize the range of a regular expression -// The cases are complicated, see test cases for details -const sanitizeRange = range => range.replace( - REGEX_REGEXP_RANGE, - (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) - ? match - // Invalid range (out of order) which is ok for gitignore rules but - // fatal for JavaScript regular expression, so eliminate it. - : '' -) + return path_ === cwd; +}; -// > If the pattern ends with a slash, -// > it is removed for the purpose of the following description, -// > but it would only find a match with a directory. -// > In other words, foo/ will match a directory foo and paths underneath it, -// > but will not match a regular file or a symbolic link foo -// > (this is consistent with the way how pathspec works in general in Git). -// '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`' -// -> ignore-rules will not deal with it, because it costs extra `fs.stat` call -// you could use option `mark: true` with `glob` -// '`foo/`' should not continue with the '`..`' -const DEFAULT_REPLACER_PREFIX = [ +/***/ }), +/* 670 */ +/***/ (function(module, exports, __webpack_require__) { - // > Trailing spaces are ignored unless they are quoted with backslash ("\") - [ - // (a\ ) -> (a ) - // (a ) -> (a) - // (a \ ) -> (a ) - /\\?\s+$/, - match => match.indexOf('\\') === 0 - ? ' ' - : '' - ], +"use strict"; - // replace (\ ) with ' ' - [ - /\\\s/g, - () => ' ' - ], +const path = __webpack_require__(16); - // Escape metacharacters - // which is written down by users but means special for regular expressions. +module.exports = (childPath, parentPath) => { + childPath = path.resolve(childPath); + parentPath = path.resolve(parentPath); - // > There are 12 characters with special meanings: - // > - the backslash \, - // > - the caret ^, - // > - the dollar sign $, - // > - the period or dot ., - // > - the vertical bar or pipe symbol |, - // > - the question mark ?, - // > - the asterisk or star *, - // > - the plus sign +, - // > - the opening parenthesis (, - // > - the closing parenthesis ), - // > - and the opening square bracket [, - // > - the opening curly brace {, - // > These special characters are often called "metacharacters". - [ - /[\\^$.|*+(){]/g, - match => `\\${match}` - ], + if (process.platform === 'win32') { + childPath = childPath.toLowerCase(); + parentPath = parentPath.toLowerCase(); + } - [ - // > [abc] matches any character inside the brackets - // > (in this case a, b, or c); - /\[([^\]/]*)($|\])/g, - (match, p1, p2) => p2 === ']' - ? `[${sanitizeRange(p1)}]` - : `\\${match}` - ], + if (childPath === parentPath) { + return false; + } - [ - // > a question mark (?) matches a single character - /(?!\\)\?/g, - () => '[^/]' - ], + childPath += path.sep; + parentPath += path.sep; - // leading slash - [ + return childPath.startsWith(parentPath); +}; - // > A leading slash matches the beginning of the pathname. - // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c". - // A leading slash matches the beginning of the pathname - /^\//, - () => '^' - ], - // replace special metacharacter slash after the leading slash - [ - /\//g, - () => '\\/' - ], +/***/ }), +/* 671 */ +/***/ (function(module, exports, __webpack_require__) { - [ - // > A leading "**" followed by a slash means match in all directories. - // > For example, "**/foo" matches file or directory "foo" anywhere, - // > the same as pattern "foo". - // > "**/foo/bar" matches file or directory "bar" anywhere that is directly - // > under directory "foo". - // Notice that the '*'s have been replaced as '\\*' - /^\^*\\\*\\\*\\\//, +const assert = __webpack_require__(30) +const path = __webpack_require__(16) +const fs = __webpack_require__(23) +let glob = undefined +try { + glob = __webpack_require__(592) +} catch (_err) { + // treat glob as optional. +} - // '**/foo' <-> 'foo' - () => '^(?:.*\\/)?' - ] -] +const defaultGlobOpts = { + nosort: true, + silent: true +} -const DEFAULT_REPLACER_SUFFIX = [ - // starting - [ - // there will be no leading '/' - // (which has been replaced by section "leading slash") - // If starts with '**', adding a '^' to the regular expression also works - /^(?=[^^])/, - function startingReplacer () { - return !/\/(?!$)/.test(this) - // > If the pattern does not contain a slash /, - // > Git treats it as a shell glob pattern - // Actually, if there is only a trailing slash, - // git also treats it as a shell glob pattern - ? '(?:^|\\/)' +// for EMFILE handling +let timeout = 0 - // > Otherwise, Git treats the pattern as a shell glob suitable for - // > consumption by fnmatch(3) - : '^' - } - ], +const isWindows = (process.platform === "win32") - // two globstars - [ - // Use lookahead assertions so that we could match more than one `'/**'` - /\\\/\\\*\\\*(?=\\\/|$)/g, +const defaults = options => { + const methods = [ + 'unlink', + 'chmod', + 'stat', + 'lstat', + 'rmdir', + 'readdir' + ] + methods.forEach(m => { + options[m] = options[m] || fs[m] + m = m + 'Sync' + options[m] = options[m] || fs[m] + }) - // Zero, one or several directories - // should not use '*', or it will be replaced by the next replacer + options.maxBusyTries = options.maxBusyTries || 3 + options.emfileWait = options.emfileWait || 1000 + if (options.glob === false) { + options.disableGlob = true + } + if (options.disableGlob !== true && glob === undefined) { + throw Error('glob dependency not found, set `options.disableGlob = true` if intentional') + } + options.disableGlob = options.disableGlob || false + options.glob = options.glob || defaultGlobOpts +} - // Check if it is not the last `'/**'` - (_, index, str) => index + 6 < str.length +const rimraf = (p, options, cb) => { + if (typeof options === 'function') { + cb = options + options = {} + } - // case: /**/ - // > A slash followed by two consecutive asterisks then a slash matches - // > zero or more directories. - // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on. - // '/**/' - ? '(?:\\/[^\\/]+)*' + assert(p, 'rimraf: missing path') + assert.equal(typeof p, 'string', 'rimraf: path should be a string') + assert.equal(typeof cb, 'function', 'rimraf: callback function required') + assert(options, 'rimraf: invalid options argument provided') + assert.equal(typeof options, 'object', 'rimraf: options should be object') - // case: /** - // > A trailing `"/**"` matches everything inside. + defaults(options) - // #21: everything inside but it should not include the current folder - : '\\/.+' - ], + let busyTries = 0 + let errState = null + let n = 0 - // intermediate wildcards - [ - // Never replace escaped '*' - // ignore rule '\*' will match the path '*' + const next = (er) => { + errState = errState || er + if (--n === 0) + cb(errState) + } - // 'abc.*/' -> go - // 'abc.*' -> skip this rule - /(^|[^\\]+)\\\*(?=.+)/g, + const afterGlob = (er, results) => { + if (er) + return cb(er) - // '*.js' matches '.js' - // '*.js' doesn't match 'abc' - (_, p1) => `${p1}[^\\/]*` - ], + n = results.length + if (n === 0) + return cb() - // trailing wildcard - [ - /(\^|\\\/)?\\\*$/, - (_, p1) => { - const prefix = p1 - // '\^': - // '/*' does not match '' - // '/*' does not match everything + results.forEach(p => { + const CB = (er) => { + if (er) { + if ((er.code === "EBUSY" || er.code === "ENOTEMPTY" || er.code === "EPERM") && + busyTries < options.maxBusyTries) { + busyTries ++ + // try again, with the same exact callback as this one. + return setTimeout(() => rimraf_(p, options, CB), busyTries * 100) + } - // '\\\/': - // 'abc/*' does not match 'abc/' - ? `${p1}[^/]+` + // this one won't happen if graceful-fs is used. + if (er.code === "EMFILE" && timeout < options.emfileWait) { + return setTimeout(() => rimraf_(p, options, CB), timeout ++) + } - // 'a*' matches 'a' - // 'a*' matches 'aa' - : '[^/]*' + // already gone + if (er.code === "ENOENT") er = null + } - return `${prefix}(?=$|\\/$)` - } - ], + timeout = 0 + next(er) + } + rimraf_(p, options, CB) + }) + } - [ - // unescape - /\\\\\\/g, - () => '\\' - ] -] + if (options.disableGlob || !glob.hasMagic(p)) + return afterGlob(null, [p]) -const POSITIVE_REPLACERS = [ - ...DEFAULT_REPLACER_PREFIX, + options.lstat(p, (er, stat) => { + if (!er) + return afterGlob(null, [p]) - // 'f' - // matches - // - /f(end) - // - /f/ - // - (start)f(end) - // - (start)f/ - // doesn't match - // - oof - // - foo - // pseudo: - // -> (^|/)f(/|$) + glob(p, options.glob, afterGlob) + }) - // ending - [ - // 'js' will not match 'js.' - // 'ab' will not match 'abc' - /(?:[^*/])$/, +} - // 'js*' will not match 'a.js' - // 'js/' will not match 'a.js' - // 'js' will match 'a.js' and 'a.js/' - match => `${match}(?=$|\\/)` - ], +// Two possible strategies. +// 1. Assume it's a file. unlink it, then do the dir stuff on EPERM or EISDIR +// 2. Assume it's a directory. readdir, then do the file stuff on ENOTDIR +// +// Both result in an extra syscall when you guess wrong. However, there +// are likely far more normal files in the world than directories. This +// is based on the assumption that a the average number of files per +// directory is >= 1. +// +// If anyone ever complains about this, then I guess the strategy could +// be made configurable somehow. But until then, YAGNI. +const rimraf_ = (p, options, cb) => { + assert(p) + assert(options) + assert(typeof cb === 'function') - ...DEFAULT_REPLACER_SUFFIX -] + // sunos lets the root user unlink directories, which is... weird. + // so we have to lstat here and make sure it's not a dir. + options.lstat(p, (er, st) => { + if (er && er.code === "ENOENT") + return cb(null) -const NEGATIVE_REPLACERS = [ - ...DEFAULT_REPLACER_PREFIX, + // Windows can EPERM on stat. Life is suffering. + if (er && er.code === "EPERM" && isWindows) + fixWinEPERM(p, options, er, cb) - // #24, #38 - // The MISSING rule of [gitignore docs](https://git-scm.com/docs/gitignore) - // A negative pattern without a trailing wildcard should not - // re-include the things inside that directory. + if (st && st.isDirectory()) + return rmdir(p, options, er, cb) - // eg: - // ['node_modules/*', '!node_modules'] - // should ignore `node_modules/a.js` - [ - /(?:[^*])$/, - match => `${match}(?=$|\\/$)` - ], + options.unlink(p, er => { + if (er) { + if (er.code === "ENOENT") + return cb(null) + if (er.code === "EPERM") + return (isWindows) + ? fixWinEPERM(p, options, er, cb) + : rmdir(p, options, er, cb) + if (er.code === "EISDIR") + return rmdir(p, options, er, cb) + } + return cb(er) + }) + }) +} - ...DEFAULT_REPLACER_SUFFIX -] +const fixWinEPERM = (p, options, er, cb) => { + assert(p) + assert(options) + assert(typeof cb === 'function') + if (er) + assert(er instanceof Error) -// A simple cache, because an ignore rule only has only one certain meaning -const regexCache = Object.create(null) + options.chmod(p, 0o666, er2 => { + if (er2) + cb(er2.code === "ENOENT" ? null : er) + else + options.stat(p, (er3, stats) => { + if (er3) + cb(er3.code === "ENOENT" ? null : er) + else if (stats.isDirectory()) + rmdir(p, options, er, cb) + else + options.unlink(p, cb) + }) + }) +} -// @param {pattern} -const makeRegex = (pattern, negative, ignorecase) => { - const r = regexCache[pattern] - if (r) { - return r +const fixWinEPERMSync = (p, options, er) => { + assert(p) + assert(options) + if (er) + assert(er instanceof Error) + + try { + options.chmodSync(p, 0o666) + } catch (er2) { + if (er2.code === "ENOENT") + return + else + throw er } - const replacers = negative - ? NEGATIVE_REPLACERS - : POSITIVE_REPLACERS + let stats + try { + stats = options.statSync(p) + } catch (er3) { + if (er3.code === "ENOENT") + return + else + throw er + } - const source = replacers.reduce( - (prev, current) => prev.replace(current[0], current[1].bind(pattern)), - pattern - ) + if (stats.isDirectory()) + rmdirSync(p, options, er) + else + options.unlinkSync(p) +} - return regexCache[pattern] = ignorecase - ? new RegExp(source, 'i') - : new RegExp(source) +const rmdir = (p, options, originalEr, cb) => { + assert(p) + assert(options) + if (originalEr) + assert(originalEr instanceof Error) + assert(typeof cb === 'function') + + // try to rmdir first, and only readdir on ENOTEMPTY or EEXIST (SunOS) + // if we guessed wrong, and it's not a directory, then + // raise the original error. + options.rmdir(p, er => { + if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM")) + rmkids(p, options, cb) + else if (er && er.code === "ENOTDIR") + cb(originalEr) + else + cb(er) + }) } -const isString = subject => typeof subject === 'string' +const rmkids = (p, options, cb) => { + assert(p) + assert(options) + assert(typeof cb === 'function') -// > A blank line matches no files, so it can serve as a separator for readability. -const checkPattern = pattern => pattern - && isString(pattern) - && !REGEX_TEST_BLANK_LINE.test(pattern) + options.readdir(p, (er, files) => { + if (er) + return cb(er) + let n = files.length + if (n === 0) + return options.rmdir(p, cb) + let errState + files.forEach(f => { + rimraf(path.join(p, f), options, er => { + if (errState) + return + if (er) + return cb(errState = er) + if (--n === 0) + options.rmdir(p, cb) + }) + }) + }) +} - // > A line starting with # serves as a comment. - && pattern.indexOf('#') !== 0 +// this looks simpler, and is strictly *faster*, but will +// tie up the JavaScript thread and fail on excessively +// deep directory trees. +const rimrafSync = (p, options) => { + options = options || {} + defaults(options) -const splitPattern = pattern => pattern.split(REGEX_SPLITALL_CRLF) + assert(p, 'rimraf: missing path') + assert.equal(typeof p, 'string', 'rimraf: path should be a string') + assert(options, 'rimraf: missing options') + assert.equal(typeof options, 'object', 'rimraf: options should be object') -class IgnoreRule { - constructor ( - origin, - pattern, - negative, - regex - ) { - this.origin = origin - this.pattern = pattern - this.negative = negative - this.regex = regex + let results + + if (options.disableGlob || !glob.hasMagic(p)) { + results = [p] + } else { + try { + options.lstatSync(p) + results = [p] + } catch (er) { + results = glob.sync(p, options.glob) + } } -} -const createRule = (pattern, ignorecase) => { - const origin = pattern - let negative = false + if (!results.length) + return - // > An optional prefix "!" which negates the pattern; - if (pattern.indexOf('!') === 0) { - negative = true - pattern = pattern.substr(1) - } + for (let i = 0; i < results.length; i++) { + const p = results[i] - pattern = pattern - // > Put a backslash ("\") in front of the first "!" for patterns that - // > begin with a literal "!", for example, `"\!important!.txt"`. - .replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, '!') - // > Put a backslash ("\") in front of the first hash for patterns that - // > begin with a hash. - .replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, '#') + let st + try { + st = options.lstatSync(p) + } catch (er) { + if (er.code === "ENOENT") + return - const regex = makeRegex(pattern, negative, ignorecase) + // Windows can EPERM on stat. Life is suffering. + if (er.code === "EPERM" && isWindows) + fixWinEPERMSync(p, options, er) + } - return new IgnoreRule( - origin, - pattern, - negative, - regex - ) -} + try { + // sunos lets the root user unlink directories, which is... weird. + if (st && st.isDirectory()) + rmdirSync(p, options, null) + else + options.unlinkSync(p) + } catch (er) { + if (er.code === "ENOENT") + return + if (er.code === "EPERM") + return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er) + if (er.code !== "EISDIR") + throw er -const throwError = (message, Ctor) => { - throw new Ctor(message) + rmdirSync(p, options, er) + } + } } -const checkPath = (path, originalPath, doThrow) => { - if (!isString(path)) { - return doThrow( - `path must be a string, but got \`${originalPath}\``, - TypeError - ) - } +const rmdirSync = (p, options, originalEr) => { + assert(p) + assert(options) + if (originalEr) + assert(originalEr instanceof Error) - // We don't know if we should ignore '', so throw - if (!path) { - return doThrow(`path must not be empty`, TypeError) + try { + options.rmdirSync(p) + } catch (er) { + if (er.code === "ENOENT") + return + if (er.code === "ENOTDIR") + throw originalEr + if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM") + rmkidsSync(p, options) } +} - // Check if it is a relative path - if (checkPath.isNotRelative(path)) { - const r = '`path.relative()`d' - return doThrow( - `path should be a ${r} string, but got "${originalPath}"`, - RangeError - ) - } +const rmkidsSync = (p, options) => { + assert(p) + assert(options) + options.readdirSync(p).forEach(f => rimrafSync(path.join(p, f), options)) - return true + // We only end up here once we got ENOTEMPTY at least once, and + // at this point, we are guaranteed to have removed all the kids. + // So, we know that it won't be ENOENT or ENOTDIR or anything else. + // try really hard to delete stuff on windows, because it has a + // PROFOUNDLY annoying habit of not closing handles promptly when + // files are deleted, resulting in spurious ENOTEMPTY errors. + const retries = isWindows ? 100 : 1 + let i = 0 + do { + let threw = true + try { + const ret = options.rmdirSync(p, options) + threw = false + return ret + } finally { + if (++i < retries && threw) + continue + } + } while (true) } -const isNotRelative = path => REGEX_TEST_INVALID_PATH.test(path) +module.exports = rimraf +rimraf.sync = rimrafSync -checkPath.isNotRelative = isNotRelative -checkPath.convert = p => p -class Ignore { - constructor ({ - ignorecase = true - } = {}) { - this._rules = [] - this._ignorecase = ignorecase - define(this, KEY_IGNORE, true) - this._initCache() - } +/***/ }), +/* 672 */ +/***/ (function(module, exports, __webpack_require__) { - _initCache () { - this._ignoreCache = Object.create(null) - this._testCache = Object.create(null) - } +"use strict"; - _addPattern (pattern) { - // #32 - if (pattern && pattern[KEY_IGNORE]) { - this._rules = this._rules.concat(pattern._rules) - this._added = true - return - } +const AggregateError = __webpack_require__(673); - if (checkPattern(pattern)) { - const rule = createRule(pattern, this._ignorecase) - this._added = true - this._rules.push(rule) - } - } +module.exports = async ( + iterable, + mapper, + { + concurrency = Infinity, + stopOnError = true + } = {} +) => { + return new Promise((resolve, reject) => { + if (typeof mapper !== 'function') { + throw new TypeError('Mapper function is required'); + } - // @param {Array | string | Ignore} pattern - add (pattern) { - this._added = false + if (!(typeof concurrency === 'number' && concurrency >= 1)) { + throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${concurrency}\` (${typeof concurrency})`); + } - makeArray( - isString(pattern) - ? splitPattern(pattern) - : pattern - ).forEach(this._addPattern, this) + const ret = []; + const errors = []; + const iterator = iterable[Symbol.iterator](); + let isRejected = false; + let isIterableDone = false; + let resolvingCount = 0; + let currentIndex = 0; - // Some rules have just added to the ignore, - // making the behavior changed. - if (this._added) { - this._initCache() - } + const next = () => { + if (isRejected) { + return; + } - return this - } + const nextItem = iterator.next(); + const i = currentIndex; + currentIndex++; - // legacy - addPattern (pattern) { - return this.add(pattern) - } + if (nextItem.done) { + isIterableDone = true; - // | ignored : unignored - // negative | 0:0 | 0:1 | 1:0 | 1:1 - // -------- | ------- | ------- | ------- | -------- - // 0 | TEST | TEST | SKIP | X - // 1 | TESTIF | SKIP | TEST | X + if (resolvingCount === 0) { + if (!stopOnError && errors.length !== 0) { + reject(new AggregateError(errors)); + } else { + resolve(ret); + } + } - // - SKIP: always skip - // - TEST: always test - // - TESTIF: only test if checkUnignored - // - X: that never happen + return; + } - // @param {boolean} whether should check if the path is unignored, - // setting `checkUnignored` to `false` could reduce additional - // path matching. + resolvingCount++; - // @returns {TestResult} true if a file is ignored - _testOne (path, checkUnignored) { - let ignored = false - let unignored = false + (async () => { + try { + const element = await nextItem.value; + ret[i] = await mapper(element, i); + resolvingCount--; + next(); + } catch (error) { + if (stopOnError) { + isRejected = true; + reject(error); + } else { + errors.push(error); + resolvingCount--; + next(); + } + } + })(); + }; - this._rules.forEach(rule => { - const {negative} = rule - if ( - unignored === negative && ignored !== unignored - || negative && !ignored && !unignored && !checkUnignored - ) { - return - } + for (let i = 0; i < concurrency; i++) { + next(); - const matched = rule.regex.test(path) + if (isIterableDone) { + break; + } + } + }); +}; - if (matched) { - ignored = !negative - unignored = negative - } - }) - return { - ignored, - unignored - } - } +/***/ }), +/* 673 */ +/***/ (function(module, exports, __webpack_require__) { - // @returns {TestResult} - _test (originalPath, cache, checkUnignored, slices) { - const path = originalPath - // Supports nullable path - && checkPath.convert(originalPath) +"use strict"; - checkPath(path, originalPath, throwError) +const indentString = __webpack_require__(674); +const cleanStack = __webpack_require__(675); - return this._t(path, cache, checkUnignored, slices) - } +const cleanInternalStack = stack => stack.replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g, ''); - _t (path, cache, checkUnignored, slices) { - if (path in cache) { - return cache[path] - } +class AggregateError extends Error { + constructor(errors) { + if (!Array.isArray(errors)) { + throw new TypeError(`Expected input to be an Array, got ${typeof errors}`); + } - if (!slices) { - // path/to/a.js - // ['path', 'to', 'a.js'] - slices = path.split(SLASH) - } + errors = [...errors].map(error => { + if (error instanceof Error) { + return error; + } - slices.pop() + if (error !== null && typeof error === 'object') { + // Handle plain error objects with message property and/or possibly other metadata + return Object.assign(new Error(error.message), error); + } - // If the path has no parent directory, just test it - if (!slices.length) { - return cache[path] = this._testOne(path, checkUnignored) - } + return new Error(error); + }); - const parent = this._t( - slices.join(SLASH) + SLASH, - cache, - checkUnignored, - slices - ) + let message = errors + .map(error => { + // The `stack` property is not standardized, so we can't assume it exists + return typeof error.stack === 'string' ? cleanInternalStack(cleanStack(error.stack)) : String(error); + }) + .join('\n'); + message = '\n' + indentString(message, 4); + super(message); - // If the path contains a parent directory, check the parent first - return cache[path] = parent.ignored - // > It is not possible to re-include a file if a parent directory of - // > that file is excluded. - ? parent - : this._testOne(path, checkUnignored) - } + this.name = 'AggregateError'; - ignores (path) { - return this._test(path, this._ignoreCache, false).ignored - } + Object.defineProperty(this, '_errors', {value: errors}); + } - createFilter () { - return path => !this.ignores(path) - } + * [Symbol.iterator]() { + for (const error of this._errors) { + yield error; + } + } +} - filter (paths) { - return makeArray(paths).filter(this.createFilter()) - } +module.exports = AggregateError; - // @returns {TestResult} - test (path) { - return this._test(path, this._testCache, true) - } -} -const factory = options => new Ignore(options) +/***/ }), +/* 674 */ +/***/ (function(module, exports, __webpack_require__) { -const returnFalse = () => false +"use strict"; -const isPathValid = path => - checkPath(path && checkPath.convert(path), path, returnFalse) -factory.isPathValid = isPathValid +module.exports = (string, count = 1, options) => { + options = { + indent: ' ', + includeEmptyLines: false, + ...options + }; -// Fixes typescript -factory.default = factory + if (typeof string !== 'string') { + throw new TypeError( + `Expected \`input\` to be a \`string\`, got \`${typeof string}\`` + ); + } -module.exports = factory + if (typeof count !== 'number') { + throw new TypeError( + `Expected \`count\` to be a \`number\`, got \`${typeof count}\`` + ); + } -// Windows -// -------------------------------------------------------------- -/* istanbul ignore if */ -if ( - // Detect `process` so that it can run in browsers. - typeof process !== 'undefined' - && ( - process.env && process.env.IGNORE_TEST_WIN32 - || process.platform === 'win32' - ) -) { - /* eslint no-control-regex: "off" */ - const makePosix = str => /^\\\\\?\\/.test(str) - || /["<>|\u0000-\u001F]+/u.test(str) - ? str - : str.replace(/\\/g, '/') + if (typeof options.indent !== 'string') { + throw new TypeError( + `Expected \`options.indent\` to be a \`string\`, got \`${typeof options.indent}\`` + ); + } - checkPath.convert = makePosix + if (count === 0) { + return string; + } - // 'C:\\foo' <- 'C:\\foo' has been converted to 'C:/' - // 'd:\\foo' - const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i - checkPath.isNotRelative = path => - REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path) - || isNotRelative(path) -} + const regex = options.includeEmptyLines ? /^/gm : /^(?!\s*$)/gm; + + return string.replace(regex, options.indent.repeat(count)); +}; /***/ }), -/* 662 */ +/* 675 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -module.exports = path => { - const isExtendedLengthPath = /^\\\\\?\\/.test(path); - const hasNonAscii = /[^\u0000-\u0080]+/.test(path); // eslint-disable-line no-control-regex +const os = __webpack_require__(11); - if (isExtendedLengthPath || hasNonAscii) { - return path; - } +const extractPathRegex = /\s+at.*(?:\(|\s)(.*)\)?/; +const pathRegex = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)\.js:\d+:\d+)|native)/; +const homeDir = typeof os.homedir === 'undefined' ? '' : os.homedir(); + +module.exports = (stack, options) => { + options = Object.assign({pretty: false}, options); + + return stack.replace(/\\/g, '/') + .split('\n') + .filter(line => { + const pathMatches = line.match(extractPathRegex); + if (pathMatches === null || !pathMatches[1]) { + return true; + } + + const match = pathMatches[1]; + + // Electron + if ( + match.includes('.app/Contents/Resources/electron.asar') || + match.includes('.app/Contents/Resources/default_app.asar') + ) { + return false; + } + + return !pathRegex.test(match); + }) + .filter(line => line.trim() !== '') + .map(line => { + if (options.pretty) { + return line.replace(extractPathRegex, (m, p1) => m.replace(p1, p1.replace(homeDir, '~'))); + } - return path.replace(/\\/g, '/'); + return line; + }) + .join('\n'); }; /***/ }), -/* 663 */ +/* 676 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const {Transform} = __webpack_require__(27); +const chalk = __webpack_require__(677); +const cliCursor = __webpack_require__(681); +const cliSpinners = __webpack_require__(685); +const logSymbols = __webpack_require__(566); -class ObjectTransform extends Transform { - constructor() { - super({ - objectMode: true - }); - } -} +class Ora { + constructor(options) { + if (typeof options === 'string') { + options = { + text: options + }; + } -class FilterStream extends ObjectTransform { - constructor(filter) { - super(); - this._filter = filter; - } + this.options = Object.assign({ + text: '', + color: 'cyan', + stream: process.stderr + }, options); - _transform(data, encoding, callback) { - if (this._filter(data)) { - this.push(data); - } + const sp = this.options.spinner; + this.spinner = typeof sp === 'object' ? sp : (process.platform === 'win32' ? cliSpinners.line : (cliSpinners[sp] || cliSpinners.dots)); // eslint-disable-line no-nested-ternary - callback(); - } -} + if (this.spinner.frames === undefined) { + throw new Error('Spinner must define `frames`'); + } -class UniqueStream extends ObjectTransform { - constructor() { - super(); - this._pushed = new Set(); + this.text = this.options.text; + this.color = this.options.color; + this.interval = this.options.interval || this.spinner.interval || 100; + this.stream = this.options.stream; + this.id = null; + this.frameIndex = 0; + this.enabled = typeof this.options.enabled === 'boolean' ? this.options.enabled : ((this.stream && this.stream.isTTY) && !process.env.CI); } + frame() { + const frames = this.spinner.frames; + let frame = frames[this.frameIndex]; - _transform(data, encoding, callback) { - if (!this._pushed.has(data)) { - this.push(data); - this._pushed.add(data); + if (this.color) { + frame = chalk[this.color](frame); } - callback(); - } -} + this.frameIndex = ++this.frameIndex % frames.length; -module.exports = { - FilterStream, - UniqueStream -}; + return frame + ' ' + this.text; + } + clear() { + if (!this.enabled) { + return this; + } + this.stream.clearLine(); + this.stream.cursorTo(0); -/***/ }), -/* 664 */ -/***/ (function(module, exports, __webpack_require__) { + return this; + } + render() { + this.clear(); + this.stream.write(this.frame()); -var fs = __webpack_require__(23) -var polyfills = __webpack_require__(665) -var legacy = __webpack_require__(666) -var clone = __webpack_require__(667) + return this; + } + start(text) { + if (text) { + this.text = text; + } -var util = __webpack_require__(29) + if (!this.enabled || this.id) { + return this; + } -/* istanbul ignore next - node 0.x polyfill */ -var gracefulQueue -var previousSymbol + cliCursor.hide(this.stream); + this.render(); + this.id = setInterval(this.render.bind(this), this.interval); -/* istanbul ignore else - node 0.x polyfill */ -if (typeof Symbol === 'function' && typeof Symbol.for === 'function') { - gracefulQueue = Symbol.for('graceful-fs.queue') - // This is used in testing by future versions - previousSymbol = Symbol.for('graceful-fs.previous') -} else { - gracefulQueue = '___graceful-fs.queue' - previousSymbol = '___graceful-fs.previous' -} + return this; + } + stop() { + if (!this.enabled) { + return this; + } -function noop () {} + clearInterval(this.id); + this.id = null; + this.frameIndex = 0; + this.clear(); + cliCursor.show(this.stream); -var debug = noop -if (util.debuglog) - debug = util.debuglog('gfs4') -else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || '')) - debug = function() { - var m = util.format.apply(util, arguments) - m = 'GFS4: ' + m.split(/\n/).join('\nGFS4: ') - console.error(m) - } + return this; + } + succeed(text) { + return this.stopAndPersist({symbol: logSymbols.success, text}); + } + fail(text) { + return this.stopAndPersist({symbol: logSymbols.error, text}); + } + warn(text) { + return this.stopAndPersist({symbol: logSymbols.warning, text}); + } + info(text) { + return this.stopAndPersist({symbol: logSymbols.info, text}); + } + stopAndPersist(options) { + if (!this.enabled) { + return this; + } -// Once time initialization -if (!global[gracefulQueue]) { - // This queue can be shared by multiple loaded instances - var queue = [] - Object.defineProperty(global, gracefulQueue, { - get: function() { - return queue - } - }) + // Legacy argument + // TODO: Deprecate sometime in the future + if (typeof options === 'string') { + options = { + symbol: options + }; + } - // Patch fs.close/closeSync to shared queue version, because we need - // to retry() whenever a close happens *anywhere* in the program. - // This is essential when multiple graceful-fs instances are - // in play at the same time. - fs.close = (function (fs$close) { - function close (fd, cb) { - return fs$close.call(fs, fd, function (err) { - // This function uses the graceful-fs shared queue - if (!err) { - retry() - } + options = options || {}; - if (typeof cb === 'function') - cb.apply(this, arguments) - }) - } + this.stop(); + this.stream.write(`${options.symbol || ' '} ${options.text || this.text}\n`); - Object.defineProperty(close, previousSymbol, { - value: fs$close - }) - return close - })(fs.close) + return this; + } +} - fs.closeSync = (function (fs$closeSync) { - function closeSync (fd) { - // This function uses the graceful-fs shared queue - fs$closeSync.apply(fs, arguments) - retry() - } +module.exports = function (opts) { + return new Ora(opts); +}; - Object.defineProperty(closeSync, previousSymbol, { - value: fs$closeSync - }) - return closeSync - })(fs.closeSync) +module.exports.promise = (action, options) => { + if (typeof action.then !== 'function') { + throw new TypeError('Parameter `action` must be a Promise'); + } - if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || '')) { - process.on('exit', function() { - debug(global[gracefulQueue]) - __webpack_require__(30).equal(global[gracefulQueue].length, 0) - }) - } -} + const spinner = new Ora(options); + spinner.start(); -module.exports = patch(clone(fs)) -if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) { - module.exports = patch(fs) - fs.__patched = true; -} + action.then( + () => { + spinner.succeed(); + }, + () => { + spinner.fail(); + } + ); -function patch (fs) { - // Everything that references the open() function needs to be in here - polyfills(fs) - fs.gracefulify = patch + return spinner; +}; - fs.createReadStream = createReadStream - fs.createWriteStream = createWriteStream - var fs$readFile = fs.readFile - fs.readFile = readFile - function readFile (path, options, cb) { - if (typeof options === 'function') - cb = options, options = null - return go$readFile(path, options, cb) +/***/ }), +/* 677 */ +/***/ (function(module, exports, __webpack_require__) { - function go$readFile (path, options, cb) { - return fs$readFile(path, options, function (err) { - if (err && (err.code === 'EMFILE' || err.code === 'ENFILE')) - enqueue([go$readFile, [path, options, cb]]) - else { - if (typeof cb === 'function') - cb.apply(this, arguments) - retry() - } - }) - } - } +"use strict"; - var fs$writeFile = fs.writeFile - fs.writeFile = writeFile - function writeFile (path, data, options, cb) { - if (typeof options === 'function') - cb = options, options = null +const escapeStringRegexp = __webpack_require__(3); +const ansiStyles = __webpack_require__(678); +const stdoutColor = __webpack_require__(679).stdout; - return go$writeFile(path, data, options, cb) +const template = __webpack_require__(680); - function go$writeFile (path, data, options, cb) { - return fs$writeFile(path, data, options, function (err) { - if (err && (err.code === 'EMFILE' || err.code === 'ENFILE')) - enqueue([go$writeFile, [path, data, options, cb]]) - else { - if (typeof cb === 'function') - cb.apply(this, arguments) - retry() - } - }) - } - } +const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); - var fs$appendFile = fs.appendFile - if (fs$appendFile) - fs.appendFile = appendFile - function appendFile (path, data, options, cb) { - if (typeof options === 'function') - cb = options, options = null +// `supportsColor.level` → `ansiStyles.color[name]` mapping +const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; - return go$appendFile(path, data, options, cb) +// `color-convert` models to exclude from the Chalk API due to conflicts and such +const skipModels = new Set(['gray']); - function go$appendFile (path, data, options, cb) { - return fs$appendFile(path, data, options, function (err) { - if (err && (err.code === 'EMFILE' || err.code === 'ENFILE')) - enqueue([go$appendFile, [path, data, options, cb]]) - else { - if (typeof cb === 'function') - cb.apply(this, arguments) - retry() - } - }) - } - } +const styles = Object.create(null); - var fs$readdir = fs.readdir - fs.readdir = readdir - function readdir (path, options, cb) { - var args = [path] - if (typeof options !== 'function') { - args.push(options) - } else { - cb = options - } - args.push(go$readdir$cb) +function applyOptions(obj, options) { + options = options || {}; - return go$readdir(args) + // Detect level if not set manually + const scLevel = stdoutColor ? stdoutColor.level : 0; + obj.level = options.level === undefined ? scLevel : options.level; + obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0; +} - function go$readdir$cb (err, files) { - if (files && files.sort) - files.sort() +function Chalk(options) { + // We check for this.template here since calling `chalk.constructor()` + // by itself will have a `this` of a previously constructed chalk object + if (!this || !(this instanceof Chalk) || this.template) { + const chalk = {}; + applyOptions(chalk, options); - if (err && (err.code === 'EMFILE' || err.code === 'ENFILE')) - enqueue([go$readdir, [args]]) + chalk.template = function () { + const args = [].slice.call(arguments); + return chalkTag.apply(null, [chalk.template].concat(args)); + }; - else { - if (typeof cb === 'function') - cb.apply(this, arguments) - retry() - } - } - } + Object.setPrototypeOf(chalk, Chalk.prototype); + Object.setPrototypeOf(chalk.template, chalk); - function go$readdir (args) { - return fs$readdir.apply(fs, args) - } + chalk.template.constructor = Chalk; - if (process.version.substr(0, 4) === 'v0.8') { - var legStreams = legacy(fs) - ReadStream = legStreams.ReadStream - WriteStream = legStreams.WriteStream - } + return chalk.template; + } - var fs$ReadStream = fs.ReadStream - if (fs$ReadStream) { - ReadStream.prototype = Object.create(fs$ReadStream.prototype) - ReadStream.prototype.open = ReadStream$open - } + applyOptions(this, options); +} - var fs$WriteStream = fs.WriteStream - if (fs$WriteStream) { - WriteStream.prototype = Object.create(fs$WriteStream.prototype) - WriteStream.prototype.open = WriteStream$open - } +// Use bright blue on Windows as the normal blue color is illegible +if (isSimpleWindowsTerm) { + ansiStyles.blue.open = '\u001B[94m'; +} - Object.defineProperty(fs, 'ReadStream', { - get: function () { - return ReadStream - }, - set: function (val) { - ReadStream = val - }, - enumerable: true, - configurable: true - }) - Object.defineProperty(fs, 'WriteStream', { - get: function () { - return WriteStream - }, - set: function (val) { - WriteStream = val - }, - enumerable: true, - configurable: true - }) +for (const key of Object.keys(ansiStyles)) { + ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g'); - // legacy names - Object.defineProperty(fs, 'FileReadStream', { - get: function () { - return ReadStream - }, - set: function (val) { - ReadStream = val - }, - enumerable: true, - configurable: true - }) - Object.defineProperty(fs, 'FileWriteStream', { - get: function () { - return WriteStream - }, - set: function (val) { - WriteStream = val - }, - enumerable: true, - configurable: true - }) + styles[key] = { + get() { + const codes = ansiStyles[key]; + return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key); + } + }; +} - function ReadStream (path, options) { - if (this instanceof ReadStream) - return fs$ReadStream.apply(this, arguments), this - else - return ReadStream.apply(Object.create(ReadStream.prototype), arguments) - } +styles.visible = { + get() { + return build.call(this, this._styles || [], true, 'visible'); + } +}; - function ReadStream$open () { - var that = this - open(that.path, that.flags, that.mode, function (err, fd) { - if (err) { - if (that.autoClose) - that.destroy() +ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g'); +for (const model of Object.keys(ansiStyles.color.ansi)) { + if (skipModels.has(model)) { + continue; + } - that.emit('error', err) - } else { - that.fd = fd - that.emit('open', fd) - that.read() - } - }) - } + styles[model] = { + get() { + const level = this.level; + return function () { + const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments); + const codes = { + open, + close: ansiStyles.color.close, + closeRe: ansiStyles.color.closeRe + }; + return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model); + }; + } + }; +} - function WriteStream (path, options) { - if (this instanceof WriteStream) - return fs$WriteStream.apply(this, arguments), this - else - return WriteStream.apply(Object.create(WriteStream.prototype), arguments) - } +ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g'); +for (const model of Object.keys(ansiStyles.bgColor.ansi)) { + if (skipModels.has(model)) { + continue; + } - function WriteStream$open () { - var that = this - open(that.path, that.flags, that.mode, function (err, fd) { - if (err) { - that.destroy() - that.emit('error', err) - } else { - that.fd = fd - that.emit('open', fd) - } - }) - } + const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1); + styles[bgModel] = { + get() { + const level = this.level; + return function () { + const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments); + const codes = { + open, + close: ansiStyles.bgColor.close, + closeRe: ansiStyles.bgColor.closeRe + }; + return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model); + }; + } + }; +} - function createReadStream (path, options) { - return new fs.ReadStream(path, options) - } +const proto = Object.defineProperties(() => {}, styles); - function createWriteStream (path, options) { - return new fs.WriteStream(path, options) - } +function build(_styles, _empty, key) { + const builder = function () { + return applyStyle.apply(builder, arguments); + }; - var fs$open = fs.open - fs.open = open - function open (path, flags, mode, cb) { - if (typeof mode === 'function') - cb = mode, mode = null + builder._styles = _styles; + builder._empty = _empty; - return go$open(path, flags, mode, cb) + const self = this; - function go$open (path, flags, mode, cb) { - return fs$open(path, flags, mode, function (err, fd) { - if (err && (err.code === 'EMFILE' || err.code === 'ENFILE')) - enqueue([go$open, [path, flags, mode, cb]]) - else { - if (typeof cb === 'function') - cb.apply(this, arguments) - retry() - } - }) - } - } + Object.defineProperty(builder, 'level', { + enumerable: true, + get() { + return self.level; + }, + set(level) { + self.level = level; + } + }); - return fs -} + Object.defineProperty(builder, 'enabled', { + enumerable: true, + get() { + return self.enabled; + }, + set(enabled) { + self.enabled = enabled; + } + }); -function enqueue (elem) { - debug('ENQUEUE', elem[0].name, elem[1]) - global[gracefulQueue].push(elem) -} + // See below for fix regarding invisible grey/dim combination on Windows + builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; -function retry () { - var elem = global[gracefulQueue].shift() - if (elem) { - debug('RETRY', elem[0].name, elem[1]) - elem[0].apply(null, elem[1]) - } + // `__proto__` is used because we must return a function, but there is + // no way to create a function with a different prototype + builder.__proto__ = proto; // eslint-disable-line no-proto + + return builder; } +function applyStyle() { + // Support varags, but simply cast to string in case there's only one arg + const args = arguments; + const argsLen = args.length; + let str = String(arguments[0]); -/***/ }), -/* 665 */ -/***/ (function(module, exports, __webpack_require__) { + if (argsLen === 0) { + return ''; + } -var constants = __webpack_require__(25) + if (argsLen > 1) { + // Don't slice `arguments`, it prevents V8 optimizations + for (let a = 1; a < argsLen; a++) { + str += ' ' + args[a]; + } + } -var origCwd = process.cwd -var cwd = null + if (!this.enabled || this.level <= 0 || !str) { + return this._empty ? '' : str; + } -var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform + // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe, + // see https://github.com/chalk/chalk/issues/58 + // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop. + const originalDim = ansiStyles.dim.open; + if (isSimpleWindowsTerm && this.hasGrey) { + ansiStyles.dim.open = ''; + } -process.cwd = function() { - if (!cwd) - cwd = origCwd.call(process) - return cwd -} -try { - process.cwd() -} catch (er) {} + for (const code of this._styles.slice().reverse()) { + // Replace any instances already present with a re-opening code + // otherwise only the part of the string until said closing code + // will be colored, and the rest will simply be 'plain'. + str = code.open + str.replace(code.closeRe, code.open) + code.close; -var chdir = process.chdir -process.chdir = function(d) { - cwd = null - chdir.call(process, d) -} + // Close the styling before a linebreak and reopen + // after next line to fix a bleed issue on macOS + // https://github.com/chalk/chalk/pull/92 + str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`); + } -module.exports = patch + // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue + ansiStyles.dim.open = originalDim; -function patch (fs) { - // (re-)implement some things that are known busted or missing. + return str; +} - // lchmod, broken prior to 0.6.2 - // back-port the fix here. - if (constants.hasOwnProperty('O_SYMLINK') && - process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) { - patchLchmod(fs) - } +function chalkTag(chalk, strings) { + if (!Array.isArray(strings)) { + // If chalk() was called by itself or with a string, + // return the string itself as a string. + return [].slice.call(arguments, 1).join(' '); + } - // lutimes implementation, or no-op - if (!fs.lutimes) { - patchLutimes(fs) - } + const args = [].slice.call(arguments, 2); + const parts = [strings.raw[0]]; - // https://github.com/isaacs/node-graceful-fs/issues/4 - // Chown should not fail on einval or eperm if non-root. - // It should not fail on enosys ever, as this just indicates - // that a fs doesn't support the intended operation. + for (let i = 1; i < strings.length; i++) { + parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&')); + parts.push(String(strings.raw[i])); + } - fs.chown = chownFix(fs.chown) - fs.fchown = chownFix(fs.fchown) - fs.lchown = chownFix(fs.lchown) + return template(chalk, parts.join('')); +} - fs.chmod = chmodFix(fs.chmod) - fs.fchmod = chmodFix(fs.fchmod) - fs.lchmod = chmodFix(fs.lchmod) +Object.defineProperties(Chalk.prototype, styles); - fs.chownSync = chownFixSync(fs.chownSync) - fs.fchownSync = chownFixSync(fs.fchownSync) - fs.lchownSync = chownFixSync(fs.lchownSync) +module.exports = Chalk(); // eslint-disable-line new-cap +module.exports.supportsColor = stdoutColor; +module.exports.default = module.exports; // For TypeScript - fs.chmodSync = chmodFixSync(fs.chmodSync) - fs.fchmodSync = chmodFixSync(fs.fchmodSync) - fs.lchmodSync = chmodFixSync(fs.lchmodSync) - fs.stat = statFix(fs.stat) - fs.fstat = statFix(fs.fstat) - fs.lstat = statFix(fs.lstat) +/***/ }), +/* 678 */ +/***/ (function(module, exports, __webpack_require__) { - fs.statSync = statFixSync(fs.statSync) - fs.fstatSync = statFixSync(fs.fstatSync) - fs.lstatSync = statFixSync(fs.lstatSync) +"use strict"; +/* WEBPACK VAR INJECTION */(function(module) { +const colorConvert = __webpack_require__(6); - // if lchmod/lchown do not exist, then make them no-ops - if (!fs.lchmod) { - fs.lchmod = function (path, mode, cb) { - if (cb) process.nextTick(cb) - } - fs.lchmodSync = function () {} - } - if (!fs.lchown) { - fs.lchown = function (path, uid, gid, cb) { - if (cb) process.nextTick(cb) - } - fs.lchownSync = function () {} - } +const wrapAnsi16 = (fn, offset) => function () { + const code = fn.apply(colorConvert, arguments); + return `\u001B[${code + offset}m`; +}; - // on Windows, A/V software can lock the directory, causing this - // to fail with an EACCES or EPERM if the directory contains newly - // created files. Try again on failure, for up to 60 seconds. +const wrapAnsi256 = (fn, offset) => function () { + const code = fn.apply(colorConvert, arguments); + return `\u001B[${38 + offset};5;${code}m`; +}; - // Set the timeout this long because some Windows Anti-Virus, such as Parity - // bit9, may lock files for up to a minute, causing npm package install - // failures. Also, take care to yield the scheduler. Windows scheduling gives - // CPU to a busy looping process, which can cause the program causing the lock - // contention to be starved of CPU by node, so the contention doesn't resolve. - if (platform === "win32") { - fs.rename = (function (fs$rename) { return function (from, to, cb) { - var start = Date.now() - var backoff = 0; - fs$rename(from, to, function CB (er) { - if (er - && (er.code === "EACCES" || er.code === "EPERM") - && Date.now() - start < 60000) { - setTimeout(function() { - fs.stat(to, function (stater, st) { - if (stater && stater.code === "ENOENT") - fs$rename(from, to, CB); - else - cb(er) - }) - }, backoff) - if (backoff < 100) - backoff += 10; - return; - } - if (cb) cb(er) - }) - }})(fs.rename) - } +const wrapAnsi16m = (fn, offset) => function () { + const rgb = fn.apply(colorConvert, arguments); + return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`; +}; - // if read() returns EAGAIN, then just try it again. - fs.read = (function (fs$read) { - function read (fd, buffer, offset, length, position, callback_) { - var callback - if (callback_ && typeof callback_ === 'function') { - var eagCounter = 0 - callback = function (er, _, __) { - if (er && er.code === 'EAGAIN' && eagCounter < 10) { - eagCounter ++ - return fs$read.call(fs, fd, buffer, offset, length, position, callback) - } - callback_.apply(this, arguments) - } - } - return fs$read.call(fs, fd, buffer, offset, length, position, callback) - } +function assembleStyles() { + const codes = new Map(); + const styles = { + modifier: { + reset: [0, 0], + // 21 isn't widely supported and 22 does the same thing + bold: [1, 22], + dim: [2, 22], + italic: [3, 23], + underline: [4, 24], + inverse: [7, 27], + hidden: [8, 28], + strikethrough: [9, 29] + }, + color: { + black: [30, 39], + red: [31, 39], + green: [32, 39], + yellow: [33, 39], + blue: [34, 39], + magenta: [35, 39], + cyan: [36, 39], + white: [37, 39], + gray: [90, 39], - // This ensures `util.promisify` works as it does for native `fs.read`. - read.__proto__ = fs$read - return read - })(fs.read) + // Bright color + redBright: [91, 39], + greenBright: [92, 39], + yellowBright: [93, 39], + blueBright: [94, 39], + magentaBright: [95, 39], + cyanBright: [96, 39], + whiteBright: [97, 39] + }, + bgColor: { + bgBlack: [40, 49], + bgRed: [41, 49], + bgGreen: [42, 49], + bgYellow: [43, 49], + bgBlue: [44, 49], + bgMagenta: [45, 49], + bgCyan: [46, 49], + bgWhite: [47, 49], - fs.readSync = (function (fs$readSync) { return function (fd, buffer, offset, length, position) { - var eagCounter = 0 - while (true) { - try { - return fs$readSync.call(fs, fd, buffer, offset, length, position) - } catch (er) { - if (er.code === 'EAGAIN' && eagCounter < 10) { - eagCounter ++ - continue - } - throw er - } - } - }})(fs.readSync) + // Bright color + bgBlackBright: [100, 49], + bgRedBright: [101, 49], + bgGreenBright: [102, 49], + bgYellowBright: [103, 49], + bgBlueBright: [104, 49], + bgMagentaBright: [105, 49], + bgCyanBright: [106, 49], + bgWhiteBright: [107, 49] + } + }; - function patchLchmod (fs) { - fs.lchmod = function (path, mode, callback) { - fs.open( path - , constants.O_WRONLY | constants.O_SYMLINK - , mode - , function (err, fd) { - if (err) { - if (callback) callback(err) - return - } - // prefer to return the chmod error, if one occurs, - // but still try to close, and report closing errors if they occur. - fs.fchmod(fd, mode, function (err) { - fs.close(fd, function(err2) { - if (callback) callback(err || err2) - }) - }) - }) - } + // Fix humans + styles.color.grey = styles.color.gray; - fs.lchmodSync = function (path, mode) { - var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode) + for (const groupName of Object.keys(styles)) { + const group = styles[groupName]; - // prefer to return the chmod error, if one occurs, - // but still try to close, and report closing errors if they occur. - var threw = true - var ret - try { - ret = fs.fchmodSync(fd, mode) - threw = false - } finally { - if (threw) { - try { - fs.closeSync(fd) - } catch (er) {} - } else { - fs.closeSync(fd) - } - } - return ret - } - } + for (const styleName of Object.keys(group)) { + const style = group[styleName]; - function patchLutimes (fs) { - if (constants.hasOwnProperty("O_SYMLINK")) { - fs.lutimes = function (path, at, mt, cb) { - fs.open(path, constants.O_SYMLINK, function (er, fd) { - if (er) { - if (cb) cb(er) - return - } - fs.futimes(fd, at, mt, function (er) { - fs.close(fd, function (er2) { - if (cb) cb(er || er2) - }) - }) - }) - } + styles[styleName] = { + open: `\u001B[${style[0]}m`, + close: `\u001B[${style[1]}m` + }; - fs.lutimesSync = function (path, at, mt) { - var fd = fs.openSync(path, constants.O_SYMLINK) - var ret - var threw = true - try { - ret = fs.futimesSync(fd, at, mt) - threw = false - } finally { - if (threw) { - try { - fs.closeSync(fd) - } catch (er) {} - } else { - fs.closeSync(fd) - } - } - return ret - } + group[styleName] = styles[styleName]; - } else { - fs.lutimes = function (_a, _b, _c, cb) { if (cb) process.nextTick(cb) } - fs.lutimesSync = function () {} - } - } + codes.set(style[0], style[1]); + } - function chmodFix (orig) { - if (!orig) return orig - return function (target, mode, cb) { - return orig.call(fs, target, mode, function (er) { - if (chownErOk(er)) er = null - if (cb) cb.apply(this, arguments) - }) - } - } + Object.defineProperty(styles, groupName, { + value: group, + enumerable: false + }); - function chmodFixSync (orig) { - if (!orig) return orig - return function (target, mode) { - try { - return orig.call(fs, target, mode) - } catch (er) { - if (!chownErOk(er)) throw er - } - } - } + Object.defineProperty(styles, 'codes', { + value: codes, + enumerable: false + }); + } + const ansi2ansi = n => n; + const rgb2rgb = (r, g, b) => [r, g, b]; - function chownFix (orig) { - if (!orig) return orig - return function (target, uid, gid, cb) { - return orig.call(fs, target, uid, gid, function (er) { - if (chownErOk(er)) er = null - if (cb) cb.apply(this, arguments) - }) - } - } + styles.color.close = '\u001B[39m'; + styles.bgColor.close = '\u001B[49m'; - function chownFixSync (orig) { - if (!orig) return orig - return function (target, uid, gid) { - try { - return orig.call(fs, target, uid, gid) - } catch (er) { - if (!chownErOk(er)) throw er - } - } - } + styles.color.ansi = { + ansi: wrapAnsi16(ansi2ansi, 0) + }; + styles.color.ansi256 = { + ansi256: wrapAnsi256(ansi2ansi, 0) + }; + styles.color.ansi16m = { + rgb: wrapAnsi16m(rgb2rgb, 0) + }; - function statFix (orig) { - if (!orig) return orig - // Older versions of Node erroneously returned signed integers for - // uid + gid. - return function (target, options, cb) { - if (typeof options === 'function') { - cb = options - options = null - } - function callback (er, stats) { - if (stats) { - if (stats.uid < 0) stats.uid += 0x100000000 - if (stats.gid < 0) stats.gid += 0x100000000 - } - if (cb) cb.apply(this, arguments) - } - return options ? orig.call(fs, target, options, callback) - : orig.call(fs, target, callback) - } - } + styles.bgColor.ansi = { + ansi: wrapAnsi16(ansi2ansi, 10) + }; + styles.bgColor.ansi256 = { + ansi256: wrapAnsi256(ansi2ansi, 10) + }; + styles.bgColor.ansi16m = { + rgb: wrapAnsi16m(rgb2rgb, 10) + }; - function statFixSync (orig) { - if (!orig) return orig - // Older versions of Node erroneously returned signed integers for - // uid + gid. - return function (target, options) { - var stats = options ? orig.call(fs, target, options) - : orig.call(fs, target) - if (stats.uid < 0) stats.uid += 0x100000000 - if (stats.gid < 0) stats.gid += 0x100000000 - return stats; - } - } + for (let key of Object.keys(colorConvert)) { + if (typeof colorConvert[key] !== 'object') { + continue; + } - // ENOSYS means that the fs doesn't support the op. Just ignore - // that, because it doesn't matter. - // - // if there's no getuid, or if getuid() is something other - // than 0, and the error is EINVAL or EPERM, then just ignore - // it. - // - // This specific case is a silent failure in cp, install, tar, - // and most other unix tools that manage permissions. - // - // When running as root, or if other types of errors are - // encountered, then it's strict. - function chownErOk (er) { - if (!er) - return true + const suite = colorConvert[key]; - if (er.code === "ENOSYS") - return true + if (key === 'ansi16') { + key = 'ansi'; + } - var nonroot = !process.getuid || process.getuid() !== 0 - if (nonroot) { - if (er.code === "EINVAL" || er.code === "EPERM") - return true - } + if ('ansi16' in suite) { + styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0); + styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10); + } - return false - } + if ('ansi256' in suite) { + styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0); + styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10); + } + + if ('rgb' in suite) { + styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0); + styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10); + } + } + + return styles; } +// Make the export immutable +Object.defineProperty(module, 'exports', { + enumerable: true, + get: assembleStyles +}); + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(5)(module))) /***/ }), -/* 666 */ +/* 679 */ /***/ (function(module, exports, __webpack_require__) { -var Stream = __webpack_require__(27).Stream - -module.exports = legacy - -function legacy (fs) { - return { - ReadStream: ReadStream, - WriteStream: WriteStream - } +"use strict"; - function ReadStream (path, options) { - if (!(this instanceof ReadStream)) return new ReadStream(path, options); +const os = __webpack_require__(11); +const hasFlag = __webpack_require__(12); - Stream.call(this); +const env = process.env; - var self = this; +let forceColor; +if (hasFlag('no-color') || + hasFlag('no-colors') || + hasFlag('color=false')) { + forceColor = false; +} else if (hasFlag('color') || + hasFlag('colors') || + hasFlag('color=true') || + hasFlag('color=always')) { + forceColor = true; +} +if ('FORCE_COLOR' in env) { + forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0; +} - this.path = path; - this.fd = null; - this.readable = true; - this.paused = false; +function translateLevel(level) { + if (level === 0) { + return false; + } - this.flags = 'r'; - this.mode = 438; /*=0666*/ - this.bufferSize = 64 * 1024; + return { + level, + hasBasic: true, + has256: level >= 2, + has16m: level >= 3 + }; +} - options = options || {}; +function supportsColor(stream) { + if (forceColor === false) { + return 0; + } - // Mixin options into this - var keys = Object.keys(options); - for (var index = 0, length = keys.length; index < length; index++) { - var key = keys[index]; - this[key] = options[key]; - } + if (hasFlag('color=16m') || + hasFlag('color=full') || + hasFlag('color=truecolor')) { + return 3; + } - if (this.encoding) this.setEncoding(this.encoding); + if (hasFlag('color=256')) { + return 2; + } - if (this.start !== undefined) { - if ('number' !== typeof this.start) { - throw TypeError('start must be a Number'); - } - if (this.end === undefined) { - this.end = Infinity; - } else if ('number' !== typeof this.end) { - throw TypeError('end must be a Number'); - } + if (stream && !stream.isTTY && forceColor !== true) { + // VS code debugger doesn't have isTTY set + if (env.VSCODE_PID) { + return 1; + } + return 0; + } - if (this.start > this.end) { - throw new Error('start must be <= end'); - } + const min = forceColor ? 1 : 0; - this.pos = this.start; - } + if (process.platform === 'win32') { + // Node.js 7.5.0 is the first version of Node.js to include a patch to + // libuv that enables 256 color output on Windows. Anything earlier and it + // won't work. However, here we target Node.js 8 at minimum as it is an LTS + // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows + // release that supports 256 colors. Windows 10 build 14931 is the first release + // that supports 16m/TrueColor. + const osRelease = os.release().split('.'); + if ( + Number(process.versions.node.split('.')[0]) >= 8 && + Number(osRelease[0]) >= 10 && + Number(osRelease[2]) >= 10586 + ) { + return Number(osRelease[2]) >= 14931 ? 3 : 2; + } - if (this.fd !== null) { - process.nextTick(function() { - self._read(); - }); - return; - } + return 1; + } - fs.open(this.path, this.flags, this.mode, function (err, fd) { - if (err) { - self.emit('error', err); - self.readable = false; - return; - } + if ('CI' in env) { + if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') { + return 1; + } - self.fd = fd; - self.emit('open', fd); - self._read(); - }) - } + return min; + } - function WriteStream (path, options) { - if (!(this instanceof WriteStream)) return new WriteStream(path, options); + if ('TEAMCITY_VERSION' in env) { + return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0; + } - Stream.call(this); + if (env.COLORTERM === 'truecolor') { + return 3; + } - this.path = path; - this.fd = null; - this.writable = true; + if ('TERM_PROGRAM' in env) { + const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10); - this.flags = 'w'; - this.encoding = 'binary'; - this.mode = 438; /*=0666*/ - this.bytesWritten = 0; + switch (env.TERM_PROGRAM) { + case 'iTerm.app': + return version >= 3 ? 3 : 2; + case 'Apple_Terminal': + return 2; + // No default + } + } - options = options || {}; + if (/-256(color)?$/i.test(env.TERM)) { + return 2; + } - // Mixin options into this - var keys = Object.keys(options); - for (var index = 0, length = keys.length; index < length; index++) { - var key = keys[index]; - this[key] = options[key]; - } + if (/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) { + return 1; + } - if (this.start !== undefined) { - if ('number' !== typeof this.start) { - throw TypeError('start must be a Number'); - } - if (this.start < 0) { - throw new Error('start must be >= zero'); - } + if ('COLORTERM' in env) { + return 1; + } - this.pos = this.start; - } + if (env.TERM === 'dumb') { + return min; + } - this.busy = false; - this._queue = []; + return min; +} - if (this.fd === null) { - this._open = fs.open; - this._queue.push([this._open, this.path, this.flags, this.mode, undefined]); - this.flush(); - } - } +function getSupportLevel(stream) { + const level = supportsColor(stream); + return translateLevel(level); } +module.exports = { + supportsColor: getSupportLevel, + stdout: getSupportLevel(process.stdout), + stderr: getSupportLevel(process.stderr) +}; + /***/ }), -/* 667 */ +/* 680 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; +const TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi; +const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g; +const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/; +const ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi; -module.exports = clone +const ESCAPES = new Map([ + ['n', '\n'], + ['r', '\r'], + ['t', '\t'], + ['b', '\b'], + ['f', '\f'], + ['v', '\v'], + ['0', '\0'], + ['\\', '\\'], + ['e', '\u001B'], + ['a', '\u0007'] +]); -function clone (obj) { - if (obj === null || typeof obj !== 'object') - return obj +function unescape(c) { + if ((c[0] === 'u' && c.length === 5) || (c[0] === 'x' && c.length === 3)) { + return String.fromCharCode(parseInt(c.slice(1), 16)); + } - if (obj instanceof Object) - var copy = { __proto__: obj.__proto__ } - else - var copy = Object.create(null) + return ESCAPES.get(c) || c; +} - Object.getOwnPropertyNames(obj).forEach(function (key) { - Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key)) - }) +function parseArguments(name, args) { + const results = []; + const chunks = args.trim().split(/\s*,\s*/g); + let matches; - return copy + for (const chunk of chunks) { + if (!isNaN(chunk)) { + results.push(Number(chunk)); + } else if ((matches = chunk.match(STRING_REGEX))) { + results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr)); + } else { + throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`); + } + } + + return results; } +function parseStyle(style) { + STYLE_REGEX.lastIndex = 0; -/***/ }), -/* 668 */ -/***/ (function(module, exports, __webpack_require__) { + const results = []; + let matches; -"use strict"; + while ((matches = STYLE_REGEX.exec(style)) !== null) { + const name = matches[1]; -const path = __webpack_require__(16); + if (matches[2]) { + const args = parseArguments(name, matches[2]); + results.push([name].concat(args)); + } else { + results.push([name]); + } + } -module.exports = path_ => { - let cwd = process.cwd(); + return results; +} - path_ = path.resolve(path_); +function buildStyle(chalk, styles) { + const enabled = {}; - if (process.platform === 'win32') { - cwd = cwd.toLowerCase(); - path_ = path_.toLowerCase(); + for (const layer of styles) { + for (const style of layer.styles) { + enabled[style[0]] = layer.inverse ? null : style.slice(1); + } } - return path_ === cwd; + let current = chalk; + for (const styleName of Object.keys(enabled)) { + if (Array.isArray(enabled[styleName])) { + if (!(styleName in current)) { + throw new Error(`Unknown Chalk style: ${styleName}`); + } + + if (enabled[styleName].length > 0) { + current = current[styleName].apply(current, enabled[styleName]); + } else { + current = current[styleName]; + } + } + } + + return current; +} + +module.exports = (chalk, tmp) => { + const styles = []; + const chunks = []; + let chunk = []; + + // eslint-disable-next-line max-params + tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => { + if (escapeChar) { + chunk.push(unescape(escapeChar)); + } else if (style) { + const str = chunk.join(''); + chunk = []; + chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str)); + styles.push({inverse, styles: parseStyle(style)}); + } else if (close) { + if (styles.length === 0) { + throw new Error('Found extraneous } in Chalk template literal'); + } + + chunks.push(buildStyle(chalk, styles)(chunk.join(''))); + chunk = []; + styles.pop(); + } else { + chunk.push(chr); + } + }); + + chunks.push(chunk.join('')); + + if (styles.length > 0) { + const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`; + throw new Error(errMsg); + } + + return chunks.join(''); }; /***/ }), -/* 669 */ +/* 681 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const path = __webpack_require__(16); +const restoreCursor = __webpack_require__(682); -module.exports = (childPath, parentPath) => { - childPath = path.resolve(childPath); - parentPath = path.resolve(parentPath); +let hidden = false; - if (process.platform === 'win32') { - childPath = childPath.toLowerCase(); - parentPath = parentPath.toLowerCase(); +exports.show = stream => { + const s = stream || process.stderr; + + if (!s.isTTY) { + return; } - if (childPath === parentPath) { - return false; + hidden = false; + s.write('\u001b[?25h'); +}; + +exports.hide = stream => { + const s = stream || process.stderr; + + if (!s.isTTY) { + return; } - childPath += path.sep; - parentPath += path.sep; + restoreCursor(); + hidden = true; + s.write('\u001b[?25l'); +}; - return childPath.startsWith(parentPath); +exports.toggle = (force, stream) => { + if (force !== undefined) { + hidden = force; + } + + if (hidden) { + exports.show(stream); + } else { + exports.hide(stream); + } }; /***/ }), -/* 670 */ +/* 682 */ /***/ (function(module, exports, __webpack_require__) { -const assert = __webpack_require__(30) -const path = __webpack_require__(16) -const fs = __webpack_require__(23) -let glob = undefined -try { - glob = __webpack_require__(502) -} catch (_err) { - // treat glob as optional. -} +"use strict"; -const defaultGlobOpts = { - nosort: true, - silent: true -} +const onetime = __webpack_require__(683); +const signalExit = __webpack_require__(377); -// for EMFILE handling -let timeout = 0 +module.exports = onetime(() => { + signalExit(() => { + process.stderr.write('\u001b[?25h'); + }, {alwaysLast: true}); +}); -const isWindows = (process.platform === "win32") -const defaults = options => { - const methods = [ - 'unlink', - 'chmod', - 'stat', - 'lstat', - 'rmdir', - 'readdir' - ] - methods.forEach(m => { - options[m] = options[m] || fs[m] - m = m + 'Sync' - options[m] = options[m] || fs[m] - }) +/***/ }), +/* 683 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +const mimicFn = __webpack_require__(684); + +module.exports = (fn, opts) => { + // TODO: Remove this in v3 + if (opts === true) { + throw new TypeError('The second argument is now an options object'); + } + + if (typeof fn !== 'function') { + throw new TypeError('Expected a function'); + } + + opts = opts || {}; + + let ret; + let called = false; + const fnName = fn.displayName || fn.name || ''; - options.maxBusyTries = options.maxBusyTries || 3 - options.emfileWait = options.emfileWait || 1000 - if (options.glob === false) { - options.disableGlob = true - } - if (options.disableGlob !== true && glob === undefined) { - throw Error('glob dependency not found, set `options.disableGlob = true` if intentional') - } - options.disableGlob = options.disableGlob || false - options.glob = options.glob || defaultGlobOpts -} + const onetime = function () { + if (called) { + if (opts.throw === true) { + throw new Error(`Function \`${fnName}\` can only be called once`); + } -const rimraf = (p, options, cb) => { - if (typeof options === 'function') { - cb = options - options = {} - } + return ret; + } - assert(p, 'rimraf: missing path') - assert.equal(typeof p, 'string', 'rimraf: path should be a string') - assert.equal(typeof cb, 'function', 'rimraf: callback function required') - assert(options, 'rimraf: invalid options argument provided') - assert.equal(typeof options, 'object', 'rimraf: options should be object') + called = true; + ret = fn.apply(this, arguments); + fn = null; - defaults(options) + return ret; + }; - let busyTries = 0 - let errState = null - let n = 0 + mimicFn(onetime, fn); - const next = (er) => { - errState = errState || er - if (--n === 0) - cb(errState) - } + return onetime; +}; - const afterGlob = (er, results) => { - if (er) - return cb(er) - n = results.length - if (n === 0) - return cb() +/***/ }), +/* 684 */ +/***/ (function(module, exports, __webpack_require__) { - results.forEach(p => { - const CB = (er) => { - if (er) { - if ((er.code === "EBUSY" || er.code === "ENOTEMPTY" || er.code === "EPERM") && - busyTries < options.maxBusyTries) { - busyTries ++ - // try again, with the same exact callback as this one. - return setTimeout(() => rimraf_(p, options, CB), busyTries * 100) - } +"use strict"; - // this one won't happen if graceful-fs is used. - if (er.code === "EMFILE" && timeout < options.emfileWait) { - return setTimeout(() => rimraf_(p, options, CB), timeout ++) - } +module.exports = (to, from) => { + // TODO: use `Reflect.ownKeys()` when targeting Node.js 6 + for (const prop of Object.getOwnPropertyNames(from).concat(Object.getOwnPropertySymbols(from))) { + Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(from, prop)); + } - // already gone - if (er.code === "ENOENT") er = null - } + return to; +}; - timeout = 0 - next(er) - } - rimraf_(p, options, CB) - }) - } - if (options.disableGlob || !glob.hasMagic(p)) - return afterGlob(null, [p]) +/***/ }), +/* 685 */ +/***/ (function(module, exports, __webpack_require__) { - options.lstat(p, (er, stat) => { - if (!er) - return afterGlob(null, [p]) +"use strict"; - glob(p, options.glob, afterGlob) - }) +module.exports = __webpack_require__(686); -} -// Two possible strategies. -// 1. Assume it's a file. unlink it, then do the dir stuff on EPERM or EISDIR -// 2. Assume it's a directory. readdir, then do the file stuff on ENOTDIR -// -// Both result in an extra syscall when you guess wrong. However, there -// are likely far more normal files in the world than directories. This -// is based on the assumption that a the average number of files per -// directory is >= 1. -// -// If anyone ever complains about this, then I guess the strategy could -// be made configurable somehow. But until then, YAGNI. -const rimraf_ = (p, options, cb) => { - assert(p) - assert(options) - assert(typeof cb === 'function') +/***/ }), +/* 686 */ +/***/ (function(module) { - // sunos lets the root user unlink directories, which is... weird. - // so we have to lstat here and make sure it's not a dir. - options.lstat(p, (er, st) => { - if (er && er.code === "ENOENT") - return cb(null) +module.exports = JSON.parse("{\"dots\":{\"interval\":80,\"frames\":[\"⠋\",\"⠙\",\"⠹\",\"⠸\",\"⠼\",\"⠴\",\"⠦\",\"⠧\",\"⠇\",\"⠏\"]},\"dots2\":{\"interval\":80,\"frames\":[\"⣾\",\"⣽\",\"⣻\",\"⢿\",\"⡿\",\"⣟\",\"⣯\",\"⣷\"]},\"dots3\":{\"interval\":80,\"frames\":[\"⠋\",\"⠙\",\"⠚\",\"⠞\",\"⠖\",\"⠦\",\"⠴\",\"⠲\",\"⠳\",\"⠓\"]},\"dots4\":{\"interval\":80,\"frames\":[\"⠄\",\"⠆\",\"⠇\",\"⠋\",\"⠙\",\"⠸\",\"⠰\",\"⠠\",\"⠰\",\"⠸\",\"⠙\",\"⠋\",\"⠇\",\"⠆\"]},\"dots5\":{\"interval\":80,\"frames\":[\"⠋\",\"⠙\",\"⠚\",\"⠒\",\"⠂\",\"⠂\",\"⠒\",\"⠲\",\"⠴\",\"⠦\",\"⠖\",\"⠒\",\"⠐\",\"⠐\",\"⠒\",\"⠓\",\"⠋\"]},\"dots6\":{\"interval\":80,\"frames\":[\"⠁\",\"⠉\",\"⠙\",\"⠚\",\"⠒\",\"⠂\",\"⠂\",\"⠒\",\"⠲\",\"⠴\",\"⠤\",\"⠄\",\"⠄\",\"⠤\",\"⠴\",\"⠲\",\"⠒\",\"⠂\",\"⠂\",\"⠒\",\"⠚\",\"⠙\",\"⠉\",\"⠁\"]},\"dots7\":{\"interval\":80,\"frames\":[\"⠈\",\"⠉\",\"⠋\",\"⠓\",\"⠒\",\"⠐\",\"⠐\",\"⠒\",\"⠖\",\"⠦\",\"⠤\",\"⠠\",\"⠠\",\"⠤\",\"⠦\",\"⠖\",\"⠒\",\"⠐\",\"⠐\",\"⠒\",\"⠓\",\"⠋\",\"⠉\",\"⠈\"]},\"dots8\":{\"interval\":80,\"frames\":[\"⠁\",\"⠁\",\"⠉\",\"⠙\",\"⠚\",\"⠒\",\"⠂\",\"⠂\",\"⠒\",\"⠲\",\"⠴\",\"⠤\",\"⠄\",\"⠄\",\"⠤\",\"⠠\",\"⠠\",\"⠤\",\"⠦\",\"⠖\",\"⠒\",\"⠐\",\"⠐\",\"⠒\",\"⠓\",\"⠋\",\"⠉\",\"⠈\",\"⠈\"]},\"dots9\":{\"interval\":80,\"frames\":[\"⢹\",\"⢺\",\"⢼\",\"⣸\",\"⣇\",\"⡧\",\"⡗\",\"⡏\"]},\"dots10\":{\"interval\":80,\"frames\":[\"⢄\",\"⢂\",\"⢁\",\"⡁\",\"⡈\",\"⡐\",\"⡠\"]},\"dots11\":{\"interval\":100,\"frames\":[\"⠁\",\"⠂\",\"⠄\",\"⡀\",\"⢀\",\"⠠\",\"⠐\",\"⠈\"]},\"dots12\":{\"interval\":80,\"frames\":[\"⢀⠀\",\"⡀⠀\",\"⠄⠀\",\"⢂⠀\",\"⡂⠀\",\"⠅⠀\",\"⢃⠀\",\"⡃⠀\",\"⠍⠀\",\"⢋⠀\",\"⡋⠀\",\"⠍⠁\",\"⢋⠁\",\"⡋⠁\",\"⠍⠉\",\"⠋⠉\",\"⠋⠉\",\"⠉⠙\",\"⠉⠙\",\"⠉⠩\",\"⠈⢙\",\"⠈⡙\",\"⢈⠩\",\"⡀⢙\",\"⠄⡙\",\"⢂⠩\",\"⡂⢘\",\"⠅⡘\",\"⢃⠨\",\"⡃⢐\",\"⠍⡐\",\"⢋⠠\",\"⡋⢀\",\"⠍⡁\",\"⢋⠁\",\"⡋⠁\",\"⠍⠉\",\"⠋⠉\",\"⠋⠉\",\"⠉⠙\",\"⠉⠙\",\"⠉⠩\",\"⠈⢙\",\"⠈⡙\",\"⠈⠩\",\"⠀⢙\",\"⠀⡙\",\"⠀⠩\",\"⠀⢘\",\"⠀⡘\",\"⠀⠨\",\"⠀⢐\",\"⠀⡐\",\"⠀⠠\",\"⠀⢀\",\"⠀⡀\"]},\"line\":{\"interval\":130,\"frames\":[\"-\",\"\\\\\",\"|\",\"/\"]},\"line2\":{\"interval\":100,\"frames\":[\"⠂\",\"-\",\"–\",\"—\",\"–\",\"-\"]},\"pipe\":{\"interval\":100,\"frames\":[\"┤\",\"┘\",\"┴\",\"└\",\"├\",\"┌\",\"┬\",\"┐\"]},\"simpleDots\":{\"interval\":400,\"frames\":[\". \",\".. \",\"...\",\" \"]},\"simpleDotsScrolling\":{\"interval\":200,\"frames\":[\". \",\".. \",\"...\",\" ..\",\" .\",\" \"]},\"star\":{\"interval\":70,\"frames\":[\"✶\",\"✸\",\"✹\",\"✺\",\"✹\",\"✷\"]},\"star2\":{\"interval\":80,\"frames\":[\"+\",\"x\",\"*\"]},\"flip\":{\"interval\":70,\"frames\":[\"_\",\"_\",\"_\",\"-\",\"`\",\"`\",\"'\",\"´\",\"-\",\"_\",\"_\",\"_\"]},\"hamburger\":{\"interval\":100,\"frames\":[\"☱\",\"☲\",\"☴\"]},\"growVertical\":{\"interval\":120,\"frames\":[\"▁\",\"▃\",\"▄\",\"▅\",\"▆\",\"▇\",\"▆\",\"▅\",\"▄\",\"▃\"]},\"growHorizontal\":{\"interval\":120,\"frames\":[\"▏\",\"▎\",\"▍\",\"▌\",\"▋\",\"▊\",\"▉\",\"▊\",\"▋\",\"▌\",\"▍\",\"▎\"]},\"balloon\":{\"interval\":140,\"frames\":[\" \",\".\",\"o\",\"O\",\"@\",\"*\",\" \"]},\"balloon2\":{\"interval\":120,\"frames\":[\".\",\"o\",\"O\",\"°\",\"O\",\"o\",\".\"]},\"noise\":{\"interval\":100,\"frames\":[\"▓\",\"▒\",\"░\"]},\"bounce\":{\"interval\":120,\"frames\":[\"⠁\",\"⠂\",\"⠄\",\"⠂\"]},\"boxBounce\":{\"interval\":120,\"frames\":[\"▖\",\"▘\",\"▝\",\"▗\"]},\"boxBounce2\":{\"interval\":100,\"frames\":[\"▌\",\"▀\",\"▐\",\"▄\"]},\"triangle\":{\"interval\":50,\"frames\":[\"◢\",\"◣\",\"◤\",\"◥\"]},\"arc\":{\"interval\":100,\"frames\":[\"◜\",\"◠\",\"◝\",\"◞\",\"◡\",\"◟\"]},\"circle\":{\"interval\":120,\"frames\":[\"◡\",\"⊙\",\"◠\"]},\"squareCorners\":{\"interval\":180,\"frames\":[\"◰\",\"◳\",\"◲\",\"◱\"]},\"circleQuarters\":{\"interval\":120,\"frames\":[\"◴\",\"◷\",\"◶\",\"◵\"]},\"circleHalves\":{\"interval\":50,\"frames\":[\"◐\",\"◓\",\"◑\",\"◒\"]},\"squish\":{\"interval\":100,\"frames\":[\"╫\",\"╪\"]},\"toggle\":{\"interval\":250,\"frames\":[\"⊶\",\"⊷\"]},\"toggle2\":{\"interval\":80,\"frames\":[\"▫\",\"▪\"]},\"toggle3\":{\"interval\":120,\"frames\":[\"□\",\"■\"]},\"toggle4\":{\"interval\":100,\"frames\":[\"■\",\"□\",\"▪\",\"▫\"]},\"toggle5\":{\"interval\":100,\"frames\":[\"▮\",\"▯\"]},\"toggle6\":{\"interval\":300,\"frames\":[\"ဝ\",\"၀\"]},\"toggle7\":{\"interval\":80,\"frames\":[\"⦾\",\"⦿\"]},\"toggle8\":{\"interval\":100,\"frames\":[\"◍\",\"◌\"]},\"toggle9\":{\"interval\":100,\"frames\":[\"◉\",\"◎\"]},\"toggle10\":{\"interval\":100,\"frames\":[\"㊂\",\"㊀\",\"㊁\"]},\"toggle11\":{\"interval\":50,\"frames\":[\"⧇\",\"⧆\"]},\"toggle12\":{\"interval\":120,\"frames\":[\"☗\",\"☖\"]},\"toggle13\":{\"interval\":80,\"frames\":[\"=\",\"*\",\"-\"]},\"arrow\":{\"interval\":100,\"frames\":[\"←\",\"↖\",\"↑\",\"↗\",\"→\",\"↘\",\"↓\",\"↙\"]},\"arrow2\":{\"interval\":80,\"frames\":[\"⬆️ \",\"↗️ \",\"➡️ \",\"↘️ \",\"⬇️ \",\"↙️ \",\"⬅️ \",\"↖️ \"]},\"arrow3\":{\"interval\":120,\"frames\":[\"▹▹▹▹▹\",\"▸▹▹▹▹\",\"▹▸▹▹▹\",\"▹▹▸▹▹\",\"▹▹▹▸▹\",\"▹▹▹▹▸\"]},\"bouncingBar\":{\"interval\":80,\"frames\":[\"[ ]\",\"[= ]\",\"[== ]\",\"[=== ]\",\"[ ===]\",\"[ ==]\",\"[ =]\",\"[ ]\",\"[ =]\",\"[ ==]\",\"[ ===]\",\"[====]\",\"[=== ]\",\"[== ]\",\"[= ]\"]},\"bouncingBall\":{\"interval\":80,\"frames\":[\"( ● )\",\"( ● )\",\"( ● )\",\"( ● )\",\"( ●)\",\"( ● )\",\"( ● )\",\"( ● )\",\"( ● )\",\"(● )\"]},\"smiley\":{\"interval\":200,\"frames\":[\"😄 \",\"😝 \"]},\"monkey\":{\"interval\":300,\"frames\":[\"🙈 \",\"🙈 \",\"🙉 \",\"🙊 \"]},\"hearts\":{\"interval\":100,\"frames\":[\"💛 \",\"💙 \",\"💜 \",\"💚 \",\"❤️ \"]},\"clock\":{\"interval\":100,\"frames\":[\"🕐 \",\"🕑 \",\"🕒 \",\"🕓 \",\"🕔 \",\"🕕 \",\"🕖 \",\"🕗 \",\"🕘 \",\"🕙 \",\"🕚 \"]},\"earth\":{\"interval\":180,\"frames\":[\"🌍 \",\"🌎 \",\"🌏 \"]},\"moon\":{\"interval\":80,\"frames\":[\"🌑 \",\"🌒 \",\"🌓 \",\"🌔 \",\"🌕 \",\"🌖 \",\"🌗 \",\"🌘 \"]},\"runner\":{\"interval\":140,\"frames\":[\"🚶 \",\"🏃 \"]},\"pong\":{\"interval\":80,\"frames\":[\"▐⠂ ▌\",\"▐⠈ ▌\",\"▐ ⠂ ▌\",\"▐ ⠠ ▌\",\"▐ ⡀ ▌\",\"▐ ⠠ ▌\",\"▐ ⠂ ▌\",\"▐ ⠈ ▌\",\"▐ ⠂ ▌\",\"▐ ⠠ ▌\",\"▐ ⡀ ▌\",\"▐ ⠠ ▌\",\"▐ ⠂ ▌\",\"▐ ⠈ ▌\",\"▐ ⠂▌\",\"▐ ⠠▌\",\"▐ ⡀▌\",\"▐ ⠠ ▌\",\"▐ ⠂ ▌\",\"▐ ⠈ ▌\",\"▐ ⠂ ▌\",\"▐ ⠠ ▌\",\"▐ ⡀ ▌\",\"▐ ⠠ ▌\",\"▐ ⠂ ▌\",\"▐ ⠈ ▌\",\"▐ ⠂ ▌\",\"▐ ⠠ ▌\",\"▐ ⡀ ▌\",\"▐⠠ ▌\"]},\"shark\":{\"interval\":120,\"frames\":[\"▐|\\\\____________▌\",\"▐_|\\\\___________▌\",\"▐__|\\\\__________▌\",\"▐___|\\\\_________▌\",\"▐____|\\\\________▌\",\"▐_____|\\\\_______▌\",\"▐______|\\\\______▌\",\"▐_______|\\\\_____▌\",\"▐________|\\\\____▌\",\"▐_________|\\\\___▌\",\"▐__________|\\\\__▌\",\"▐___________|\\\\_▌\",\"▐____________|\\\\▌\",\"▐____________/|▌\",\"▐___________/|_▌\",\"▐__________/|__▌\",\"▐_________/|___▌\",\"▐________/|____▌\",\"▐_______/|_____▌\",\"▐______/|______▌\",\"▐_____/|_______▌\",\"▐____/|________▌\",\"▐___/|_________▌\",\"▐__/|__________▌\",\"▐_/|___________▌\",\"▐/|____________▌\"]},\"dqpb\":{\"interval\":100,\"frames\":[\"d\",\"q\",\"p\",\"b\"]},\"weather\":{\"interval\":100,\"frames\":[\"☀️ \",\"☀️ \",\"☀️ \",\"🌤 \",\"⛅️ \",\"🌥 \",\"☁️ \",\"🌧 \",\"🌨 \",\"🌧 \",\"🌨 \",\"🌧 \",\"🌨 \",\"⛈ \",\"🌨 \",\"🌧 \",\"🌨 \",\"☁️ \",\"🌥 \",\"⛅️ \",\"🌤 \",\"☀️ \",\"☀️ \"]},\"christmas\":{\"interval\":400,\"frames\":[\"🌲\",\"🎄\"]}}"); - // Windows can EPERM on stat. Life is suffering. - if (er && er.code === "EPERM" && isWindows) - fixWinEPERM(p, options, er, cb) +/***/ }), +/* 687 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - if (st && st.isDirectory()) - return rmdir(p, options, er, cb) +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RunCommand", function() { return RunCommand; }); +/* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2); +/* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _utils_log__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(34); +/* harmony import */ var _utils_parallelize__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(500); +/* harmony import */ var _utils_projects__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(501); +/* + * 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. + */ - options.unlink(p, er => { - if (er) { - if (er.code === "ENOENT") - return cb(null) - if (er.code === "EPERM") - return (isWindows) - ? fixWinEPERM(p, options, er, cb) - : rmdir(p, options, er, cb) - if (er.code === "EISDIR") - return rmdir(p, options, er, cb) - } - return cb(er) - }) - }) -} -const fixWinEPERM = (p, options, er, cb) => { - assert(p) - assert(options) - assert(typeof cb === 'function') - if (er) - assert(er instanceof Error) - options.chmod(p, 0o666, er2 => { - if (er2) - cb(er2.code === "ENOENT" ? null : er) - else - options.stat(p, (er3, stats) => { - if (er3) - cb(er3.code === "ENOENT" ? null : er) - else if (stats.isDirectory()) - rmdir(p, options, er, cb) - else - options.unlink(p, cb) - }) - }) -} -const fixWinEPERMSync = (p, options, er) => { - assert(p) - assert(options) - if (er) - assert(er instanceof Error) +const RunCommand = { + description: 'Run script defined in package.json in each package that contains that script.', + name: 'run', - try { - options.chmodSync(p, 0o666) - } catch (er2) { - if (er2.code === "ENOENT") - return - else - throw er - } + async run(projects, projectGraph, { + extraArgs + }) { + const batchedProjects = Object(_utils_projects__WEBPACK_IMPORTED_MODULE_3__["topologicallyBatchProjects"])(projects, projectGraph); - let stats - try { - stats = options.statSync(p) - } catch (er3) { - if (er3.code === "ENOENT") - return - else - throw er + if (extraArgs.length === 0) { + _utils_log__WEBPACK_IMPORTED_MODULE_1__["log"].write(chalk__WEBPACK_IMPORTED_MODULE_0___default.a.red.bold('\nNo script specified')); + process.exit(1); + } + + const scriptName = extraArgs[0]; + const scriptArgs = extraArgs.slice(1); + _utils_log__WEBPACK_IMPORTED_MODULE_1__["log"].write(chalk__WEBPACK_IMPORTED_MODULE_0___default.a.bold(`\nRunning script [${chalk__WEBPACK_IMPORTED_MODULE_0___default.a.green(scriptName)}] in batched topological order\n`)); + await Object(_utils_parallelize__WEBPACK_IMPORTED_MODULE_2__["parallelizeBatches"])(batchedProjects, async pkg => { + if (pkg.hasScript(scriptName)) { + await pkg.runScriptStreaming(scriptName, scriptArgs); + } + }); } - if (stats.isDirectory()) - rmdirSync(p, options, er) - else - options.unlinkSync(p) -} +}; -const rmdir = (p, options, originalEr, cb) => { - assert(p) - assert(options) - if (originalEr) - assert(originalEr instanceof Error) - assert(typeof cb === 'function') +/***/ }), +/* 688 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - // try to rmdir first, and only readdir on ENOTEMPTY or EEXIST (SunOS) - // if we guessed wrong, and it's not a directory, then - // raise the original error. - options.rmdir(p, er => { - if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM")) - rmkids(p, options, cb) - else if (er && er.code === "ENOTDIR") - cb(originalEr) - else - cb(er) - }) -} +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WatchCommand", function() { return WatchCommand; }); +/* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2); +/* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _utils_log__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(34); +/* harmony import */ var _utils_parallelize__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(500); +/* harmony import */ var _utils_projects__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(501); +/* harmony import */ var _utils_watch__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(689); +/* + * 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. + */ -const rmkids = (p, options, cb) => { - assert(p) - assert(options) - assert(typeof cb === 'function') - options.readdir(p, (er, files) => { - if (er) - return cb(er) - let n = files.length - if (n === 0) - return options.rmdir(p, cb) - let errState - files.forEach(f => { - rimraf(path.join(p, f), options, er => { - if (errState) - return - if (er) - return cb(errState = er) - if (--n === 0) - options.rmdir(p, cb) - }) - }) - }) -} -// this looks simpler, and is strictly *faster*, but will -// tie up the JavaScript thread and fail on excessively -// deep directory trees. -const rimrafSync = (p, options) => { - options = options || {} - defaults(options) - assert(p, 'rimraf: missing path') - assert.equal(typeof p, 'string', 'rimraf: path should be a string') - assert(options, 'rimraf: missing options') - assert.equal(typeof options, 'object', 'rimraf: options should be object') - let results - if (options.disableGlob || !glob.hasMagic(p)) { - results = [p] - } else { - try { - options.lstatSync(p) - results = [p] - } catch (er) { - results = glob.sync(p, options.glob) - } - } +/** + * Name of the script in the package/project package.json file to run during `kbn watch`. + */ +const watchScriptName = 'kbn:watch'; +/** + * Name of the Kibana project. + */ - if (!results.length) - return +const kibanaProjectName = 'kibana'; +/** + * Command that traverses through list of available projects/packages that have `kbn:watch` script in their + * package.json files, groups them into topology aware batches and then processes theses batches one by one + * running `kbn:watch` scripts in parallel within the same batch. + * + * Command internally relies on the fact that most of the build systems that are triggered by `kbn:watch` + * will emit special "marker" once build/watch process is ready that we can use as completion condition for + * the `kbn:watch` script and eventually for the entire batch. Currently we support completion "markers" for + * `webpack` and `tsc` only, for the rest we rely on predefined timeouts. + */ - for (let i = 0; i < results.length; i++) { - const p = results[i] +const WatchCommand = { + description: 'Runs `kbn:watch` script for every project.', + name: 'watch', - let st - try { - st = options.lstatSync(p) - } catch (er) { - if (er.code === "ENOENT") - return + async run(projects, projectGraph) { + const projectsToWatch = new Map(); - // Windows can EPERM on stat. Life is suffering. - if (er.code === "EPERM" && isWindows) - fixWinEPERMSync(p, options, er) + for (const project of projects.values()) { + // We can't watch project that doesn't have `kbn:watch` script. + if (project.hasScript(watchScriptName)) { + projectsToWatch.set(project.name, project); + } } - try { - // sunos lets the root user unlink directories, which is... weird. - if (st && st.isDirectory()) - rmdirSync(p, options, null) - else - options.unlinkSync(p) - } catch (er) { - if (er.code === "ENOENT") - return - if (er.code === "EPERM") - return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er) - if (er.code !== "EISDIR") - throw er - - rmdirSync(p, options, er) + if (projectsToWatch.size === 0) { + _utils_log__WEBPACK_IMPORTED_MODULE_1__["log"].write(chalk__WEBPACK_IMPORTED_MODULE_0___default.a.red(`\nThere are no projects to watch found. Make sure that projects define 'kbn:watch' script in 'package.json'.\n`)); + return; } - } -} - -const rmdirSync = (p, options, originalEr) => { - assert(p) - assert(options) - if (originalEr) - assert(originalEr instanceof Error) - try { - options.rmdirSync(p) - } catch (er) { - if (er.code === "ENOENT") - return - if (er.code === "ENOTDIR") - throw originalEr - if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM") - rmkidsSync(p, options) - } -} + const projectNames = Array.from(projectsToWatch.keys()); + _utils_log__WEBPACK_IMPORTED_MODULE_1__["log"].write(chalk__WEBPACK_IMPORTED_MODULE_0___default.a.bold(chalk__WEBPACK_IMPORTED_MODULE_0___default.a.green(`Running ${watchScriptName} scripts for [${projectNames.join(', ')}].`))); // Kibana should always be run the last, so we don't rely on automatic + // topological batching and push it to the last one-entry batch manually. -const rmkidsSync = (p, options) => { - assert(p) - assert(options) - options.readdirSync(p).forEach(f => rimrafSync(path.join(p, f), options)) + const shouldWatchKibanaProject = projectsToWatch.delete(kibanaProjectName); + const batchedProjects = Object(_utils_projects__WEBPACK_IMPORTED_MODULE_3__["topologicallyBatchProjects"])(projectsToWatch, projectGraph); - // We only end up here once we got ENOTEMPTY at least once, and - // at this point, we are guaranteed to have removed all the kids. - // So, we know that it won't be ENOENT or ENOTDIR or anything else. - // try really hard to delete stuff on windows, because it has a - // PROFOUNDLY annoying habit of not closing handles promptly when - // files are deleted, resulting in spurious ENOTEMPTY errors. - const retries = isWindows ? 100 : 1 - let i = 0 - do { - let threw = true - try { - const ret = options.rmdirSync(p, options) - threw = false - return ret - } finally { - if (++i < retries && threw) - continue + if (shouldWatchKibanaProject) { + batchedProjects.push([projects.get(kibanaProjectName)]); } - } while (true) -} -module.exports = rimraf -rimraf.sync = rimrafSync + await Object(_utils_parallelize__WEBPACK_IMPORTED_MODULE_2__["parallelizeBatches"])(batchedProjects, async pkg => { + const completionHint = await Object(_utils_watch__WEBPACK_IMPORTED_MODULE_4__["waitUntilWatchIsReady"])(pkg.runScriptStreaming(watchScriptName).stdout); + _utils_log__WEBPACK_IMPORTED_MODULE_1__["log"].write(chalk__WEBPACK_IMPORTED_MODULE_0___default.a.bold(`[${chalk__WEBPACK_IMPORTED_MODULE_0___default.a.green(pkg.name)}] Initial build completed (${completionHint}).`)); + }); + } +}; /***/ }), -/* 671 */ -/***/ (function(module, exports, __webpack_require__) { +/* 689 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "waitUntilWatchIsReady", function() { return waitUntilWatchIsReady; }); +/* harmony import */ var rxjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(392); +/* harmony import */ var rxjs_operators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(169); +/* + * 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. + */ -const AggregateError = __webpack_require__(672); -module.exports = async ( - iterable, - mapper, - { - concurrency = Infinity, - stopOnError = true - } = {} -) => { - return new Promise((resolve, reject) => { - if (typeof mapper !== 'function') { - throw new TypeError('Mapper function is required'); - } +/** + * Number of milliseconds we wait before we fall back to the default watch handler. + */ - if (!(typeof concurrency === 'number' && concurrency >= 1)) { - throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${concurrency}\` (${typeof concurrency})`); - } +const defaultHandlerDelay = 3000; +/** + * If default watch handler is used, then it's the number of milliseconds we wait for + * any build output before we consider watch task ready. + */ - const ret = []; - const errors = []; - const iterator = iterable[Symbol.iterator](); - let isRejected = false; - let isIterableDone = false; - let resolvingCount = 0; - let currentIndex = 0; +const defaultHandlerReadinessTimeout = 2000; +/** + * Describes configurable watch options. + */ + +function getWatchHandlers(buildOutput$, { + handlerDelay = defaultHandlerDelay, + handlerReadinessTimeout = defaultHandlerReadinessTimeout +}) { + const typescriptHandler = buildOutput$.pipe(Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["first"])(data => data.includes('$ tsc')), Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["map"])(() => buildOutput$.pipe(Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["first"])(data => data.includes('Compilation complete.')), Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["mapTo"])('tsc')))); + const webpackHandler = buildOutput$.pipe(Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["first"])(data => data.includes('$ webpack')), Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["map"])(() => buildOutput$.pipe(Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["first"])(data => data.includes('Chunk Names')), Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["mapTo"])('webpack')))); + const defaultHandler = rxjs__WEBPACK_IMPORTED_MODULE_0__["of"](undefined).pipe(Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["delay"])(handlerReadinessTimeout), Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["map"])(() => buildOutput$.pipe(Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["timeout"])(handlerDelay), Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["catchError"])(() => rxjs__WEBPACK_IMPORTED_MODULE_0__["of"]('timeout'))))); + return [typescriptHandler, webpackHandler, defaultHandler]; +} - const next = () => { - if (isRejected) { - return; - } +function waitUntilWatchIsReady(stream, opts = {}) { + const buildOutput$ = new rxjs__WEBPACK_IMPORTED_MODULE_0__["Subject"](); - const nextItem = iterator.next(); - const i = currentIndex; - currentIndex++; + const onDataListener = data => buildOutput$.next(data.toString('utf-8')); - if (nextItem.done) { - isIterableDone = true; + const onEndListener = () => buildOutput$.complete(); - if (resolvingCount === 0) { - if (!stopOnError && errors.length !== 0) { - reject(new AggregateError(errors)); - } else { - resolve(ret); - } - } + const onErrorListener = e => buildOutput$.error(e); - return; - } + stream.once('end', onEndListener); + stream.once('error', onErrorListener); + stream.on('data', onDataListener); + return rxjs__WEBPACK_IMPORTED_MODULE_0__["race"](getWatchHandlers(buildOutput$, opts)).pipe(Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["mergeMap"])(whenReady => whenReady), Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["finalize"])(() => { + stream.removeListener('data', onDataListener); + stream.removeListener('end', onEndListener); + stream.removeListener('error', onErrorListener); + buildOutput$.complete(); + })).toPromise(); +} - resolvingCount++; +/***/ }), +/* 690 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - (async () => { - try { - const element = await nextItem.value; - ret[i] = await mapper(element, i); - resolvingCount--; - next(); - } catch (error) { - if (stopOnError) { - isRejected = true; - reject(error); - } else { - errors.push(error); - resolvingCount--; - next(); - } - } - })(); - }; +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "runCommand", function() { return runCommand; }); +/* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2); +/* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var indent_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(691); +/* harmony import */ var indent_string__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(indent_string__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var wrap_ansi__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(692); +/* harmony import */ var wrap_ansi__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(wrap_ansi__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var _utils_errors__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(515); +/* harmony import */ var _utils_log__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(34); +/* harmony import */ var _utils_projects__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(501); +/* harmony import */ var _utils_projects_tree__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(699); +/* harmony import */ var _utils_kibana__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(700); +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } - for (let i = 0; i < concurrency; i++) { - next(); +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } - if (isIterableDone) { - break; - } - } - }); -}; +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } +/* + * 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. + */ -/***/ }), -/* 672 */ -/***/ (function(module, exports, __webpack_require__) { -"use strict"; -const indentString = __webpack_require__(673); -const cleanStack = __webpack_require__(674); -const cleanInternalStack = stack => stack.replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g, ''); -class AggregateError extends Error { - constructor(errors) { - if (!Array.isArray(errors)) { - throw new TypeError(`Expected input to be an Array, got ${typeof errors}`); - } - errors = [...errors].map(error => { - if (error instanceof Error) { - return error; - } - if (error !== null && typeof error === 'object') { - // Handle plain error objects with message property and/or possibly other metadata - return Object.assign(new Error(error.message), error); - } - return new Error(error); - }); +async function runCommand(command, config) { + try { + _utils_log__WEBPACK_IMPORTED_MODULE_4__["log"].write(chalk__WEBPACK_IMPORTED_MODULE_0___default.a.bold(`Running [${chalk__WEBPACK_IMPORTED_MODULE_0___default.a.green(command.name)}] command from [${chalk__WEBPACK_IMPORTED_MODULE_0___default.a.yellow(config.rootPath)}]:\n`)); + const kbn = await _utils_kibana__WEBPACK_IMPORTED_MODULE_7__["Kibana"].loadFrom(config.rootPath); + const projects = kbn.getFilteredProjects({ + skipKibanaPlugins: Boolean(config.options['skip-kibana-plugins']), + ossOnly: Boolean(config.options.oss), + exclude: toArray(config.options.exclude), + include: toArray(config.options.include) + }); - let message = errors - .map(error => { - // The `stack` property is not standardized, so we can't assume it exists - return typeof error.stack === 'string' ? cleanInternalStack(cleanStack(error.stack)) : String(error); - }) - .join('\n'); - message = '\n' + indentString(message, 4); - super(message); + if (projects.size === 0) { + _utils_log__WEBPACK_IMPORTED_MODULE_4__["log"].write(chalk__WEBPACK_IMPORTED_MODULE_0___default.a.red(`There are no projects found. Double check project name(s) in '-i/--include' and '-e/--exclude' filters.\n`)); + return process.exit(1); + } - this.name = 'AggregateError'; + const projectGraph = Object(_utils_projects__WEBPACK_IMPORTED_MODULE_5__["buildProjectGraph"])(projects); + _utils_log__WEBPACK_IMPORTED_MODULE_4__["log"].write(chalk__WEBPACK_IMPORTED_MODULE_0___default.a.bold(`Found [${chalk__WEBPACK_IMPORTED_MODULE_0___default.a.green(projects.size.toString())}] projects:\n`)); + _utils_log__WEBPACK_IMPORTED_MODULE_4__["log"].write(Object(_utils_projects_tree__WEBPACK_IMPORTED_MODULE_6__["renderProjectsTree"])(config.rootPath, projects)); + await command.run(projects, projectGraph, _objectSpread({}, config, { + kbn + })); + } catch (e) { + _utils_log__WEBPACK_IMPORTED_MODULE_4__["log"].write(chalk__WEBPACK_IMPORTED_MODULE_0___default.a.bold.red(`\n[${command.name}] failed:\n`)); - Object.defineProperty(this, '_errors', {value: errors}); - } + if (e instanceof _utils_errors__WEBPACK_IMPORTED_MODULE_3__["CliError"]) { + const msg = chalk__WEBPACK_IMPORTED_MODULE_0___default.a.red(`CliError: ${e.message}\n`); + _utils_log__WEBPACK_IMPORTED_MODULE_4__["log"].write(wrap_ansi__WEBPACK_IMPORTED_MODULE_2___default()(msg, 80)); + const keys = Object.keys(e.meta); - * [Symbol.iterator]() { - for (const error of this._errors) { - yield error; - } - } + if (keys.length > 0) { + const metaOutput = keys.map(key => { + const value = e.meta[key]; + return `${key}: ${value}`; + }); + _utils_log__WEBPACK_IMPORTED_MODULE_4__["log"].write('Additional debugging info:\n'); + _utils_log__WEBPACK_IMPORTED_MODULE_4__["log"].write(indent_string__WEBPACK_IMPORTED_MODULE_1___default()(metaOutput.join('\n'), 3)); + } + } else { + _utils_log__WEBPACK_IMPORTED_MODULE_4__["log"].write(e.stack); + } + + process.exit(1); + } } -module.exports = AggregateError; +function toArray(value) { + if (value == null) { + return []; + } + return Array.isArray(value) ? value : [value]; +} /***/ }), -/* 673 */ +/* 691 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -77778,1043 +79919,754 @@ module.exports = (str, count, opts) => { /***/ }), -/* 674 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - -const os = __webpack_require__(11); - -const extractPathRegex = /\s+at.*(?:\(|\s)(.*)\)?/; -const pathRegex = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)\.js:\d+:\d+)|native)/; -const homeDir = os.homedir(); - -module.exports = (stack, options) => { - options = Object.assign({pretty: false}, options); - - return stack.replace(/\\/g, '/') - .split('\n') - .filter(line => { - const pathMatches = line.match(extractPathRegex); - if (pathMatches === null || !pathMatches[1]) { - return true; - } - - const match = pathMatches[1]; - - // Electron - if ( - match.includes('.app/Contents/Resources/electron.asar') || - match.includes('.app/Contents/Resources/default_app.asar') - ) { - return false; - } - - return !pathRegex.test(match); - }) - .filter(line => line.trim() !== '') - .map(line => { - if (options.pretty) { - return line.replace(extractPathRegex, (m, p1) => m.replace(p1, p1.replace(homeDir, '~'))); - } - - return line; - }) - .join('\n'); -}; - - -/***/ }), -/* 675 */ +/* 692 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const chalk = __webpack_require__(676); -const cliCursor = __webpack_require__(680); -const cliSpinners = __webpack_require__(684); -const logSymbols = __webpack_require__(566); - -class Ora { - constructor(options) { - if (typeof options === 'string') { - options = { - text: options - }; - } - - this.options = Object.assign({ - text: '', - color: 'cyan', - stream: process.stderr - }, options); - - const sp = this.options.spinner; - this.spinner = typeof sp === 'object' ? sp : (process.platform === 'win32' ? cliSpinners.line : (cliSpinners[sp] || cliSpinners.dots)); // eslint-disable-line no-nested-ternary - - if (this.spinner.frames === undefined) { - throw new Error('Spinner must define `frames`'); - } - - this.text = this.options.text; - this.color = this.options.color; - this.interval = this.options.interval || this.spinner.interval || 100; - this.stream = this.options.stream; - this.id = null; - this.frameIndex = 0; - this.enabled = typeof this.options.enabled === 'boolean' ? this.options.enabled : ((this.stream && this.stream.isTTY) && !process.env.CI); - } - frame() { - const frames = this.spinner.frames; - let frame = frames[this.frameIndex]; - - if (this.color) { - frame = chalk[this.color](frame); - } - - this.frameIndex = ++this.frameIndex % frames.length; - - return frame + ' ' + this.text; - } - clear() { - if (!this.enabled) { - return this; - } - - this.stream.clearLine(); - this.stream.cursorTo(0); - - return this; - } - render() { - this.clear(); - this.stream.write(this.frame()); - - return this; - } - start(text) { - if (text) { - this.text = text; - } - - if (!this.enabled || this.id) { - return this; - } - - cliCursor.hide(this.stream); - this.render(); - this.id = setInterval(this.render.bind(this), this.interval); - - return this; - } - stop() { - if (!this.enabled) { - return this; - } - - clearInterval(this.id); - this.id = null; - this.frameIndex = 0; - this.clear(); - cliCursor.show(this.stream); +const stringWidth = __webpack_require__(693); +const stripAnsi = __webpack_require__(697); - return this; - } - succeed(text) { - return this.stopAndPersist({symbol: logSymbols.success, text}); - } - fail(text) { - return this.stopAndPersist({symbol: logSymbols.error, text}); - } - warn(text) { - return this.stopAndPersist({symbol: logSymbols.warning, text}); - } - info(text) { - return this.stopAndPersist({symbol: logSymbols.info, text}); - } - stopAndPersist(options) { - if (!this.enabled) { - return this; - } +const ESCAPES = new Set([ + '\u001B', + '\u009B' +]); - // Legacy argument - // TODO: Deprecate sometime in the future - if (typeof options === 'string') { - options = { - symbol: options - }; - } +const END_CODE = 39; - options = options || {}; +const ESCAPE_CODES = new Map([ + [0, 0], + [1, 22], + [2, 22], + [3, 23], + [4, 24], + [7, 27], + [8, 28], + [9, 29], + [30, 39], + [31, 39], + [32, 39], + [33, 39], + [34, 39], + [35, 39], + [36, 39], + [37, 39], + [90, 39], + [40, 49], + [41, 49], + [42, 49], + [43, 49], + [44, 49], + [45, 49], + [46, 49], + [47, 49] +]); - this.stop(); - this.stream.write(`${options.symbol || ' '} ${options.text || this.text}\n`); +const wrapAnsi = code => `${ESCAPES.values().next().value}[${code}m`; - return this; - } -} +// Calculate the length of words split on ' ', ignoring +// the extra characters added by ansi escape codes +const wordLengths = str => str.split(' ').map(s => stringWidth(s)); -module.exports = function (opts) { - return new Ora(opts); -}; +// Wrap a long word across multiple rows +// Ansi escape codes do not count towards length +const wrapWord = (rows, word, cols) => { + const arr = Array.from(word); -module.exports.promise = (action, options) => { - if (typeof action.then !== 'function') { - throw new TypeError('Parameter `action` must be a Promise'); - } + let insideEscape = false; + let visible = stringWidth(stripAnsi(rows[rows.length - 1])); - const spinner = new Ora(options); - spinner.start(); + for (const item of arr.entries()) { + const i = item[0]; + const char = item[1]; + const charLength = stringWidth(char); - action.then( - () => { - spinner.succeed(); - }, - () => { - spinner.fail(); + if (visible + charLength <= cols) { + rows[rows.length - 1] += char; + } else { + rows.push(char); + visible = 0; } - ); - - return spinner; -}; - - -/***/ }), -/* 676 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - -const escapeStringRegexp = __webpack_require__(3); -const ansiStyles = __webpack_require__(677); -const stdoutColor = __webpack_require__(678).stdout; - -const template = __webpack_require__(679); - -const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); - -// `supportsColor.level` → `ansiStyles.color[name]` mapping -const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; - -// `color-convert` models to exclude from the Chalk API due to conflicts and such -const skipModels = new Set(['gray']); - -const styles = Object.create(null); - -function applyOptions(obj, options) { - options = options || {}; - - // Detect level if not set manually - const scLevel = stdoutColor ? stdoutColor.level : 0; - obj.level = options.level === undefined ? scLevel : options.level; - obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0; -} - -function Chalk(options) { - // We check for this.template here since calling `chalk.constructor()` - // by itself will have a `this` of a previously constructed chalk object - if (!this || !(this instanceof Chalk) || this.template) { - const chalk = {}; - applyOptions(chalk, options); - - chalk.template = function () { - const args = [].slice.call(arguments); - return chalkTag.apply(null, [chalk.template].concat(args)); - }; - - Object.setPrototypeOf(chalk, Chalk.prototype); - Object.setPrototypeOf(chalk.template, chalk); - - chalk.template.constructor = Chalk; - - return chalk.template; - } - - applyOptions(this, options); -} - -// Use bright blue on Windows as the normal blue color is illegible -if (isSimpleWindowsTerm) { - ansiStyles.blue.open = '\u001B[94m'; -} - -for (const key of Object.keys(ansiStyles)) { - ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g'); - styles[key] = { - get() { - const codes = ansiStyles[key]; - return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key); + if (ESCAPES.has(char)) { + insideEscape = true; + } else if (insideEscape && char === 'm') { + insideEscape = false; + continue; } - }; -} - -styles.visible = { - get() { - return build.call(this, this._styles || [], true, 'visible'); - } -}; - -ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g'); -for (const model of Object.keys(ansiStyles.color.ansi)) { - if (skipModels.has(model)) { - continue; - } - - styles[model] = { - get() { - const level = this.level; - return function () { - const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments); - const codes = { - open, - close: ansiStyles.color.close, - closeRe: ansiStyles.color.closeRe - }; - return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model); - }; + + if (insideEscape) { + continue; } - }; -} -ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g'); -for (const model of Object.keys(ansiStyles.bgColor.ansi)) { - if (skipModels.has(model)) { - continue; - } + visible += charLength; - const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1); - styles[bgModel] = { - get() { - const level = this.level; - return function () { - const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments); - const codes = { - open, - close: ansiStyles.bgColor.close, - closeRe: ansiStyles.bgColor.closeRe - }; - return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model); - }; + if (visible === cols && i < arr.length - 1) { + rows.push(''); + visible = 0; } - }; -} + } -const proto = Object.defineProperties(() => {}, styles); + // It's possible that the last row we copy over is only + // ansi escape characters, handle this edge-case + if (!visible && rows[rows.length - 1].length > 0 && rows.length > 1) { + rows[rows.length - 2] += rows.pop(); + } +}; -function build(_styles, _empty, key) { - const builder = function () { - return applyStyle.apply(builder, arguments); - }; +// The wrap-ansi module can be invoked +// in either 'hard' or 'soft' wrap mode +// +// 'hard' will never allow a string to take up more +// than cols characters +// +// 'soft' allows long words to expand past the column length +const exec = (str, cols, opts) => { + const options = opts || {}; - builder._styles = _styles; - builder._empty = _empty; + if (str.trim() === '') { + return options.trim === false ? str : str.trim(); + } - const self = this; + let pre = ''; + let ret = ''; + let escapeCode; - Object.defineProperty(builder, 'level', { - enumerable: true, - get() { - return self.level; - }, - set(level) { - self.level = level; - } - }); + const lengths = wordLengths(str); + const words = str.split(' '); + const rows = ['']; - Object.defineProperty(builder, 'enabled', { - enumerable: true, - get() { - return self.enabled; - }, - set(enabled) { - self.enabled = enabled; - } - }); + for (const item of Array.from(words).entries()) { + const i = item[0]; + const word = item[1]; - // See below for fix regarding invisible grey/dim combination on Windows - builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; + rows[rows.length - 1] = options.trim === false ? rows[rows.length - 1] : rows[rows.length - 1].trim(); + let rowLength = stringWidth(rows[rows.length - 1]); - // `__proto__` is used because we must return a function, but there is - // no way to create a function with a different prototype - builder.__proto__ = proto; // eslint-disable-line no-proto + if (rowLength || word === '') { + if (rowLength === cols && options.wordWrap === false) { + // If we start with a new word but the current row length equals the length of the columns, add a new row + rows.push(''); + rowLength = 0; + } - return builder; -} + rows[rows.length - 1] += ' '; + rowLength++; + } -function applyStyle() { - // Support varags, but simply cast to string in case there's only one arg - const args = arguments; - const argsLen = args.length; - let str = String(arguments[0]); + // In 'hard' wrap mode, the length of a line is + // never allowed to extend past 'cols' + if (lengths[i] > cols && options.hard) { + if (rowLength) { + rows.push(''); + } + wrapWord(rows, word, cols); + continue; + } - if (argsLen === 0) { - return ''; - } + if (rowLength + lengths[i] > cols && rowLength > 0) { + if (options.wordWrap === false && rowLength < cols) { + wrapWord(rows, word, cols); + continue; + } - if (argsLen > 1) { - // Don't slice `arguments`, it prevents V8 optimizations - for (let a = 1; a < argsLen; a++) { - str += ' ' + args[a]; + rows.push(''); } - } - if (!this.enabled || this.level <= 0 || !str) { - return this._empty ? '' : str; - } + if (rowLength + lengths[i] > cols && options.wordWrap === false) { + wrapWord(rows, word, cols); + continue; + } - // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe, - // see https://github.com/chalk/chalk/issues/58 - // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop. - const originalDim = ansiStyles.dim.open; - if (isSimpleWindowsTerm && this.hasGrey) { - ansiStyles.dim.open = ''; + rows[rows.length - 1] += word; } - for (const code of this._styles.slice().reverse()) { - // Replace any instances already present with a re-opening code - // otherwise only the part of the string until said closing code - // will be colored, and the rest will simply be 'plain'. - str = code.open + str.replace(code.closeRe, code.open) + code.close; - - // Close the styling before a linebreak and reopen - // after next line to fix a bleed issue on macOS - // https://github.com/chalk/chalk/pull/92 - str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`); - } + pre = rows.map(r => options.trim === false ? r : r.trim()).join('\n'); - // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue - ansiStyles.dim.open = originalDim; + for (const item of Array.from(pre).entries()) { + const i = item[0]; + const char = item[1]; - return str; -} + ret += char; -function chalkTag(chalk, strings) { - if (!Array.isArray(strings)) { - // If chalk() was called by itself or with a string, - // return the string itself as a string. - return [].slice.call(arguments, 1).join(' '); - } + if (ESCAPES.has(char)) { + const code = parseFloat(/\d[^m]*/.exec(pre.slice(i, i + 4))); + escapeCode = code === END_CODE ? null : code; + } - const args = [].slice.call(arguments, 2); - const parts = [strings.raw[0]]; + const code = ESCAPE_CODES.get(Number(escapeCode)); - for (let i = 1; i < strings.length; i++) { - parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&')); - parts.push(String(strings.raw[i])); + if (escapeCode && code) { + if (pre[i + 1] === '\n') { + ret += wrapAnsi(code); + } else if (char === '\n') { + ret += wrapAnsi(escapeCode); + } + } } - return template(chalk, parts.join('')); -} - -Object.defineProperties(Chalk.prototype, styles); + return ret; +}; -module.exports = Chalk(); // eslint-disable-line new-cap -module.exports.supportsColor = stdoutColor; -module.exports.default = module.exports; // For TypeScript +// For each newline, invoke the method separately +module.exports = (str, cols, opts) => { + return String(str) + .normalize() + .split('\n') + .map(line => exec(line, cols, opts)) + .join('\n'); +}; /***/ }), -/* 677 */ +/* 693 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -/* WEBPACK VAR INJECTION */(function(module) { -const colorConvert = __webpack_require__(6); -const wrapAnsi16 = (fn, offset) => function () { - const code = fn.apply(colorConvert, arguments); - return `\u001B[${code + offset}m`; -}; +const stripAnsi = __webpack_require__(694); +const isFullwidthCodePoint = __webpack_require__(696); -const wrapAnsi256 = (fn, offset) => function () { - const code = fn.apply(colorConvert, arguments); - return `\u001B[${38 + offset};5;${code}m`; -}; +module.exports = str => { + if (typeof str !== 'string' || str.length === 0) { + return 0; + } -const wrapAnsi16m = (fn, offset) => function () { - const rgb = fn.apply(colorConvert, arguments); - return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`; -}; + str = stripAnsi(str); -function assembleStyles() { - const codes = new Map(); - const styles = { - modifier: { - reset: [0, 0], - // 21 isn't widely supported and 22 does the same thing - bold: [1, 22], - dim: [2, 22], - italic: [3, 23], - underline: [4, 24], - inverse: [7, 27], - hidden: [8, 28], - strikethrough: [9, 29] - }, - color: { - black: [30, 39], - red: [31, 39], - green: [32, 39], - yellow: [33, 39], - blue: [34, 39], - magenta: [35, 39], - cyan: [36, 39], - white: [37, 39], - gray: [90, 39], + let width = 0; - // Bright color - redBright: [91, 39], - greenBright: [92, 39], - yellowBright: [93, 39], - blueBright: [94, 39], - magentaBright: [95, 39], - cyanBright: [96, 39], - whiteBright: [97, 39] - }, - bgColor: { - bgBlack: [40, 49], - bgRed: [41, 49], - bgGreen: [42, 49], - bgYellow: [43, 49], - bgBlue: [44, 49], - bgMagenta: [45, 49], - bgCyan: [46, 49], - bgWhite: [47, 49], + for (let i = 0; i < str.length; i++) { + const code = str.codePointAt(i); - // Bright color - bgBlackBright: [100, 49], - bgRedBright: [101, 49], - bgGreenBright: [102, 49], - bgYellowBright: [103, 49], - bgBlueBright: [104, 49], - bgMagentaBright: [105, 49], - bgCyanBright: [106, 49], - bgWhiteBright: [107, 49] + // Ignore control characters + if (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) { + continue; } - }; - // Fix humans - styles.color.grey = styles.color.gray; + // Ignore combining characters + if (code >= 0x300 && code <= 0x36F) { + continue; + } - for (const groupName of Object.keys(styles)) { - const group = styles[groupName]; + // Surrogates + if (code > 0xFFFF) { + i++; + } - for (const styleName of Object.keys(group)) { - const style = group[styleName]; + width += isFullwidthCodePoint(code) ? 2 : 1; + } - styles[styleName] = { - open: `\u001B[${style[0]}m`, - close: `\u001B[${style[1]}m` - }; + return width; +}; - group[styleName] = styles[styleName]; - codes.set(style[0], style[1]); - } +/***/ }), +/* 694 */ +/***/ (function(module, exports, __webpack_require__) { - Object.defineProperty(styles, groupName, { - value: group, - enumerable: false - }); +"use strict"; - Object.defineProperty(styles, 'codes', { - value: codes, - enumerable: false - }); - } +const ansiRegex = __webpack_require__(695); - const ansi2ansi = n => n; - const rgb2rgb = (r, g, b) => [r, g, b]; +module.exports = input => typeof input === 'string' ? input.replace(ansiRegex(), '') : input; - styles.color.close = '\u001B[39m'; - styles.bgColor.close = '\u001B[49m'; - styles.color.ansi = { - ansi: wrapAnsi16(ansi2ansi, 0) - }; - styles.color.ansi256 = { - ansi256: wrapAnsi256(ansi2ansi, 0) - }; - styles.color.ansi16m = { - rgb: wrapAnsi16m(rgb2rgb, 0) - }; +/***/ }), +/* 695 */ +/***/ (function(module, exports, __webpack_require__) { - styles.bgColor.ansi = { - ansi: wrapAnsi16(ansi2ansi, 10) - }; - styles.bgColor.ansi256 = { - ansi256: wrapAnsi256(ansi2ansi, 10) - }; - styles.bgColor.ansi16m = { - rgb: wrapAnsi16m(rgb2rgb, 10) - }; +"use strict"; - for (let key of Object.keys(colorConvert)) { - if (typeof colorConvert[key] !== 'object') { - continue; - } - const suite = colorConvert[key]; +module.exports = () => { + const pattern = [ + '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)', + '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))' + ].join('|'); - if (key === 'ansi16') { - key = 'ansi'; - } + return new RegExp(pattern, 'g'); +}; - if ('ansi16' in suite) { - styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0); - styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10); - } - if ('ansi256' in suite) { - styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0); - styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10); - } +/***/ }), +/* 696 */ +/***/ (function(module, exports, __webpack_require__) { - if ('rgb' in suite) { - styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0); - styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10); - } +"use strict"; + +/* eslint-disable yoda */ +module.exports = x => { + if (Number.isNaN(x)) { + return false; } - return styles; -} + // code points are derived from: + // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt + if ( + x >= 0x1100 && ( + x <= 0x115f || // Hangul Jamo + x === 0x2329 || // LEFT-POINTING ANGLE BRACKET + x === 0x232a || // RIGHT-POINTING ANGLE BRACKET + // CJK Radicals Supplement .. Enclosed CJK Letters and Months + (0x2e80 <= x && x <= 0x3247 && x !== 0x303f) || + // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A + (0x3250 <= x && x <= 0x4dbf) || + // CJK Unified Ideographs .. Yi Radicals + (0x4e00 <= x && x <= 0xa4c6) || + // Hangul Jamo Extended-A + (0xa960 <= x && x <= 0xa97c) || + // Hangul Syllables + (0xac00 <= x && x <= 0xd7a3) || + // CJK Compatibility Ideographs + (0xf900 <= x && x <= 0xfaff) || + // Vertical Forms + (0xfe10 <= x && x <= 0xfe19) || + // CJK Compatibility Forms .. Small Form Variants + (0xfe30 <= x && x <= 0xfe6b) || + // Halfwidth and Fullwidth Forms + (0xff01 <= x && x <= 0xff60) || + (0xffe0 <= x && x <= 0xffe6) || + // Kana Supplement + (0x1b000 <= x && x <= 0x1b001) || + // Enclosed Ideographic Supplement + (0x1f200 <= x && x <= 0x1f251) || + // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane + (0x20000 <= x && x <= 0x3fffd) + ) + ) { + return true; + } -// Make the export immutable -Object.defineProperty(module, 'exports', { - enumerable: true, - get: assembleStyles -}); + return false; +}; -/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(5)(module))) /***/ }), -/* 678 */ +/* 697 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const os = __webpack_require__(11); -const hasFlag = __webpack_require__(12); +const ansiRegex = __webpack_require__(698); -const env = process.env; +module.exports = input => typeof input === 'string' ? input.replace(ansiRegex(), '') : input; -let forceColor; -if (hasFlag('no-color') || - hasFlag('no-colors') || - hasFlag('color=false')) { - forceColor = false; -} else if (hasFlag('color') || - hasFlag('colors') || - hasFlag('color=true') || - hasFlag('color=always')) { - forceColor = true; -} -if ('FORCE_COLOR' in env) { - forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0; -} -function translateLevel(level) { - if (level === 0) { - return false; - } +/***/ }), +/* 698 */ +/***/ (function(module, exports, __webpack_require__) { - return { - level, - hasBasic: true, - has256: level >= 2, - has16m: level >= 3 - }; -} +"use strict"; -function supportsColor(stream) { - if (forceColor === false) { - return 0; - } - if (hasFlag('color=16m') || - hasFlag('color=full') || - hasFlag('color=truecolor')) { - return 3; - } +module.exports = () => { + const pattern = [ + '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)', + '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))' + ].join('|'); - if (hasFlag('color=256')) { - return 2; - } + return new RegExp(pattern, 'g'); +}; + + +/***/ }), +/* 699 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "renderProjectsTree", function() { return renderProjectsTree; }); +/* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2); +/* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(16); +/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__); +/* + * 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. + */ - if (stream && !stream.isTTY && forceColor !== true) { - // VS code debugger doesn't have isTTY set - if (env.VSCODE_PID) { - return 1; - } - return 0; - } - const min = forceColor ? 1 : 0; +const projectKey = Symbol('__project'); +function renderProjectsTree(rootPath, projects) { + const projectsTree = buildProjectsTree(rootPath, projects); + return treeToString(createTreeStructure(projectsTree)); +} - if (process.platform === 'win32') { - // Node.js 7.5.0 is the first version of Node.js to include a patch to - // libuv that enables 256 color output on Windows. Anything earlier and it - // won't work. However, here we target Node.js 8 at minimum as it is an LTS - // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows - // release that supports 256 colors. Windows 10 build 14931 is the first release - // that supports 16m/TrueColor. - const osRelease = os.release().split('.'); - if ( - Number(process.versions.node.split('.')[0]) >= 8 && - Number(osRelease[0]) >= 10 && - Number(osRelease[2]) >= 10586 - ) { - return Number(osRelease[2]) >= 14931 ? 3 : 2; - } +function treeToString(tree) { + return [tree.name].concat(childrenToStrings(tree.children, '')).join('\n'); +} - return 1; - } +function childrenToStrings(tree, treePrefix) { + if (tree === undefined) { + return []; + } - if ('CI' in env) { - if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') { - return 1; - } + let strings = []; + tree.forEach((node, index) => { + const isLastNode = tree.length - 1 === index; + const nodePrefix = isLastNode ? '└── ' : '├── '; + const childPrefix = isLastNode ? ' ' : '│ '; + const childrenPrefix = treePrefix + childPrefix; + strings.push(`${treePrefix}${nodePrefix}${node.name}`); + strings = strings.concat(childrenToStrings(node.children, childrenPrefix)); + }); + return strings; +} - return min; - } +function createTreeStructure(tree) { + let name; + const children = []; - if ('TEAMCITY_VERSION' in env) { - return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0; - } + for (const [dir, project] of tree.entries()) { + // This is a leaf node (aka a project) + if (typeof project === 'string') { + name = chalk__WEBPACK_IMPORTED_MODULE_0___default.a.green(project); + continue; + } // If there's only one project and the key indicates it's a leaf node, we + // know that we're at a package folder that contains a package.json, so we + // "inline it" so we don't get unnecessary levels, i.e. we'll just see + // `foo` instead of `foo -> foo`. - if (env.COLORTERM === 'truecolor') { - return 3; - } - if ('TERM_PROGRAM' in env) { - const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10); + if (project.size === 1 && project.has(projectKey)) { + const projectName = project.get(projectKey); + children.push({ + children: [], + name: dirOrProjectName(dir, projectName) + }); + continue; + } - switch (env.TERM_PROGRAM) { - case 'iTerm.app': - return version >= 3 ? 3 : 2; - case 'Apple_Terminal': - return 2; - // No default - } - } + const subtree = createTreeStructure(project); // If the name is specified, we know there's a package at the "root" of the + // subtree itself. - if (/-256(color)?$/i.test(env.TERM)) { - return 2; - } + if (subtree.name !== undefined) { + const projectName = subtree.name; + children.push({ + children: subtree.children, + name: dirOrProjectName(dir, projectName) + }); + continue; + } // Special-case whenever we have one child, so we don't get unnecessary + // folders in the output. E.g. instead of `foo -> bar -> baz` we get + // `foo/bar/baz` instead. - if (/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) { - return 1; - } - if ('COLORTERM' in env) { - return 1; - } + if (subtree.children && subtree.children.length === 1) { + const child = subtree.children[0]; + const newName = chalk__WEBPACK_IMPORTED_MODULE_0___default.a.dim(path__WEBPACK_IMPORTED_MODULE_1___default.a.join(dir.toString(), child.name)); + children.push({ + children: child.children, + name: newName + }); + continue; + } - if (env.TERM === 'dumb') { - return min; - } + children.push({ + children: subtree.children, + name: chalk__WEBPACK_IMPORTED_MODULE_0___default.a.dim(dir.toString()) + }); + } - return min; + return { + name, + children + }; } -function getSupportLevel(stream) { - const level = supportsColor(stream); - return translateLevel(level); +function dirOrProjectName(dir, projectName) { + return dir === projectName ? chalk__WEBPACK_IMPORTED_MODULE_0___default.a.green(dir) : chalk__WEBPACK_IMPORTED_MODULE_0___default.a`{dim ${dir.toString()} ({reset.green ${projectName}})}`; } -module.exports = { - supportsColor: getSupportLevel, - stdout: getSupportLevel(process.stdout), - stderr: getSupportLevel(process.stderr) -}; - - -/***/ }), -/* 679 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - -const TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi; -const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g; -const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/; -const ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi; - -const ESCAPES = new Map([ - ['n', '\n'], - ['r', '\r'], - ['t', '\t'], - ['b', '\b'], - ['f', '\f'], - ['v', '\v'], - ['0', '\0'], - ['\\', '\\'], - ['e', '\u001B'], - ['a', '\u0007'] -]); +function buildProjectsTree(rootPath, projects) { + const tree = new Map(); -function unescape(c) { - if ((c[0] === 'u' && c.length === 5) || (c[0] === 'x' && c.length === 3)) { - return String.fromCharCode(parseInt(c.slice(1), 16)); - } + for (const project of projects.values()) { + if (rootPath === project.path) { + tree.set(projectKey, project.name); + } else { + const relativeProjectPath = path__WEBPACK_IMPORTED_MODULE_1___default.a.relative(rootPath, project.path); + addProjectToTree(tree, relativeProjectPath.split(path__WEBPACK_IMPORTED_MODULE_1___default.a.sep), project); + } + } - return ESCAPES.get(c) || c; + return tree; } -function parseArguments(name, args) { - const results = []; - const chunks = args.trim().split(/\s*,\s*/g); - let matches; +function addProjectToTree(tree, pathParts, project) { + if (pathParts.length === 0) { + tree.set(projectKey, project.name); + } else { + const [currentDir, ...rest] = pathParts; - for (const chunk of chunks) { - if (!isNaN(chunk)) { - results.push(Number(chunk)); - } else if ((matches = chunk.match(STRING_REGEX))) { - results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr)); - } else { - throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`); - } - } + if (!tree.has(currentDir)) { + tree.set(currentDir, new Map()); + } - return results; + const subtree = tree.get(currentDir); + addProjectToTree(subtree, rest, project); + } } -function parseStyle(style) { - STYLE_REGEX.lastIndex = 0; +/***/ }), +/* 700 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - const results = []; - let matches; +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Kibana", function() { return Kibana; }); +/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(16); +/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var multimatch__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(701); +/* harmony import */ var multimatch__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(multimatch__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _projects__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(501); +/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(580); +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } - while ((matches = STYLE_REGEX.exec(style)) !== null) { - const name = matches[1]; +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } - if (matches[2]) { - const args = parseArguments(name, matches[2]); - results.push([name].concat(args)); - } else { - results.push([name]); - } - } +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } - return results; -} +/* + * 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. + */ -function buildStyle(chalk, styles) { - const enabled = {}; - for (const layer of styles) { - for (const style of layer.styles) { - enabled[style[0]] = layer.inverse ? null : style.slice(1); - } - } - let current = chalk; - for (const styleName of Object.keys(enabled)) { - if (Array.isArray(enabled[styleName])) { - if (!(styleName in current)) { - throw new Error(`Unknown Chalk style: ${styleName}`); - } - if (enabled[styleName].length > 0) { - current = current[styleName].apply(current, enabled[styleName]); - } else { - current = current[styleName]; - } - } - } +/** + * Helper class for dealing with a set of projects as children of + * the Kibana project. The kbn/pm is currently implemented to be + * more generic, where everything is an operation of generic projects, + * but that leads to exceptions where we need the kibana project and + * do things like `project.get('kibana')!`. + * + * Using this helper we can restructre the generic list of projects + * as a Kibana object which encapulates all the projects in the + * workspace and knows about the root Kibana project. + */ - return current; -} +class Kibana { + static async loadFrom(rootPath) { + return new Kibana((await Object(_projects__WEBPACK_IMPORTED_MODULE_2__["getProjects"])(rootPath, Object(_config__WEBPACK_IMPORTED_MODULE_3__["getProjectPaths"])({ + rootPath + })))); + } -module.exports = (chalk, tmp) => { - const styles = []; - const chunks = []; - let chunk = []; + constructor(allWorkspaceProjects) { + this.allWorkspaceProjects = allWorkspaceProjects; - // eslint-disable-next-line max-params - tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => { - if (escapeChar) { - chunk.push(unescape(escapeChar)); - } else if (style) { - const str = chunk.join(''); - chunk = []; - chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str)); - styles.push({inverse, styles: parseStyle(style)}); - } else if (close) { - if (styles.length === 0) { - throw new Error('Found extraneous } in Chalk template literal'); - } + _defineProperty(this, "kibanaProject", void 0); - chunks.push(buildStyle(chalk, styles)(chunk.join(''))); - chunk = []; - styles.pop(); - } else { - chunk.push(chr); - } - }); + const kibanaProject = allWorkspaceProjects.get('kibana'); - chunks.push(chunk.join('')); + if (!kibanaProject) { + throw new TypeError('Unable to create Kibana object without all projects, including the Kibana project.'); + } - if (styles.length > 0) { - const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`; - throw new Error(errMsg); - } + this.kibanaProject = kibanaProject; + } + /** make an absolute path by resolving subPath relative to the kibana repo */ - return chunks.join(''); -}; + getAbsolute(...subPath) { + return path__WEBPACK_IMPORTED_MODULE_0___default.a.resolve(this.kibanaProject.path, ...subPath); + } + /** convert an absolute path to a relative path, relative to the kibana repo */ -/***/ }), -/* 680 */ -/***/ (function(module, exports, __webpack_require__) { -"use strict"; + getRelative(absolute) { + return path__WEBPACK_IMPORTED_MODULE_0___default.a.relative(this.kibanaProject.path, absolute); + } + /** get a copy of the map of all projects in the kibana workspace */ -const restoreCursor = __webpack_require__(681); -let hidden = false; + getAllProjects() { + return new Map(this.allWorkspaceProjects); + } + /** determine if a project with the given name exists */ -exports.show = stream => { - const s = stream || process.stderr; - if (!s.isTTY) { - return; - } + hasProject(name) { + return this.allWorkspaceProjects.has(name); + } + /** get a specific project, throws if the name is not known (use hasProject() first) */ - hidden = false; - s.write('\u001b[?25h'); -}; -exports.hide = stream => { - const s = stream || process.stderr; + getProject(name) { + const project = this.allWorkspaceProjects.get(name); - if (!s.isTTY) { - return; - } + if (!project) { + throw new Error(`No package with name "${name}" in the workspace`); + } - restoreCursor(); - hidden = true; - s.write('\u001b[?25l'); -}; + return project; + } + /** get a project and all of the projects it depends on in a ProjectMap */ -exports.toggle = (force, stream) => { - if (force !== undefined) { - hidden = force; - } - if (hidden) { - exports.show(stream); - } else { - exports.hide(stream); - } -}; + getProjectAndDeps(name) { + const project = this.getProject(name); + return Object(_projects__WEBPACK_IMPORTED_MODULE_2__["includeTransitiveProjects"])([project], this.allWorkspaceProjects); + } + /** filter the projects to just those matching certain paths/include/exclude tags */ -/***/ }), -/* 681 */ -/***/ (function(module, exports, __webpack_require__) { + getFilteredProjects(options) { + const allProjects = this.getAllProjects(); + const filteredProjects = new Map(); + const pkgJsonPaths = Array.from(allProjects.values()).map(p => p.packageJsonLocation); + const filteredPkgJsonGlobs = Object(_config__WEBPACK_IMPORTED_MODULE_3__["getProjectPaths"])(_objectSpread({}, options, { + rootPath: this.kibanaProject.path + })).map(g => path__WEBPACK_IMPORTED_MODULE_0___default.a.resolve(g, 'package.json')); + const matchingPkgJsonPaths = multimatch__WEBPACK_IMPORTED_MODULE_1___default()(pkgJsonPaths, filteredPkgJsonGlobs); -"use strict"; + for (const project of allProjects.values()) { + const pathMatches = matchingPkgJsonPaths.includes(project.packageJsonLocation); + const notExcluded = !options.exclude.includes(project.name); + const isIncluded = !options.include.length || options.include.includes(project.name); -const onetime = __webpack_require__(682); -const signalExit = __webpack_require__(377); + if (pathMatches && notExcluded && isIncluded) { + filteredProjects.set(project.name, project); + } + } -module.exports = onetime(() => { - signalExit(() => { - process.stderr.write('\u001b[?25h'); - }, {alwaysLast: true}); -}); + return filteredProjects; + } +} /***/ }), -/* 682 */ +/* 701 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const mimicFn = __webpack_require__(683); +const minimatch = __webpack_require__(505); +const arrayUnion = __webpack_require__(702); +const arrayDiffer = __webpack_require__(703); +const arrify = __webpack_require__(704); -module.exports = (fn, opts) => { - // TODO: Remove this in v3 - if (opts === true) { - throw new TypeError('The second argument is now an options object'); - } +module.exports = (list, patterns, options = {}) => { + list = arrify(list); + patterns = arrify(patterns); - if (typeof fn !== 'function') { - throw new TypeError('Expected a function'); + if (list.length === 0 || patterns.length === 0) { + return []; } - opts = opts || {}; + return patterns.reduce((result, pattern) => { + let process = arrayUnion; - let ret; - let called = false; - const fnName = fn.displayName || fn.name || ''; + if (pattern[0] === '!') { + pattern = pattern.slice(1); + process = arrayDiffer; + } - const onetime = function () { - if (called) { - if (opts.throw === true) { - throw new Error(`Function \`${fnName}\` can only be called once`); - } + return process(result, minimatch.match(list, pattern, options)); + }, []); +}; - return ret; - } - called = true; - ret = fn.apply(this, arguments); - fn = null; +/***/ }), +/* 702 */ +/***/ (function(module, exports, __webpack_require__) { - return ret; - }; +"use strict"; - mimicFn(onetime, fn); - return onetime; +module.exports = (...arguments_) => { + return [...new Set([].concat(...arguments_))]; }; /***/ }), -/* 683 */ +/* 703 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -module.exports = (to, from) => { - // TODO: use `Reflect.ownKeys()` when targeting Node.js 6 - for (const prop of Object.getOwnPropertyNames(from).concat(Object.getOwnPropertySymbols(from))) { - Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(from, prop)); - } - return to; +const arrayDiffer = (array, ...values) => { + const rest = new Set([].concat(...values)); + return array.filter(element => !rest.has(element)); }; +module.exports = arrayDiffer; + /***/ }), -/* 684 */ +/* 704 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -module.exports = __webpack_require__(685); +const arrify = value => { + if (value === null || value === undefined) { + return []; + } -/***/ }), -/* 685 */ -/***/ (function(module) { + if (Array.isArray(value)) { + return value; + } + + if (typeof value === 'string') { + return [value]; + } + + if (typeof value[Symbol.iterator] === 'function') { + return [...value]; + } + + return [value]; +}; + +module.exports = arrify; -module.exports = JSON.parse("{\"dots\":{\"interval\":80,\"frames\":[\"⠋\",\"⠙\",\"⠹\",\"⠸\",\"⠼\",\"⠴\",\"⠦\",\"⠧\",\"⠇\",\"⠏\"]},\"dots2\":{\"interval\":80,\"frames\":[\"⣾\",\"⣽\",\"⣻\",\"⢿\",\"⡿\",\"⣟\",\"⣯\",\"⣷\"]},\"dots3\":{\"interval\":80,\"frames\":[\"⠋\",\"⠙\",\"⠚\",\"⠞\",\"⠖\",\"⠦\",\"⠴\",\"⠲\",\"⠳\",\"⠓\"]},\"dots4\":{\"interval\":80,\"frames\":[\"⠄\",\"⠆\",\"⠇\",\"⠋\",\"⠙\",\"⠸\",\"⠰\",\"⠠\",\"⠰\",\"⠸\",\"⠙\",\"⠋\",\"⠇\",\"⠆\"]},\"dots5\":{\"interval\":80,\"frames\":[\"⠋\",\"⠙\",\"⠚\",\"⠒\",\"⠂\",\"⠂\",\"⠒\",\"⠲\",\"⠴\",\"⠦\",\"⠖\",\"⠒\",\"⠐\",\"⠐\",\"⠒\",\"⠓\",\"⠋\"]},\"dots6\":{\"interval\":80,\"frames\":[\"⠁\",\"⠉\",\"⠙\",\"⠚\",\"⠒\",\"⠂\",\"⠂\",\"⠒\",\"⠲\",\"⠴\",\"⠤\",\"⠄\",\"⠄\",\"⠤\",\"⠴\",\"⠲\",\"⠒\",\"⠂\",\"⠂\",\"⠒\",\"⠚\",\"⠙\",\"⠉\",\"⠁\"]},\"dots7\":{\"interval\":80,\"frames\":[\"⠈\",\"⠉\",\"⠋\",\"⠓\",\"⠒\",\"⠐\",\"⠐\",\"⠒\",\"⠖\",\"⠦\",\"⠤\",\"⠠\",\"⠠\",\"⠤\",\"⠦\",\"⠖\",\"⠒\",\"⠐\",\"⠐\",\"⠒\",\"⠓\",\"⠋\",\"⠉\",\"⠈\"]},\"dots8\":{\"interval\":80,\"frames\":[\"⠁\",\"⠁\",\"⠉\",\"⠙\",\"⠚\",\"⠒\",\"⠂\",\"⠂\",\"⠒\",\"⠲\",\"⠴\",\"⠤\",\"⠄\",\"⠄\",\"⠤\",\"⠠\",\"⠠\",\"⠤\",\"⠦\",\"⠖\",\"⠒\",\"⠐\",\"⠐\",\"⠒\",\"⠓\",\"⠋\",\"⠉\",\"⠈\",\"⠈\"]},\"dots9\":{\"interval\":80,\"frames\":[\"⢹\",\"⢺\",\"⢼\",\"⣸\",\"⣇\",\"⡧\",\"⡗\",\"⡏\"]},\"dots10\":{\"interval\":80,\"frames\":[\"⢄\",\"⢂\",\"⢁\",\"⡁\",\"⡈\",\"⡐\",\"⡠\"]},\"dots11\":{\"interval\":100,\"frames\":[\"⠁\",\"⠂\",\"⠄\",\"⡀\",\"⢀\",\"⠠\",\"⠐\",\"⠈\"]},\"dots12\":{\"interval\":80,\"frames\":[\"⢀⠀\",\"⡀⠀\",\"⠄⠀\",\"⢂⠀\",\"⡂⠀\",\"⠅⠀\",\"⢃⠀\",\"⡃⠀\",\"⠍⠀\",\"⢋⠀\",\"⡋⠀\",\"⠍⠁\",\"⢋⠁\",\"⡋⠁\",\"⠍⠉\",\"⠋⠉\",\"⠋⠉\",\"⠉⠙\",\"⠉⠙\",\"⠉⠩\",\"⠈⢙\",\"⠈⡙\",\"⢈⠩\",\"⡀⢙\",\"⠄⡙\",\"⢂⠩\",\"⡂⢘\",\"⠅⡘\",\"⢃⠨\",\"⡃⢐\",\"⠍⡐\",\"⢋⠠\",\"⡋⢀\",\"⠍⡁\",\"⢋⠁\",\"⡋⠁\",\"⠍⠉\",\"⠋⠉\",\"⠋⠉\",\"⠉⠙\",\"⠉⠙\",\"⠉⠩\",\"⠈⢙\",\"⠈⡙\",\"⠈⠩\",\"⠀⢙\",\"⠀⡙\",\"⠀⠩\",\"⠀⢘\",\"⠀⡘\",\"⠀⠨\",\"⠀⢐\",\"⠀⡐\",\"⠀⠠\",\"⠀⢀\",\"⠀⡀\"]},\"line\":{\"interval\":130,\"frames\":[\"-\",\"\\\\\",\"|\",\"/\"]},\"line2\":{\"interval\":100,\"frames\":[\"⠂\",\"-\",\"–\",\"—\",\"–\",\"-\"]},\"pipe\":{\"interval\":100,\"frames\":[\"┤\",\"┘\",\"┴\",\"└\",\"├\",\"┌\",\"┬\",\"┐\"]},\"simpleDots\":{\"interval\":400,\"frames\":[\". \",\".. \",\"...\",\" \"]},\"simpleDotsScrolling\":{\"interval\":200,\"frames\":[\". \",\".. \",\"...\",\" ..\",\" .\",\" \"]},\"star\":{\"interval\":70,\"frames\":[\"✶\",\"✸\",\"✹\",\"✺\",\"✹\",\"✷\"]},\"star2\":{\"interval\":80,\"frames\":[\"+\",\"x\",\"*\"]},\"flip\":{\"interval\":70,\"frames\":[\"_\",\"_\",\"_\",\"-\",\"`\",\"`\",\"'\",\"´\",\"-\",\"_\",\"_\",\"_\"]},\"hamburger\":{\"interval\":100,\"frames\":[\"☱\",\"☲\",\"☴\"]},\"growVertical\":{\"interval\":120,\"frames\":[\"▁\",\"▃\",\"▄\",\"▅\",\"▆\",\"▇\",\"▆\",\"▅\",\"▄\",\"▃\"]},\"growHorizontal\":{\"interval\":120,\"frames\":[\"▏\",\"▎\",\"▍\",\"▌\",\"▋\",\"▊\",\"▉\",\"▊\",\"▋\",\"▌\",\"▍\",\"▎\"]},\"balloon\":{\"interval\":140,\"frames\":[\" \",\".\",\"o\",\"O\",\"@\",\"*\",\" \"]},\"balloon2\":{\"interval\":120,\"frames\":[\".\",\"o\",\"O\",\"°\",\"O\",\"o\",\".\"]},\"noise\":{\"interval\":100,\"frames\":[\"▓\",\"▒\",\"░\"]},\"bounce\":{\"interval\":120,\"frames\":[\"⠁\",\"⠂\",\"⠄\",\"⠂\"]},\"boxBounce\":{\"interval\":120,\"frames\":[\"▖\",\"▘\",\"▝\",\"▗\"]},\"boxBounce2\":{\"interval\":100,\"frames\":[\"▌\",\"▀\",\"▐\",\"▄\"]},\"triangle\":{\"interval\":50,\"frames\":[\"◢\",\"◣\",\"◤\",\"◥\"]},\"arc\":{\"interval\":100,\"frames\":[\"◜\",\"◠\",\"◝\",\"◞\",\"◡\",\"◟\"]},\"circle\":{\"interval\":120,\"frames\":[\"◡\",\"⊙\",\"◠\"]},\"squareCorners\":{\"interval\":180,\"frames\":[\"◰\",\"◳\",\"◲\",\"◱\"]},\"circleQuarters\":{\"interval\":120,\"frames\":[\"◴\",\"◷\",\"◶\",\"◵\"]},\"circleHalves\":{\"interval\":50,\"frames\":[\"◐\",\"◓\",\"◑\",\"◒\"]},\"squish\":{\"interval\":100,\"frames\":[\"╫\",\"╪\"]},\"toggle\":{\"interval\":250,\"frames\":[\"⊶\",\"⊷\"]},\"toggle2\":{\"interval\":80,\"frames\":[\"▫\",\"▪\"]},\"toggle3\":{\"interval\":120,\"frames\":[\"□\",\"■\"]},\"toggle4\":{\"interval\":100,\"frames\":[\"■\",\"□\",\"▪\",\"▫\"]},\"toggle5\":{\"interval\":100,\"frames\":[\"▮\",\"▯\"]},\"toggle6\":{\"interval\":300,\"frames\":[\"ဝ\",\"၀\"]},\"toggle7\":{\"interval\":80,\"frames\":[\"⦾\",\"⦿\"]},\"toggle8\":{\"interval\":100,\"frames\":[\"◍\",\"◌\"]},\"toggle9\":{\"interval\":100,\"frames\":[\"◉\",\"◎\"]},\"toggle10\":{\"interval\":100,\"frames\":[\"㊂\",\"㊀\",\"㊁\"]},\"toggle11\":{\"interval\":50,\"frames\":[\"⧇\",\"⧆\"]},\"toggle12\":{\"interval\":120,\"frames\":[\"☗\",\"☖\"]},\"toggle13\":{\"interval\":80,\"frames\":[\"=\",\"*\",\"-\"]},\"arrow\":{\"interval\":100,\"frames\":[\"←\",\"↖\",\"↑\",\"↗\",\"→\",\"↘\",\"↓\",\"↙\"]},\"arrow2\":{\"interval\":80,\"frames\":[\"⬆️ \",\"↗️ \",\"➡️ \",\"↘️ \",\"⬇️ \",\"↙️ \",\"⬅️ \",\"↖️ \"]},\"arrow3\":{\"interval\":120,\"frames\":[\"▹▹▹▹▹\",\"▸▹▹▹▹\",\"▹▸▹▹▹\",\"▹▹▸▹▹\",\"▹▹▹▸▹\",\"▹▹▹▹▸\"]},\"bouncingBar\":{\"interval\":80,\"frames\":[\"[ ]\",\"[= ]\",\"[== ]\",\"[=== ]\",\"[ ===]\",\"[ ==]\",\"[ =]\",\"[ ]\",\"[ =]\",\"[ ==]\",\"[ ===]\",\"[====]\",\"[=== ]\",\"[== ]\",\"[= ]\"]},\"bouncingBall\":{\"interval\":80,\"frames\":[\"( ● )\",\"( ● )\",\"( ● )\",\"( ● )\",\"( ●)\",\"( ● )\",\"( ● )\",\"( ● )\",\"( ● )\",\"(● )\"]},\"smiley\":{\"interval\":200,\"frames\":[\"😄 \",\"😝 \"]},\"monkey\":{\"interval\":300,\"frames\":[\"🙈 \",\"🙈 \",\"🙉 \",\"🙊 \"]},\"hearts\":{\"interval\":100,\"frames\":[\"💛 \",\"💙 \",\"💜 \",\"💚 \",\"❤️ \"]},\"clock\":{\"interval\":100,\"frames\":[\"🕐 \",\"🕑 \",\"🕒 \",\"🕓 \",\"🕔 \",\"🕕 \",\"🕖 \",\"🕗 \",\"🕘 \",\"🕙 \",\"🕚 \"]},\"earth\":{\"interval\":180,\"frames\":[\"🌍 \",\"🌎 \",\"🌏 \"]},\"moon\":{\"interval\":80,\"frames\":[\"🌑 \",\"🌒 \",\"🌓 \",\"🌔 \",\"🌕 \",\"🌖 \",\"🌗 \",\"🌘 \"]},\"runner\":{\"interval\":140,\"frames\":[\"🚶 \",\"🏃 \"]},\"pong\":{\"interval\":80,\"frames\":[\"▐⠂ ▌\",\"▐⠈ ▌\",\"▐ ⠂ ▌\",\"▐ ⠠ ▌\",\"▐ ⡀ ▌\",\"▐ ⠠ ▌\",\"▐ ⠂ ▌\",\"▐ ⠈ ▌\",\"▐ ⠂ ▌\",\"▐ ⠠ ▌\",\"▐ ⡀ ▌\",\"▐ ⠠ ▌\",\"▐ ⠂ ▌\",\"▐ ⠈ ▌\",\"▐ ⠂▌\",\"▐ ⠠▌\",\"▐ ⡀▌\",\"▐ ⠠ ▌\",\"▐ ⠂ ▌\",\"▐ ⠈ ▌\",\"▐ ⠂ ▌\",\"▐ ⠠ ▌\",\"▐ ⡀ ▌\",\"▐ ⠠ ▌\",\"▐ ⠂ ▌\",\"▐ ⠈ ▌\",\"▐ ⠂ ▌\",\"▐ ⠠ ▌\",\"▐ ⡀ ▌\",\"▐⠠ ▌\"]},\"shark\":{\"interval\":120,\"frames\":[\"▐|\\\\____________▌\",\"▐_|\\\\___________▌\",\"▐__|\\\\__________▌\",\"▐___|\\\\_________▌\",\"▐____|\\\\________▌\",\"▐_____|\\\\_______▌\",\"▐______|\\\\______▌\",\"▐_______|\\\\_____▌\",\"▐________|\\\\____▌\",\"▐_________|\\\\___▌\",\"▐__________|\\\\__▌\",\"▐___________|\\\\_▌\",\"▐____________|\\\\▌\",\"▐____________/|▌\",\"▐___________/|_▌\",\"▐__________/|__▌\",\"▐_________/|___▌\",\"▐________/|____▌\",\"▐_______/|_____▌\",\"▐______/|______▌\",\"▐_____/|_______▌\",\"▐____/|________▌\",\"▐___/|_________▌\",\"▐__/|__________▌\",\"▐_/|___________▌\",\"▐/|____________▌\"]},\"dqpb\":{\"interval\":100,\"frames\":[\"d\",\"q\",\"p\",\"b\"]},\"weather\":{\"interval\":100,\"frames\":[\"☀️ \",\"☀️ \",\"☀️ \",\"🌤 \",\"⛅️ \",\"🌥 \",\"☁️ \",\"🌧 \",\"🌨 \",\"🌧 \",\"🌨 \",\"🌧 \",\"🌨 \",\"⛈ \",\"🌨 \",\"🌧 \",\"🌨 \",\"☁️ \",\"🌥 \",\"⛅️ \",\"🌤 \",\"☀️ \",\"☀️ \"]},\"christmas\":{\"interval\":400,\"frames\":[\"🌲\",\"🎄\"]}}"); /***/ }), -/* 686 */ +/* 705 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RunCommand", function() { return RunCommand; }); -/* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2); -/* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _utils_log__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(34); -/* harmony import */ var _utils_parallelize__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(500); -/* harmony import */ var _utils_projects__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(501); +/* harmony import */ var _build_production_projects__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(706); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "buildProductionProjects", function() { return _build_production_projects__WEBPACK_IMPORTED_MODULE_0__["buildProductionProjects"]; }); + +/* harmony import */ var _prepare_project_dependencies__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(923); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "prepareExternalProjectDependencies", function() { return _prepare_project_dependencies__WEBPACK_IMPORTED_MODULE_1__["prepareExternalProjectDependencies"]; }); + /* * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with @@ -78836,46 +80688,24 @@ __webpack_require__.r(__webpack_exports__); - -const RunCommand = { - description: 'Run script defined in package.json in each package that contains that script.', - name: 'run', - - async run(projects, projectGraph, { - extraArgs - }) { - const batchedProjects = Object(_utils_projects__WEBPACK_IMPORTED_MODULE_3__["topologicallyBatchProjects"])(projects, projectGraph); - - if (extraArgs.length === 0) { - _utils_log__WEBPACK_IMPORTED_MODULE_1__["log"].write(chalk__WEBPACK_IMPORTED_MODULE_0___default.a.red.bold('\nNo script specified')); - process.exit(1); - } - - const scriptName = extraArgs[0]; - const scriptArgs = extraArgs.slice(1); - _utils_log__WEBPACK_IMPORTED_MODULE_1__["log"].write(chalk__WEBPACK_IMPORTED_MODULE_0___default.a.bold(`\nRunning script [${chalk__WEBPACK_IMPORTED_MODULE_0___default.a.green(scriptName)}] in batched topological order\n`)); - await Object(_utils_parallelize__WEBPACK_IMPORTED_MODULE_2__["parallelizeBatches"])(batchedProjects, async pkg => { - if (pkg.hasScript(scriptName)) { - await pkg.runScriptStreaming(scriptName, scriptArgs); - } - }); - } - -}; - /***/ }), -/* 687 */ +/* 706 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WatchCommand", function() { return WatchCommand; }); -/* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2); -/* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _utils_log__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(34); -/* harmony import */ var _utils_parallelize__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(500); -/* harmony import */ var _utils_projects__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(501); -/* harmony import */ var _utils_watch__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(688); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "buildProductionProjects", function() { return buildProductionProjects; }); +/* harmony import */ var cpy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(707); +/* harmony import */ var cpy__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(cpy__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var del__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(588); +/* harmony import */ var del__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(del__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(16); +/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(580); +/* harmony import */ var _utils_fs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(20); +/* harmony import */ var _utils_log__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(34); +/* harmony import */ var _utils_package_json__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(517); +/* harmony import */ var _utils_projects__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(501); /* * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with @@ -78900,1532 +80730,2066 @@ __webpack_require__.r(__webpack_exports__); + + +async function buildProductionProjects({ + kibanaRoot, + buildRoot, + onlyOSS +}) { + const projects = await getProductionProjects(kibanaRoot, onlyOSS); + const projectGraph = Object(_utils_projects__WEBPACK_IMPORTED_MODULE_7__["buildProjectGraph"])(projects); + const batchedProjects = Object(_utils_projects__WEBPACK_IMPORTED_MODULE_7__["topologicallyBatchProjects"])(projects, projectGraph); + const projectNames = [...projects.values()].map(project => project.name); + _utils_log__WEBPACK_IMPORTED_MODULE_5__["log"].write(`Preparing production build for [${projectNames.join(', ')}]`); + + for (const batch of batchedProjects) { + for (const project of batch) { + await deleteTarget(project); + await buildProject(project); + await copyToBuild(project, kibanaRoot, buildRoot); + } + } +} /** - * Name of the script in the package/project package.json file to run during `kbn watch`. - */ -const watchScriptName = 'kbn:watch'; -/** - * Name of the Kibana project. + * Returns the subset of projects that should be built into the production + * bundle. As we copy these into Kibana's `node_modules` during the build step, + * and let Kibana's build process be responsible for installing dependencies, + * we only include Kibana's transitive _production_ dependencies. If onlyOSS + * is supplied, we omit projects with build.oss in their package.json set to false. */ -const kibanaProjectName = 'kibana'; +async function getProductionProjects(rootPath, onlyOSS) { + const projectPaths = Object(_config__WEBPACK_IMPORTED_MODULE_3__["getProjectPaths"])({ + rootPath + }); + const projects = await Object(_utils_projects__WEBPACK_IMPORTED_MODULE_7__["getProjects"])(rootPath, projectPaths); + const projectsSubset = [projects.get('kibana')]; + + if (projects.has('x-pack')) { + projectsSubset.push(projects.get('x-pack')); + } + + const productionProjects = Object(_utils_projects__WEBPACK_IMPORTED_MODULE_7__["includeTransitiveProjects"])(projectsSubset, projects, { + onlyProductionDependencies: true + }); // We remove Kibana, as we're already building Kibana + + productionProjects.delete('kibana'); + + if (onlyOSS) { + productionProjects.forEach(project => { + if (project.getBuildConfig().oss === false) { + productionProjects.delete(project.json.name); + } + }); + } + + return productionProjects; +} + +async function deleteTarget(project) { + const targetDir = project.targetLocation; + + if (await Object(_utils_fs__WEBPACK_IMPORTED_MODULE_4__["isDirectory"])(targetDir)) { + await del__WEBPACK_IMPORTED_MODULE_1___default()(targetDir, { + force: true + }); + } +} + +async function buildProject(project) { + if (project.hasScript('build')) { + await project.runScript('build'); + } +} /** - * Command that traverses through list of available projects/packages that have `kbn:watch` script in their - * package.json files, groups them into topology aware batches and then processes theses batches one by one - * running `kbn:watch` scripts in parallel within the same batch. + * Copy all the project's files from its "intermediate build directory" and + * into the build. The intermediate directory can either be the root of the + * project or some other location defined in the project's `package.json`. * - * Command internally relies on the fact that most of the build systems that are triggered by `kbn:watch` - * will emit special "marker" once build/watch process is ready that we can use as completion condition for - * the `kbn:watch` script and eventually for the entire batch. Currently we support completion "markers" for - * `webpack` and `tsc` only, for the rest we rely on predefined timeouts. + * When copying all the files into the build, we exclude `node_modules` because + * we want the Kibana build to be responsible for actually installing all + * dependencies. The primary reason for allowing the Kibana build process to + * manage dependencies is that it will "dedupe" them, so we don't include + * unnecessary copies of dependencies. */ -const WatchCommand = { - description: 'Runs `kbn:watch` script for every project.', - name: 'watch', - async run(projects, projectGraph) { - const projectsToWatch = new Map(); +async function copyToBuild(project, kibanaRoot, buildRoot) { + // We want the package to have the same relative location within the build + const relativeProjectPath = Object(path__WEBPACK_IMPORTED_MODULE_2__["relative"])(kibanaRoot, project.path); + const buildProjectPath = Object(path__WEBPACK_IMPORTED_MODULE_2__["resolve"])(buildRoot, relativeProjectPath); + await cpy__WEBPACK_IMPORTED_MODULE_0___default()(['**/*', '!node_modules/**'], buildProjectPath, { + cwd: project.getIntermediateBuildDirectory(), + dot: true, + nodir: true, + parents: true + }); // If a project is using an intermediate build directory, we special-case our + // handling of `package.json`, as the project build process might have copied + // (a potentially modified) `package.json` into the intermediate build + // directory already. If so, we want to use that `package.json` as the basis + // for creating the production-ready `package.json`. If it's not present in + // the intermediate build, we fall back to using the project's already defined + // `package.json`. - for (const project of projects.values()) { - // We can't watch project that doesn't have `kbn:watch` script. - if (project.hasScript(watchScriptName)) { - projectsToWatch.set(project.name, project); - } - } + const packageJson = (await Object(_utils_fs__WEBPACK_IMPORTED_MODULE_4__["isFile"])(Object(path__WEBPACK_IMPORTED_MODULE_2__["join"])(buildProjectPath, 'package.json'))) ? await Object(_utils_package_json__WEBPACK_IMPORTED_MODULE_6__["readPackageJson"])(buildProjectPath) : project.json; + await Object(_utils_package_json__WEBPACK_IMPORTED_MODULE_6__["writePackageJson"])(buildProjectPath, packageJson); +} - if (projectsToWatch.size === 0) { - _utils_log__WEBPACK_IMPORTED_MODULE_1__["log"].write(chalk__WEBPACK_IMPORTED_MODULE_0___default.a.red(`\nThere are no projects to watch found. Make sure that projects define 'kbn:watch' script in 'package.json'.\n`)); - return; - } +/***/ }), +/* 707 */ +/***/ (function(module, exports, __webpack_require__) { - const projectNames = Array.from(projectsToWatch.keys()); - _utils_log__WEBPACK_IMPORTED_MODULE_1__["log"].write(chalk__WEBPACK_IMPORTED_MODULE_0___default.a.bold(chalk__WEBPACK_IMPORTED_MODULE_0___default.a.green(`Running ${watchScriptName} scripts for [${projectNames.join(', ')}].`))); // Kibana should always be run the last, so we don't rely on automatic - // topological batching and push it to the last one-entry batch manually. +"use strict"; - const shouldWatchKibanaProject = projectsToWatch.delete(kibanaProjectName); - const batchedProjects = Object(_utils_projects__WEBPACK_IMPORTED_MODULE_3__["topologicallyBatchProjects"])(projectsToWatch, projectGraph); +const EventEmitter = __webpack_require__(379); +const path = __webpack_require__(16); +const arrify = __webpack_require__(708); +const globby = __webpack_require__(709); +const cpFile = __webpack_require__(912); +const CpyError = __webpack_require__(921); - if (shouldWatchKibanaProject) { - batchedProjects.push([projects.get(kibanaProjectName)]); - } +const preprocessSrcPath = (srcPath, options) => options.cwd ? path.resolve(options.cwd, srcPath) : srcPath; - await Object(_utils_parallelize__WEBPACK_IMPORTED_MODULE_2__["parallelizeBatches"])(batchedProjects, async pkg => { - const completionHint = await Object(_utils_watch__WEBPACK_IMPORTED_MODULE_4__["waitUntilWatchIsReady"])(pkg.runScriptStreaming(watchScriptName).stdout); - _utils_log__WEBPACK_IMPORTED_MODULE_1__["log"].write(chalk__WEBPACK_IMPORTED_MODULE_0___default.a.bold(`[${chalk__WEBPACK_IMPORTED_MODULE_0___default.a.green(pkg.name)}] Initial build completed (${completionHint}).`)); - }); - } +const preprocessDestPath = (srcPath, dest, options) => { + let basename = path.basename(srcPath); + const dirname = path.dirname(srcPath); + + if (typeof options.rename === 'string') { + basename = options.rename; + } else if (typeof options.rename === 'function') { + basename = options.rename(basename); + } + + if (options.cwd) { + dest = path.resolve(options.cwd, dest); + } + + if (options.parents) { + return path.join(dest, dirname, basename); + } + + return path.join(dest, basename); +}; + +const cpy = (src, dest, options = {}) => { + src = arrify(src); + + const progressEmitter = new EventEmitter(); + + if (src.length === 0 || !dest) { + const promise = Promise.reject(new CpyError('`files` and `destination` required')); + promise.on = (...args) => { + progressEmitter.on(...args); + return promise; + }; + + return promise; + } + + const copyStatus = new Map(); + let completedFiles = 0; + let completedSize = 0; + + const promise = globby(src, options) + .catch(error => { + throw new CpyError(`Cannot glob \`${src}\`: ${error.message}`, error); + }) + .then(files => { + if (files.length === 0) { + progressEmitter.emit('progress', { + totalFiles: 0, + percent: 1, + completedFiles: 0, + completedSize: 0 + }); + } + + return Promise.all(files.map(srcPath => { + const from = preprocessSrcPath(srcPath, options); + const to = preprocessDestPath(srcPath, dest, options); + + return cpFile(from, to, options) + .on('progress', event => { + const fileStatus = copyStatus.get(event.src) || {written: 0, percent: 0}; + + if (fileStatus.written !== event.written || fileStatus.percent !== event.percent) { + completedSize -= fileStatus.written; + completedSize += event.written; + + if (event.percent === 1 && fileStatus.percent !== 1) { + completedFiles++; + } + + copyStatus.set(event.src, {written: event.written, percent: event.percent}); + + progressEmitter.emit('progress', { + totalFiles: files.length, + percent: completedFiles / files.length, + completedFiles, + completedSize + }); + } + }) + .then(() => to) + .catch(error => { + throw new CpyError(`Cannot copy from \`${from}\` to \`${to}\`: ${error.message}`, error); + }); + })); + }); + + promise.on = (...args) => { + progressEmitter.on(...args); + return promise; + }; + return promise; }; +module.exports = cpy; +// TODO: Remove this for the next major release +module.exports.default = cpy; + + /***/ }), -/* 688 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { +/* 708 */ +/***/ (function(module, exports, __webpack_require__) { "use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "waitUntilWatchIsReady", function() { return waitUntilWatchIsReady; }); -/* harmony import */ var rxjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(392); -/* harmony import */ var rxjs_operators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(169); -/* - * 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. - */ +module.exports = function (val) { + if (val === null || val === undefined) { + return []; + } -/** - * Number of milliseconds we wait before we fall back to the default watch handler. - */ + return Array.isArray(val) ? val : [val]; +}; -const defaultHandlerDelay = 3000; -/** - * If default watch handler is used, then it's the number of milliseconds we wait for - * any build output before we consider watch task ready. - */ -const defaultHandlerReadinessTimeout = 2000; -/** - * Describes configurable watch options. - */ +/***/ }), +/* 709 */ +/***/ (function(module, exports, __webpack_require__) { -function getWatchHandlers(buildOutput$, { - handlerDelay = defaultHandlerDelay, - handlerReadinessTimeout = defaultHandlerReadinessTimeout -}) { - const typescriptHandler = buildOutput$.pipe(Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["first"])(data => data.includes('$ tsc')), Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["map"])(() => buildOutput$.pipe(Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["first"])(data => data.includes('Compilation complete.')), Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["mapTo"])('tsc')))); - const webpackHandler = buildOutput$.pipe(Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["first"])(data => data.includes('$ webpack')), Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["map"])(() => buildOutput$.pipe(Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["first"])(data => data.includes('Chunk Names')), Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["mapTo"])('webpack')))); - const defaultHandler = rxjs__WEBPACK_IMPORTED_MODULE_0__["of"](undefined).pipe(Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["delay"])(handlerReadinessTimeout), Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["map"])(() => buildOutput$.pipe(Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["timeout"])(handlerDelay), Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["catchError"])(() => rxjs__WEBPACK_IMPORTED_MODULE_0__["of"]('timeout'))))); - return [typescriptHandler, webpackHandler, defaultHandler]; -} +"use strict"; -function waitUntilWatchIsReady(stream, opts = {}) { - const buildOutput$ = new rxjs__WEBPACK_IMPORTED_MODULE_0__["Subject"](); +const fs = __webpack_require__(23); +const arrayUnion = __webpack_require__(710); +const glob = __webpack_require__(712); +const fastGlob = __webpack_require__(717); +const dirGlob = __webpack_require__(905); +const gitignore = __webpack_require__(908); - const onDataListener = data => buildOutput$.next(data.toString('utf-8')); +const DEFAULT_FILTER = () => false; - const onEndListener = () => buildOutput$.complete(); +const isNegative = pattern => pattern[0] === '!'; - const onErrorListener = e => buildOutput$.error(e); +const assertPatternsInput = patterns => { + if (!patterns.every(x => typeof x === 'string')) { + throw new TypeError('Patterns must be a string or an array of strings'); + } +}; + +const checkCwdOption = options => { + if (options && options.cwd && !fs.statSync(options.cwd).isDirectory()) { + throw new Error('The `cwd` option must be a path to a directory'); + } +}; + +const generateGlobTasks = (patterns, taskOptions) => { + patterns = arrayUnion([].concat(patterns)); + assertPatternsInput(patterns); + checkCwdOption(taskOptions); + + const globTasks = []; + + taskOptions = Object.assign({ + ignore: [], + expandDirectories: true + }, taskOptions); + + patterns.forEach((pattern, i) => { + if (isNegative(pattern)) { + return; + } + + const ignore = patterns + .slice(i) + .filter(isNegative) + .map(pattern => pattern.slice(1)); + + const options = Object.assign({}, taskOptions, { + ignore: taskOptions.ignore.concat(ignore) + }); + + globTasks.push({pattern, options}); + }); + + return globTasks; +}; + +const globDirs = (task, fn) => { + let options = {}; + if (task.options.cwd) { + options.cwd = task.options.cwd; + } + + if (Array.isArray(task.options.expandDirectories)) { + options = Object.assign(options, {files: task.options.expandDirectories}); + } else if (typeof task.options.expandDirectories === 'object') { + options = Object.assign(options, task.options.expandDirectories); + } + + return fn(task.pattern, options); +}; + +const getPattern = (task, fn) => task.options.expandDirectories ? globDirs(task, fn) : [task.pattern]; + +const globToTask = task => glob => { + const {options} = task; + if (options.ignore && Array.isArray(options.ignore) && options.expandDirectories) { + options.ignore = dirGlob.sync(options.ignore); + } + + return { + pattern: glob, + options + }; +}; + +const globby = (patterns, options) => { + let globTasks; + + try { + globTasks = generateGlobTasks(patterns, options); + } catch (error) { + return Promise.reject(error); + } + + const getTasks = Promise.all(globTasks.map(task => Promise.resolve(getPattern(task, dirGlob)) + .then(globs => Promise.all(globs.map(globToTask(task)))) + )) + .then(tasks => arrayUnion(...tasks)); + + const getFilter = () => { + return Promise.resolve( + options && options.gitignore ? + gitignore({cwd: options.cwd, ignore: options.ignore}) : + DEFAULT_FILTER + ); + }; + + return getFilter() + .then(filter => { + return getTasks + .then(tasks => Promise.all(tasks.map(task => fastGlob(task.pattern, task.options)))) + .then(paths => arrayUnion(...paths)) + .then(paths => paths.filter(p => !filter(p))); + }); +}; + +module.exports = globby; +// TODO: Remove this for the next major release +module.exports.default = globby; + +module.exports.sync = (patterns, options) => { + const globTasks = generateGlobTasks(patterns, options); + + const getFilter = () => { + return options && options.gitignore ? + gitignore.sync({cwd: options.cwd, ignore: options.ignore}) : + DEFAULT_FILTER; + }; + + const tasks = globTasks.reduce((tasks, task) => { + const newTask = getPattern(task, dirGlob.sync).map(globToTask(task)); + return tasks.concat(newTask); + }, []); + + const filter = getFilter(); + return tasks.reduce( + (matches, task) => arrayUnion(matches, fastGlob.sync(task.pattern, task.options)), + [] + ).filter(p => !filter(p)); +}; + +module.exports.generateGlobTasks = generateGlobTasks; + +module.exports.hasMagic = (patterns, options) => [] + .concat(patterns) + .some(pattern => glob.hasMagic(pattern, options)); + +module.exports.gitignore = gitignore; - stream.once('end', onEndListener); - stream.once('error', onErrorListener); - stream.on('data', onDataListener); - return rxjs__WEBPACK_IMPORTED_MODULE_0__["race"](getWatchHandlers(buildOutput$, opts)).pipe(Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["mergeMap"])(whenReady => whenReady), Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_1__["finalize"])(() => { - stream.removeListener('data', onDataListener); - stream.removeListener('end', onEndListener); - stream.removeListener('error', onErrorListener); - buildOutput$.complete(); - })).toPromise(); -} /***/ }), -/* 689 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { +/* 710 */ +/***/ (function(module, exports, __webpack_require__) { "use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "runCommand", function() { return runCommand; }); -/* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2); -/* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var indent_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(673); -/* harmony import */ var indent_string__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(indent_string__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var wrap_ansi__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(690); -/* harmony import */ var wrap_ansi__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(wrap_ansi__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var _utils_errors__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(515); -/* harmony import */ var _utils_log__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(34); -/* harmony import */ var _utils_projects__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(501); -/* harmony import */ var _utils_projects_tree__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(697); -/* harmony import */ var _utils_kibana__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(698); -function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } - -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } +var arrayUniq = __webpack_require__(711); -/* - * 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. - */ +module.exports = function () { + return arrayUniq([].concat.apply([], arguments)); +}; +/***/ }), +/* 711 */ +/***/ (function(module, exports, __webpack_require__) { +"use strict"; +// there's 3 implementations written in increasing order of efficiency +// 1 - no Set type is defined +function uniqNoSet(arr) { + var ret = []; + for (var i = 0; i < arr.length; i++) { + if (ret.indexOf(arr[i]) === -1) { + ret.push(arr[i]); + } + } -async function runCommand(command, config) { - try { - _utils_log__WEBPACK_IMPORTED_MODULE_4__["log"].write(chalk__WEBPACK_IMPORTED_MODULE_0___default.a.bold(`Running [${chalk__WEBPACK_IMPORTED_MODULE_0___default.a.green(command.name)}] command from [${chalk__WEBPACK_IMPORTED_MODULE_0___default.a.yellow(config.rootPath)}]:\n`)); - const kbn = await _utils_kibana__WEBPACK_IMPORTED_MODULE_7__["Kibana"].loadFrom(config.rootPath); - const projects = kbn.getFilteredProjects({ - skipKibanaPlugins: Boolean(config.options['skip-kibana-plugins']), - ossOnly: Boolean(config.options.oss), - exclude: toArray(config.options.exclude), - include: toArray(config.options.include) - }); + return ret; +} - if (projects.size === 0) { - _utils_log__WEBPACK_IMPORTED_MODULE_4__["log"].write(chalk__WEBPACK_IMPORTED_MODULE_0___default.a.red(`There are no projects found. Double check project name(s) in '-i/--include' and '-e/--exclude' filters.\n`)); - return process.exit(1); - } +// 2 - a simple Set type is defined +function uniqSet(arr) { + var seen = new Set(); + return arr.filter(function (el) { + if (!seen.has(el)) { + seen.add(el); + return true; + } - const projectGraph = Object(_utils_projects__WEBPACK_IMPORTED_MODULE_5__["buildProjectGraph"])(projects); - _utils_log__WEBPACK_IMPORTED_MODULE_4__["log"].write(chalk__WEBPACK_IMPORTED_MODULE_0___default.a.bold(`Found [${chalk__WEBPACK_IMPORTED_MODULE_0___default.a.green(projects.size.toString())}] projects:\n`)); - _utils_log__WEBPACK_IMPORTED_MODULE_4__["log"].write(Object(_utils_projects_tree__WEBPACK_IMPORTED_MODULE_6__["renderProjectsTree"])(config.rootPath, projects)); - await command.run(projects, projectGraph, _objectSpread({}, config, { - kbn - })); - } catch (e) { - _utils_log__WEBPACK_IMPORTED_MODULE_4__["log"].write(chalk__WEBPACK_IMPORTED_MODULE_0___default.a.bold.red(`\n[${command.name}] failed:\n`)); + return false; + }); +} - if (e instanceof _utils_errors__WEBPACK_IMPORTED_MODULE_3__["CliError"]) { - const msg = chalk__WEBPACK_IMPORTED_MODULE_0___default.a.red(`CliError: ${e.message}\n`); - _utils_log__WEBPACK_IMPORTED_MODULE_4__["log"].write(wrap_ansi__WEBPACK_IMPORTED_MODULE_2___default()(msg, 80)); - const keys = Object.keys(e.meta); +// 3 - a standard Set type is defined and it has a forEach method +function uniqSetWithForEach(arr) { + var ret = []; - if (keys.length > 0) { - const metaOutput = keys.map(key => { - const value = e.meta[key]; - return `${key}: ${value}`; - }); - _utils_log__WEBPACK_IMPORTED_MODULE_4__["log"].write('Additional debugging info:\n'); - _utils_log__WEBPACK_IMPORTED_MODULE_4__["log"].write(indent_string__WEBPACK_IMPORTED_MODULE_1___default()(metaOutput.join('\n'), 3)); - } - } else { - _utils_log__WEBPACK_IMPORTED_MODULE_4__["log"].write(e.stack); - } + (new Set(arr)).forEach(function (el) { + ret.push(el); + }); - process.exit(1); - } + return ret; } -function toArray(value) { - if (value == null) { - return []; - } +// V8 currently has a broken implementation +// https://github.com/joyent/node/issues/8449 +function doesForEachActuallyWork() { + var ret = false; - return Array.isArray(value) ? value : [value]; + (new Set([true])).forEach(function (el) { + ret = el; + }); + + return ret === true; +} + +if ('Set' in global) { + if (typeof Set.prototype.forEach === 'function' && doesForEachActuallyWork()) { + module.exports = uniqSetWithForEach; + } else { + module.exports = uniqSet; + } +} else { + module.exports = uniqNoSet; } + /***/ }), -/* 690 */ +/* 712 */ /***/ (function(module, exports, __webpack_require__) { -"use strict"; +// Approach: +// +// 1. Get the minimatch set +// 2. For each pattern in the set, PROCESS(pattern, false) +// 3. Store matches per-set, then uniq them +// +// PROCESS(pattern, inGlobStar) +// Get the first [n] items from pattern that are all strings +// Join these together. This is PREFIX. +// If there is no more remaining, then stat(PREFIX) and +// add to matches if it succeeds. END. +// +// If inGlobStar and PREFIX is symlink and points to dir +// set ENTRIES = [] +// else readdir(PREFIX) as ENTRIES +// If fail, END +// +// with ENTRIES +// If pattern[n] is GLOBSTAR +// // handle the case where the globstar match is empty +// // by pruning it out, and testing the resulting pattern +// PROCESS(pattern[0..n] + pattern[n+1 .. $], false) +// // handle other cases. +// for ENTRY in ENTRIES (not dotfiles) +// // attach globstar + tail onto the entry +// // Mark that this entry is a globstar match +// PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true) +// +// else // not globstar +// for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot) +// Test ENTRY against pattern[n] +// If fails, continue +// If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $]) +// +// Caveat: +// Cache all stats and readdirs results to minimize syscall. Since all +// we ever care about is existence and directory-ness, we can just keep +// `true` for files, and [children,...] for directories, or `false` for +// things that don't exist. -const stringWidth = __webpack_require__(691); -const stripAnsi = __webpack_require__(695); +module.exports = glob -const ESCAPES = new Set([ - '\u001B', - '\u009B' -]); +var fs = __webpack_require__(23) +var rp = __webpack_require__(503) +var minimatch = __webpack_require__(505) +var Minimatch = minimatch.Minimatch +var inherits = __webpack_require__(713) +var EE = __webpack_require__(379).EventEmitter +var path = __webpack_require__(16) +var assert = __webpack_require__(30) +var isAbsolute = __webpack_require__(511) +var globSync = __webpack_require__(715) +var common = __webpack_require__(716) +var alphasort = common.alphasort +var alphasorti = common.alphasorti +var setopts = common.setopts +var ownProp = common.ownProp +var inflight = __webpack_require__(514) +var util = __webpack_require__(29) +var childrenIgnored = common.childrenIgnored +var isIgnored = common.isIgnored -const END_CODE = 39; +var once = __webpack_require__(385) -const ESCAPE_CODES = new Map([ - [0, 0], - [1, 22], - [2, 22], - [3, 23], - [4, 24], - [7, 27], - [8, 28], - [9, 29], - [30, 39], - [31, 39], - [32, 39], - [33, 39], - [34, 39], - [35, 39], - [36, 39], - [37, 39], - [90, 39], - [40, 49], - [41, 49], - [42, 49], - [43, 49], - [44, 49], - [45, 49], - [46, 49], - [47, 49] -]); +function glob (pattern, options, cb) { + if (typeof options === 'function') cb = options, options = {} + if (!options) options = {} -const wrapAnsi = code => `${ESCAPES.values().next().value}[${code}m`; + if (options.sync) { + if (cb) + throw new TypeError('callback provided to sync glob') + return globSync(pattern, options) + } -// Calculate the length of words split on ' ', ignoring -// the extra characters added by ansi escape codes -const wordLengths = str => str.split(' ').map(s => stringWidth(s)); + return new Glob(pattern, options, cb) +} -// Wrap a long word across multiple rows -// Ansi escape codes do not count towards length -const wrapWord = (rows, word, cols) => { - const arr = Array.from(word); +glob.sync = globSync +var GlobSync = glob.GlobSync = globSync.GlobSync - let insideEscape = false; - let visible = stringWidth(stripAnsi(rows[rows.length - 1])); +// old api surface +glob.glob = glob - for (const item of arr.entries()) { - const i = item[0]; - const char = item[1]; - const charLength = stringWidth(char); +function extend (origin, add) { + if (add === null || typeof add !== 'object') { + return origin + } - if (visible + charLength <= cols) { - rows[rows.length - 1] += char; - } else { - rows.push(char); - visible = 0; - } + var keys = Object.keys(add) + var i = keys.length + while (i--) { + origin[keys[i]] = add[keys[i]] + } + return origin +} - if (ESCAPES.has(char)) { - insideEscape = true; - } else if (insideEscape && char === 'm') { - insideEscape = false; - continue; - } +glob.hasMagic = function (pattern, options_) { + var options = extend({}, options_) + options.noprocess = true - if (insideEscape) { - continue; - } + var g = new Glob(pattern, options) + var set = g.minimatch.set - visible += charLength; + if (!pattern) + return false - if (visible === cols && i < arr.length - 1) { - rows.push(''); - visible = 0; - } - } + if (set.length > 1) + return true - // It's possible that the last row we copy over is only - // ansi escape characters, handle this edge-case - if (!visible && rows[rows.length - 1].length > 0 && rows.length > 1) { - rows[rows.length - 2] += rows.pop(); - } -}; + for (var j = 0; j < set[0].length; j++) { + if (typeof set[0][j] !== 'string') + return true + } -// The wrap-ansi module can be invoked -// in either 'hard' or 'soft' wrap mode -// -// 'hard' will never allow a string to take up more -// than cols characters -// -// 'soft' allows long words to expand past the column length -const exec = (str, cols, opts) => { - const options = opts || {}; + return false +} - if (str.trim() === '') { - return options.trim === false ? str : str.trim(); - } +glob.Glob = Glob +inherits(Glob, EE) +function Glob (pattern, options, cb) { + if (typeof options === 'function') { + cb = options + options = null + } - let pre = ''; - let ret = ''; - let escapeCode; + if (options && options.sync) { + if (cb) + throw new TypeError('callback provided to sync glob') + return new GlobSync(pattern, options) + } - const lengths = wordLengths(str); - const words = str.split(' '); - const rows = ['']; + if (!(this instanceof Glob)) + return new Glob(pattern, options, cb) - for (const item of Array.from(words).entries()) { - const i = item[0]; - const word = item[1]; + setopts(this, pattern, options) + this._didRealPath = false - rows[rows.length - 1] = options.trim === false ? rows[rows.length - 1] : rows[rows.length - 1].trim(); - let rowLength = stringWidth(rows[rows.length - 1]); + // process each pattern in the minimatch set + var n = this.minimatch.set.length - if (rowLength || word === '') { - if (rowLength === cols && options.wordWrap === false) { - // If we start with a new word but the current row length equals the length of the columns, add a new row - rows.push(''); - rowLength = 0; - } + // The matches are stored as {: true,...} so that + // duplicates are automagically pruned. + // Later, we do an Object.keys() on these. + // Keep them as a list so we can fill in when nonull is set. + this.matches = new Array(n) - rows[rows.length - 1] += ' '; - rowLength++; - } + if (typeof cb === 'function') { + cb = once(cb) + this.on('error', cb) + this.on('end', function (matches) { + cb(null, matches) + }) + } - // In 'hard' wrap mode, the length of a line is - // never allowed to extend past 'cols' - if (lengths[i] > cols && options.hard) { - if (rowLength) { - rows.push(''); - } - wrapWord(rows, word, cols); - continue; - } + var self = this + this._processing = 0 - if (rowLength + lengths[i] > cols && rowLength > 0) { - if (options.wordWrap === false && rowLength < cols) { - wrapWord(rows, word, cols); - continue; - } + this._emitQueue = [] + this._processQueue = [] + this.paused = false - rows.push(''); - } + if (this.noprocess) + return this - if (rowLength + lengths[i] > cols && options.wordWrap === false) { - wrapWord(rows, word, cols); - continue; - } + if (n === 0) + return done() - rows[rows.length - 1] += word; - } + var sync = true + for (var i = 0; i < n; i ++) { + this._process(this.minimatch.set[i], i, false, done) + } + sync = false - pre = rows.map(r => options.trim === false ? r : r.trim()).join('\n'); + function done () { + --self._processing + if (self._processing <= 0) { + if (sync) { + process.nextTick(function () { + self._finish() + }) + } else { + self._finish() + } + } + } +} - for (const item of Array.from(pre).entries()) { - const i = item[0]; - const char = item[1]; +Glob.prototype._finish = function () { + assert(this instanceof Glob) + if (this.aborted) + return - ret += char; + if (this.realpath && !this._didRealpath) + return this._realpath() - if (ESCAPES.has(char)) { - const code = parseFloat(/\d[^m]*/.exec(pre.slice(i, i + 4))); - escapeCode = code === END_CODE ? null : code; - } + common.finish(this) + this.emit('end', this.found) +} - const code = ESCAPE_CODES.get(Number(escapeCode)); +Glob.prototype._realpath = function () { + if (this._didRealpath) + return - if (escapeCode && code) { - if (pre[i + 1] === '\n') { - ret += wrapAnsi(code); - } else if (char === '\n') { - ret += wrapAnsi(escapeCode); - } - } - } + this._didRealpath = true - return ret; -}; + var n = this.matches.length + if (n === 0) + return this._finish() -// For each newline, invoke the method separately -module.exports = (str, cols, opts) => { - return String(str) - .normalize() - .split('\n') - .map(line => exec(line, cols, opts)) - .join('\n'); -}; + var self = this + for (var i = 0; i < this.matches.length; i++) + this._realpathSet(i, next) + + function next () { + if (--n === 0) + self._finish() + } +} +Glob.prototype._realpathSet = function (index, cb) { + var matchset = this.matches[index] + if (!matchset) + return cb() -/***/ }), -/* 691 */ -/***/ (function(module, exports, __webpack_require__) { + var found = Object.keys(matchset) + var self = this + var n = found.length + + if (n === 0) + return cb() + + var set = this.matches[index] = Object.create(null) + found.forEach(function (p, i) { + // If there's a problem with the stat, then it means that + // one or more of the links in the realpath couldn't be + // resolved. just return the abs value in that case. + p = self._makeAbs(p) + rp.realpath(p, self.realpathCache, function (er, real) { + if (!er) + set[real] = true + else if (er.syscall === 'stat') + set[p] = true + else + self.emit('error', er) // srsly wtf right here + + if (--n === 0) { + self.matches[index] = set + cb() + } + }) + }) +} + +Glob.prototype._mark = function (p) { + return common.mark(this, p) +} -"use strict"; +Glob.prototype._makeAbs = function (f) { + return common.makeAbs(this, f) +} -const stripAnsi = __webpack_require__(692); -const isFullwidthCodePoint = __webpack_require__(694); +Glob.prototype.abort = function () { + this.aborted = true + this.emit('abort') +} -module.exports = str => { - if (typeof str !== 'string' || str.length === 0) { - return 0; - } +Glob.prototype.pause = function () { + if (!this.paused) { + this.paused = true + this.emit('pause') + } +} - str = stripAnsi(str); +Glob.prototype.resume = function () { + if (this.paused) { + this.emit('resume') + this.paused = false + if (this._emitQueue.length) { + var eq = this._emitQueue.slice(0) + this._emitQueue.length = 0 + for (var i = 0; i < eq.length; i ++) { + var e = eq[i] + this._emitMatch(e[0], e[1]) + } + } + if (this._processQueue.length) { + var pq = this._processQueue.slice(0) + this._processQueue.length = 0 + for (var i = 0; i < pq.length; i ++) { + var p = pq[i] + this._processing-- + this._process(p[0], p[1], p[2], p[3]) + } + } + } +} - let width = 0; +Glob.prototype._process = function (pattern, index, inGlobStar, cb) { + assert(this instanceof Glob) + assert(typeof cb === 'function') - for (let i = 0; i < str.length; i++) { - const code = str.codePointAt(i); + if (this.aborted) + return - // Ignore control characters - if (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) { - continue; - } + this._processing++ + if (this.paused) { + this._processQueue.push([pattern, index, inGlobStar, cb]) + return + } - // Ignore combining characters - if (code >= 0x300 && code <= 0x36F) { - continue; - } + //console.error('PROCESS %d', this._processing, pattern) - // Surrogates - if (code > 0xFFFF) { - i++; - } + // Get the first [n] parts of pattern that are all strings. + var n = 0 + while (typeof pattern[n] === 'string') { + n ++ + } + // now n is the index of the first one that is *not* a string. - width += isFullwidthCodePoint(code) ? 2 : 1; - } + // see if there's anything else + var prefix + switch (n) { + // if not, then this is rather simple + case pattern.length: + this._processSimple(pattern.join('/'), index, cb) + return - return width; -}; + case 0: + // pattern *starts* with some non-trivial item. + // going to readdir(cwd), but not include the prefix in matches. + prefix = null + break + default: + // pattern has some string bits in the front. + // whatever it starts with, whether that's 'absolute' like /foo/bar, + // or 'relative' like '../baz' + prefix = pattern.slice(0, n).join('/') + break + } -/***/ }), -/* 692 */ -/***/ (function(module, exports, __webpack_require__) { + var remain = pattern.slice(n) -"use strict"; + // get the list of entries. + var read + if (prefix === null) + read = '.' + else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) { + if (!prefix || !isAbsolute(prefix)) + prefix = '/' + prefix + read = prefix + } else + read = prefix -const ansiRegex = __webpack_require__(693); + var abs = this._makeAbs(read) -module.exports = input => typeof input === 'string' ? input.replace(ansiRegex(), '') : input; + //if ignored, skip _processing + if (childrenIgnored(this, read)) + return cb() + var isGlobStar = remain[0] === minimatch.GLOBSTAR + if (isGlobStar) + this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb) + else + this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb) +} -/***/ }), -/* 693 */ -/***/ (function(module, exports, __webpack_require__) { +Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) { + var self = this + this._readdir(abs, inGlobStar, function (er, entries) { + return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb) + }) +} -"use strict"; +Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { + // if the abs isn't a dir, then nothing can match! + if (!entries) + return cb() -module.exports = () => { - const pattern = [ - '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)', - '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))' - ].join('|'); + // It will only match dot entries if it starts with a dot, or if + // dot is set. Stuff like @(.foo|.bar) isn't allowed. + var pn = remain[0] + var negate = !!this.minimatch.negate + var rawGlob = pn._glob + var dotOk = this.dot || rawGlob.charAt(0) === '.' - return new RegExp(pattern, 'g'); -}; + var matchedEntries = [] + for (var i = 0; i < entries.length; i++) { + var e = entries[i] + if (e.charAt(0) !== '.' || dotOk) { + var m + if (negate && !prefix) { + m = !e.match(pn) + } else { + m = e.match(pn) + } + if (m) + matchedEntries.push(e) + } + } + //console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries) -/***/ }), -/* 694 */ -/***/ (function(module, exports, __webpack_require__) { + var len = matchedEntries.length + // If there are no matched entries, then nothing matches. + if (len === 0) + return cb() -"use strict"; + // if this is the last remaining pattern bit, then no need for + // an additional stat *unless* the user has specified mark or + // stat explicitly. We know they exist, since readdir returned + // them. -/* eslint-disable yoda */ -module.exports = x => { - if (Number.isNaN(x)) { - return false; - } + if (remain.length === 1 && !this.mark && !this.stat) { + if (!this.matches[index]) + this.matches[index] = Object.create(null) - // code points are derived from: - // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt - if ( - x >= 0x1100 && ( - x <= 0x115f || // Hangul Jamo - x === 0x2329 || // LEFT-POINTING ANGLE BRACKET - x === 0x232a || // RIGHT-POINTING ANGLE BRACKET - // CJK Radicals Supplement .. Enclosed CJK Letters and Months - (0x2e80 <= x && x <= 0x3247 && x !== 0x303f) || - // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A - (0x3250 <= x && x <= 0x4dbf) || - // CJK Unified Ideographs .. Yi Radicals - (0x4e00 <= x && x <= 0xa4c6) || - // Hangul Jamo Extended-A - (0xa960 <= x && x <= 0xa97c) || - // Hangul Syllables - (0xac00 <= x && x <= 0xd7a3) || - // CJK Compatibility Ideographs - (0xf900 <= x && x <= 0xfaff) || - // Vertical Forms - (0xfe10 <= x && x <= 0xfe19) || - // CJK Compatibility Forms .. Small Form Variants - (0xfe30 <= x && x <= 0xfe6b) || - // Halfwidth and Fullwidth Forms - (0xff01 <= x && x <= 0xff60) || - (0xffe0 <= x && x <= 0xffe6) || - // Kana Supplement - (0x1b000 <= x && x <= 0x1b001) || - // Enclosed Ideographic Supplement - (0x1f200 <= x && x <= 0x1f251) || - // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane - (0x20000 <= x && x <= 0x3fffd) - ) - ) { - return true; - } + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i] + if (prefix) { + if (prefix !== '/') + e = prefix + '/' + e + else + e = prefix + e + } - return false; -}; + if (e.charAt(0) === '/' && !this.nomount) { + e = path.join(this.root, e) + } + this._emitMatch(index, e) + } + // This was the last one, and no stats were needed + return cb() + } + // now test all matched entries as stand-ins for that part + // of the pattern. + remain.shift() + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i] + var newPattern + if (prefix) { + if (prefix !== '/') + e = prefix + '/' + e + else + e = prefix + e + } + this._process([e].concat(remain), index, inGlobStar, cb) + } + cb() +} -/***/ }), -/* 695 */ -/***/ (function(module, exports, __webpack_require__) { +Glob.prototype._emitMatch = function (index, e) { + if (this.aborted) + return -"use strict"; + if (isIgnored(this, e)) + return -const ansiRegex = __webpack_require__(696); + if (this.paused) { + this._emitQueue.push([index, e]) + return + } -module.exports = input => typeof input === 'string' ? input.replace(ansiRegex(), '') : input; + var abs = isAbsolute(e) ? e : this._makeAbs(e) + if (this.mark) + e = this._mark(e) -/***/ }), -/* 696 */ -/***/ (function(module, exports, __webpack_require__) { + if (this.absolute) + e = abs -"use strict"; + if (this.matches[index][e]) + return + if (this.nodir) { + var c = this.cache[abs] + if (c === 'DIR' || Array.isArray(c)) + return + } -module.exports = () => { - const pattern = [ - '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)', - '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))' - ].join('|'); + this.matches[index][e] = true - return new RegExp(pattern, 'g'); -}; + var st = this.statCache[abs] + if (st) + this.emit('stat', e, st) + this.emit('match', e) +} -/***/ }), -/* 697 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { +Glob.prototype._readdirInGlobStar = function (abs, cb) { + if (this.aborted) + return -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "renderProjectsTree", function() { return renderProjectsTree; }); -/* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2); -/* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(16); -/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__); -/* - * 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. - */ + // follow all symlinked directories forever + // just proceed as if this is a non-globstar situation + if (this.follow) + return this._readdir(abs, false, cb) + var lstatkey = 'lstat\0' + abs + var self = this + var lstatcb = inflight(lstatkey, lstatcb_) -const projectKey = Symbol('__project'); -function renderProjectsTree(rootPath, projects) { - const projectsTree = buildProjectsTree(rootPath, projects); - return treeToString(createTreeStructure(projectsTree)); -} + if (lstatcb) + fs.lstat(abs, lstatcb) -function treeToString(tree) { - return [tree.name].concat(childrenToStrings(tree.children, '')).join('\n'); -} + function lstatcb_ (er, lstat) { + if (er && er.code === 'ENOENT') + return cb() -function childrenToStrings(tree, treePrefix) { - if (tree === undefined) { - return []; - } + var isSym = lstat && lstat.isSymbolicLink() + self.symlinks[abs] = isSym - let strings = []; - tree.forEach((node, index) => { - const isLastNode = tree.length - 1 === index; - const nodePrefix = isLastNode ? '└── ' : '├── '; - const childPrefix = isLastNode ? ' ' : '│ '; - const childrenPrefix = treePrefix + childPrefix; - strings.push(`${treePrefix}${nodePrefix}${node.name}`); - strings = strings.concat(childrenToStrings(node.children, childrenPrefix)); - }); - return strings; + // If it's not a symlink or a dir, then it's definitely a regular file. + // don't bother doing a readdir in that case. + if (!isSym && lstat && !lstat.isDirectory()) { + self.cache[abs] = 'FILE' + cb() + } else + self._readdir(abs, false, cb) + } } -function createTreeStructure(tree) { - let name; - const children = []; +Glob.prototype._readdir = function (abs, inGlobStar, cb) { + if (this.aborted) + return - for (const [dir, project] of tree.entries()) { - // This is a leaf node (aka a project) - if (typeof project === 'string') { - name = chalk__WEBPACK_IMPORTED_MODULE_0___default.a.green(project); - continue; - } // If there's only one project and the key indicates it's a leaf node, we - // know that we're at a package folder that contains a package.json, so we - // "inline it" so we don't get unnecessary levels, i.e. we'll just see - // `foo` instead of `foo -> foo`. + cb = inflight('readdir\0'+abs+'\0'+inGlobStar, cb) + if (!cb) + return + //console.error('RD %j %j', +inGlobStar, abs) + if (inGlobStar && !ownProp(this.symlinks, abs)) + return this._readdirInGlobStar(abs, cb) - if (project.size === 1 && project.has(projectKey)) { - const projectName = project.get(projectKey); - children.push({ - children: [], - name: dirOrProjectName(dir, projectName) - }); - continue; - } + if (ownProp(this.cache, abs)) { + var c = this.cache[abs] + if (!c || c === 'FILE') + return cb() - const subtree = createTreeStructure(project); // If the name is specified, we know there's a package at the "root" of the - // subtree itself. + if (Array.isArray(c)) + return cb(null, c) + } - if (subtree.name !== undefined) { - const projectName = subtree.name; - children.push({ - children: subtree.children, - name: dirOrProjectName(dir, projectName) - }); - continue; - } // Special-case whenever we have one child, so we don't get unnecessary - // folders in the output. E.g. instead of `foo -> bar -> baz` we get - // `foo/bar/baz` instead. + var self = this + fs.readdir(abs, readdirCb(this, abs, cb)) +} +function readdirCb (self, abs, cb) { + return function (er, entries) { + if (er) + self._readdirError(abs, er, cb) + else + self._readdirEntries(abs, entries, cb) + } +} - if (subtree.children && subtree.children.length === 1) { - const child = subtree.children[0]; - const newName = chalk__WEBPACK_IMPORTED_MODULE_0___default.a.dim(path__WEBPACK_IMPORTED_MODULE_1___default.a.join(dir.toString(), child.name)); - children.push({ - children: child.children, - name: newName - }); - continue; - } +Glob.prototype._readdirEntries = function (abs, entries, cb) { + if (this.aborted) + return - children.push({ - children: subtree.children, - name: chalk__WEBPACK_IMPORTED_MODULE_0___default.a.dim(dir.toString()) - }); + // if we haven't asked to stat everything, then just + // assume that everything in there exists, so we can avoid + // having to stat it a second time. + if (!this.mark && !this.stat) { + for (var i = 0; i < entries.length; i ++) { + var e = entries[i] + if (abs === '/') + e = abs + e + else + e = abs + '/' + e + this.cache[e] = true + } } - return { - name, - children - }; + this.cache[abs] = entries + return cb(null, entries) } -function dirOrProjectName(dir, projectName) { - return dir === projectName ? chalk__WEBPACK_IMPORTED_MODULE_0___default.a.green(dir) : chalk__WEBPACK_IMPORTED_MODULE_0___default.a`{dim ${dir.toString()} ({reset.green ${projectName}})}`; -} +Glob.prototype._readdirError = function (f, er, cb) { + if (this.aborted) + return -function buildProjectsTree(rootPath, projects) { - const tree = new Map(); + // handle errors, and cache the information + switch (er.code) { + case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205 + case 'ENOTDIR': // totally normal. means it *does* exist. + var abs = this._makeAbs(f) + this.cache[abs] = 'FILE' + if (abs === this.cwdAbs) { + var error = new Error(er.code + ' invalid cwd ' + this.cwd) + error.path = this.cwd + error.code = er.code + this.emit('error', error) + this.abort() + } + break - for (const project of projects.values()) { - if (rootPath === project.path) { - tree.set(projectKey, project.name); - } else { - const relativeProjectPath = path__WEBPACK_IMPORTED_MODULE_1___default.a.relative(rootPath, project.path); - addProjectToTree(tree, relativeProjectPath.split(path__WEBPACK_IMPORTED_MODULE_1___default.a.sep), project); - } + case 'ENOENT': // not terribly unusual + case 'ELOOP': + case 'ENAMETOOLONG': + case 'UNKNOWN': + this.cache[this._makeAbs(f)] = false + break + + default: // some unusual error. Treat as failure. + this.cache[this._makeAbs(f)] = false + if (this.strict) { + this.emit('error', er) + // If the error is handled, then we abort + // if not, we threw out of here + this.abort() + } + if (!this.silent) + console.error('glob error', er) + break } - return tree; + return cb() } -function addProjectToTree(tree, pathParts, project) { - if (pathParts.length === 0) { - tree.set(projectKey, project.name); - } else { - const [currentDir, ...rest] = pathParts; - - if (!tree.has(currentDir)) { - tree.set(currentDir, new Map()); - } - - const subtree = tree.get(currentDir); - addProjectToTree(subtree, rest, project); - } +Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) { + var self = this + this._readdir(abs, inGlobStar, function (er, entries) { + self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb) + }) } -/***/ }), -/* 698 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Kibana", function() { return Kibana; }); -/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(16); -/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var multimatch__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(699); -/* harmony import */ var multimatch__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(multimatch__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _projects__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(501); -/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(580); -function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } +Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { + //console.error('pgs2', prefix, remain[0], entries) -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + // no entries means not a dir, so it can never have matches + // foo.txt/** doesn't match foo.txt + if (!entries) + return cb() -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + // test without the globstar, and with every child both below + // and replacing the globstar. + var remainWithoutGlobStar = remain.slice(1) + var gspref = prefix ? [ prefix ] : [] + var noGlobStar = gspref.concat(remainWithoutGlobStar) -/* - * 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. - */ + // the noGlobStar pattern exits the inGlobStar state + this._process(noGlobStar, index, false, cb) + var isSym = this.symlinks[abs] + var len = entries.length + // If it's a symlink, and we're in a globstar, then stop + if (isSym && inGlobStar) + return cb() + for (var i = 0; i < len; i++) { + var e = entries[i] + if (e.charAt(0) === '.' && !this.dot) + continue -/** - * Helper class for dealing with a set of projects as children of - * the Kibana project. The kbn/pm is currently implemented to be - * more generic, where everything is an operation of generic projects, - * but that leads to exceptions where we need the kibana project and - * do things like `project.get('kibana')!`. - * - * Using this helper we can restructre the generic list of projects - * as a Kibana object which encapulates all the projects in the - * workspace and knows about the root Kibana project. - */ + // these two cases enter the inGlobStar state + var instead = gspref.concat(entries[i], remainWithoutGlobStar) + this._process(instead, index, true, cb) -class Kibana { - static async loadFrom(rootPath) { - return new Kibana((await Object(_projects__WEBPACK_IMPORTED_MODULE_2__["getProjects"])(rootPath, Object(_config__WEBPACK_IMPORTED_MODULE_3__["getProjectPaths"])({ - rootPath - })))); + var below = gspref.concat(entries[i], remain) + this._process(below, index, true, cb) } - constructor(allWorkspaceProjects) { - this.allWorkspaceProjects = allWorkspaceProjects; - - _defineProperty(this, "kibanaProject", void 0); + cb() +} - const kibanaProject = allWorkspaceProjects.get('kibana'); +Glob.prototype._processSimple = function (prefix, index, cb) { + // XXX review this. Shouldn't it be doing the mounting etc + // before doing stat? kinda weird? + var self = this + this._stat(prefix, function (er, exists) { + self._processSimple2(prefix, index, er, exists, cb) + }) +} +Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) { - if (!kibanaProject) { - throw new TypeError('Unable to create Kibana object without all projects, including the Kibana project.'); - } + //console.error('ps2', prefix, exists) - this.kibanaProject = kibanaProject; - } - /** make an absolute path by resolving subPath relative to the kibana repo */ + if (!this.matches[index]) + this.matches[index] = Object.create(null) + // If it doesn't exist, then just mark the lack of results + if (!exists) + return cb() - getAbsolute(...subPath) { - return path__WEBPACK_IMPORTED_MODULE_0___default.a.resolve(this.kibanaProject.path, ...subPath); + if (prefix && isAbsolute(prefix) && !this.nomount) { + var trail = /[\/\\]$/.test(prefix) + if (prefix.charAt(0) === '/') { + prefix = path.join(this.root, prefix) + } else { + prefix = path.resolve(this.root, prefix) + if (trail) + prefix += '/' + } } - /** convert an absolute path to a relative path, relative to the kibana repo */ + if (process.platform === 'win32') + prefix = prefix.replace(/\\/g, '/') - getRelative(absolute) { - return path__WEBPACK_IMPORTED_MODULE_0___default.a.relative(this.kibanaProject.path, absolute); - } - /** get a copy of the map of all projects in the kibana workspace */ - + // Mark this as a match + this._emitMatch(index, prefix) + cb() +} - getAllProjects() { - return new Map(this.allWorkspaceProjects); - } - /** determine if a project with the given name exists */ +// Returns either 'DIR', 'FILE', or false +Glob.prototype._stat = function (f, cb) { + var abs = this._makeAbs(f) + var needDir = f.slice(-1) === '/' + if (f.length > this.maxLength) + return cb() - hasProject(name) { - return this.allWorkspaceProjects.has(name); - } - /** get a specific project, throws if the name is not known (use hasProject() first) */ + if (!this.stat && ownProp(this.cache, abs)) { + var c = this.cache[abs] + if (Array.isArray(c)) + c = 'DIR' - getProject(name) { - const project = this.allWorkspaceProjects.get(name); + // It exists, but maybe not how we need it + if (!needDir || c === 'DIR') + return cb(null, c) - if (!project) { - throw new Error(`No package with name "${name}" in the workspace`); - } + if (needDir && c === 'FILE') + return cb() - return project; + // otherwise we have to stat, because maybe c=true + // if we know it exists, but not what it is. } - /** get a project and all of the projects it depends on in a ProjectMap */ - - getProjectAndDeps(name) { - const project = this.getProject(name); - return Object(_projects__WEBPACK_IMPORTED_MODULE_2__["includeTransitiveProjects"])([project], this.allWorkspaceProjects); + var exists + var stat = this.statCache[abs] + if (stat !== undefined) { + if (stat === false) + return cb(null, stat) + else { + var type = stat.isDirectory() ? 'DIR' : 'FILE' + if (needDir && type === 'FILE') + return cb() + else + return cb(null, type, stat) + } } - /** filter the projects to just those matching certain paths/include/exclude tags */ - - - getFilteredProjects(options) { - const allProjects = this.getAllProjects(); - const filteredProjects = new Map(); - const pkgJsonPaths = Array.from(allProjects.values()).map(p => p.packageJsonLocation); - const filteredPkgJsonGlobs = Object(_config__WEBPACK_IMPORTED_MODULE_3__["getProjectPaths"])(_objectSpread({}, options, { - rootPath: this.kibanaProject.path - })).map(g => path__WEBPACK_IMPORTED_MODULE_0___default.a.resolve(g, 'package.json')); - const matchingPkgJsonPaths = multimatch__WEBPACK_IMPORTED_MODULE_1___default()(pkgJsonPaths, filteredPkgJsonGlobs); - for (const project of allProjects.values()) { - const pathMatches = matchingPkgJsonPaths.includes(project.packageJsonLocation); - const notExcluded = !options.exclude.includes(project.name); - const isIncluded = !options.include.length || options.include.includes(project.name); + var self = this + var statcb = inflight('stat\0' + abs, lstatcb_) + if (statcb) + fs.lstat(abs, statcb) - if (pathMatches && notExcluded && isIncluded) { - filteredProjects.set(project.name, project); - } + function lstatcb_ (er, lstat) { + if (lstat && lstat.isSymbolicLink()) { + // If it's a symlink, then treat it as the target, unless + // the target does not exist, then treat it as a file. + return fs.stat(abs, function (er, stat) { + if (er) + self._stat2(f, abs, null, lstat, cb) + else + self._stat2(f, abs, er, stat, cb) + }) + } else { + self._stat2(f, abs, er, lstat, cb) } - - return filteredProjects; } - } -/***/ }), -/* 699 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - -const minimatch = __webpack_require__(505); -const arrayUnion = __webpack_require__(700); -const arrayDiffer = __webpack_require__(701); -const arrify = __webpack_require__(702); +Glob.prototype._stat2 = function (f, abs, er, stat, cb) { + if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { + this.statCache[abs] = false + return cb() + } -module.exports = (list, patterns, options = {}) => { - list = arrify(list); - patterns = arrify(patterns); + var needDir = f.slice(-1) === '/' + this.statCache[abs] = stat - if (list.length === 0 || patterns.length === 0) { - return []; - } + if (abs.slice(-1) === '/' && stat && !stat.isDirectory()) + return cb(null, false, stat) - return patterns.reduce((result, pattern) => { - let process = arrayUnion; + var c = true + if (stat) + c = stat.isDirectory() ? 'DIR' : 'FILE' + this.cache[abs] = this.cache[abs] || c - if (pattern[0] === '!') { - pattern = pattern.slice(1); - process = arrayDiffer; - } + if (needDir && c === 'FILE') + return cb() - return process(result, minimatch.match(list, pattern, options)); - }, []); -}; + return cb(null, c, stat) +} /***/ }), -/* 700 */ +/* 713 */ /***/ (function(module, exports, __webpack_require__) { -"use strict"; +try { + var util = __webpack_require__(29); + /* istanbul ignore next */ + if (typeof util.inherits !== 'function') throw ''; + module.exports = util.inherits; +} catch (e) { + /* istanbul ignore next */ + module.exports = __webpack_require__(714); +} -module.exports = (...arguments_) => { - return [...new Set([].concat(...arguments_))]; -}; +/***/ }), +/* 714 */ +/***/ (function(module, exports) { + +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }) + } + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } + } +} /***/ }), -/* 701 */ +/* 715 */ /***/ (function(module, exports, __webpack_require__) { -"use strict"; +module.exports = globSync +globSync.GlobSync = GlobSync +var fs = __webpack_require__(23) +var rp = __webpack_require__(503) +var minimatch = __webpack_require__(505) +var Minimatch = minimatch.Minimatch +var Glob = __webpack_require__(712).Glob +var util = __webpack_require__(29) +var path = __webpack_require__(16) +var assert = __webpack_require__(30) +var isAbsolute = __webpack_require__(511) +var common = __webpack_require__(716) +var alphasort = common.alphasort +var alphasorti = common.alphasorti +var setopts = common.setopts +var ownProp = common.ownProp +var childrenIgnored = common.childrenIgnored +var isIgnored = common.isIgnored -const arrayDiffer = (array, ...values) => { - const rest = new Set([].concat(...values)); - return array.filter(element => !rest.has(element)); -}; +function globSync (pattern, options) { + if (typeof options === 'function' || arguments.length === 3) + throw new TypeError('callback provided to sync glob\n'+ + 'See: https://github.com/isaacs/node-glob/issues/167') -module.exports = arrayDiffer; + return new GlobSync(pattern, options).found +} +function GlobSync (pattern, options) { + if (!pattern) + throw new Error('must provide pattern') -/***/ }), -/* 702 */ -/***/ (function(module, exports, __webpack_require__) { + if (typeof options === 'function' || arguments.length === 3) + throw new TypeError('callback provided to sync glob\n'+ + 'See: https://github.com/isaacs/node-glob/issues/167') -"use strict"; + if (!(this instanceof GlobSync)) + return new GlobSync(pattern, options) + setopts(this, pattern, options) -const arrify = value => { - if (value === null || value === undefined) { - return []; - } + if (this.noprocess) + return this - if (Array.isArray(value)) { - return value; - } + var n = this.minimatch.set.length + this.matches = new Array(n) + for (var i = 0; i < n; i ++) { + this._process(this.minimatch.set[i], i, false) + } + this._finish() +} - if (typeof value === 'string') { - return [value]; - } +GlobSync.prototype._finish = function () { + assert(this instanceof GlobSync) + if (this.realpath) { + var self = this + this.matches.forEach(function (matchset, index) { + var set = self.matches[index] = Object.create(null) + for (var p in matchset) { + try { + p = self._makeAbs(p) + var real = rp.realpathSync(p, self.realpathCache) + set[real] = true + } catch (er) { + if (er.syscall === 'stat') + set[self._makeAbs(p)] = true + else + throw er + } + } + }) + } + common.finish(this) +} - if (typeof value[Symbol.iterator] === 'function') { - return [...value]; - } - return [value]; -}; +GlobSync.prototype._process = function (pattern, index, inGlobStar) { + assert(this instanceof GlobSync) -module.exports = arrify; + // Get the first [n] parts of pattern that are all strings. + var n = 0 + while (typeof pattern[n] === 'string') { + n ++ + } + // now n is the index of the first one that is *not* a string. + // See if there's anything else + var prefix + switch (n) { + // if not, then this is rather simple + case pattern.length: + this._processSimple(pattern.join('/'), index) + return -/***/ }), -/* 703 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + case 0: + // pattern *starts* with some non-trivial item. + // going to readdir(cwd), but not include the prefix in matches. + prefix = null + break -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var _build_production_projects__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(704); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "buildProductionProjects", function() { return _build_production_projects__WEBPACK_IMPORTED_MODULE_0__["buildProductionProjects"]; }); + default: + // pattern has some string bits in the front. + // whatever it starts with, whether that's 'absolute' like /foo/bar, + // or 'relative' like '../baz' + prefix = pattern.slice(0, n).join('/') + break + } -/* harmony import */ var _prepare_project_dependencies__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(914); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "prepareExternalProjectDependencies", function() { return _prepare_project_dependencies__WEBPACK_IMPORTED_MODULE_1__["prepareExternalProjectDependencies"]; }); + var remain = pattern.slice(n) -/* - * 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. - */ + // get the list of entries. + var read + if (prefix === null) + read = '.' + else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) { + if (!prefix || !isAbsolute(prefix)) + prefix = '/' + prefix + read = prefix + } else + read = prefix + var abs = this._makeAbs(read) + //if ignored, skip processing + if (childrenIgnored(this, read)) + return -/***/ }), -/* 704 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + var isGlobStar = remain[0] === minimatch.GLOBSTAR + if (isGlobStar) + this._processGlobStar(prefix, read, abs, remain, index, inGlobStar) + else + this._processReaddir(prefix, read, abs, remain, index, inGlobStar) +} -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "buildProductionProjects", function() { return buildProductionProjects; }); -/* harmony import */ var cpy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(705); -/* harmony import */ var cpy__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(cpy__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var del__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(588); -/* harmony import */ var del__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(del__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(16); -/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(580); -/* harmony import */ var _utils_fs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(20); -/* harmony import */ var _utils_log__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(34); -/* harmony import */ var _utils_package_json__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(517); -/* harmony import */ var _utils_projects__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(501); -/* - * 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. - */ +GlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) { + var entries = this._readdir(abs, inGlobStar) + // if the abs isn't a dir, then nothing can match! + if (!entries) + return + // It will only match dot entries if it starts with a dot, or if + // dot is set. Stuff like @(.foo|.bar) isn't allowed. + var pn = remain[0] + var negate = !!this.minimatch.negate + var rawGlob = pn._glob + var dotOk = this.dot || rawGlob.charAt(0) === '.' + var matchedEntries = [] + for (var i = 0; i < entries.length; i++) { + var e = entries[i] + if (e.charAt(0) !== '.' || dotOk) { + var m + if (negate && !prefix) { + m = !e.match(pn) + } else { + m = e.match(pn) + } + if (m) + matchedEntries.push(e) + } + } + var len = matchedEntries.length + // If there are no matched entries, then nothing matches. + if (len === 0) + return + // if this is the last remaining pattern bit, then no need for + // an additional stat *unless* the user has specified mark or + // stat explicitly. We know they exist, since readdir returned + // them. + if (remain.length === 1 && !this.mark && !this.stat) { + if (!this.matches[index]) + this.matches[index] = Object.create(null) -async function buildProductionProjects({ - kibanaRoot, - buildRoot, - onlyOSS -}) { - const projects = await getProductionProjects(kibanaRoot, onlyOSS); - const projectGraph = Object(_utils_projects__WEBPACK_IMPORTED_MODULE_7__["buildProjectGraph"])(projects); - const batchedProjects = Object(_utils_projects__WEBPACK_IMPORTED_MODULE_7__["topologicallyBatchProjects"])(projects, projectGraph); - const projectNames = [...projects.values()].map(project => project.name); - _utils_log__WEBPACK_IMPORTED_MODULE_5__["log"].write(`Preparing production build for [${projectNames.join(', ')}]`); + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i] + if (prefix) { + if (prefix.slice(-1) !== '/') + e = prefix + '/' + e + else + e = prefix + e + } - for (const batch of batchedProjects) { - for (const project of batch) { - await deleteTarget(project); - await buildProject(project); - await copyToBuild(project, kibanaRoot, buildRoot); + if (e.charAt(0) === '/' && !this.nomount) { + e = path.join(this.root, e) + } + this._emitMatch(index, e) } + // This was the last one, and no stats were needed + return + } + + // now test all matched entries as stand-ins for that part + // of the pattern. + remain.shift() + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i] + var newPattern + if (prefix) + newPattern = [prefix, e] + else + newPattern = [e] + this._process(newPattern.concat(remain), index, inGlobStar) } } -/** - * Returns the subset of projects that should be built into the production - * bundle. As we copy these into Kibana's `node_modules` during the build step, - * and let Kibana's build process be responsible for installing dependencies, - * we only include Kibana's transitive _production_ dependencies. If onlyOSS - * is supplied, we omit projects with build.oss in their package.json set to false. - */ -async function getProductionProjects(rootPath, onlyOSS) { - const projectPaths = Object(_config__WEBPACK_IMPORTED_MODULE_3__["getProjectPaths"])({ - rootPath - }); - const projects = await Object(_utils_projects__WEBPACK_IMPORTED_MODULE_7__["getProjects"])(rootPath, projectPaths); - const projectsSubset = [projects.get('kibana')]; - if (projects.has('x-pack')) { - projectsSubset.push(projects.get('x-pack')); - } +GlobSync.prototype._emitMatch = function (index, e) { + if (isIgnored(this, e)) + return - const productionProjects = Object(_utils_projects__WEBPACK_IMPORTED_MODULE_7__["includeTransitiveProjects"])(projectsSubset, projects, { - onlyProductionDependencies: true - }); // We remove Kibana, as we're already building Kibana + var abs = this._makeAbs(e) - productionProjects.delete('kibana'); + if (this.mark) + e = this._mark(e) - if (onlyOSS) { - productionProjects.forEach(project => { - if (project.getBuildConfig().oss === false) { - productionProjects.delete(project.json.name); - } - }); + if (this.absolute) { + e = abs } - return productionProjects; -} - -async function deleteTarget(project) { - const targetDir = project.targetLocation; + if (this.matches[index][e]) + return - if (await Object(_utils_fs__WEBPACK_IMPORTED_MODULE_4__["isDirectory"])(targetDir)) { - await del__WEBPACK_IMPORTED_MODULE_1___default()(targetDir, { - force: true - }); + if (this.nodir) { + var c = this.cache[abs] + if (c === 'DIR' || Array.isArray(c)) + return } -} -async function buildProject(project) { - if (project.hasScript('build')) { - await project.runScript('build'); - } + this.matches[index][e] = true + + if (this.stat) + this._stat(e) } -/** - * Copy all the project's files from its "intermediate build directory" and - * into the build. The intermediate directory can either be the root of the - * project or some other location defined in the project's `package.json`. - * - * When copying all the files into the build, we exclude `node_modules` because - * we want the Kibana build to be responsible for actually installing all - * dependencies. The primary reason for allowing the Kibana build process to - * manage dependencies is that it will "dedupe" them, so we don't include - * unnecessary copies of dependencies. - */ -async function copyToBuild(project, kibanaRoot, buildRoot) { - // We want the package to have the same relative location within the build - const relativeProjectPath = Object(path__WEBPACK_IMPORTED_MODULE_2__["relative"])(kibanaRoot, project.path); - const buildProjectPath = Object(path__WEBPACK_IMPORTED_MODULE_2__["resolve"])(buildRoot, relativeProjectPath); - await cpy__WEBPACK_IMPORTED_MODULE_0___default()(['**/*', '!node_modules/**'], buildProjectPath, { - cwd: project.getIntermediateBuildDirectory(), - dot: true, - nodir: true, - parents: true - }); // If a project is using an intermediate build directory, we special-case our - // handling of `package.json`, as the project build process might have copied - // (a potentially modified) `package.json` into the intermediate build - // directory already. If so, we want to use that `package.json` as the basis - // for creating the production-ready `package.json`. If it's not present in - // the intermediate build, we fall back to using the project's already defined - // `package.json`. +GlobSync.prototype._readdirInGlobStar = function (abs) { + // follow all symlinked directories forever + // just proceed as if this is a non-globstar situation + if (this.follow) + return this._readdir(abs, false) - const packageJson = (await Object(_utils_fs__WEBPACK_IMPORTED_MODULE_4__["isFile"])(Object(path__WEBPACK_IMPORTED_MODULE_2__["join"])(buildProjectPath, 'package.json'))) ? await Object(_utils_package_json__WEBPACK_IMPORTED_MODULE_6__["readPackageJson"])(buildProjectPath) : project.json; - await Object(_utils_package_json__WEBPACK_IMPORTED_MODULE_6__["writePackageJson"])(buildProjectPath, packageJson); -} + var entries + var lstat + var stat + try { + lstat = fs.lstatSync(abs) + } catch (er) { + if (er.code === 'ENOENT') { + // lstat failed, doesn't exist + return null + } + } -/***/ }), -/* 705 */ -/***/ (function(module, exports, __webpack_require__) { + var isSym = lstat && lstat.isSymbolicLink() + this.symlinks[abs] = isSym -"use strict"; + // If it's not a symlink or a dir, then it's definitely a regular file. + // don't bother doing a readdir in that case. + if (!isSym && lstat && !lstat.isDirectory()) + this.cache[abs] = 'FILE' + else + entries = this._readdir(abs, false) -const EventEmitter = __webpack_require__(379); -const path = __webpack_require__(16); -const arrify = __webpack_require__(706); -const globby = __webpack_require__(707); -const cpFile = __webpack_require__(905); -const CpyError = __webpack_require__(912); + return entries +} -const preprocessSrcPath = (srcPath, options) => options.cwd ? path.resolve(options.cwd, srcPath) : srcPath; +GlobSync.prototype._readdir = function (abs, inGlobStar) { + var entries -const preprocessDestPath = (srcPath, dest, options) => { - let basename = path.basename(srcPath); - const dirname = path.dirname(srcPath); + if (inGlobStar && !ownProp(this.symlinks, abs)) + return this._readdirInGlobStar(abs) - if (typeof options.rename === 'string') { - basename = options.rename; - } else if (typeof options.rename === 'function') { - basename = options.rename(basename); - } + if (ownProp(this.cache, abs)) { + var c = this.cache[abs] + if (!c || c === 'FILE') + return null - if (options.cwd) { - dest = path.resolve(options.cwd, dest); - } + if (Array.isArray(c)) + return c + } - if (options.parents) { - return path.join(dest, dirname, basename); - } + try { + return this._readdirEntries(abs, fs.readdirSync(abs)) + } catch (er) { + this._readdirError(abs, er) + return null + } +} - return path.join(dest, basename); -}; +GlobSync.prototype._readdirEntries = function (abs, entries) { + // if we haven't asked to stat everything, then just + // assume that everything in there exists, so we can avoid + // having to stat it a second time. + if (!this.mark && !this.stat) { + for (var i = 0; i < entries.length; i ++) { + var e = entries[i] + if (abs === '/') + e = abs + e + else + e = abs + '/' + e + this.cache[e] = true + } + } -const cpy = (src, dest, options = {}) => { - src = arrify(src); + this.cache[abs] = entries - const progressEmitter = new EventEmitter(); + // mark and cache dir-ness + return entries +} - if (src.length === 0 || !dest) { - const promise = Promise.reject(new CpyError('`files` and `destination` required')); - promise.on = (...args) => { - progressEmitter.on(...args); - return promise; - }; +GlobSync.prototype._readdirError = function (f, er) { + // handle errors, and cache the information + switch (er.code) { + case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205 + case 'ENOTDIR': // totally normal. means it *does* exist. + var abs = this._makeAbs(f) + this.cache[abs] = 'FILE' + if (abs === this.cwdAbs) { + var error = new Error(er.code + ' invalid cwd ' + this.cwd) + error.path = this.cwd + error.code = er.code + throw error + } + break - return promise; - } + case 'ENOENT': // not terribly unusual + case 'ELOOP': + case 'ENAMETOOLONG': + case 'UNKNOWN': + this.cache[this._makeAbs(f)] = false + break - const copyStatus = new Map(); - let completedFiles = 0; - let completedSize = 0; + default: // some unusual error. Treat as failure. + this.cache[this._makeAbs(f)] = false + if (this.strict) + throw er + if (!this.silent) + console.error('glob error', er) + break + } +} - const promise = globby(src, options) - .catch(error => { - throw new CpyError(`Cannot glob \`${src}\`: ${error.message}`, error); - }) - .then(files => { - if (files.length === 0) { - progressEmitter.emit('progress', { - totalFiles: 0, - percent: 1, - completedFiles: 0, - completedSize: 0 - }); - } +GlobSync.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) { - return Promise.all(files.map(srcPath => { - const from = preprocessSrcPath(srcPath, options); - const to = preprocessDestPath(srcPath, dest, options); + var entries = this._readdir(abs, inGlobStar) - return cpFile(from, to, options) - .on('progress', event => { - const fileStatus = copyStatus.get(event.src) || {written: 0, percent: 0}; + // no entries means not a dir, so it can never have matches + // foo.txt/** doesn't match foo.txt + if (!entries) + return - if (fileStatus.written !== event.written || fileStatus.percent !== event.percent) { - completedSize -= fileStatus.written; - completedSize += event.written; + // test without the globstar, and with every child both below + // and replacing the globstar. + var remainWithoutGlobStar = remain.slice(1) + var gspref = prefix ? [ prefix ] : [] + var noGlobStar = gspref.concat(remainWithoutGlobStar) - if (event.percent === 1 && fileStatus.percent !== 1) { - completedFiles++; - } + // the noGlobStar pattern exits the inGlobStar state + this._process(noGlobStar, index, false) - copyStatus.set(event.src, {written: event.written, percent: event.percent}); + var len = entries.length + var isSym = this.symlinks[abs] - progressEmitter.emit('progress', { - totalFiles: files.length, - percent: completedFiles / files.length, - completedFiles, - completedSize - }); - } - }) - .then(() => to) - .catch(error => { - throw new CpyError(`Cannot copy from \`${from}\` to \`${to}\`: ${error.message}`, error); - }); - })); - }); + // If it's a symlink, and we're in a globstar, then stop + if (isSym && inGlobStar) + return - promise.on = (...args) => { - progressEmitter.on(...args); - return promise; - }; + for (var i = 0; i < len; i++) { + var e = entries[i] + if (e.charAt(0) === '.' && !this.dot) + continue - return promise; -}; + // these two cases enter the inGlobStar state + var instead = gspref.concat(entries[i], remainWithoutGlobStar) + this._process(instead, index, true) -module.exports = cpy; -// TODO: Remove this for the next major release -module.exports.default = cpy; + var below = gspref.concat(entries[i], remain) + this._process(below, index, true) + } +} +GlobSync.prototype._processSimple = function (prefix, index) { + // XXX review this. Shouldn't it be doing the mounting etc + // before doing stat? kinda weird? + var exists = this._stat(prefix) -/***/ }), -/* 706 */ -/***/ (function(module, exports, __webpack_require__) { + if (!this.matches[index]) + this.matches[index] = Object.create(null) -"use strict"; + // If it doesn't exist, then just mark the lack of results + if (!exists) + return -module.exports = function (val) { - if (val === null || val === undefined) { - return []; - } + if (prefix && isAbsolute(prefix) && !this.nomount) { + var trail = /[\/\\]$/.test(prefix) + if (prefix.charAt(0) === '/') { + prefix = path.join(this.root, prefix) + } else { + prefix = path.resolve(this.root, prefix) + if (trail) + prefix += '/' + } + } - return Array.isArray(val) ? val : [val]; -}; + if (process.platform === 'win32') + prefix = prefix.replace(/\\/g, '/') + // Mark this as a match + this._emitMatch(index, prefix) +} -/***/ }), -/* 707 */ -/***/ (function(module, exports, __webpack_require__) { +// Returns either 'DIR', 'FILE', or false +GlobSync.prototype._stat = function (f) { + var abs = this._makeAbs(f) + var needDir = f.slice(-1) === '/' -"use strict"; + if (f.length > this.maxLength) + return false -const fs = __webpack_require__(23); -const arrayUnion = __webpack_require__(708); -const glob = __webpack_require__(502); -const fastGlob = __webpack_require__(710); -const dirGlob = __webpack_require__(898); -const gitignore = __webpack_require__(901); + if (!this.stat && ownProp(this.cache, abs)) { + var c = this.cache[abs] -const DEFAULT_FILTER = () => false; + if (Array.isArray(c)) + c = 'DIR' -const isNegative = pattern => pattern[0] === '!'; + // It exists, but maybe not how we need it + if (!needDir || c === 'DIR') + return c -const assertPatternsInput = patterns => { - if (!patterns.every(x => typeof x === 'string')) { - throw new TypeError('Patterns must be a string or an array of strings'); - } -}; + if (needDir && c === 'FILE') + return false -const checkCwdOption = options => { - if (options && options.cwd && !fs.statSync(options.cwd).isDirectory()) { - throw new Error('The `cwd` option must be a path to a directory'); - } -}; + // otherwise we have to stat, because maybe c=true + // if we know it exists, but not what it is. + } -const generateGlobTasks = (patterns, taskOptions) => { - patterns = arrayUnion([].concat(patterns)); - assertPatternsInput(patterns); - checkCwdOption(taskOptions); + var exists + var stat = this.statCache[abs] + if (!stat) { + var lstat + try { + lstat = fs.lstatSync(abs) + } catch (er) { + if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { + this.statCache[abs] = false + return false + } + } - const globTasks = []; + if (lstat && lstat.isSymbolicLink()) { + try { + stat = fs.statSync(abs) + } catch (er) { + stat = lstat + } + } else { + stat = lstat + } + } - taskOptions = Object.assign({ - ignore: [], - expandDirectories: true - }, taskOptions); + this.statCache[abs] = stat - patterns.forEach((pattern, i) => { - if (isNegative(pattern)) { - return; - } + var c = true + if (stat) + c = stat.isDirectory() ? 'DIR' : 'FILE' - const ignore = patterns - .slice(i) - .filter(isNegative) - .map(pattern => pattern.slice(1)); + this.cache[abs] = this.cache[abs] || c - const options = Object.assign({}, taskOptions, { - ignore: taskOptions.ignore.concat(ignore) - }); + if (needDir && c === 'FILE') + return false - globTasks.push({pattern, options}); - }); + return c +} - return globTasks; -}; +GlobSync.prototype._mark = function (p) { + return common.mark(this, p) +} -const globDirs = (task, fn) => { - let options = {}; - if (task.options.cwd) { - options.cwd = task.options.cwd; - } +GlobSync.prototype._makeAbs = function (f) { + return common.makeAbs(this, f) +} - if (Array.isArray(task.options.expandDirectories)) { - options = Object.assign(options, {files: task.options.expandDirectories}); - } else if (typeof task.options.expandDirectories === 'object') { - options = Object.assign(options, task.options.expandDirectories); - } - return fn(task.pattern, options); -}; +/***/ }), +/* 716 */ +/***/ (function(module, exports, __webpack_require__) { -const getPattern = (task, fn) => task.options.expandDirectories ? globDirs(task, fn) : [task.pattern]; +exports.alphasort = alphasort +exports.alphasorti = alphasorti +exports.setopts = setopts +exports.ownProp = ownProp +exports.makeAbs = makeAbs +exports.finish = finish +exports.mark = mark +exports.isIgnored = isIgnored +exports.childrenIgnored = childrenIgnored -const globToTask = task => glob => { - const {options} = task; - if (options.ignore && Array.isArray(options.ignore) && options.expandDirectories) { - options.ignore = dirGlob.sync(options.ignore); - } +function ownProp (obj, field) { + return Object.prototype.hasOwnProperty.call(obj, field) +} - return { - pattern: glob, - options - }; -}; +var path = __webpack_require__(16) +var minimatch = __webpack_require__(505) +var isAbsolute = __webpack_require__(511) +var Minimatch = minimatch.Minimatch -const globby = (patterns, options) => { - let globTasks; +function alphasorti (a, b) { + return a.toLowerCase().localeCompare(b.toLowerCase()) +} - try { - globTasks = generateGlobTasks(patterns, options); - } catch (error) { - return Promise.reject(error); - } +function alphasort (a, b) { + return a.localeCompare(b) +} - const getTasks = Promise.all(globTasks.map(task => Promise.resolve(getPattern(task, dirGlob)) - .then(globs => Promise.all(globs.map(globToTask(task)))) - )) - .then(tasks => arrayUnion(...tasks)); +function setupIgnores (self, options) { + self.ignore = options.ignore || [] - const getFilter = () => { - return Promise.resolve( - options && options.gitignore ? - gitignore({cwd: options.cwd, ignore: options.ignore}) : - DEFAULT_FILTER - ); - }; + if (!Array.isArray(self.ignore)) + self.ignore = [self.ignore] - return getFilter() - .then(filter => { - return getTasks - .then(tasks => Promise.all(tasks.map(task => fastGlob(task.pattern, task.options)))) - .then(paths => arrayUnion(...paths)) - .then(paths => paths.filter(p => !filter(p))); - }); -}; + if (self.ignore.length) { + self.ignore = self.ignore.map(ignoreMap) + } +} -module.exports = globby; -// TODO: Remove this for the next major release -module.exports.default = globby; +// ignore patterns are always in dot:true mode. +function ignoreMap (pattern) { + var gmatcher = null + if (pattern.slice(-3) === '/**') { + var gpattern = pattern.replace(/(\/\*\*)+$/, '') + gmatcher = new Minimatch(gpattern, { dot: true }) + } -module.exports.sync = (patterns, options) => { - const globTasks = generateGlobTasks(patterns, options); + return { + matcher: new Minimatch(pattern, { dot: true }), + gmatcher: gmatcher + } +} - const getFilter = () => { - return options && options.gitignore ? - gitignore.sync({cwd: options.cwd, ignore: options.ignore}) : - DEFAULT_FILTER; - }; +function setopts (self, pattern, options) { + if (!options) + options = {} - const tasks = globTasks.reduce((tasks, task) => { - const newTask = getPattern(task, dirGlob.sync).map(globToTask(task)); - return tasks.concat(newTask); - }, []); + // base-matching: just use globstar for that. + if (options.matchBase && -1 === pattern.indexOf("/")) { + if (options.noglobstar) { + throw new Error("base matching requires globstar") + } + pattern = "**/" + pattern + } - const filter = getFilter(); - return tasks.reduce( - (matches, task) => arrayUnion(matches, fastGlob.sync(task.pattern, task.options)), - [] - ).filter(p => !filter(p)); -}; + self.silent = !!options.silent + self.pattern = pattern + self.strict = options.strict !== false + self.realpath = !!options.realpath + self.realpathCache = options.realpathCache || Object.create(null) + self.follow = !!options.follow + self.dot = !!options.dot + self.mark = !!options.mark + self.nodir = !!options.nodir + if (self.nodir) + self.mark = true + self.sync = !!options.sync + self.nounique = !!options.nounique + self.nonull = !!options.nonull + self.nosort = !!options.nosort + self.nocase = !!options.nocase + self.stat = !!options.stat + self.noprocess = !!options.noprocess + self.absolute = !!options.absolute -module.exports.generateGlobTasks = generateGlobTasks; + self.maxLength = options.maxLength || Infinity + self.cache = options.cache || Object.create(null) + self.statCache = options.statCache || Object.create(null) + self.symlinks = options.symlinks || Object.create(null) -module.exports.hasMagic = (patterns, options) => [] - .concat(patterns) - .some(pattern => glob.hasMagic(pattern, options)); + setupIgnores(self, options) -module.exports.gitignore = gitignore; + self.changedCwd = false + var cwd = process.cwd() + if (!ownProp(options, "cwd")) + self.cwd = cwd + else { + self.cwd = path.resolve(options.cwd) + self.changedCwd = self.cwd !== cwd + } + self.root = options.root || path.resolve(self.cwd, "/") + self.root = path.resolve(self.root) + if (process.platform === "win32") + self.root = self.root.replace(/\\/g, "/") -/***/ }), -/* 708 */ -/***/ (function(module, exports, __webpack_require__) { + // TODO: is an absolute `cwd` supposed to be resolved against `root`? + // e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test') + self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd) + if (process.platform === "win32") + self.cwdAbs = self.cwdAbs.replace(/\\/g, "/") + self.nomount = !!options.nomount -"use strict"; + // disable comments and negation in Minimatch. + // Note that they are not supported in Glob itself anyway. + options.nonegate = true + options.nocomment = true -var arrayUniq = __webpack_require__(709); + self.minimatch = new Minimatch(pattern, options) + self.options = self.minimatch.options +} -module.exports = function () { - return arrayUniq([].concat.apply([], arguments)); -}; +function finish (self) { + var nou = self.nounique + var all = nou ? [] : Object.create(null) + for (var i = 0, l = self.matches.length; i < l; i ++) { + var matches = self.matches[i] + if (!matches || Object.keys(matches).length === 0) { + if (self.nonull) { + // do like the shell, and spit out the literal glob + var literal = self.minimatch.globSet[i] + if (nou) + all.push(literal) + else + all[literal] = true + } + } else { + // had matches + var m = Object.keys(matches) + if (nou) + all.push.apply(all, m) + else + m.forEach(function (m) { + all[m] = true + }) + } + } -/***/ }), -/* 709 */ -/***/ (function(module, exports, __webpack_require__) { + if (!nou) + all = Object.keys(all) -"use strict"; + if (!self.nosort) + all = all.sort(self.nocase ? alphasorti : alphasort) + // at *some* point we statted all of these + if (self.mark) { + for (var i = 0; i < all.length; i++) { + all[i] = self._mark(all[i]) + } + if (self.nodir) { + all = all.filter(function (e) { + var notDir = !(/\/$/.test(e)) + var c = self.cache[e] || self.cache[makeAbs(self, e)] + if (notDir && c) + notDir = c !== 'DIR' && !Array.isArray(c) + return notDir + }) + } + } -// there's 3 implementations written in increasing order of efficiency + if (self.ignore.length) + all = all.filter(function(m) { + return !isIgnored(self, m) + }) -// 1 - no Set type is defined -function uniqNoSet(arr) { - var ret = []; + self.found = all +} - for (var i = 0; i < arr.length; i++) { - if (ret.indexOf(arr[i]) === -1) { - ret.push(arr[i]); - } - } +function mark (self, p) { + var abs = makeAbs(self, p) + var c = self.cache[abs] + var m = p + if (c) { + var isDir = c === 'DIR' || Array.isArray(c) + var slash = p.slice(-1) === '/' - return ret; -} + if (isDir && !slash) + m += '/' + else if (!isDir && slash) + m = m.slice(0, -1) -// 2 - a simple Set type is defined -function uniqSet(arr) { - var seen = new Set(); - return arr.filter(function (el) { - if (!seen.has(el)) { - seen.add(el); - return true; - } + if (m !== p) { + var mabs = makeAbs(self, m) + self.statCache[mabs] = self.statCache[abs] + self.cache[mabs] = self.cache[abs] + } + } - return false; - }); + return m } -// 3 - a standard Set type is defined and it has a forEach method -function uniqSetWithForEach(arr) { - var ret = []; +// lotta situps... +function makeAbs (self, f) { + var abs = f + if (f.charAt(0) === '/') { + abs = path.join(self.root, f) + } else if (isAbsolute(f) || f === '') { + abs = f + } else if (self.changedCwd) { + abs = path.resolve(self.cwd, f) + } else { + abs = path.resolve(f) + } - (new Set(arr)).forEach(function (el) { - ret.push(el); - }); + if (process.platform === 'win32') + abs = abs.replace(/\\/g, '/') - return ret; + return abs } -// V8 currently has a broken implementation -// https://github.com/joyent/node/issues/8449 -function doesForEachActuallyWork() { - var ret = false; - (new Set([true])).forEach(function (el) { - ret = el; - }); +// Return true, if pattern ends with globstar '**', for the accompanying parent directory. +// Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents +function isIgnored (self, path) { + if (!self.ignore.length) + return false - return ret === true; + return self.ignore.some(function(item) { + return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path)) + }) } -if ('Set' in global) { - if (typeof Set.prototype.forEach === 'function' && doesForEachActuallyWork()) { - module.exports = uniqSetWithForEach; - } else { - module.exports = uniqSet; - } -} else { - module.exports = uniqNoSet; +function childrenIgnored (self, path) { + if (!self.ignore.length) + return false + + return self.ignore.some(function(item) { + return !!(item.gmatcher && item.gmatcher.match(path)) + }) } /***/ }), -/* 710 */ +/* 717 */ /***/ (function(module, exports, __webpack_require__) { -const pkg = __webpack_require__(711); +const pkg = __webpack_require__(718); module.exports = pkg.async; module.exports.default = pkg.async; @@ -80438,19 +82802,19 @@ module.exports.generateTasks = pkg.generateTasks; /***/ }), -/* 711 */ +/* 718 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var optionsManager = __webpack_require__(712); -var taskManager = __webpack_require__(713); -var reader_async_1 = __webpack_require__(869); -var reader_stream_1 = __webpack_require__(893); -var reader_sync_1 = __webpack_require__(894); -var arrayUtils = __webpack_require__(896); -var streamUtils = __webpack_require__(897); +var optionsManager = __webpack_require__(719); +var taskManager = __webpack_require__(720); +var reader_async_1 = __webpack_require__(876); +var reader_stream_1 = __webpack_require__(900); +var reader_sync_1 = __webpack_require__(901); +var arrayUtils = __webpack_require__(903); +var streamUtils = __webpack_require__(904); /** * Synchronous API. */ @@ -80516,7 +82880,7 @@ function isString(source) { /***/ }), -/* 712 */ +/* 719 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -80554,13 +82918,13 @@ exports.prepare = prepare; /***/ }), -/* 713 */ +/* 720 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var patternUtils = __webpack_require__(714); +var patternUtils = __webpack_require__(721); /** * Generate tasks based on parent directory of each pattern. */ @@ -80651,16 +83015,16 @@ exports.convertPatternGroupToTask = convertPatternGroupToTask; /***/ }), -/* 714 */ +/* 721 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var path = __webpack_require__(16); -var globParent = __webpack_require__(715); -var isGlob = __webpack_require__(718); -var micromatch = __webpack_require__(719); +var globParent = __webpack_require__(722); +var isGlob = __webpack_require__(725); +var micromatch = __webpack_require__(726); var GLOBSTAR = '**'; /** * Return true for static pattern. @@ -80806,15 +83170,15 @@ exports.matchAny = matchAny; /***/ }), -/* 715 */ +/* 722 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var path = __webpack_require__(16); -var isglob = __webpack_require__(716); -var pathDirname = __webpack_require__(717); +var isglob = __webpack_require__(723); +var pathDirname = __webpack_require__(724); var isWin32 = __webpack_require__(11).platform() === 'win32'; module.exports = function globParent(str) { @@ -80837,7 +83201,7 @@ module.exports = function globParent(str) { /***/ }), -/* 716 */ +/* 723 */ /***/ (function(module, exports, __webpack_require__) { /*! @@ -80847,7 +83211,7 @@ module.exports = function globParent(str) { * Licensed under the MIT License. */ -var isExtglob = __webpack_require__(602); +var isExtglob = __webpack_require__(607); module.exports = function isGlob(str) { if (typeof str !== 'string' || str === '') { @@ -80868,7 +83232,7 @@ module.exports = function isGlob(str) { /***/ }), -/* 717 */ +/* 724 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -81018,7 +83382,7 @@ module.exports.win32 = win32; /***/ }), -/* 718 */ +/* 725 */ /***/ (function(module, exports, __webpack_require__) { /*! @@ -81028,7 +83392,7 @@ module.exports.win32 = win32; * Released under the MIT License. */ -var isExtglob = __webpack_require__(602); +var isExtglob = __webpack_require__(607); var chars = { '{': '}', '(': ')', '[': ']'}; module.exports = function isGlob(str, options) { @@ -81070,7 +83434,7 @@ module.exports = function isGlob(str, options) { /***/ }), -/* 719 */ +/* 726 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -81081,18 +83445,18 @@ module.exports = function isGlob(str, options) { */ var util = __webpack_require__(29); -var braces = __webpack_require__(720); -var toRegex = __webpack_require__(822); -var extend = __webpack_require__(830); +var braces = __webpack_require__(727); +var toRegex = __webpack_require__(829); +var extend = __webpack_require__(837); /** * Local dependencies */ -var compilers = __webpack_require__(833); -var parsers = __webpack_require__(865); -var cache = __webpack_require__(866); -var utils = __webpack_require__(867); +var compilers = __webpack_require__(840); +var parsers = __webpack_require__(872); +var cache = __webpack_require__(873); +var utils = __webpack_require__(874); var MAX_LENGTH = 1024 * 64; /** @@ -81954,7 +84318,7 @@ module.exports = micromatch; /***/ }), -/* 720 */ +/* 727 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -81964,18 +84328,18 @@ module.exports = micromatch; * Module dependencies */ -var toRegex = __webpack_require__(721); -var unique = __webpack_require__(733); -var extend = __webpack_require__(730); +var toRegex = __webpack_require__(728); +var unique = __webpack_require__(740); +var extend = __webpack_require__(737); /** * Local dependencies */ -var compilers = __webpack_require__(734); -var parsers = __webpack_require__(749); -var Braces = __webpack_require__(759); -var utils = __webpack_require__(735); +var compilers = __webpack_require__(741); +var parsers = __webpack_require__(756); +var Braces = __webpack_require__(766); +var utils = __webpack_require__(742); var MAX_LENGTH = 1024 * 64; var cache = {}; @@ -82279,15 +84643,15 @@ module.exports = braces; /***/ }), -/* 721 */ +/* 728 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var define = __webpack_require__(722); -var extend = __webpack_require__(730); -var not = __webpack_require__(732); +var define = __webpack_require__(729); +var extend = __webpack_require__(737); +var not = __webpack_require__(739); var MAX_LENGTH = 1024 * 64; /** @@ -82434,7 +84798,7 @@ module.exports.makeRe = makeRe; /***/ }), -/* 722 */ +/* 729 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -82447,7 +84811,7 @@ module.exports.makeRe = makeRe; -var isDescriptor = __webpack_require__(723); +var isDescriptor = __webpack_require__(730); module.exports = function defineProperty(obj, prop, val) { if (typeof obj !== 'object' && typeof obj !== 'function') { @@ -82472,7 +84836,7 @@ module.exports = function defineProperty(obj, prop, val) { /***/ }), -/* 723 */ +/* 730 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -82485,9 +84849,9 @@ module.exports = function defineProperty(obj, prop, val) { -var typeOf = __webpack_require__(724); -var isAccessor = __webpack_require__(725); -var isData = __webpack_require__(728); +var typeOf = __webpack_require__(731); +var isAccessor = __webpack_require__(732); +var isData = __webpack_require__(735); module.exports = function isDescriptor(obj, key) { if (typeOf(obj) !== 'object') { @@ -82501,7 +84865,7 @@ module.exports = function isDescriptor(obj, key) { /***/ }), -/* 724 */ +/* 731 */ /***/ (function(module, exports) { var toString = Object.prototype.toString; @@ -82654,7 +85018,7 @@ function isBuffer(val) { /***/ }), -/* 725 */ +/* 732 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -82667,7 +85031,7 @@ function isBuffer(val) { -var typeOf = __webpack_require__(726); +var typeOf = __webpack_require__(733); // accessor descriptor properties var accessor = { @@ -82730,10 +85094,10 @@ module.exports = isAccessorDescriptor; /***/ }), -/* 726 */ +/* 733 */ /***/ (function(module, exports, __webpack_require__) { -var isBuffer = __webpack_require__(727); +var isBuffer = __webpack_require__(734); var toString = Object.prototype.toString; /** @@ -82852,7 +85216,7 @@ module.exports = function kindOf(val) { /***/ }), -/* 727 */ +/* 734 */ /***/ (function(module, exports) { /*! @@ -82879,7 +85243,7 @@ function isSlowBuffer (obj) { /***/ }), -/* 728 */ +/* 735 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -82892,7 +85256,7 @@ function isSlowBuffer (obj) { -var typeOf = __webpack_require__(729); +var typeOf = __webpack_require__(736); // data descriptor properties var data = { @@ -82941,10 +85305,10 @@ module.exports = isDataDescriptor; /***/ }), -/* 729 */ +/* 736 */ /***/ (function(module, exports, __webpack_require__) { -var isBuffer = __webpack_require__(727); +var isBuffer = __webpack_require__(734); var toString = Object.prototype.toString; /** @@ -83063,13 +85427,13 @@ module.exports = function kindOf(val) { /***/ }), -/* 730 */ +/* 737 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var isObject = __webpack_require__(731); +var isObject = __webpack_require__(738); module.exports = function extend(o/*, objects*/) { if (!isObject(o)) { o = {}; } @@ -83103,7 +85467,7 @@ function hasOwn(obj, key) { /***/ }), -/* 731 */ +/* 738 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -83123,13 +85487,13 @@ module.exports = function isExtendable(val) { /***/ }), -/* 732 */ +/* 739 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var extend = __webpack_require__(730); +var extend = __webpack_require__(737); /** * The main export is a function that takes a `pattern` string and an `options` object. @@ -83196,7 +85560,7 @@ module.exports = toRegex; /***/ }), -/* 733 */ +/* 740 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -83246,13 +85610,13 @@ module.exports.immutable = function uniqueImmutable(arr) { /***/ }), -/* 734 */ +/* 741 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var utils = __webpack_require__(735); +var utils = __webpack_require__(742); module.exports = function(braces, options) { braces.compiler @@ -83535,25 +85899,25 @@ function hasQueue(node) { /***/ }), -/* 735 */ +/* 742 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var splitString = __webpack_require__(736); +var splitString = __webpack_require__(743); var utils = module.exports; /** * Module dependencies */ -utils.extend = __webpack_require__(730); -utils.flatten = __webpack_require__(742); -utils.isObject = __webpack_require__(740); -utils.fillRange = __webpack_require__(743); -utils.repeat = __webpack_require__(748); -utils.unique = __webpack_require__(733); +utils.extend = __webpack_require__(737); +utils.flatten = __webpack_require__(749); +utils.isObject = __webpack_require__(747); +utils.fillRange = __webpack_require__(750); +utils.repeat = __webpack_require__(755); +utils.unique = __webpack_require__(740); utils.define = function(obj, key, val) { Object.defineProperty(obj, key, { @@ -83885,7 +86249,7 @@ utils.escapeRegex = function(str) { /***/ }), -/* 736 */ +/* 743 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -83898,7 +86262,7 @@ utils.escapeRegex = function(str) { -var extend = __webpack_require__(737); +var extend = __webpack_require__(744); module.exports = function(str, options, fn) { if (typeof str !== 'string') { @@ -84063,14 +86427,14 @@ function keepEscaping(opts, str, idx) { /***/ }), -/* 737 */ +/* 744 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var isExtendable = __webpack_require__(738); -var assignSymbols = __webpack_require__(741); +var isExtendable = __webpack_require__(745); +var assignSymbols = __webpack_require__(748); module.exports = Object.assign || function(obj/*, objects*/) { if (obj === null || typeof obj === 'undefined') { @@ -84130,7 +86494,7 @@ function isEnum(obj, key) { /***/ }), -/* 738 */ +/* 745 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -84143,7 +86507,7 @@ function isEnum(obj, key) { -var isPlainObject = __webpack_require__(739); +var isPlainObject = __webpack_require__(746); module.exports = function isExtendable(val) { return isPlainObject(val) || typeof val === 'function' || Array.isArray(val); @@ -84151,7 +86515,7 @@ module.exports = function isExtendable(val) { /***/ }), -/* 739 */ +/* 746 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -84164,7 +86528,7 @@ module.exports = function isExtendable(val) { -var isObject = __webpack_require__(740); +var isObject = __webpack_require__(747); function isObjectObject(o) { return isObject(o) === true @@ -84195,7 +86559,7 @@ module.exports = function isPlainObject(o) { /***/ }), -/* 740 */ +/* 747 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -84214,7 +86578,7 @@ module.exports = function isObject(val) { /***/ }), -/* 741 */ +/* 748 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -84261,7 +86625,7 @@ module.exports = function(receiver, objects) { /***/ }), -/* 742 */ +/* 749 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -84290,7 +86654,7 @@ function flat(arr, res) { /***/ }), -/* 743 */ +/* 750 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -84304,10 +86668,10 @@ function flat(arr, res) { var util = __webpack_require__(29); -var isNumber = __webpack_require__(744); -var extend = __webpack_require__(730); -var repeat = __webpack_require__(746); -var toRegex = __webpack_require__(747); +var isNumber = __webpack_require__(751); +var extend = __webpack_require__(737); +var repeat = __webpack_require__(753); +var toRegex = __webpack_require__(754); /** * Return a range of numbers or letters. @@ -84505,7 +86869,7 @@ module.exports = fillRange; /***/ }), -/* 744 */ +/* 751 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -84518,7 +86882,7 @@ module.exports = fillRange; -var typeOf = __webpack_require__(745); +var typeOf = __webpack_require__(752); module.exports = function isNumber(num) { var type = typeOf(num); @@ -84534,10 +86898,10 @@ module.exports = function isNumber(num) { /***/ }), -/* 745 */ +/* 752 */ /***/ (function(module, exports, __webpack_require__) { -var isBuffer = __webpack_require__(727); +var isBuffer = __webpack_require__(734); var toString = Object.prototype.toString; /** @@ -84656,7 +87020,7 @@ module.exports = function kindOf(val) { /***/ }), -/* 746 */ +/* 753 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -84733,7 +87097,7 @@ function repeat(str, num) { /***/ }), -/* 747 */ +/* 754 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -84746,8 +87110,8 @@ function repeat(str, num) { -var repeat = __webpack_require__(746); -var isNumber = __webpack_require__(744); +var repeat = __webpack_require__(753); +var isNumber = __webpack_require__(751); var cache = {}; function toRegexRange(min, max, options) { @@ -85034,7 +87398,7 @@ module.exports = toRegexRange; /***/ }), -/* 748 */ +/* 755 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -85059,14 +87423,14 @@ module.exports = function repeat(ele, num) { /***/ }), -/* 749 */ +/* 756 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var Node = __webpack_require__(750); -var utils = __webpack_require__(735); +var Node = __webpack_require__(757); +var utils = __webpack_require__(742); /** * Braces parsers @@ -85426,15 +87790,15 @@ function concatNodes(pos, node, parent, options) { /***/ }), -/* 750 */ +/* 757 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var isObject = __webpack_require__(740); -var define = __webpack_require__(751); -var utils = __webpack_require__(758); +var isObject = __webpack_require__(747); +var define = __webpack_require__(758); +var utils = __webpack_require__(765); var ownNames; /** @@ -85925,7 +88289,7 @@ exports = module.exports = Node; /***/ }), -/* 751 */ +/* 758 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -85938,7 +88302,7 @@ exports = module.exports = Node; -var isDescriptor = __webpack_require__(752); +var isDescriptor = __webpack_require__(759); module.exports = function defineProperty(obj, prop, val) { if (typeof obj !== 'object' && typeof obj !== 'function') { @@ -85963,7 +88327,7 @@ module.exports = function defineProperty(obj, prop, val) { /***/ }), -/* 752 */ +/* 759 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -85976,9 +88340,9 @@ module.exports = function defineProperty(obj, prop, val) { -var typeOf = __webpack_require__(753); -var isAccessor = __webpack_require__(754); -var isData = __webpack_require__(756); +var typeOf = __webpack_require__(760); +var isAccessor = __webpack_require__(761); +var isData = __webpack_require__(763); module.exports = function isDescriptor(obj, key) { if (typeOf(obj) !== 'object') { @@ -85992,7 +88356,7 @@ module.exports = function isDescriptor(obj, key) { /***/ }), -/* 753 */ +/* 760 */ /***/ (function(module, exports) { var toString = Object.prototype.toString; @@ -86127,7 +88491,7 @@ function isBuffer(val) { /***/ }), -/* 754 */ +/* 761 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -86140,7 +88504,7 @@ function isBuffer(val) { -var typeOf = __webpack_require__(755); +var typeOf = __webpack_require__(762); // accessor descriptor properties var accessor = { @@ -86203,7 +88567,7 @@ module.exports = isAccessorDescriptor; /***/ }), -/* 755 */ +/* 762 */ /***/ (function(module, exports) { var toString = Object.prototype.toString; @@ -86338,7 +88702,7 @@ function isBuffer(val) { /***/ }), -/* 756 */ +/* 763 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -86351,7 +88715,7 @@ function isBuffer(val) { -var typeOf = __webpack_require__(757); +var typeOf = __webpack_require__(764); module.exports = function isDataDescriptor(obj, prop) { // data descriptor properties @@ -86394,7 +88758,7 @@ module.exports = function isDataDescriptor(obj, prop) { /***/ }), -/* 757 */ +/* 764 */ /***/ (function(module, exports) { var toString = Object.prototype.toString; @@ -86529,13 +88893,13 @@ function isBuffer(val) { /***/ }), -/* 758 */ +/* 765 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var typeOf = __webpack_require__(745); +var typeOf = __webpack_require__(752); var utils = module.exports; /** @@ -87555,17 +89919,17 @@ function assert(val, message) { /***/ }), -/* 759 */ +/* 766 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var extend = __webpack_require__(730); -var Snapdragon = __webpack_require__(760); -var compilers = __webpack_require__(734); -var parsers = __webpack_require__(749); -var utils = __webpack_require__(735); +var extend = __webpack_require__(737); +var Snapdragon = __webpack_require__(767); +var compilers = __webpack_require__(741); +var parsers = __webpack_require__(756); +var utils = __webpack_require__(742); /** * Customize Snapdragon parser and renderer @@ -87666,17 +90030,17 @@ module.exports = Braces; /***/ }), -/* 760 */ +/* 767 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var Base = __webpack_require__(761); -var define = __webpack_require__(722); -var Compiler = __webpack_require__(790); -var Parser = __webpack_require__(819); -var utils = __webpack_require__(799); +var Base = __webpack_require__(768); +var define = __webpack_require__(729); +var Compiler = __webpack_require__(797); +var Parser = __webpack_require__(826); +var utils = __webpack_require__(806); var regexCache = {}; var cache = {}; @@ -87847,20 +90211,20 @@ module.exports.Parser = Parser; /***/ }), -/* 761 */ +/* 768 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var util = __webpack_require__(29); -var define = __webpack_require__(762); -var CacheBase = __webpack_require__(763); -var Emitter = __webpack_require__(764); -var isObject = __webpack_require__(740); -var merge = __webpack_require__(781); -var pascal = __webpack_require__(784); -var cu = __webpack_require__(785); +var define = __webpack_require__(769); +var CacheBase = __webpack_require__(770); +var Emitter = __webpack_require__(771); +var isObject = __webpack_require__(747); +var merge = __webpack_require__(788); +var pascal = __webpack_require__(791); +var cu = __webpack_require__(792); /** * Optionally define a custom `cache` namespace to use. @@ -88289,7 +90653,7 @@ module.exports.namespace = namespace; /***/ }), -/* 762 */ +/* 769 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -88302,7 +90666,7 @@ module.exports.namespace = namespace; -var isDescriptor = __webpack_require__(752); +var isDescriptor = __webpack_require__(759); module.exports = function defineProperty(obj, prop, val) { if (typeof obj !== 'object' && typeof obj !== 'function') { @@ -88327,21 +90691,21 @@ module.exports = function defineProperty(obj, prop, val) { /***/ }), -/* 763 */ +/* 770 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var isObject = __webpack_require__(740); -var Emitter = __webpack_require__(764); -var visit = __webpack_require__(765); -var toPath = __webpack_require__(768); -var union = __webpack_require__(769); -var del = __webpack_require__(773); -var get = __webpack_require__(771); -var has = __webpack_require__(778); -var set = __webpack_require__(772); +var isObject = __webpack_require__(747); +var Emitter = __webpack_require__(771); +var visit = __webpack_require__(772); +var toPath = __webpack_require__(775); +var union = __webpack_require__(776); +var del = __webpack_require__(780); +var get = __webpack_require__(778); +var has = __webpack_require__(785); +var set = __webpack_require__(779); /** * Create a `Cache` constructor that when instantiated will @@ -88595,7 +90959,7 @@ module.exports.namespace = namespace; /***/ }), -/* 764 */ +/* 771 */ /***/ (function(module, exports, __webpack_require__) { @@ -88764,7 +91128,7 @@ Emitter.prototype.hasListeners = function(event){ /***/ }), -/* 765 */ +/* 772 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -88777,8 +91141,8 @@ Emitter.prototype.hasListeners = function(event){ -var visit = __webpack_require__(766); -var mapVisit = __webpack_require__(767); +var visit = __webpack_require__(773); +var mapVisit = __webpack_require__(774); module.exports = function(collection, method, val) { var result; @@ -88801,7 +91165,7 @@ module.exports = function(collection, method, val) { /***/ }), -/* 766 */ +/* 773 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -88814,7 +91178,7 @@ module.exports = function(collection, method, val) { -var isObject = __webpack_require__(740); +var isObject = __webpack_require__(747); module.exports = function visit(thisArg, method, target, val) { if (!isObject(thisArg) && typeof thisArg !== 'function') { @@ -88841,14 +91205,14 @@ module.exports = function visit(thisArg, method, target, val) { /***/ }), -/* 767 */ +/* 774 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var util = __webpack_require__(29); -var visit = __webpack_require__(766); +var visit = __webpack_require__(773); /** * Map `visit` over an array of objects. @@ -88885,7 +91249,7 @@ function isObject(val) { /***/ }), -/* 768 */ +/* 775 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -88898,7 +91262,7 @@ function isObject(val) { -var typeOf = __webpack_require__(745); +var typeOf = __webpack_require__(752); module.exports = function toPath(args) { if (typeOf(args) !== 'arguments') { @@ -88925,16 +91289,16 @@ function filter(arr) { /***/ }), -/* 769 */ +/* 776 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var isObject = __webpack_require__(731); -var union = __webpack_require__(770); -var get = __webpack_require__(771); -var set = __webpack_require__(772); +var isObject = __webpack_require__(738); +var union = __webpack_require__(777); +var get = __webpack_require__(778); +var set = __webpack_require__(779); module.exports = function unionValue(obj, prop, value) { if (!isObject(obj)) { @@ -88962,7 +91326,7 @@ function arrayify(val) { /***/ }), -/* 770 */ +/* 777 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -88998,7 +91362,7 @@ module.exports = function union(init) { /***/ }), -/* 771 */ +/* 778 */ /***/ (function(module, exports) { /*! @@ -89054,7 +91418,7 @@ function toString(val) { /***/ }), -/* 772 */ +/* 779 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -89067,10 +91431,10 @@ function toString(val) { -var split = __webpack_require__(736); -var extend = __webpack_require__(730); -var isPlainObject = __webpack_require__(739); -var isObject = __webpack_require__(731); +var split = __webpack_require__(743); +var extend = __webpack_require__(737); +var isPlainObject = __webpack_require__(746); +var isObject = __webpack_require__(738); module.exports = function(obj, prop, val) { if (!isObject(obj)) { @@ -89116,7 +91480,7 @@ function isValidKey(key) { /***/ }), -/* 773 */ +/* 780 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -89129,8 +91493,8 @@ function isValidKey(key) { -var isObject = __webpack_require__(740); -var has = __webpack_require__(774); +var isObject = __webpack_require__(747); +var has = __webpack_require__(781); module.exports = function unset(obj, prop) { if (!isObject(obj)) { @@ -89155,7 +91519,7 @@ module.exports = function unset(obj, prop) { /***/ }), -/* 774 */ +/* 781 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -89168,9 +91532,9 @@ module.exports = function unset(obj, prop) { -var isObject = __webpack_require__(775); -var hasValues = __webpack_require__(777); -var get = __webpack_require__(771); +var isObject = __webpack_require__(782); +var hasValues = __webpack_require__(784); +var get = __webpack_require__(778); module.exports = function(obj, prop, noZero) { if (isObject(obj)) { @@ -89181,7 +91545,7 @@ module.exports = function(obj, prop, noZero) { /***/ }), -/* 775 */ +/* 782 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -89194,7 +91558,7 @@ module.exports = function(obj, prop, noZero) { -var isArray = __webpack_require__(776); +var isArray = __webpack_require__(783); module.exports = function isObject(val) { return val != null && typeof val === 'object' && isArray(val) === false; @@ -89202,7 +91566,7 @@ module.exports = function isObject(val) { /***/ }), -/* 776 */ +/* 783 */ /***/ (function(module, exports) { var toString = {}.toString; @@ -89213,7 +91577,7 @@ module.exports = Array.isArray || function (arr) { /***/ }), -/* 777 */ +/* 784 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -89256,7 +91620,7 @@ module.exports = function hasValue(o, noZero) { /***/ }), -/* 778 */ +/* 785 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -89269,9 +91633,9 @@ module.exports = function hasValue(o, noZero) { -var isObject = __webpack_require__(740); -var hasValues = __webpack_require__(779); -var get = __webpack_require__(771); +var isObject = __webpack_require__(747); +var hasValues = __webpack_require__(786); +var get = __webpack_require__(778); module.exports = function(val, prop) { return hasValues(isObject(val) && prop ? get(val, prop) : val); @@ -89279,7 +91643,7 @@ module.exports = function(val, prop) { /***/ }), -/* 779 */ +/* 786 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -89292,8 +91656,8 @@ module.exports = function(val, prop) { -var typeOf = __webpack_require__(780); -var isNumber = __webpack_require__(744); +var typeOf = __webpack_require__(787); +var isNumber = __webpack_require__(751); module.exports = function hasValue(val) { // is-number checks for NaN and other edge cases @@ -89346,10 +91710,10 @@ module.exports = function hasValue(val) { /***/ }), -/* 780 */ +/* 787 */ /***/ (function(module, exports, __webpack_require__) { -var isBuffer = __webpack_require__(727); +var isBuffer = __webpack_require__(734); var toString = Object.prototype.toString; /** @@ -89471,14 +91835,14 @@ module.exports = function kindOf(val) { /***/ }), -/* 781 */ +/* 788 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var isExtendable = __webpack_require__(782); -var forIn = __webpack_require__(783); +var isExtendable = __webpack_require__(789); +var forIn = __webpack_require__(790); function mixinDeep(target, objects) { var len = arguments.length, i = 0; @@ -89542,7 +91906,7 @@ module.exports = mixinDeep; /***/ }), -/* 782 */ +/* 789 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -89555,7 +91919,7 @@ module.exports = mixinDeep; -var isPlainObject = __webpack_require__(739); +var isPlainObject = __webpack_require__(746); module.exports = function isExtendable(val) { return isPlainObject(val) || typeof val === 'function' || Array.isArray(val); @@ -89563,7 +91927,7 @@ module.exports = function isExtendable(val) { /***/ }), -/* 783 */ +/* 790 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -89586,7 +91950,7 @@ module.exports = function forIn(obj, fn, thisArg) { /***/ }), -/* 784 */ +/* 791 */ /***/ (function(module, exports) { /*! @@ -89613,14 +91977,14 @@ module.exports = pascalcase; /***/ }), -/* 785 */ +/* 792 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var util = __webpack_require__(29); -var utils = __webpack_require__(786); +var utils = __webpack_require__(793); /** * Expose class utils @@ -89985,7 +92349,7 @@ cu.bubble = function(Parent, events) { /***/ }), -/* 786 */ +/* 793 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -89999,10 +92363,10 @@ var utils = {}; * Lazily required module dependencies */ -utils.union = __webpack_require__(770); -utils.define = __webpack_require__(722); -utils.isObj = __webpack_require__(740); -utils.staticExtend = __webpack_require__(787); +utils.union = __webpack_require__(777); +utils.define = __webpack_require__(729); +utils.isObj = __webpack_require__(747); +utils.staticExtend = __webpack_require__(794); /** @@ -90013,7 +92377,7 @@ module.exports = utils; /***/ }), -/* 787 */ +/* 794 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -90026,8 +92390,8 @@ module.exports = utils; -var copy = __webpack_require__(788); -var define = __webpack_require__(722); +var copy = __webpack_require__(795); +var define = __webpack_require__(729); var util = __webpack_require__(29); /** @@ -90110,15 +92474,15 @@ module.exports = extend; /***/ }), -/* 788 */ +/* 795 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var typeOf = __webpack_require__(745); -var copyDescriptor = __webpack_require__(789); -var define = __webpack_require__(722); +var typeOf = __webpack_require__(752); +var copyDescriptor = __webpack_require__(796); +var define = __webpack_require__(729); /** * Copy static properties, prototype properties, and descriptors from one object to another. @@ -90291,7 +92655,7 @@ module.exports.has = has; /***/ }), -/* 789 */ +/* 796 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -90379,16 +92743,16 @@ function isObject(val) { /***/ }), -/* 790 */ +/* 797 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var use = __webpack_require__(791); -var define = __webpack_require__(722); -var debug = __webpack_require__(793)('snapdragon:compiler'); -var utils = __webpack_require__(799); +var use = __webpack_require__(798); +var define = __webpack_require__(729); +var debug = __webpack_require__(800)('snapdragon:compiler'); +var utils = __webpack_require__(806); /** * Create a new `Compiler` with the given `options`. @@ -90542,7 +92906,7 @@ Compiler.prototype = { // source map support if (opts.sourcemap) { - var sourcemaps = __webpack_require__(818); + var sourcemaps = __webpack_require__(825); sourcemaps(this); this.mapVisit(this.ast.nodes); this.applySourceMaps(); @@ -90563,7 +92927,7 @@ module.exports = Compiler; /***/ }), -/* 791 */ +/* 798 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -90576,7 +92940,7 @@ module.exports = Compiler; -var utils = __webpack_require__(792); +var utils = __webpack_require__(799); module.exports = function base(app, opts) { if (!utils.isObject(app) && typeof app !== 'function') { @@ -90691,7 +93055,7 @@ module.exports = function base(app, opts) { /***/ }), -/* 792 */ +/* 799 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -90705,8 +93069,8 @@ var utils = {}; * Lazily required module dependencies */ -utils.define = __webpack_require__(722); -utils.isObject = __webpack_require__(740); +utils.define = __webpack_require__(729); +utils.isObject = __webpack_require__(747); utils.isString = function(val) { @@ -90721,7 +93085,7 @@ module.exports = utils; /***/ }), -/* 793 */ +/* 800 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -90730,14 +93094,14 @@ module.exports = utils; */ if (typeof process !== 'undefined' && process.type === 'renderer') { - module.exports = __webpack_require__(794); + module.exports = __webpack_require__(801); } else { - module.exports = __webpack_require__(797); + module.exports = __webpack_require__(804); } /***/ }), -/* 794 */ +/* 801 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -90746,7 +93110,7 @@ if (typeof process !== 'undefined' && process.type === 'renderer') { * Expose `debug()` as the module. */ -exports = module.exports = __webpack_require__(795); +exports = module.exports = __webpack_require__(802); exports.log = log; exports.formatArgs = formatArgs; exports.save = save; @@ -90928,7 +93292,7 @@ function localstorage() { /***/ }), -/* 795 */ +/* 802 */ /***/ (function(module, exports, __webpack_require__) { @@ -90944,7 +93308,7 @@ exports.coerce = coerce; exports.disable = disable; exports.enable = enable; exports.enabled = enabled; -exports.humanize = __webpack_require__(796); +exports.humanize = __webpack_require__(803); /** * The currently active debug mode names, and names to skip. @@ -91136,7 +93500,7 @@ function coerce(val) { /***/ }), -/* 796 */ +/* 803 */ /***/ (function(module, exports) { /** @@ -91294,7 +93658,7 @@ function plural(ms, n, name) { /***/ }), -/* 797 */ +/* 804 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -91310,7 +93674,7 @@ var util = __webpack_require__(29); * Expose `debug()` as the module. */ -exports = module.exports = __webpack_require__(795); +exports = module.exports = __webpack_require__(802); exports.init = init; exports.log = log; exports.formatArgs = formatArgs; @@ -91489,7 +93853,7 @@ function createWritableStdioStream (fd) { case 'PIPE': case 'TCP': - var net = __webpack_require__(798); + var net = __webpack_require__(805); stream = new net.Socket({ fd: fd, readable: false, @@ -91548,13 +93912,13 @@ exports.enable(load()); /***/ }), -/* 798 */ +/* 805 */ /***/ (function(module, exports) { module.exports = require("net"); /***/ }), -/* 799 */ +/* 806 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -91564,9 +93928,9 @@ module.exports = require("net"); * Module dependencies */ -exports.extend = __webpack_require__(730); -exports.SourceMap = __webpack_require__(800); -exports.sourceMapResolve = __webpack_require__(811); +exports.extend = __webpack_require__(737); +exports.SourceMap = __webpack_require__(807); +exports.sourceMapResolve = __webpack_require__(818); /** * Convert backslash in the given string to forward slashes @@ -91609,7 +93973,7 @@ exports.last = function(arr, n) { /***/ }), -/* 800 */ +/* 807 */ /***/ (function(module, exports, __webpack_require__) { /* @@ -91617,13 +93981,13 @@ exports.last = function(arr, n) { * Licensed under the New BSD license. See LICENSE.txt or: * http://opensource.org/licenses/BSD-3-Clause */ -exports.SourceMapGenerator = __webpack_require__(801).SourceMapGenerator; -exports.SourceMapConsumer = __webpack_require__(807).SourceMapConsumer; -exports.SourceNode = __webpack_require__(810).SourceNode; +exports.SourceMapGenerator = __webpack_require__(808).SourceMapGenerator; +exports.SourceMapConsumer = __webpack_require__(814).SourceMapConsumer; +exports.SourceNode = __webpack_require__(817).SourceNode; /***/ }), -/* 801 */ +/* 808 */ /***/ (function(module, exports, __webpack_require__) { /* -*- Mode: js; js-indent-level: 2; -*- */ @@ -91633,10 +93997,10 @@ exports.SourceNode = __webpack_require__(810).SourceNode; * http://opensource.org/licenses/BSD-3-Clause */ -var base64VLQ = __webpack_require__(802); -var util = __webpack_require__(804); -var ArraySet = __webpack_require__(805).ArraySet; -var MappingList = __webpack_require__(806).MappingList; +var base64VLQ = __webpack_require__(809); +var util = __webpack_require__(811); +var ArraySet = __webpack_require__(812).ArraySet; +var MappingList = __webpack_require__(813).MappingList; /** * An instance of the SourceMapGenerator represents a source map which is @@ -92045,7 +94409,7 @@ exports.SourceMapGenerator = SourceMapGenerator; /***/ }), -/* 802 */ +/* 809 */ /***/ (function(module, exports, __webpack_require__) { /* -*- Mode: js; js-indent-level: 2; -*- */ @@ -92085,7 +94449,7 @@ exports.SourceMapGenerator = SourceMapGenerator; * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -var base64 = __webpack_require__(803); +var base64 = __webpack_require__(810); // A single base 64 digit can contain 6 bits of data. For the base 64 variable // length quantities we use in the source map spec, the first bit is the sign, @@ -92191,7 +94555,7 @@ exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) { /***/ }), -/* 803 */ +/* 810 */ /***/ (function(module, exports) { /* -*- Mode: js; js-indent-level: 2; -*- */ @@ -92264,7 +94628,7 @@ exports.decode = function (charCode) { /***/ }), -/* 804 */ +/* 811 */ /***/ (function(module, exports) { /* -*- Mode: js; js-indent-level: 2; -*- */ @@ -92687,7 +95051,7 @@ exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflate /***/ }), -/* 805 */ +/* 812 */ /***/ (function(module, exports, __webpack_require__) { /* -*- Mode: js; js-indent-level: 2; -*- */ @@ -92697,7 +95061,7 @@ exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflate * http://opensource.org/licenses/BSD-3-Clause */ -var util = __webpack_require__(804); +var util = __webpack_require__(811); var has = Object.prototype.hasOwnProperty; var hasNativeMap = typeof Map !== "undefined"; @@ -92814,7 +95178,7 @@ exports.ArraySet = ArraySet; /***/ }), -/* 806 */ +/* 813 */ /***/ (function(module, exports, __webpack_require__) { /* -*- Mode: js; js-indent-level: 2; -*- */ @@ -92824,7 +95188,7 @@ exports.ArraySet = ArraySet; * http://opensource.org/licenses/BSD-3-Clause */ -var util = __webpack_require__(804); +var util = __webpack_require__(811); /** * Determine whether mappingB is after mappingA with respect to generated @@ -92899,7 +95263,7 @@ exports.MappingList = MappingList; /***/ }), -/* 807 */ +/* 814 */ /***/ (function(module, exports, __webpack_require__) { /* -*- Mode: js; js-indent-level: 2; -*- */ @@ -92909,11 +95273,11 @@ exports.MappingList = MappingList; * http://opensource.org/licenses/BSD-3-Clause */ -var util = __webpack_require__(804); -var binarySearch = __webpack_require__(808); -var ArraySet = __webpack_require__(805).ArraySet; -var base64VLQ = __webpack_require__(802); -var quickSort = __webpack_require__(809).quickSort; +var util = __webpack_require__(811); +var binarySearch = __webpack_require__(815); +var ArraySet = __webpack_require__(812).ArraySet; +var base64VLQ = __webpack_require__(809); +var quickSort = __webpack_require__(816).quickSort; function SourceMapConsumer(aSourceMap) { var sourceMap = aSourceMap; @@ -93987,7 +96351,7 @@ exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer; /***/ }), -/* 808 */ +/* 815 */ /***/ (function(module, exports) { /* -*- Mode: js; js-indent-level: 2; -*- */ @@ -94104,7 +96468,7 @@ exports.search = function search(aNeedle, aHaystack, aCompare, aBias) { /***/ }), -/* 809 */ +/* 816 */ /***/ (function(module, exports) { /* -*- Mode: js; js-indent-level: 2; -*- */ @@ -94224,7 +96588,7 @@ exports.quickSort = function (ary, comparator) { /***/ }), -/* 810 */ +/* 817 */ /***/ (function(module, exports, __webpack_require__) { /* -*- Mode: js; js-indent-level: 2; -*- */ @@ -94234,8 +96598,8 @@ exports.quickSort = function (ary, comparator) { * http://opensource.org/licenses/BSD-3-Clause */ -var SourceMapGenerator = __webpack_require__(801).SourceMapGenerator; -var util = __webpack_require__(804); +var SourceMapGenerator = __webpack_require__(808).SourceMapGenerator; +var util = __webpack_require__(811); // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other // operating systems these days (capturing the result). @@ -94643,17 +97007,17 @@ exports.SourceNode = SourceNode; /***/ }), -/* 811 */ +/* 818 */ /***/ (function(module, exports, __webpack_require__) { // Copyright 2014, 2015, 2016, 2017 Simon Lydell // X11 (“MIT”) Licensed. (See LICENSE.) -var sourceMappingURL = __webpack_require__(812) -var resolveUrl = __webpack_require__(813) -var decodeUriComponent = __webpack_require__(814) -var urix = __webpack_require__(816) -var atob = __webpack_require__(817) +var sourceMappingURL = __webpack_require__(819) +var resolveUrl = __webpack_require__(820) +var decodeUriComponent = __webpack_require__(821) +var urix = __webpack_require__(823) +var atob = __webpack_require__(824) @@ -94951,7 +97315,7 @@ module.exports = { /***/ }), -/* 812 */ +/* 819 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;// Copyright 2014 Simon Lydell @@ -95014,7 +97378,7 @@ void (function(root, factory) { /***/ }), -/* 813 */ +/* 820 */ /***/ (function(module, exports, __webpack_require__) { // Copyright 2014 Simon Lydell @@ -95032,13 +97396,13 @@ module.exports = resolveUrl /***/ }), -/* 814 */ +/* 821 */ /***/ (function(module, exports, __webpack_require__) { // Copyright 2017 Simon Lydell // X11 (“MIT”) Licensed. (See LICENSE.) -var decodeUriComponent = __webpack_require__(815) +var decodeUriComponent = __webpack_require__(822) function customDecodeUriComponent(string) { // `decodeUriComponent` turns `+` into ` `, but that's not wanted. @@ -95049,7 +97413,7 @@ module.exports = customDecodeUriComponent /***/ }), -/* 815 */ +/* 822 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -95150,7 +97514,7 @@ module.exports = function (encodedURI) { /***/ }), -/* 816 */ +/* 823 */ /***/ (function(module, exports, __webpack_require__) { // Copyright 2014 Simon Lydell @@ -95173,7 +97537,7 @@ module.exports = urix /***/ }), -/* 817 */ +/* 824 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -95187,7 +97551,7 @@ module.exports = atob.atob = atob; /***/ }), -/* 818 */ +/* 825 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -95195,8 +97559,8 @@ module.exports = atob.atob = atob; var fs = __webpack_require__(23); var path = __webpack_require__(16); -var define = __webpack_require__(722); -var utils = __webpack_require__(799); +var define = __webpack_require__(729); +var utils = __webpack_require__(806); /** * Expose `mixin()`. @@ -95339,19 +97703,19 @@ exports.comment = function(node) { /***/ }), -/* 819 */ +/* 826 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var use = __webpack_require__(791); +var use = __webpack_require__(798); var util = __webpack_require__(29); -var Cache = __webpack_require__(820); -var define = __webpack_require__(722); -var debug = __webpack_require__(793)('snapdragon:parser'); -var Position = __webpack_require__(821); -var utils = __webpack_require__(799); +var Cache = __webpack_require__(827); +var define = __webpack_require__(729); +var debug = __webpack_require__(800)('snapdragon:parser'); +var Position = __webpack_require__(828); +var utils = __webpack_require__(806); /** * Create a new `Parser` with the given `input` and `options`. @@ -95879,7 +98243,7 @@ module.exports = Parser; /***/ }), -/* 820 */ +/* 827 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -95986,13 +98350,13 @@ MapCache.prototype.del = function mapDelete(key) { /***/ }), -/* 821 */ +/* 828 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var define = __webpack_require__(722); +var define = __webpack_require__(729); /** * Store position for a node @@ -96007,16 +98371,16 @@ module.exports = function Position(start, parser) { /***/ }), -/* 822 */ +/* 829 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var safe = __webpack_require__(823); -var define = __webpack_require__(829); -var extend = __webpack_require__(830); -var not = __webpack_require__(832); +var safe = __webpack_require__(830); +var define = __webpack_require__(836); +var extend = __webpack_require__(837); +var not = __webpack_require__(839); var MAX_LENGTH = 1024 * 64; /** @@ -96169,10 +98533,10 @@ module.exports.makeRe = makeRe; /***/ }), -/* 823 */ +/* 830 */ /***/ (function(module, exports, __webpack_require__) { -var parse = __webpack_require__(824); +var parse = __webpack_require__(831); var types = parse.types; module.exports = function (re, opts) { @@ -96218,13 +98582,13 @@ function isRegExp (x) { /***/ }), -/* 824 */ +/* 831 */ /***/ (function(module, exports, __webpack_require__) { -var util = __webpack_require__(825); -var types = __webpack_require__(826); -var sets = __webpack_require__(827); -var positions = __webpack_require__(828); +var util = __webpack_require__(832); +var types = __webpack_require__(833); +var sets = __webpack_require__(834); +var positions = __webpack_require__(835); module.exports = function(regexpStr) { @@ -96506,11 +98870,11 @@ module.exports.types = types; /***/ }), -/* 825 */ +/* 832 */ /***/ (function(module, exports, __webpack_require__) { -var types = __webpack_require__(826); -var sets = __webpack_require__(827); +var types = __webpack_require__(833); +var sets = __webpack_require__(834); // All of these are private and only used by randexp. @@ -96623,7 +98987,7 @@ exports.error = function(regexp, msg) { /***/ }), -/* 826 */ +/* 833 */ /***/ (function(module, exports) { module.exports = { @@ -96639,10 +99003,10 @@ module.exports = { /***/ }), -/* 827 */ +/* 834 */ /***/ (function(module, exports, __webpack_require__) { -var types = __webpack_require__(826); +var types = __webpack_require__(833); var INTS = function() { return [{ type: types.RANGE , from: 48, to: 57 }]; @@ -96727,10 +99091,10 @@ exports.anyChar = function() { /***/ }), -/* 828 */ +/* 835 */ /***/ (function(module, exports, __webpack_require__) { -var types = __webpack_require__(826); +var types = __webpack_require__(833); exports.wordBoundary = function() { return { type: types.POSITION, value: 'b' }; @@ -96750,7 +99114,7 @@ exports.end = function() { /***/ }), -/* 829 */ +/* 836 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -96763,8 +99127,8 @@ exports.end = function() { -var isobject = __webpack_require__(740); -var isDescriptor = __webpack_require__(752); +var isobject = __webpack_require__(747); +var isDescriptor = __webpack_require__(759); var define = (typeof Reflect !== 'undefined' && Reflect.defineProperty) ? Reflect.defineProperty : Object.defineProperty; @@ -96795,14 +99159,14 @@ module.exports = function defineProperty(obj, key, val) { /***/ }), -/* 830 */ +/* 837 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var isExtendable = __webpack_require__(831); -var assignSymbols = __webpack_require__(741); +var isExtendable = __webpack_require__(838); +var assignSymbols = __webpack_require__(748); module.exports = Object.assign || function(obj/*, objects*/) { if (obj === null || typeof obj === 'undefined') { @@ -96862,7 +99226,7 @@ function isEnum(obj, key) { /***/ }), -/* 831 */ +/* 838 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -96875,7 +99239,7 @@ function isEnum(obj, key) { -var isPlainObject = __webpack_require__(739); +var isPlainObject = __webpack_require__(746); module.exports = function isExtendable(val) { return isPlainObject(val) || typeof val === 'function' || Array.isArray(val); @@ -96883,14 +99247,14 @@ module.exports = function isExtendable(val) { /***/ }), -/* 832 */ +/* 839 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var extend = __webpack_require__(830); -var safe = __webpack_require__(823); +var extend = __webpack_require__(837); +var safe = __webpack_require__(830); /** * The main export is a function that takes a `pattern` string and an `options` object. @@ -96962,14 +99326,14 @@ module.exports = toRegex; /***/ }), -/* 833 */ +/* 840 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var nanomatch = __webpack_require__(834); -var extglob = __webpack_require__(849); +var nanomatch = __webpack_require__(841); +var extglob = __webpack_require__(856); module.exports = function(snapdragon) { var compilers = snapdragon.compiler.compilers; @@ -97046,7 +99410,7 @@ function escapeExtglobs(compiler) { /***/ }), -/* 834 */ +/* 841 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -97057,17 +99421,17 @@ function escapeExtglobs(compiler) { */ var util = __webpack_require__(29); -var toRegex = __webpack_require__(721); -var extend = __webpack_require__(835); +var toRegex = __webpack_require__(728); +var extend = __webpack_require__(842); /** * Local dependencies */ -var compilers = __webpack_require__(837); -var parsers = __webpack_require__(838); -var cache = __webpack_require__(841); -var utils = __webpack_require__(843); +var compilers = __webpack_require__(844); +var parsers = __webpack_require__(845); +var cache = __webpack_require__(848); +var utils = __webpack_require__(850); var MAX_LENGTH = 1024 * 64; /** @@ -97891,14 +100255,14 @@ module.exports = nanomatch; /***/ }), -/* 835 */ +/* 842 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var isExtendable = __webpack_require__(836); -var assignSymbols = __webpack_require__(741); +var isExtendable = __webpack_require__(843); +var assignSymbols = __webpack_require__(748); module.exports = Object.assign || function(obj/*, objects*/) { if (obj === null || typeof obj === 'undefined') { @@ -97958,7 +100322,7 @@ function isEnum(obj, key) { /***/ }), -/* 836 */ +/* 843 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -97971,7 +100335,7 @@ function isEnum(obj, key) { -var isPlainObject = __webpack_require__(739); +var isPlainObject = __webpack_require__(746); module.exports = function isExtendable(val) { return isPlainObject(val) || typeof val === 'function' || Array.isArray(val); @@ -97979,7 +100343,7 @@ module.exports = function isExtendable(val) { /***/ }), -/* 837 */ +/* 844 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -98325,15 +100689,15 @@ module.exports = function(nanomatch, options) { /***/ }), -/* 838 */ +/* 845 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var regexNot = __webpack_require__(732); -var toRegex = __webpack_require__(721); -var isOdd = __webpack_require__(839); +var regexNot = __webpack_require__(739); +var toRegex = __webpack_require__(728); +var isOdd = __webpack_require__(846); /** * Characters to use in negation regex (we want to "not" match @@ -98719,7 +101083,7 @@ module.exports.not = NOT_REGEX; /***/ }), -/* 839 */ +/* 846 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -98732,7 +101096,7 @@ module.exports.not = NOT_REGEX; -var isNumber = __webpack_require__(840); +var isNumber = __webpack_require__(847); module.exports = function isOdd(i) { if (!isNumber(i)) { @@ -98746,7 +101110,7 @@ module.exports = function isOdd(i) { /***/ }), -/* 840 */ +/* 847 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -98774,14 +101138,14 @@ module.exports = function isNumber(num) { /***/ }), -/* 841 */ +/* 848 */ /***/ (function(module, exports, __webpack_require__) { -module.exports = new (__webpack_require__(842))(); +module.exports = new (__webpack_require__(849))(); /***/ }), -/* 842 */ +/* 849 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -98794,7 +101158,7 @@ module.exports = new (__webpack_require__(842))(); -var MapCache = __webpack_require__(820); +var MapCache = __webpack_require__(827); /** * Create a new `FragmentCache` with an optional object to use for `caches`. @@ -98916,7 +101280,7 @@ exports = module.exports = FragmentCache; /***/ }), -/* 843 */ +/* 850 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -98929,14 +101293,14 @@ var path = __webpack_require__(16); * Module dependencies */ -var isWindows = __webpack_require__(844)(); -var Snapdragon = __webpack_require__(760); -utils.define = __webpack_require__(845); -utils.diff = __webpack_require__(846); -utils.extend = __webpack_require__(835); -utils.pick = __webpack_require__(847); -utils.typeOf = __webpack_require__(848); -utils.unique = __webpack_require__(733); +var isWindows = __webpack_require__(851)(); +var Snapdragon = __webpack_require__(767); +utils.define = __webpack_require__(852); +utils.diff = __webpack_require__(853); +utils.extend = __webpack_require__(842); +utils.pick = __webpack_require__(854); +utils.typeOf = __webpack_require__(855); +utils.unique = __webpack_require__(740); /** * Returns true if the given value is effectively an empty string @@ -99302,7 +101666,7 @@ utils.unixify = function(options) { /***/ }), -/* 844 */ +/* 851 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! @@ -99330,7 +101694,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ /***/ }), -/* 845 */ +/* 852 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -99343,8 +101707,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ -var isobject = __webpack_require__(740); -var isDescriptor = __webpack_require__(752); +var isobject = __webpack_require__(747); +var isDescriptor = __webpack_require__(759); var define = (typeof Reflect !== 'undefined' && Reflect.defineProperty) ? Reflect.defineProperty : Object.defineProperty; @@ -99375,7 +101739,7 @@ module.exports = function defineProperty(obj, key, val) { /***/ }), -/* 846 */ +/* 853 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -99429,7 +101793,7 @@ function diffArray(one, two) { /***/ }), -/* 847 */ +/* 854 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -99442,7 +101806,7 @@ function diffArray(one, two) { -var isObject = __webpack_require__(740); +var isObject = __webpack_require__(747); module.exports = function pick(obj, keys) { if (!isObject(obj) && typeof obj !== 'function') { @@ -99471,7 +101835,7 @@ module.exports = function pick(obj, keys) { /***/ }), -/* 848 */ +/* 855 */ /***/ (function(module, exports) { var toString = Object.prototype.toString; @@ -99606,7 +101970,7 @@ function isBuffer(val) { /***/ }), -/* 849 */ +/* 856 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -99616,18 +101980,18 @@ function isBuffer(val) { * Module dependencies */ -var extend = __webpack_require__(730); -var unique = __webpack_require__(733); -var toRegex = __webpack_require__(721); +var extend = __webpack_require__(737); +var unique = __webpack_require__(740); +var toRegex = __webpack_require__(728); /** * Local dependencies */ -var compilers = __webpack_require__(850); -var parsers = __webpack_require__(861); -var Extglob = __webpack_require__(864); -var utils = __webpack_require__(863); +var compilers = __webpack_require__(857); +var parsers = __webpack_require__(868); +var Extglob = __webpack_require__(871); +var utils = __webpack_require__(870); var MAX_LENGTH = 1024 * 64; /** @@ -99944,13 +102308,13 @@ module.exports = extglob; /***/ }), -/* 850 */ +/* 857 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var brackets = __webpack_require__(851); +var brackets = __webpack_require__(858); /** * Extglob compilers @@ -100120,7 +102484,7 @@ module.exports = function(extglob) { /***/ }), -/* 851 */ +/* 858 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -100130,17 +102494,17 @@ module.exports = function(extglob) { * Local dependencies */ -var compilers = __webpack_require__(852); -var parsers = __webpack_require__(854); +var compilers = __webpack_require__(859); +var parsers = __webpack_require__(861); /** * Module dependencies */ -var debug = __webpack_require__(856)('expand-brackets'); -var extend = __webpack_require__(730); -var Snapdragon = __webpack_require__(760); -var toRegex = __webpack_require__(721); +var debug = __webpack_require__(863)('expand-brackets'); +var extend = __webpack_require__(737); +var Snapdragon = __webpack_require__(767); +var toRegex = __webpack_require__(728); /** * Parses the given POSIX character class `pattern` and returns a @@ -100338,13 +102702,13 @@ module.exports = brackets; /***/ }), -/* 852 */ +/* 859 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var posix = __webpack_require__(853); +var posix = __webpack_require__(860); module.exports = function(brackets) { brackets.compiler @@ -100432,7 +102796,7 @@ module.exports = function(brackets) { /***/ }), -/* 853 */ +/* 860 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -100461,14 +102825,14 @@ module.exports = { /***/ }), -/* 854 */ +/* 861 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var utils = __webpack_require__(855); -var define = __webpack_require__(722); +var utils = __webpack_require__(862); +var define = __webpack_require__(729); /** * Text regex @@ -100687,14 +103051,14 @@ module.exports.TEXT_REGEX = TEXT_REGEX; /***/ }), -/* 855 */ +/* 862 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var toRegex = __webpack_require__(721); -var regexNot = __webpack_require__(732); +var toRegex = __webpack_require__(728); +var regexNot = __webpack_require__(739); var cached; /** @@ -100728,7 +103092,7 @@ exports.createRegex = function(pattern, include) { /***/ }), -/* 856 */ +/* 863 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -100737,14 +103101,14 @@ exports.createRegex = function(pattern, include) { */ if (typeof process !== 'undefined' && process.type === 'renderer') { - module.exports = __webpack_require__(857); + module.exports = __webpack_require__(864); } else { - module.exports = __webpack_require__(860); + module.exports = __webpack_require__(867); } /***/ }), -/* 857 */ +/* 864 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -100753,7 +103117,7 @@ if (typeof process !== 'undefined' && process.type === 'renderer') { * Expose `debug()` as the module. */ -exports = module.exports = __webpack_require__(858); +exports = module.exports = __webpack_require__(865); exports.log = log; exports.formatArgs = formatArgs; exports.save = save; @@ -100935,7 +103299,7 @@ function localstorage() { /***/ }), -/* 858 */ +/* 865 */ /***/ (function(module, exports, __webpack_require__) { @@ -100951,7 +103315,7 @@ exports.coerce = coerce; exports.disable = disable; exports.enable = enable; exports.enabled = enabled; -exports.humanize = __webpack_require__(859); +exports.humanize = __webpack_require__(866); /** * The currently active debug mode names, and names to skip. @@ -101143,7 +103507,7 @@ function coerce(val) { /***/ }), -/* 859 */ +/* 866 */ /***/ (function(module, exports) { /** @@ -101301,7 +103665,7 @@ function plural(ms, n, name) { /***/ }), -/* 860 */ +/* 867 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -101317,7 +103681,7 @@ var util = __webpack_require__(29); * Expose `debug()` as the module. */ -exports = module.exports = __webpack_require__(858); +exports = module.exports = __webpack_require__(865); exports.init = init; exports.log = log; exports.formatArgs = formatArgs; @@ -101496,7 +103860,7 @@ function createWritableStdioStream (fd) { case 'PIPE': case 'TCP': - var net = __webpack_require__(798); + var net = __webpack_require__(805); stream = new net.Socket({ fd: fd, readable: false, @@ -101555,15 +103919,15 @@ exports.enable(load()); /***/ }), -/* 861 */ +/* 868 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var brackets = __webpack_require__(851); -var define = __webpack_require__(862); -var utils = __webpack_require__(863); +var brackets = __webpack_require__(858); +var define = __webpack_require__(869); +var utils = __webpack_require__(870); /** * Characters to use in text regex (we want to "not" match @@ -101718,7 +104082,7 @@ module.exports = parsers; /***/ }), -/* 862 */ +/* 869 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -101731,7 +104095,7 @@ module.exports = parsers; -var isDescriptor = __webpack_require__(752); +var isDescriptor = __webpack_require__(759); module.exports = function defineProperty(obj, prop, val) { if (typeof obj !== 'object' && typeof obj !== 'function') { @@ -101756,14 +104120,14 @@ module.exports = function defineProperty(obj, prop, val) { /***/ }), -/* 863 */ +/* 870 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var regex = __webpack_require__(732); -var Cache = __webpack_require__(842); +var regex = __webpack_require__(739); +var Cache = __webpack_require__(849); /** * Utils @@ -101832,7 +104196,7 @@ utils.createRegex = function(str) { /***/ }), -/* 864 */ +/* 871 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -101842,16 +104206,16 @@ utils.createRegex = function(str) { * Module dependencies */ -var Snapdragon = __webpack_require__(760); -var define = __webpack_require__(862); -var extend = __webpack_require__(730); +var Snapdragon = __webpack_require__(767); +var define = __webpack_require__(869); +var extend = __webpack_require__(737); /** * Local dependencies */ -var compilers = __webpack_require__(850); -var parsers = __webpack_require__(861); +var compilers = __webpack_require__(857); +var parsers = __webpack_require__(868); /** * Customize Snapdragon parser and renderer @@ -101917,16 +104281,16 @@ module.exports = Extglob; /***/ }), -/* 865 */ +/* 872 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var extglob = __webpack_require__(849); -var nanomatch = __webpack_require__(834); -var regexNot = __webpack_require__(732); -var toRegex = __webpack_require__(822); +var extglob = __webpack_require__(856); +var nanomatch = __webpack_require__(841); +var regexNot = __webpack_require__(739); +var toRegex = __webpack_require__(829); var not; /** @@ -102007,14 +104371,14 @@ function textRegex(pattern) { /***/ }), -/* 866 */ +/* 873 */ /***/ (function(module, exports, __webpack_require__) { -module.exports = new (__webpack_require__(842))(); +module.exports = new (__webpack_require__(849))(); /***/ }), -/* 867 */ +/* 874 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -102027,13 +104391,13 @@ var path = __webpack_require__(16); * Module dependencies */ -var Snapdragon = __webpack_require__(760); -utils.define = __webpack_require__(829); -utils.diff = __webpack_require__(846); -utils.extend = __webpack_require__(830); -utils.pick = __webpack_require__(847); -utils.typeOf = __webpack_require__(868); -utils.unique = __webpack_require__(733); +var Snapdragon = __webpack_require__(767); +utils.define = __webpack_require__(836); +utils.diff = __webpack_require__(853); +utils.extend = __webpack_require__(837); +utils.pick = __webpack_require__(854); +utils.typeOf = __webpack_require__(875); +utils.unique = __webpack_require__(740); /** * Returns true if the platform is windows, or `path.sep` is `\\`. @@ -102330,7 +104694,7 @@ utils.unixify = function(options) { /***/ }), -/* 868 */ +/* 875 */ /***/ (function(module, exports) { var toString = Object.prototype.toString; @@ -102465,7 +104829,7 @@ function isBuffer(val) { /***/ }), -/* 869 */ +/* 876 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -102484,9 +104848,9 @@ var __extends = (this && this.__extends) || (function () { }; })(); Object.defineProperty(exports, "__esModule", { value: true }); -var readdir = __webpack_require__(870); -var reader_1 = __webpack_require__(883); -var fs_stream_1 = __webpack_require__(887); +var readdir = __webpack_require__(877); +var reader_1 = __webpack_require__(890); +var fs_stream_1 = __webpack_require__(894); var ReaderAsync = /** @class */ (function (_super) { __extends(ReaderAsync, _super); function ReaderAsync() { @@ -102547,15 +104911,15 @@ exports.default = ReaderAsync; /***/ }), -/* 870 */ +/* 877 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const readdirSync = __webpack_require__(871); -const readdirAsync = __webpack_require__(879); -const readdirStream = __webpack_require__(882); +const readdirSync = __webpack_require__(878); +const readdirAsync = __webpack_require__(886); +const readdirStream = __webpack_require__(889); module.exports = exports = readdirAsyncPath; exports.readdir = exports.readdirAsync = exports.async = readdirAsyncPath; @@ -102639,7 +105003,7 @@ function readdirStreamStat (dir, options) { /***/ }), -/* 871 */ +/* 878 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -102647,11 +105011,11 @@ function readdirStreamStat (dir, options) { module.exports = readdirSync; -const DirectoryReader = __webpack_require__(872); +const DirectoryReader = __webpack_require__(879); let syncFacade = { - fs: __webpack_require__(877), - forEach: __webpack_require__(878), + fs: __webpack_require__(884), + forEach: __webpack_require__(885), sync: true }; @@ -102680,7 +105044,7 @@ function readdirSync (dir, options, internalOptions) { /***/ }), -/* 872 */ +/* 879 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -102689,9 +105053,9 @@ function readdirSync (dir, options, internalOptions) { const Readable = __webpack_require__(27).Readable; const EventEmitter = __webpack_require__(379).EventEmitter; const path = __webpack_require__(16); -const normalizeOptions = __webpack_require__(873); -const stat = __webpack_require__(875); -const call = __webpack_require__(876); +const normalizeOptions = __webpack_require__(880); +const stat = __webpack_require__(882); +const call = __webpack_require__(883); /** * Asynchronously reads the contents of a directory and streams the results @@ -103067,14 +105431,14 @@ module.exports = DirectoryReader; /***/ }), -/* 873 */ +/* 880 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const path = __webpack_require__(16); -const globToRegExp = __webpack_require__(874); +const globToRegExp = __webpack_require__(881); module.exports = normalizeOptions; @@ -103251,7 +105615,7 @@ function normalizeOptions (options, internalOptions) { /***/ }), -/* 874 */ +/* 881 */ /***/ (function(module, exports) { module.exports = function (glob, opts) { @@ -103388,13 +105752,13 @@ module.exports = function (glob, opts) { /***/ }), -/* 875 */ +/* 882 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const call = __webpack_require__(876); +const call = __webpack_require__(883); module.exports = stat; @@ -103469,7 +105833,7 @@ function symlinkStat (fs, path, lstats, callback) { /***/ }), -/* 876 */ +/* 883 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -103530,14 +105894,14 @@ function callOnce (fn) { /***/ }), -/* 877 */ +/* 884 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const fs = __webpack_require__(23); -const call = __webpack_require__(876); +const call = __webpack_require__(883); /** * A facade around {@link fs.readdirSync} that allows it to be called @@ -103601,7 +105965,7 @@ exports.lstat = function (path, callback) { /***/ }), -/* 878 */ +/* 885 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -103630,7 +105994,7 @@ function syncForEach (array, iterator, done) { /***/ }), -/* 879 */ +/* 886 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -103638,12 +106002,12 @@ function syncForEach (array, iterator, done) { module.exports = readdirAsync; -const maybe = __webpack_require__(880); -const DirectoryReader = __webpack_require__(872); +const maybe = __webpack_require__(887); +const DirectoryReader = __webpack_require__(879); let asyncFacade = { fs: __webpack_require__(23), - forEach: __webpack_require__(881), + forEach: __webpack_require__(888), async: true }; @@ -103685,7 +106049,7 @@ function readdirAsync (dir, options, callback, internalOptions) { /***/ }), -/* 880 */ +/* 887 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -103712,7 +106076,7 @@ module.exports = function maybe (cb, promise) { /***/ }), -/* 881 */ +/* 888 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -103748,7 +106112,7 @@ function asyncForEach (array, iterator, done) { /***/ }), -/* 882 */ +/* 889 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -103756,11 +106120,11 @@ function asyncForEach (array, iterator, done) { module.exports = readdirStream; -const DirectoryReader = __webpack_require__(872); +const DirectoryReader = __webpack_require__(879); let streamFacade = { fs: __webpack_require__(23), - forEach: __webpack_require__(881), + forEach: __webpack_require__(888), async: true }; @@ -103780,16 +106144,16 @@ function readdirStream (dir, options, internalOptions) { /***/ }), -/* 883 */ +/* 890 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var path = __webpack_require__(16); -var deep_1 = __webpack_require__(884); -var entry_1 = __webpack_require__(886); -var pathUtil = __webpack_require__(885); +var deep_1 = __webpack_require__(891); +var entry_1 = __webpack_require__(893); +var pathUtil = __webpack_require__(892); var Reader = /** @class */ (function () { function Reader(options) { this.options = options; @@ -103855,14 +106219,14 @@ exports.default = Reader; /***/ }), -/* 884 */ +/* 891 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var pathUtils = __webpack_require__(885); -var patternUtils = __webpack_require__(714); +var pathUtils = __webpack_require__(892); +var patternUtils = __webpack_require__(721); var DeepFilter = /** @class */ (function () { function DeepFilter(options, micromatchOptions) { this.options = options; @@ -103945,7 +106309,7 @@ exports.default = DeepFilter; /***/ }), -/* 885 */ +/* 892 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -103976,14 +106340,14 @@ exports.makeAbsolute = makeAbsolute; /***/ }), -/* 886 */ +/* 893 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var pathUtils = __webpack_require__(885); -var patternUtils = __webpack_require__(714); +var pathUtils = __webpack_require__(892); +var patternUtils = __webpack_require__(721); var EntryFilter = /** @class */ (function () { function EntryFilter(options, micromatchOptions) { this.options = options; @@ -104068,7 +106432,7 @@ exports.default = EntryFilter; /***/ }), -/* 887 */ +/* 894 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -104088,8 +106452,8 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); var stream = __webpack_require__(27); -var fsStat = __webpack_require__(888); -var fs_1 = __webpack_require__(892); +var fsStat = __webpack_require__(895); +var fs_1 = __webpack_require__(899); var FileSystemStream = /** @class */ (function (_super) { __extends(FileSystemStream, _super); function FileSystemStream() { @@ -104139,14 +106503,14 @@ exports.default = FileSystemStream; /***/ }), -/* 888 */ +/* 895 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const optionsManager = __webpack_require__(889); -const statProvider = __webpack_require__(891); +const optionsManager = __webpack_require__(896); +const statProvider = __webpack_require__(898); /** * Asynchronous API. */ @@ -104177,13 +106541,13 @@ exports.statSync = statSync; /***/ }), -/* 889 */ +/* 896 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const fsAdapter = __webpack_require__(890); +const fsAdapter = __webpack_require__(897); function prepare(opts) { const options = Object.assign({ fs: fsAdapter.getFileSystemAdapter(opts ? opts.fs : undefined), @@ -104196,7 +106560,7 @@ exports.prepare = prepare; /***/ }), -/* 890 */ +/* 897 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -104219,7 +106583,7 @@ exports.getFileSystemAdapter = getFileSystemAdapter; /***/ }), -/* 891 */ +/* 898 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -104271,7 +106635,7 @@ exports.isFollowedSymlink = isFollowedSymlink; /***/ }), -/* 892 */ +/* 899 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -104302,7 +106666,7 @@ exports.default = FileSystem; /***/ }), -/* 893 */ +/* 900 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -104322,9 +106686,9 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); var stream = __webpack_require__(27); -var readdir = __webpack_require__(870); -var reader_1 = __webpack_require__(883); -var fs_stream_1 = __webpack_require__(887); +var readdir = __webpack_require__(877); +var reader_1 = __webpack_require__(890); +var fs_stream_1 = __webpack_require__(894); var TransformStream = /** @class */ (function (_super) { __extends(TransformStream, _super); function TransformStream(reader) { @@ -104392,7 +106756,7 @@ exports.default = ReaderStream; /***/ }), -/* 894 */ +/* 901 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -104411,9 +106775,9 @@ var __extends = (this && this.__extends) || (function () { }; })(); Object.defineProperty(exports, "__esModule", { value: true }); -var readdir = __webpack_require__(870); -var reader_1 = __webpack_require__(883); -var fs_sync_1 = __webpack_require__(895); +var readdir = __webpack_require__(877); +var reader_1 = __webpack_require__(890); +var fs_sync_1 = __webpack_require__(902); var ReaderSync = /** @class */ (function (_super) { __extends(ReaderSync, _super); function ReaderSync() { @@ -104473,7 +106837,7 @@ exports.default = ReaderSync; /***/ }), -/* 895 */ +/* 902 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -104492,8 +106856,8 @@ var __extends = (this && this.__extends) || (function () { }; })(); Object.defineProperty(exports, "__esModule", { value: true }); -var fsStat = __webpack_require__(888); -var fs_1 = __webpack_require__(892); +var fsStat = __webpack_require__(895); +var fs_1 = __webpack_require__(899); var FileSystemSync = /** @class */ (function (_super) { __extends(FileSystemSync, _super); function FileSystemSync() { @@ -104539,7 +106903,7 @@ exports.default = FileSystemSync; /***/ }), -/* 896 */ +/* 903 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -104555,7 +106919,7 @@ exports.flatten = flatten; /***/ }), -/* 897 */ +/* 904 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -104576,13 +106940,13 @@ exports.merge = merge; /***/ }), -/* 898 */ +/* 905 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const path = __webpack_require__(16); -const pathType = __webpack_require__(899); +const pathType = __webpack_require__(906); const getExtensions = extensions => extensions.length > 1 ? `{${extensions.join(',')}}` : extensions[0]; @@ -104648,13 +107012,13 @@ module.exports.sync = (input, opts) => { /***/ }), -/* 899 */ +/* 906 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const fs = __webpack_require__(23); -const pify = __webpack_require__(900); +const pify = __webpack_require__(907); function type(fn, fn2, fp) { if (typeof fp !== 'string') { @@ -104697,7 +107061,7 @@ exports.symlinkSync = typeSync.bind(null, 'lstatSync', 'isSymbolicLink'); /***/ }), -/* 900 */ +/* 907 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -104788,17 +107152,17 @@ module.exports = (obj, opts) => { /***/ }), -/* 901 */ +/* 908 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const fs = __webpack_require__(23); const path = __webpack_require__(16); -const fastGlob = __webpack_require__(710); -const gitIgnore = __webpack_require__(902); -const pify = __webpack_require__(903); -const slash = __webpack_require__(904); +const fastGlob = __webpack_require__(717); +const gitIgnore = __webpack_require__(909); +const pify = __webpack_require__(910); +const slash = __webpack_require__(911); const DEFAULT_IGNORE = [ '**/node_modules/**', @@ -104896,7 +107260,7 @@ module.exports.sync = options => { /***/ }), -/* 902 */ +/* 909 */ /***/ (function(module, exports) { // A simple implementation of make-array @@ -105365,7 +107729,7 @@ module.exports = options => new IgnoreBase(options) /***/ }), -/* 903 */ +/* 910 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -105440,7 +107804,7 @@ module.exports = (input, options) => { /***/ }), -/* 904 */ +/* 911 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -105458,17 +107822,17 @@ module.exports = input => { /***/ }), -/* 905 */ +/* 912 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const path = __webpack_require__(16); const {constants: fsConstants} = __webpack_require__(23); -const {Buffer} = __webpack_require__(906); -const CpFileError = __webpack_require__(907); -const fs = __webpack_require__(909); -const ProgressEmitter = __webpack_require__(911); +const {Buffer} = __webpack_require__(913); +const CpFileError = __webpack_require__(914); +const fs = __webpack_require__(918); +const ProgressEmitter = __webpack_require__(920); const cpFile = (source, destination, options) => { if (!source || !destination) { @@ -105622,7 +107986,7 @@ module.exports.sync = (source, destination, options) => { /***/ }), -/* 906 */ +/* 913 */ /***/ (function(module, exports, __webpack_require__) { /* eslint-disable node/no-deprecated-api */ @@ -105690,12 +108054,12 @@ SafeBuffer.allocUnsafeSlow = function (size) { /***/ }), -/* 907 */ +/* 914 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const NestedError = __webpack_require__(908); +const NestedError = __webpack_require__(915); class CpFileError extends NestedError { constructor(message, nested) { @@ -105709,10 +108073,10 @@ module.exports = CpFileError; /***/ }), -/* 908 */ +/* 915 */ /***/ (function(module, exports, __webpack_require__) { -var inherits = __webpack_require__(509); +var inherits = __webpack_require__(916); var NestedError = function (message, nested) { this.nested = nested; @@ -105763,15 +108127,57 @@ module.exports = NestedError; /***/ }), -/* 909 */ +/* 916 */ +/***/ (function(module, exports, __webpack_require__) { + +try { + var util = __webpack_require__(29); + if (typeof util.inherits !== 'function') throw ''; + module.exports = util.inherits; +} catch (e) { + module.exports = __webpack_require__(917); +} + + +/***/ }), +/* 917 */ +/***/ (function(module, exports) { + +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } +} + + +/***/ }), +/* 918 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const fs = __webpack_require__(22); const makeDir = __webpack_require__(559); -const pify = __webpack_require__(910); -const CpFileError = __webpack_require__(907); +const pify = __webpack_require__(919); +const CpFileError = __webpack_require__(914); const fsP = pify(fs); @@ -105916,7 +108322,7 @@ if (fs.copyFileSync) { /***/ }), -/* 910 */ +/* 919 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -105991,7 +108397,7 @@ module.exports = (input, options) => { /***/ }), -/* 911 */ +/* 920 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -106032,12 +108438,12 @@ module.exports = ProgressEmitter; /***/ }), -/* 912 */ +/* 921 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const NestedError = __webpack_require__(913); +const NestedError = __webpack_require__(922); class CpyError extends NestedError { constructor(message, nested) { @@ -106051,7 +108457,7 @@ module.exports = CpyError; /***/ }), -/* 913 */ +/* 922 */ /***/ (function(module, exports, __webpack_require__) { var inherits = __webpack_require__(29).inherits; @@ -106107,7 +108513,7 @@ module.exports = NestedError; /***/ }), -/* 914 */ +/* 923 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; diff --git a/yarn.lock b/yarn.lock index caa5587a0bbd03..a36c3e15016955 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5860,12 +5860,12 @@ aggregate-error@^1.0.0: indent-string "^3.0.0" aggregate-error@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/aggregate-error/-/aggregate-error-3.0.0.tgz#5b5a3c95e9095f311c9ab16c19fb4f3527cd3f79" - integrity sha512-yKD9kEoJIR+2IFqhMwayIBgheLYbB3PS2OBhWae1L/ODTd/JF/30cW0bc9TqzRL3k4U41Dieu3BF4I29p8xesA== + version "3.0.1" + resolved "https://registry.yarnpkg.com/aggregate-error/-/aggregate-error-3.0.1.tgz#db2fe7246e536f40d9b5442a39e117d7dd6a24e0" + integrity sha512-quoaXsZ9/BLNae5yiNoUz+Nhkwz83GhWwtYFglcjEQB2NDHCIpApbqXxIFnm4Pq/Nvhrsq5sYJFyohrrxnTGAA== dependencies: clean-stack "^2.0.0" - indent-string "^3.2.0" + indent-string "^4.0.0" "airbnb-js-shims@^1 || ^2": version "2.1.1" @@ -5952,7 +5952,7 @@ ajv@^6.1.0, ajv@^6.5.5: json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ajv@^6.10.0, ajv@^6.10.2: +ajv@^6.10.0: version "6.10.2" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.10.2.tgz#d3cea04d6b017b2894ad69040fec8b623eb4bd52" integrity sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw== @@ -5962,6 +5962,16 @@ ajv@^6.10.0, ajv@^6.10.2: json-schema-traverse "^0.4.1" uri-js "^4.2.2" +ajv@^6.10.2: + version "6.11.0" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.11.0.tgz#c3607cbc8ae392d8a5a536f25b21f8e5f3f87fe9" + integrity sha512-nCprB/0syFYy9fVYU1ox1l2KN8S9I+tziH8D4zdZuLT3N6RMlGSGt5FSTpAiHB/Whv8Qs1cWHma1aMKZyaHRKA== + dependencies: + fast-deep-equal "^3.1.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" + ajv@^6.9.1: version "6.9.2" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.9.2.tgz#4927adb83e7f48e5a32b45729744c71ec39c9c7b" @@ -8341,7 +8351,7 @@ cacache@^12.0.2: unique-filename "^1.1.1" y18n "^4.0.0" -cacache@^13.0.0: +cacache@^13.0.1: version "13.0.1" resolved "https://registry.yarnpkg.com/cacache/-/cacache-13.0.1.tgz#a8000c21697089082f85287a1aec6e382024a71c" integrity sha512-5ZvAxd05HDDU+y9BVvcqYu2LLXmPnQ0hW62h32g4xBTgL/MppR4/04NHfj/ycM2y6lmTnbw6HVi+1eN0Psba6w== @@ -9021,9 +9031,9 @@ clean-stack@^1.0.0, clean-stack@^1.3.0: integrity sha1-noIVAa6XmYbEax1m0tQy2y/UrjE= clean-stack@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.1.0.tgz#9e7fec7f3f8340a2ab4f127c80273085e8fbbdd0" - integrity sha512-uQWrpRm+iZZUCAp7ZZJQbd4Za9I3AjR/3YTjmcnAtkauaIm/T5CT6U8zVI6e60T6OANqBFAzuR9/HB3NzuZCRA== + version "2.2.0" + resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b" + integrity sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A== cli-boxes@^1.0.0: version "1.0.0" @@ -9461,12 +9471,12 @@ commander@3.0.2: resolved "https://registry.yarnpkg.com/commander/-/commander-3.0.2.tgz#6837c3fb677ad9933d1cfba42dd14d5117d6b39e" integrity sha512-Gar0ASD4BDyKC4hl4DwHqDrmvjoxWKZigVnAbn5H1owvm4CxCPdb0HQDehwNYMJpla5+M2tPmPARzhtYuwpHow== -commander@^2.13.0, commander@^2.15.1, commander@^2.16.0, commander@^2.19.0, commander@^2.20.0: +commander@^2.13.0, commander@^2.15.1, commander@^2.16.0, commander@^2.19.0: version "2.20.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.0.tgz#d58bb2b5c1ee8f87b0d340027e9e94e222c5a422" integrity sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ== -commander@^2.7.1: +commander@^2.20.0, commander@^2.7.1: version "2.20.3" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== @@ -13363,9 +13373,9 @@ fast-glob@^3.0.3: micromatch "^4.0.2" fast-json-stable-stringify@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" - integrity sha1-1RQsDK7msRifh9OnYREGT4bIu/I= + version "2.1.0" + resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" + integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== fast-levenshtein@^2.0.6, fast-levenshtein@~2.0.4, fast-levenshtein@~2.0.6: version "2.0.6" @@ -13724,10 +13734,10 @@ find-cache-dir@^2.1.0: make-dir "^2.0.0" pkg-dir "^3.0.0" -find-cache-dir@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-3.0.0.tgz#cd4b7dd97b7185b7e17dbfe2d6e4115ee3eeb8fc" - integrity sha512-t7ulV1fmbxh5G9l/492O1p5+EBbr3uwpt6odhFTMc+nWyhmbloe+ja9BZ8pIBtqFWhOmCWVjx+pTW4zDkFoclw== +find-cache-dir@^3.0.0, find-cache-dir@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-3.2.0.tgz#e7fe44c1abc1299f516146e563108fd1006c1874" + integrity sha512-1JKclkYYsf1q9WIJKLZa9S9muC+08RIjzAlLrK4QcYLJMS6mk9yombQ9qf+zJ7H9LS800k0s44L4sDq9VYzqyg== dependencies: commondir "^1.0.1" make-dir "^3.0.0" @@ -14204,9 +14214,9 @@ fs-minipass@^1.2.5: minipass "^2.2.1" fs-minipass@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-2.0.0.tgz#a6415edab02fae4b9e9230bc87ee2e4472003cd1" - integrity sha512-40Qz+LFXmd9tzYVnnBmZvFfvAADfUA14TXPK1s7IfElJTIZ97rA8w4Kin7Wt5JBrC3ShnnFJO/5vPjPEeJIq9A== + version "2.1.0" + resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-2.1.0.tgz#7f5036fdbf12c63c169190cbe4199c852271f9fb" + integrity sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg== dependencies: minipass "^3.0.0" @@ -14675,7 +14685,7 @@ glob-watcher@5.0.3, glob-watcher@^5.0.3: just-debounce "^1.0.0" object.defaults "^1.1.0" -glob@7.1.3, glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@~7.1.1: +glob@7.1.3, glob@^7.0.0, glob@^7.0.3, glob@^7.1.1, glob@^7.1.2, glob@~7.1.1: version "7.1.3" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1" integrity sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ== @@ -14687,7 +14697,7 @@ glob@7.1.3, glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2, glo once "^1.3.0" path-is-absolute "^1.0.0" -glob@7.1.4, glob@^7.1.4, glob@~7.1.4: +glob@7.1.4, glob@~7.1.4: version "7.1.4" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.4.tgz#aa608a2f6c577ad357e1ae5a5c26d9a8d1969255" integrity sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A== @@ -14721,7 +14731,7 @@ glob@^6.0.1, glob@^6.0.4: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^7.1.6: +glob@^7.0.5, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6: version "7.1.6" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== @@ -15090,12 +15100,12 @@ graceful-fs@^4.1.15, graceful-fs@^4.1.9: resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00" integrity sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA== -graceful-fs@^4.1.2, graceful-fs@^4.1.6: +graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.2: version "4.2.3" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423" integrity sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ== -graceful-fs@^4.2.0, graceful-fs@^4.2.2: +graceful-fs@^4.2.0: version "4.2.2" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.2.tgz#6f0952605d0140c1cfdb138ed005775b92d67b02" integrity sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q== @@ -16551,16 +16561,21 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@2.0.3, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.0, inherits@~2.0.1, inherits@~2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" - integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= +inherits@2, inherits@~2.0.3: + version "2.0.4" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== inherits@2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1" integrity sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE= +inherits@2.0.3, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.0, inherits@~2.0.1: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= + ini@^1.2.0, ini@^1.3.4, ini@^1.3.5, ini@~1.3.0: version "1.3.5" resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" @@ -18203,6 +18218,14 @@ jest-worker@^24.9.0: merge-stream "^2.0.0" supports-color "^6.1.0" +jest-worker@^25.1.0: + version "25.1.0" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-25.1.0.tgz#75d038bad6fdf58eba0d2ec1835856c497e3907a" + integrity sha512-ZHhHtlxOWSxCoNOKHGbiLzXnl42ga9CxDr27H36Qn+15pQZd3R/F24jrmjDelw9j/iHUIWMWs08/u2QN50HHOg== + dependencies: + merge-stream "^2.0.0" + supports-color "^7.0.0" + jest@^24.9.0: version "24.9.0" resolved "https://registry.yarnpkg.com/jest/-/jest-24.9.0.tgz#987d290c05a08b52c56188c1002e368edb007171" @@ -20602,10 +20625,10 @@ minipass@^2.8.6: safe-buffer "^5.1.2" yallist "^3.0.0" -minipass@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/minipass/-/minipass-3.0.1.tgz#b4fec73bd61e8a40f0b374ddd04260ade2c8ec20" - integrity sha512-2y5okJ4uBsjoD2vAbLKL9EUQPPkC0YMIp+2mZOXG3nBba++pdfJWRxx2Ewirc0pwAJYu4XtWg2EkVo1nRXuO/w== +minipass@^3.0.0, minipass@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-3.1.1.tgz#7607ce778472a185ad6d89082aa2070f79cedcd5" + integrity sha512-UFqVihv6PQgwj8/yTGvl9kPz7xIAY+R5z6XYjRInD3Gk3qx6QGSD6zEcpeG4Dy/lQnv1J6zv8ejV90hyYIKf3w== dependencies: yallist "^4.0.0" @@ -22215,10 +22238,10 @@ p-limit@^2.0.0: dependencies: p-try "^2.0.0" -p-limit@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.2.0.tgz#417c9941e6027a9abcba5092dd2904e255b5fbc2" - integrity sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ== +p-limit@^2.2.0, p-limit@^2.2.2: + version "2.2.2" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.2.2.tgz#61279b67721f5287aa1c13a9a7fbbc48c9291b1e" + integrity sha512-WGR+xHecKTr7EbUEhyLSh5Dube9JtdiG78ufaeLxTgpudf/20KqyMioIUZJAezlTIi6evxuoUs9YXc11cU+yzQ== dependencies: p-try "^2.0.0" @@ -22299,9 +22322,9 @@ p-try@^1.0.0: integrity sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M= p-try@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.0.0.tgz#85080bb87c64688fa47996fe8f7dfbe8211760b1" - integrity sha512-hMp0onDKIajHfIkdRk3P4CdCmErkYAxxDtP3Wx/4nZ3aGlau2VKh3mZpcuFkH27WQkL/3WBCPOktzA9ZOAnMQQ== + version "2.2.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" + integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== package-hash@^3.0.0: version "3.0.0" @@ -23292,7 +23315,7 @@ private@^0.1.6, private@^0.1.8, private@~0.1.5: resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" integrity sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg== -process-nextick-args@^2.0.0, process-nextick-args@~2.0.0: +process-nextick-args@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa" integrity sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw== @@ -23302,6 +23325,11 @@ process-nextick-args@~1.0.6: resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" integrity sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M= +process-nextick-args@~2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" + integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== + process@^0.11.10: version "0.11.10" resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" @@ -24931,10 +24959,10 @@ read-pkg@^5.1.1, read-pkg@^5.2.0: parse-json "^5.0.0" type-fest "^0.6.0" -"readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.4, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.0, readable-stream@^2.3.3, readable-stream@^2.3.5, readable-stream@^2.3.6, readable-stream@~2.3.3, readable-stream@~2.3.6: - version "2.3.6" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf" - integrity sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw== +"readable-stream@1 || 2": + version "2.3.7" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" + integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== dependencies: core-util-is "~1.0.0" inherits "~2.0.3" @@ -24963,6 +24991,19 @@ readable-stream@1.0: string_decoder "^1.1.1" util-deprecate "^1.0.1" +readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.4, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.0, readable-stream@^2.3.3, readable-stream@^2.3.5, readable-stream@^2.3.6, readable-stream@~2.3.3, readable-stream@~2.3.6: + version "2.3.6" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf" + integrity sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw== + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~2.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.1.1" + util-deprecate "~1.0.1" + readable-stream@~1.1.0: version "1.1.14" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" @@ -25993,7 +26034,7 @@ right-align@^0.1.1: dependencies: align-text "^0.1.1" -rimraf@2, rimraf@^2.2.0, rimraf@^2.2.8, rimraf@^2.5.1, rimraf@^2.5.4, rimraf@^2.6.0, rimraf@^2.6.1, rimraf@^2.6.2: +rimraf@2, rimraf@^2.2.0, rimraf@^2.2.8, rimraf@^2.5.1, rimraf@^2.6.0, rimraf@^2.6.1, rimraf@^2.6.2: version "2.6.2" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" integrity sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w== @@ -26014,7 +26055,7 @@ rimraf@3.0.0, rimraf@^3.0.0: dependencies: glob "^7.1.3" -rimraf@^2.7.1: +rimraf@^2.5.4, rimraf@^2.7.1: version "2.7.1" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== @@ -26397,10 +26438,10 @@ schema-utils@^2.0.0, schema-utils@^2.0.1: ajv "^6.1.0" ajv-keywords "^3.1.0" -schema-utils@^2.4.1: - version "2.4.1" - resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.4.1.tgz#e89ade5d056dc8bcaca377574bb4a9c4e1b8be56" - integrity sha512-RqYLpkPZX5Oc3fw/kHHHyP56fg5Y+XBpIpV8nCg0znIALfq3OH+Ea9Hfeac9BAMwG5IICltiZ0vxFvJQONfA5w== +schema-utils@^2.4.1, schema-utils@^2.6.4: + version "2.6.4" + resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.6.4.tgz#a27efbf6e4e78689d91872ee3ccfa57d7bdd0f53" + integrity sha512-VNjcaUxVnEeun6B2fiiUDjXXBtD4ZSH7pdbfIu1pOFwgptDPLMo/z9jr4sUfsjFVPqDCEin/F7IYlq7/E6yDbQ== dependencies: ajv "^6.10.2" ajv-keywords "^3.4.1" @@ -26532,21 +26573,16 @@ semver@^5.5.1: resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.1.tgz#7dfdd8814bdb7cabc7be0fb1d734cfb66c940477" integrity sha512-PqpAxfrEhlSUWge8dwIp4tZnQ25DIOthpiaHNIthsjEFQD6EvqUKUDM7L8O2rShkFccYo1VjJR0coWfNkCubRw== -semver@^6.0.0: - version "6.1.2" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.1.2.tgz#079960381376a3db62eb2edc8a3bfb10c7cfe318" - integrity sha512-z4PqiCpomGtWj8633oeAdXm1Kn1W++3T8epkZYnwiVgIYIJ0QHszhInYSJTYxebByQH7KVCEAn8R9duzZW2PhQ== +semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" + integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== semver@^6.1.0: version "6.1.1" resolved "https://registry.yarnpkg.com/semver/-/semver-6.1.1.tgz#53f53da9b30b2103cd4f15eab3a18ecbcb210c9b" integrity sha512-rWYq2e5iYW+fFe/oPPtYJxYgjBm8sC4rmoGdUOgBB7VnwKt6HrL793l2voH1UlsyYZpJ4g0wfjnTEO1s1NP2eQ== -semver@^6.1.1, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0: - version "6.3.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" - integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== - semver@~5.3.0: version "5.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" @@ -26598,7 +26634,7 @@ sentence-case@^2.1.0: no-case "^2.2.0" upper-case-first "^1.1.2" -serialize-javascript@^1.7.0, serialize-javascript@^2.1.0, serialize-javascript@^2.1.1, serialize-javascript@^2.1.2: +serialize-javascript@^1.7.0, serialize-javascript@^2.1.1, serialize-javascript@^2.1.2: version "2.1.1" resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-2.1.1.tgz#952907a04a3e3a75af7f73d92d15e233862048b2" integrity sha512-MPLPRpD4FNqWq9tTIjYG5LesFouDhdyH0EPY3gVK4DRD5+g4aDqdNSzLIwceulo3Yj+PL1bPh6laE5+H6LTcrQ== @@ -27123,9 +27159,9 @@ sort-on@^3.0.0: dot-prop "^4.1.1" source-list-map@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.0.tgz#aaa47403f7b245a92fbc97ea08f250d6087ed085" - integrity sha512-I2UmuJSRr/T8jisiROLU3A3ltr+swpniSmNPI4Ml3ZCX6tVnDsuZzK7F2hl5jTqbZBWCEKlj5HRQiPExXLgE8A== + version "2.0.1" + resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34" + integrity sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw== source-map-resolve@^0.5.0, source-map-resolve@^0.5.2: version "0.5.2" @@ -27395,12 +27431,12 @@ ssri@^6.0.1: figgy-pudding "^3.5.1" ssri@^7.0.0: - version "7.0.1" - resolved "https://registry.yarnpkg.com/ssri/-/ssri-7.0.1.tgz#b0cab7bbb11ac9ea07f003453e2011f8cbed9f34" - integrity sha512-FfndBvkXL9AHyGLNzU3r9AvYIBBZ7gm+m+kd0p8cT3/v4OliMAyipZAhLVEv1Zi/k4QFq9CstRGVd9pW/zcHFQ== + version "7.1.0" + resolved "https://registry.yarnpkg.com/ssri/-/ssri-7.1.0.tgz#92c241bf6de82365b5c7fb4bd76e975522e1294d" + integrity sha512-77/WrDZUWocK0mvA5NTRQyveUf+wsrIc6vyrxpS8tVvYBcX215QbafrJR3KtkpskIzoFLqqNuuYQvxaMjXJ/0g== dependencies: figgy-pudding "^3.5.1" - minipass "^3.0.0" + minipass "^3.1.1" stable@^0.1.8: version "0.1.8" @@ -28491,21 +28527,22 @@ terser-webpack-plugin@^1.2.4, terser-webpack-plugin@^1.4.1: webpack-sources "^1.4.0" worker-farm "^1.7.0" -terser-webpack-plugin@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-2.1.2.tgz#2b9b8147a6f18918348200800cf9560c50f701bb" - integrity sha512-MF/C4KABwqYOfRDi87f7gG07GP7Wj/kyiX938UxIGIO6l5mkh8XJL7xtS0hX/CRdVQaZI7ThGUPZbznrCjsGpg== - dependencies: - cacache "^13.0.0" - find-cache-dir "^3.0.0" - jest-worker "^24.9.0" - schema-utils "^2.4.1" - serialize-javascript "^2.1.0" +terser-webpack-plugin@^2.3.4: + version "2.3.4" + resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-2.3.4.tgz#ac045703bd8da0936ce910d8fb6350d0e1dee5fe" + integrity sha512-Nv96Nws2R2nrFOpbzF6IxRDpIkkIfmhvOws+IqMvYdFLO7o6wAILWFKONFgaYy8+T4LVz77DQW0f7wOeDEAjrg== + dependencies: + cacache "^13.0.1" + find-cache-dir "^3.2.0" + jest-worker "^25.1.0" + p-limit "^2.2.2" + schema-utils "^2.6.4" + serialize-javascript "^2.1.2" source-map "^0.6.1" - terser "^4.3.4" + terser "^4.4.3" webpack-sources "^1.4.3" -terser@^4.1.2, terser@^4.3.4: +terser@^4.1.2: version "4.6.1" resolved "https://registry.yarnpkg.com/terser/-/terser-4.6.1.tgz#913e35e0d38a75285a7913ba01d753c4089ebdbd" integrity sha512-w0f2OWFD7ka3zwetgVAhNMeyzEbj39ht2Tb0qKflw9PmW9Qbo5tjTh01QJLkhO9t9RDDQYvk+WXqpECI2C6i2A== @@ -28514,6 +28551,15 @@ terser@^4.1.2, terser@^4.3.4: source-map "~0.6.1" source-map-support "~0.5.12" +terser@^4.4.3: + version "4.6.3" + resolved "https://registry.yarnpkg.com/terser/-/terser-4.6.3.tgz#e33aa42461ced5238d352d2df2a67f21921f8d87" + integrity sha512-Lw+ieAXmY69d09IIc/yqeBqXpEQIpDGZqT34ui1QWXIUpR2RjbqEkT8X7Lgex19hslSqcWM5iMN2kM11eMsESQ== + dependencies: + commander "^2.20.0" + source-map "~0.6.1" + source-map-support "~0.5.12" + test-exclude@^5.0.0, test-exclude@^5.2.3: version "5.2.3" resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-5.2.3.tgz#c3d3e1e311eb7ee405e092dac10aefd09091eac0" @@ -29906,9 +29952,9 @@ unique-filename@^1.1.1: unique-slug "^2.0.0" unique-slug@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/unique-slug/-/unique-slug-2.0.1.tgz#5e9edc6d1ce8fb264db18a507ef9bd8544451ca6" - integrity sha512-n9cU6+gITaVu7VGj1Z8feKMmfAjEAQGhwD9fE3zvpRRa0wEIx8ODYkVGfSc94M2OX00tUFV8wH3zYbm1I8mxFg== + version "2.0.2" + resolved "https://registry.yarnpkg.com/unique-slug/-/unique-slug-2.0.2.tgz#baabce91083fc64e945b0f3ad613e264f7cd4e6c" + integrity sha512-zoWr9ObaxALD3DOPfjPSqxt4fnZiWblxHIgeWqW8x7UqDzEtHEQLzji2cuJYQFCU6KmoJikOYAZlrTHHebjx2w== dependencies: imurmurhash "^0.1.4" @@ -31825,11 +31871,16 @@ yallist@^2.1.2: resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI= -yallist@^3.0.0, yallist@^3.0.2: +yallist@^3.0.0: version "3.0.2" resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.2.tgz#8452b4bb7e83c7c188d8041c1a837c773d6d8bb9" integrity sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k= +yallist@^3.0.2: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" + integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== + yallist@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.3.tgz#b4b049e314be545e3ce802236d6cd22cd91c3de9" From e74ab191fecf2d7ce64a1229c7a37c7ec1166069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20C=C3=B4t=C3=A9?= Date: Tue, 4 Feb 2020 14:54:27 -0500 Subject: [PATCH 09/22] Disable creating alerts client instances when ESO plugin is using an ephemeral encryption key (#56676) --- .../legacy/plugins/alerting/server/index.ts | 5 +- .../plugins/alerting/server/plugin.test.ts | 113 ++++++++++++++++++ .../legacy/plugins/alerting/server/plugin.ts | 18 ++- .../lib/detection_engine/rules/types.ts | 2 +- 4 files changed, 131 insertions(+), 7 deletions(-) create mode 100644 x-pack/legacy/plugins/alerting/server/plugin.test.ts diff --git a/x-pack/legacy/plugins/alerting/server/index.ts b/x-pack/legacy/plugins/alerting/server/index.ts index 2f8356c0e9d014..44ae1964ec98a3 100644 --- a/x-pack/legacy/plugins/alerting/server/index.ts +++ b/x-pack/legacy/plugins/alerting/server/index.ts @@ -4,7 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ +import { AlertsClient as AlertsClientClass } from './alerts_client'; + +export type AlertsClient = PublicMethodsOf; + export { init } from './init'; export { AlertType, AlertingPlugin, AlertExecutorOptions } from './types'; -export { AlertsClient } from './alerts_client'; export { PluginSetupContract, PluginStartContract } from './plugin'; diff --git a/x-pack/legacy/plugins/alerting/server/plugin.test.ts b/x-pack/legacy/plugins/alerting/server/plugin.test.ts new file mode 100644 index 00000000000000..50142434a86ddf --- /dev/null +++ b/x-pack/legacy/plugins/alerting/server/plugin.test.ts @@ -0,0 +1,113 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { Plugin } from './plugin'; +import { coreMock } from '../../../../../src/core/server/mocks'; +import { licensingMock } from '../../../../plugins/licensing/server/mocks'; +import { encryptedSavedObjectsMock } from '../../../../plugins/encrypted_saved_objects/server/mocks'; + +describe('Alerting Plugin', () => { + describe('start()', () => { + /** + * HACK: This test has put together to ensuire the function "getAlertsClientWithRequest" + * throws when needed. There's a lot of blockers for writing a proper test like + * misisng plugin start/setup mocks for taskManager and actions plugin, core.http.route + * is actually not a function in Kibana Platform, etc. This test contains what is needed + * to get to the necessary function within start(). + */ + describe('getAlertsClientWithRequest()', () => { + it('throws error when encryptedSavedObjects plugin has usingEphemeralEncryptionKey set to true', async () => { + const context = coreMock.createPluginInitializerContext(); + const plugin = new Plugin(context); + + const coreSetup = coreMock.createSetup(); + const encryptedSavedObjectsSetup = encryptedSavedObjectsMock.createSetup(); + await plugin.setup( + { + ...coreSetup, + http: { + ...coreSetup.http, + route: jest.fn(), + }, + } as any, + { + licensing: licensingMock.createSetup(), + encryptedSavedObjects: encryptedSavedObjectsSetup, + } as any + ); + + const startContract = plugin.start( + coreMock.createStart() as any, + { + actions: { + execute: jest.fn(), + getActionsClientWithRequest: jest.fn(), + }, + } as any + ); + + expect(encryptedSavedObjectsSetup.usingEphemeralEncryptionKey).toEqual(true); + expect(() => + startContract.getAlertsClientWithRequest({} as any) + ).toThrowErrorMatchingInlineSnapshot( + `"Unable to create alerts client due to the Encrypted Saved Objects plugin using an ephemeral encryption key. Please set xpack.encryptedSavedObjects.encryptionKey in kibana.yml"` + ); + }); + + it(`doesn't throw error when encryptedSavedObjects plugin has usingEphemeralEncryptionKey set to false`, async () => { + const context = coreMock.createPluginInitializerContext(); + const plugin = new Plugin(context); + + const coreSetup = coreMock.createSetup(); + const encryptedSavedObjectsSetup = { + ...encryptedSavedObjectsMock.createSetup(), + usingEphemeralEncryptionKey: false, + }; + await plugin.setup( + { + ...coreSetup, + http: { + ...coreSetup.http, + route: jest.fn(), + }, + } as any, + { + licensing: licensingMock.createSetup(), + encryptedSavedObjects: encryptedSavedObjectsSetup, + } as any + ); + + const startContract = plugin.start( + coreMock.createStart() as any, + { + actions: { + execute: jest.fn(), + getActionsClientWithRequest: jest.fn(), + }, + spaces: () => null, + } as any + ); + + const fakeRequest = { + headers: {}, + getBasePath: () => '', + path: '/', + route: { settings: {} }, + url: { + href: '/', + }, + raw: { + req: { + url: '/', + }, + }, + getSavedObjectsClient: jest.fn(), + }; + await startContract.getAlertsClientWithRequest(fakeRequest as any); + }); + }); + }); +}); diff --git a/x-pack/legacy/plugins/alerting/server/plugin.ts b/x-pack/legacy/plugins/alerting/server/plugin.ts index 3218d9eeb2ef46..a4de7af376fb04 100644 --- a/x-pack/legacy/plugins/alerting/server/plugin.ts +++ b/x-pack/legacy/plugins/alerting/server/plugin.ts @@ -42,7 +42,7 @@ export interface PluginSetupContract { } export interface PluginStartContract { listTypes: AlertTypeRegistry['list']; - getAlertsClientWithRequest(request: Hapi.Request): AlertsClient; + getAlertsClientWithRequest(request: Hapi.Request): PublicMethodsOf; } export class Plugin { @@ -52,6 +52,7 @@ export class Plugin { private adminClient?: IClusterClient; private serverBasePath?: string; private licenseState: LicenseState | null = null; + private isESOUsingEphemeralEncryptionKey?: boolean; constructor(initializerContext: AlertingPluginInitializerContext) { this.logger = initializerContext.logger.get('plugins', 'alerting'); @@ -63,8 +64,9 @@ export class Plugin { plugins: AlertingPluginsSetup ): Promise { this.adminClient = core.elasticsearch.adminClient; - this.licenseState = new LicenseState(plugins.licensing.license$); + this.isESOUsingEphemeralEncryptionKey = + plugins.encryptedSavedObjects.usingEphemeralEncryptionKey; // Encrypted attributes plugins.encryptedSavedObjects.registerType({ @@ -106,7 +108,7 @@ export class Plugin { } public start(core: AlertingCoreStart, plugins: AlertingPluginsStart): PluginStartContract { - const { adminClient, serverBasePath } = this; + const { adminClient, serverBasePath, isESOUsingEphemeralEncryptionKey } = this; function spaceIdToNamespace(spaceId?: string): string | undefined { const spacesPlugin = plugins.spaces(); @@ -147,8 +149,14 @@ export class Plugin { return { listTypes: this.alertTypeRegistry!.list.bind(this.alertTypeRegistry!), - getAlertsClientWithRequest: (request: Hapi.Request) => - alertsClientFactory!.create(KibanaRequest.from(request), request), + getAlertsClientWithRequest: (request: Hapi.Request) => { + if (isESOUsingEphemeralEncryptionKey === true) { + throw new Error( + `Unable to create alerts client due to the Encrypted Saved Objects plugin using an ephemeral encryption key. Please set xpack.encryptedSavedObjects.encryptionKey in kibana.yml` + ); + } + return alertsClientFactory!.create(KibanaRequest.from(request), request); + }, }; } diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/types.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/types.ts index 1b13a010bbea39..1d423c8b375d11 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/types.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/types.ts @@ -14,7 +14,7 @@ import { SavedObjectsClientContract, } from 'kibana/server'; import { SIGNALS_ID } from '../../../../common/constants'; -import { AlertsClient } from '../../../../../alerting/server/alerts_client'; +import { AlertsClient } from '../../../../../alerting/server'; import { ActionsClient } from '../../../../../../../plugins/actions/server'; import { RuleAlertParams, RuleTypeParams, RuleAlertParamsRest } from '../types'; import { RequestFacade } from '../../../types'; From 954cbee48654b79b528517a1df471dfbabdd9476 Mon Sep 17 00:00:00 2001 From: Ryland Herrick Date: Tue, 4 Feb 2020 14:24:57 -0600 Subject: [PATCH 10/22] Prevent http client from converting our form data (#56772) If we don't specify an undefined content-type like so, the client attempts to convert our form data into a JSON string, and the backend returns an understandable 415. This fixes rule imports. --- .../plugins/siem/public/containers/detection_engine/rules/api.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/api.ts b/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/api.ts index 4f50a9bd147881..06fb0c6dc34800 100644 --- a/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/api.ts +++ b/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/api.ts @@ -246,6 +246,7 @@ export const importRules = async ({ `${DETECTION_ENGINE_RULES_URL}/_import`, { method: 'POST', + headers: { 'Content-Type': undefined }, query: { overwrite }, body: formData, asResponse: true, From f18d5913590bb3b8949d534436d4c0824f387266 Mon Sep 17 00:00:00 2001 From: Alison Goryachev Date: Tue, 4 Feb 2020 15:37:39 -0500 Subject: [PATCH 11/22] [Rollups] Adjust max width for job detail panel (#56674) --- .../crud_app/sections/job_list/detail_panel/detail_panel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.js b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.js index 4534ef698b7185..f774b1d7f63b72 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.js @@ -232,7 +232,7 @@ export class DetailPanel extends Component { onClose={closeDetailPanel} aria-labelledby="rollupJobDetailsFlyoutTitle" size="m" - maxWidth={400} + maxWidth={550} > Date: Tue, 4 Feb 2020 16:41:02 -0500 Subject: [PATCH 12/22] [Canvas] Use unique Id for Canvas Embeddables (#56783) * Use uniqueID for embeddable registry * Adds type to renderer --- .../renderers/embeddable/embeddable.tsx | 10 ++++++---- .../components/element_content/element_content.js | 10 +++++++++- .../public/components/element_wrapper/lib/handlers.js | 2 ++ .../shareable_runtime/components/rendered_element.tsx | 1 + x-pack/legacy/plugins/canvas/types/renderers.ts | 2 ++ 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable/embeddable.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable/embeddable.tsx index 8642ebd901bb4d..c8cc1fe389619b 100644 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable/embeddable.tsx +++ b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable/embeddable.tsx @@ -70,7 +70,9 @@ const embeddable = () => ({ { input, embeddableType }: EmbeddableExpression, handlers: RendererHandlers ) => { - if (!embeddablesRegistry[input.id]) { + const uniqueId = handlers.getElementId(); + + if (!embeddablesRegistry[uniqueId]) { const factory = Array.from(start.getEmbeddableFactories()).find( embeddableFactory => embeddableFactory.type === embeddableType ) as EmbeddableFactory; @@ -82,7 +84,7 @@ const embeddable = () => ({ const embeddableObject = await factory.createFromSavedObject(input.id, input); - embeddablesRegistry[input.id] = embeddableObject; + embeddablesRegistry[uniqueId] = embeddableObject; ReactDOM.unmountComponentAtNode(domNode); const subscription = embeddableObject.getInput$().subscribe(function(updatedInput) { @@ -100,12 +102,12 @@ const embeddable = () => ({ subscription.unsubscribe(); handlers.onEmbeddableDestroyed(); - delete embeddablesRegistry[input.id]; + delete embeddablesRegistry[uniqueId]; return ReactDOM.unmountComponentAtNode(domNode); }); } else { - embeddablesRegistry[input.id].updateInput(input); + embeddablesRegistry[uniqueId].updateInput(input); } }, }); diff --git a/x-pack/legacy/plugins/canvas/public/components/element_content/element_content.js b/x-pack/legacy/plugins/canvas/public/components/element_content/element_content.js index 1926fb4aaa5eb8..114a457d167e77 100644 --- a/x-pack/legacy/plugins/canvas/public/components/element_content/element_content.js +++ b/x-pack/legacy/plugins/canvas/public/components/element_content/element_content.js @@ -54,6 +54,7 @@ export const ElementContent = compose( onComplete, onEmbeddableInputChange, onEmbeddableDestroyed, + getElementId, } = handlers; return Style.it( @@ -76,7 +77,14 @@ export const ElementContent = compose( config={renderable.value} css={renderable.css} // This is an actual CSS stylesheet string, it will be scoped by RenderElement size={size} // Size is only passed for the purpose of triggering the resize event, it isn't really used otherwise - handlers={{ getFilter, setFilter, done, onEmbeddableInputChange, onEmbeddableDestroyed }} + handlers={{ + getFilter, + setFilter, + done, + onEmbeddableInputChange, + onEmbeddableDestroyed, + getElementId, + }} />
diff --git a/x-pack/legacy/plugins/canvas/public/components/element_wrapper/lib/handlers.js b/x-pack/legacy/plugins/canvas/public/components/element_wrapper/lib/handlers.js index e93cea597901f9..d71c5ead2c8021 100644 --- a/x-pack/legacy/plugins/canvas/public/components/element_wrapper/lib/handlers.js +++ b/x-pack/legacy/plugins/canvas/public/components/element_wrapper/lib/handlers.js @@ -36,6 +36,8 @@ export const createHandlers = dispatch => { completeFn = fn; }, + getElementId: () => element.id, + onEmbeddableInputChange(embeddableExpression) { dispatch(updateEmbeddableExpression({ elementId: element.id, embeddableExpression })); }, diff --git a/x-pack/legacy/plugins/canvas/shareable_runtime/components/rendered_element.tsx b/x-pack/legacy/plugins/canvas/shareable_runtime/components/rendered_element.tsx index 317a3417841b8b..c4a009db3a376c 100644 --- a/x-pack/legacy/plugins/canvas/shareable_runtime/components/rendered_element.tsx +++ b/x-pack/legacy/plugins/canvas/shareable_runtime/components/rendered_element.tsx @@ -67,6 +67,7 @@ export class RenderedElementComponent extends PureComponent { done: () => {}, onDestroy: () => {}, onResize: () => {}, + getElementId: () => '', setFilter: () => {}, getFilter: () => '', onEmbeddableInputChange: () => {}, diff --git a/x-pack/legacy/plugins/canvas/types/renderers.ts b/x-pack/legacy/plugins/canvas/types/renderers.ts index af1710e69c2578..2564b045d1cf75 100644 --- a/x-pack/legacy/plugins/canvas/types/renderers.ts +++ b/x-pack/legacy/plugins/canvas/types/renderers.ts @@ -9,6 +9,8 @@ type GenericCallback = (callback: () => void) => void; export interface RendererHandlers { /** Handler to invoke when an element has finished rendering */ done: () => void; + /** Get the id of the element being rendered. Can be used as a unique ID in a render function */ + getElementId: () => string; /** Handler to invoke when an element is deleted or changes to a different render type */ onDestroy: GenericCallback; /** Handler to invoke when an element's dimensions have changed*/ From 9af0157b4f6c6319022f1edf49c4e5a9452c0135 Mon Sep 17 00:00:00 2001 From: Tyler Smalley Date: Tue, 4 Feb 2020 14:00:15 -0800 Subject: [PATCH 13/22] [docs] Update upgrade version path (#56658) When upgrading to the next major version, users should first upgrade to the last minor in the previous release. In 6.x this is 6.8. Signed-off-by: Tyler Smalley --- docs/setup/upgrade.asciidoc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/setup/upgrade.asciidoc b/docs/setup/upgrade.asciidoc index 8c03032bb8ac36..982f1167f38716 100644 --- a/docs/setup/upgrade.asciidoc +++ b/docs/setup/upgrade.asciidoc @@ -50,7 +50,7 @@ instructions. [[upgrade-6x]] === Upgrading from 6.x -The recommended path is to upgrade to 6.7 before upgrading to 7.0. This makes it +The recommended path is to upgrade to 6.8 before upgrading to 7.0. This makes it easier to identify the required changes, and enables you to use the Upgrade Assistant to prepare for your upgrade to 7.0. @@ -59,11 +59,11 @@ dashboards is supported. [float] [[upgrade-67]] -=== Upgrading from 6.7 -To help you prepare for your upgrade to 7.0, 6.7 includes an https://www.elastic.co/guide/en/kibana/6.7/upgrade-assistant.html[Upgrade Assistant] -To access the assistant, go to *Management > 7.0 Upgrade Assistant*. +=== Upgrading from 6.8 +To help you prepare for your upgrade to 7.0, 6.8 includes an https://www.elastic.co/guide/en/kibana/6.8/upgrade-assistant.html[Upgrade Assistant] +To access the assistant, go to *Management > 7.0 Upgrade Assistant*. -After you have addressed any issues that were identified by the Upgrade +After you have addressed any issues that were identified by the Upgrade Assistant, <>. From 2fc1f791c978af5235995508d82a3e90cb40eb4a Mon Sep 17 00:00:00 2001 From: Andrew Goldstein Date: Tue, 4 Feb 2020 15:24:10 -0700 Subject: [PATCH 14/22] [SIEM] Fixes Signals count spinner (#56797) ## Fixes an issue where the Signals count spinner can spin forever Per the animated gif below, in `7.6` `BC 4`, the `Signals count` spinner on the Overview page spins forever until the signals index is created (in the current Kibana space): ![signals-count-loading-spinner](https://user-images.githubusercontent.com/4459398/73785251-2ca42000-4754-11ea-8671-daa81f351c9b.gif) The `Signals count` spinner will spin forever until the user clicks the `Detections` tab, which-in turn creates the signals index (if it doesn't exist), per the animated gif below: ![create-signals-index](https://user-images.githubusercontent.com/4459398/73785319-4ba2b200-4754-11ea-9bb0-a745a8b2be5d.gif) This behavior is an issue because: - When a fresh deployment is created on Elastic Cloud, a user won't understand why the `Signals count` widget is always spinning on the `Overview` page. (The user must click the `Detections` page to resolve this.) - In deployments where authentication is disabled, or, for _reasons_, a Detections index will never be created, the `Signals count` spinner on the Overview page will always spin. To reproduce: 1. Spin up a new `7.6` `BC 4` deployment on Elastic Cloud 2. Login to Kibana for the first time 3. Navigate to the SIEM app **Expected result** - All histograms on the Overview page eventually stop displaying their respective loading spinners **Actual result** - The `Signals count` widget spinner spins forever. (The user must click the `Detections` tab to create the signals index.) ## Deleting the signals index To reproduce the issue above when a signals index has already been created (by clicking on the Detections tab), run the following from the Kibana `Dev Tools` `Console`: ``` DELETE /.siem-signals-default-000001 ``` It is also possible to reproduce this issue by creating a new space, because it won't have a signals index. https://github.com/elastic/siem-team/issues/514 --- .../signals_histogram_panel/helpers.test.tsx | 35 +++++++++++++++++++ .../signals_histogram_panel/helpers.tsx | 14 ++++++++ .../signals_histogram_panel/index.tsx | 16 +++++---- .../detection_engine/detection_engine.tsx | 1 - 4 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/helpers.test.tsx diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/helpers.test.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/helpers.test.tsx new file mode 100644 index 00000000000000..2758625c0d4af1 --- /dev/null +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/helpers.test.tsx @@ -0,0 +1,35 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { showInitialLoadingSpinner } from './helpers'; + +describe('helpers', () => { + describe('showInitialLoadingSpinner', () => { + test('it should (only) show the spinner during initial loading, while we are fetching data', () => { + expect(showInitialLoadingSpinner({ isInitialLoading: true, isLoadingSignals: true })).toBe( + true + ); + }); + + test('it should STOP showing the spinner (during initial loading) when the first data fetch completes', () => { + expect(showInitialLoadingSpinner({ isInitialLoading: true, isLoadingSignals: false })).toBe( + false + ); + }); + + test('it should NOT show the spinner after initial loading has completed, even if the user requests more data (e.g. by clicking Refresh)', () => { + expect(showInitialLoadingSpinner({ isInitialLoading: false, isLoadingSignals: true })).toBe( + false + ); + }); + + test('it should NOT show the spinner after initial loading has completed', () => { + expect(showInitialLoadingSpinner({ isInitialLoading: false, isLoadingSignals: false })).toBe( + false + ); + }); + }); +}); diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/helpers.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/helpers.tsx index 551850fa610dbd..27ee5521460928 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/helpers.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/helpers.tsx @@ -76,3 +76,17 @@ export const getSignalsHistogramQuery = ( }, }, }); + +/** + * Returns `true` when the signals histogram initial loading spinner should be shown + * + * @param isInitialLoading The loading spinner will only be displayed if this value is `true`, because after initial load, a different, non-spinner loading indicator is displayed + * @param isLoadingSignals When `true`, IO is being performed to request signals (for rendering in the histogram) + */ +export const showInitialLoadingSpinner = ({ + isInitialLoading, + isLoadingSignals, +}: { + isInitialLoading: boolean; + isLoadingSignals: boolean; +}): boolean => isInitialLoading && isLoadingSignals; diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/index.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/index.tsx index 29aaa951ff71af..4de471d6733cf5 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/index.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/index.tsx @@ -23,7 +23,7 @@ import { InspectButtonContainer } from '../../../../components/inspect'; import { useQuerySignals } from '../../../../containers/detection_engine/signals/use_query'; import { MatrixLoader } from '../../../../components/matrix_histogram/matrix_loader'; -import { formatSignalsData, getSignalsHistogramQuery } from './helpers'; +import { formatSignalsData, getSignalsHistogramQuery, showInitialLoadingSpinner } from './helpers'; import * as i18n from './translations'; const DEFAULT_PANEL_HEIGHT = 300; @@ -54,7 +54,6 @@ interface SignalsHistogramPanelProps { from: number; query?: Query; legendPosition?: Position; - loadingInitial?: boolean; panelHeight?: number; signalIndexName: string | null; setQuery: (params: RegisterQuery) => void; @@ -75,7 +74,6 @@ export const SignalsHistogramPanel = memo( query, from, legendPosition = 'right', - loadingInitial = false, panelHeight = DEFAULT_PANEL_HEIGHT, setQuery, signalIndexName, @@ -86,7 +84,7 @@ export const SignalsHistogramPanel = memo( title = i18n.HISTOGRAM_HEADER, updateDateRange, }) => { - const [isInitialLoading, setIsInitialLoading] = useState(loadingInitial || true); + const [isInitialLoading, setIsInitialLoading] = useState(true); const [defaultNumberFormat] = useUiSetting$(DEFAULT_NUMBER_FORMAT); const [totalSignalsObj, setTotalSignalsObj] = useState(defaultTotalSignalsObj); const [selectedStackByOption, setSelectedStackByOption] = useState( @@ -124,10 +122,16 @@ export const SignalsHistogramPanel = memo( const formattedSignalsData = useMemo(() => formatSignalsData(signalsData), [signalsData]); useEffect(() => { - if (!loadingInitial && isInitialLoading && !isLoadingSignals && signalsData) { + let canceled = false; + + if (!canceled && !showInitialLoadingSpinner({ isInitialLoading, isLoadingSignals })) { setIsInitialLoading(false); } - }, [loadingInitial, isLoadingSignals, signalsData]); + + return () => { + canceled = true; // prevent long running data fetches from updating state after unmounting + }; + }, [isInitialLoading, isLoadingSignals, setIsInitialLoading]); useEffect(() => { return () => { diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/detection_engine.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/detection_engine.tsx index d854c377e6ec86..ff6722840fd6b2 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/detection_engine.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/detection_engine.tsx @@ -177,7 +177,6 @@ const DetectionEnginePageComponent: React.FC deleteQuery={deleteQuery} filters={filters} from={from} - loadingInitial={loading} query={query} setQuery={setQuery} showTotalSignalsCount={true} From 5f9386471b24913cd08e23573990ef82c73028fb Mon Sep 17 00:00:00 2001 From: Luke Elmers Date: Tue, 4 Feb 2020 17:35:49 -0700 Subject: [PATCH 15/22] Move ui/agg_types in to shim data plugin (#56353) --- .../actions/filters/brush_event.test.js | 2 +- src/legacy/core_plugins/data/public/index.ts | 50 ++++- src/legacy/core_plugins/data/public/plugin.ts | 28 ++- .../buckets/_terms_other_bucket_helper.js | 2 +- .../data/public/search/aggs}/agg_config.ts | 33 +-- .../data/public/search/aggs}/agg_configs.ts | 5 +- .../data/public/search/aggs}/agg_groups.ts | 4 +- .../public/search/aggs}/agg_params.test.ts | 2 +- .../data/public/search/aggs}/agg_params.ts | 4 +- .../data/public/search/aggs}/agg_type.test.ts | 12 +- .../data/public/search/aggs}/agg_type.ts | 21 +- .../data/public/search/aggs}/agg_types.ts | 26 ++- .../search/aggs}/buckets/_bucket_agg_type.ts | 2 +- .../search/aggs}/buckets/_interval_options.ts | 18 +- .../buckets/_terms_other_bucket_helper.js | 2 +- .../search/aggs}/buckets/bucket_agg_types.ts | 0 .../create_filter/date_histogram.test.ts | 2 +- .../buckets/create_filter/date_histogram.ts | 2 +- .../buckets/create_filter/date_range.test.ts | 2 +- .../aggs}/buckets/create_filter/date_range.ts | 2 +- .../buckets/create_filter/filters.test.ts | 0 .../aggs}/buckets/create_filter/filters.ts | 2 +- .../buckets/create_filter/histogram.test.ts | 2 +- .../aggs}/buckets/create_filter/histogram.ts | 2 +- .../buckets/create_filter/ip_range.test.ts | 2 +- .../aggs}/buckets/create_filter/ip_range.ts | 2 +- .../aggs}/buckets/create_filter/range.test.ts | 2 +- .../aggs}/buckets/create_filter/range.ts | 2 +- .../aggs}/buckets/create_filter/terms.test.ts | 2 +- .../aggs}/buckets/create_filter/terms.ts | 2 +- .../search/aggs}/buckets/date_histogram.ts | 14 +- .../search/aggs}/buckets/date_range.test.ts | 0 .../public/search/aggs}/buckets/date_range.ts | 4 +- .../public/search/aggs}/buckets/filter.ts | 2 +- .../public/search/aggs}/buckets/filters.ts | 6 +- .../search/aggs}/buckets/geo_hash.test.ts | 4 +- .../public/search/aggs}/buckets/geo_hash.ts | 6 +- .../public/search/aggs}/buckets/geo_tile.ts | 4 +- .../search/aggs}/buckets/histogram.test.ts | 0 .../public/search/aggs}/buckets/histogram.ts | 6 +- .../public/search/aggs}/buckets/ip_range.ts | 6 +- .../aggs}/buckets/lib/cidr_mask.test.ts | 0 .../search/aggs}/buckets/lib/cidr_mask.ts | 2 +- .../search/aggs}/buckets/lib/geo_utils.ts | 0 .../buckets/migrate_include_exclude_format.ts | 0 .../public/search/aggs}/buckets/range.test.ts | 2 +- .../data/public/search/aggs}/buckets/range.ts | 8 +- .../public/search/aggs}/buckets/range_key.ts | 0 .../aggs}/buckets/significant_terms.test.ts | 3 +- .../search/aggs}/buckets/significant_terms.ts | 10 +- .../public/search/aggs}/buckets/terms.test.ts | 0 .../data/public/search/aggs}/buckets/terms.ts | 39 ++-- .../aggs}/filter/agg_type_filters.test.ts | 11 +- .../search/aggs}/filter/agg_type_filters.ts | 8 +- .../data/public/search/aggs}/filter/index.ts | 0 .../search/aggs}/filter/prop_filter.test.ts | 0 .../public/search/aggs}/filter/prop_filter.ts | 0 .../data/public/search/aggs}/index.test.ts | 0 .../data/public/search/aggs/index.ts | 52 +++++ .../data/public/search/aggs}/metrics/avg.ts | 6 +- .../public/search/aggs}/metrics/bucket_avg.ts | 4 +- .../public/search/aggs}/metrics/bucket_max.ts | 4 +- .../public/search/aggs}/metrics/bucket_min.ts | 4 +- .../public/search/aggs}/metrics/bucket_sum.ts | 4 +- .../search/aggs}/metrics/cardinality.ts | 6 +- .../data/public/search/aggs}/metrics/count.ts | 6 +- .../search/aggs}/metrics/cumulative_sum.ts | 4 +- .../public/search/aggs}/metrics/derivative.ts | 4 +- .../public/search/aggs}/metrics/geo_bounds.ts | 6 +- .../search/aggs}/metrics/geo_centroid.ts | 6 +- .../lib/get_response_agg_config_class.ts | 0 .../metrics/lib/make_nested_label.test.ts | 0 .../aggs}/metrics/lib/make_nested_label.ts | 0 .../aggs}/metrics/lib/nested_agg_helpers.ts | 0 .../aggs}/metrics/lib/ordinal_suffix.test.ts | 0 .../aggs}/metrics/lib/ordinal_suffix.ts | 0 .../metrics/lib/parent_pipeline_agg_helper.ts | 4 +- .../metrics/lib/parent_pipeline_agg_writer.ts | 4 +- .../lib/sibling_pipeline_agg_helper.ts | 6 +- .../lib/sibling_pipeline_agg_writer.ts | 0 .../data/public/search/aggs}/metrics/max.ts | 6 +- .../search/aggs}/metrics/median.test.ts | 4 +- .../public/search/aggs}/metrics/median.ts | 6 +- .../search/aggs}/metrics/metric_agg_type.ts | 7 +- .../search/aggs}/metrics/metric_agg_types.ts | 0 .../data/public/search/aggs}/metrics/min.ts | 6 +- .../public/search/aggs}/metrics/moving_avg.ts | 4 +- .../aggs}/metrics/parent_pipeline.test.ts | 0 .../aggs}/metrics/percentile_ranks.test.ts | 4 +- .../search/aggs}/metrics/percentile_ranks.ts | 8 +- .../search/aggs}/metrics/percentiles.test.ts | 4 +- .../search/aggs}/metrics/percentiles.ts | 8 +- .../aggs}/metrics/percentiles_get_value.ts | 0 .../search/aggs}/metrics/serial_diff.ts | 4 +- .../aggs}/metrics/sibling_pipeline.test.ts | 0 .../aggs}/metrics/std_deviation.test.ts | 0 .../search/aggs}/metrics/std_deviation.ts | 12 +- .../data/public/search/aggs}/metrics/sum.ts | 6 +- .../search/aggs}/metrics/top_hit.test.ts | 2 +- .../public/search/aggs}/metrics/top_hit.ts | 22 +- .../public/search/aggs}/param_types/agg.ts | 0 .../public/search/aggs}/param_types/base.ts | 6 +- .../search/aggs}/param_types/field.test.ts | 2 +- .../public/search/aggs}/param_types/field.ts | 27 ++- .../param_types/filter/field_filters.test.ts | 2 +- .../aggs}/param_types/filter/field_filters.ts | 0 .../search/aggs}/param_types/filter/index.ts | 0 .../public/search/aggs}/param_types/index.ts | 0 .../search/aggs}/param_types/json.test.ts | 0 .../public/search/aggs}/param_types/json.ts | 0 .../search/aggs}/param_types/optioned.test.ts | 0 .../search/aggs}/param_types/optioned.ts | 0 .../search/aggs}/param_types/string.test.ts | 0 .../public/search/aggs}/param_types/string.ts | 0 .../data/public/search/aggs}/schemas.ts | 4 +- .../data/public/search/aggs/types.ts | 29 +++ .../data/public/search/aggs}/utils.test.tsx | 0 .../data/public/search/aggs}/utils.ts | 4 +- .../data/public/search/expressions/esaggs.ts | 4 +- .../data/public/search/expressions/utils.ts | 6 +- .../core_plugins/data/public/search/index.ts | 1 + .../data/public/search/search_service.ts | 93 ++++++++ .../core_plugins/data/public/search/types.ts | 1 + .../kibana/public/discover/kibana_services.ts | 2 +- .../public/components/agg.test.tsx | 14 +- .../public/components/agg.tsx | 4 +- .../public/components/agg_add.tsx | 4 +- .../public/components/agg_common_props.ts | 12 +- .../public/components/agg_group.test.tsx | 12 +- .../public/components/agg_group.tsx | 8 +- .../components/agg_group_helper.test.ts | 8 +- .../public/components/agg_group_helper.tsx | 14 +- .../public/components/agg_group_state.tsx | 4 +- .../public/components/agg_param_props.ts | 6 +- .../public/components/agg_params.test.tsx | 4 +- .../public/components/agg_params.tsx | 4 +- .../components/agg_params_helper.test.ts | 22 +- .../public/components/agg_params_helper.ts | 18 +- .../public/components/agg_select.tsx | 12 +- .../components/controls/agg_control_props.tsx | 4 +- .../components/controls/agg_utils.test.tsx | 8 +- .../public/components/controls/field.test.tsx | 6 +- .../public/components/controls/field.tsx | 7 +- .../public/components/controls/filter.tsx | 4 +- .../components/controls/metric_agg.test.tsx | 6 +- .../public/components/controls/order_agg.tsx | 8 +- .../public/components/controls/sub_agg.tsx | 4 +- .../public/components/controls/sub_metric.tsx | 4 +- .../public/components/controls/test_utils.ts | 6 +- .../controls/top_aggregate.test.tsx | 18 +- .../components/controls/top_aggregate.tsx | 6 +- .../components/controls/utils/agg_utils.ts | 10 +- .../components/controls/utils/use_handlers.ts | 8 +- .../public/components/sidebar/data_tab.tsx | 8 +- .../components/sidebar/state/actions.ts | 18 +- .../components/sidebar/state/reducers.ts | 4 +- .../public/legacy_imports.ts | 31 ++- .../public/vis_options_props.tsx | 4 +- .../public/vis_type_agg_filter.ts | 12 +- .../vis_type_table/public/legacy_imports.ts | 2 +- .../public/table_vis_controller.test.ts | 4 +- .../options/metrics_axes/index.test.tsx | 12 +- .../components/options/metrics_axes/index.tsx | 4 +- .../vis_type_vislib/public/legacy_imports.ts | 2 +- .../public/embeddable/query_geohash_bounds.ts | 4 +- .../visualizations/public/legacy_imports.ts | 7 +- .../public/legacy/build_pipeline.test.ts | 10 +- .../np_ready/public/legacy/build_pipeline.ts | 12 +- .../public/np_ready/public/vis.d.ts | 4 +- .../public/np_ready/public/vis.js | 2 +- .../agg_response/tabify/_get_columns.ts | 8 +- src/legacy/ui/public/agg_types/index.ts | 78 ++++++- .../ui/public/time_buckets/time_buckets.js | 2 +- .../ui/public/vis/__tests__/_agg_config.js | 4 +- .../config/editor_config_providers.test.ts | 8 +- .../vis/config/editor_config_providers.ts | 6 +- .../loader/pipeline_helpers/utilities.ts | 12 +- .../editor_frame_plugin/plugin.test.tsx | 3 - .../definitions/date_histogram.test.tsx | 34 ++- .../operations/definitions/date_histogram.tsx | 2 +- x-pack/legacy/plugins/rollup/public/legacy.ts | 4 +- .../plugins/rollup/public/legacy_imports.ts | 4 +- .../translations/translations/ja-JP.json | 209 +++++++++--------- .../translations/translations/zh-CN.json | 209 +++++++++--------- .../watcher/public/legacy/time_buckets.js | 2 +- 185 files changed, 1039 insertions(+), 707 deletions(-) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/__tests__/buckets/_terms_other_bucket_helper.js (99%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/agg_config.ts (93%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/agg_configs.ts (98%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/agg_groups.ts (87%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/agg_params.test.ts (97%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/agg_params.ts (97%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/agg_type.test.ts (94%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/agg_type.ts (94%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/agg_types.ts (73%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/_bucket_agg_type.ts (96%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/_interval_options.ts (66%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/_terms_other_bucket_helper.js (99%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/bucket_agg_types.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/create_filter/date_histogram.test.ts (98%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/create_filter/date_histogram.ts (94%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/create_filter/date_range.test.ts (97%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/create_filter/date_range.ts (94%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/create_filter/filters.test.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/create_filter/filters.ts (94%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/create_filter/histogram.test.ts (97%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/create_filter/histogram.ts (94%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/create_filter/ip_range.test.ts (97%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/create_filter/ip_range.ts (95%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/create_filter/range.test.ts (97%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/create_filter/range.ts (93%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/create_filter/terms.test.ts (98%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/create_filter/terms.ts (95%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/date_histogram.ts (95%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/date_range.test.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/date_range.ts (95%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/filter.ts (93%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/filters.ts (93%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/geo_hash.test.ts (98%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/geo_hash.ts (96%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/geo_tile.ts (92%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/histogram.test.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/histogram.ts (96%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/ip_range.ts (93%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/lib/cidr_mask.test.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/lib/cidr_mask.ts (95%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/lib/geo_utils.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/migrate_include_exclude_format.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/range.test.ts (97%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/range.ts (89%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/range_key.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/significant_terms.test.ts (96%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/significant_terms.ts (82%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/terms.test.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/buckets/terms.ts (85%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/filter/agg_type_filters.test.ts (88%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/filter/agg_type_filters.ts (92%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/filter/index.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/filter/prop_filter.test.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/filter/prop_filter.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/index.test.ts (100%) create mode 100644 src/legacy/core_plugins/data/public/search/aggs/index.ts rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/avg.ts (85%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/bucket_avg.ts (91%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/bucket_max.ts (89%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/bucket_min.ts (89%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/bucket_sum.ts (89%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/cardinality.ts (86%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/count.ts (87%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/cumulative_sum.ts (88%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/derivative.ts (89%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/geo_bounds.ts (84%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/geo_centroid.ts (84%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/lib/get_response_agg_config_class.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/lib/make_nested_label.test.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/lib/make_nested_label.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/lib/nested_agg_helpers.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/lib/ordinal_suffix.test.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/lib/ordinal_suffix.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/lib/parent_pipeline_agg_helper.ts (94%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/lib/parent_pipeline_agg_writer.ts (94%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/lib/sibling_pipeline_agg_helper.ts (93%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/lib/sibling_pipeline_agg_writer.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/max.ts (86%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/median.test.ts (95%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/median.ts (88%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/metric_agg_type.ts (92%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/metric_agg_types.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/min.ts (86%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/moving_avg.ts (92%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/parent_pipeline.test.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/percentile_ranks.test.ts (96%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/percentile_ranks.ts (89%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/percentiles.test.ts (95%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/percentiles.ts (88%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/percentiles_get_value.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/serial_diff.ts (89%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/sibling_pipeline.test.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/std_deviation.test.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/std_deviation.ts (85%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/sum.ts (86%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/top_hit.test.ts (99%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/metrics/top_hit.ts (87%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/param_types/agg.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/param_types/base.ts (94%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/param_types/field.test.ts (98%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/param_types/field.ts (83%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/param_types/filter/field_filters.test.ts (97%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/param_types/filter/field_filters.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/param_types/filter/index.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/param_types/index.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/param_types/json.test.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/param_types/json.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/param_types/optioned.test.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/param_types/optioned.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/param_types/string.test.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/param_types/string.ts (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/schemas.ts (98%) create mode 100644 src/legacy/core_plugins/data/public/search/aggs/types.ts rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/utils.test.tsx (100%) rename src/legacy/{ui/public/agg_types => core_plugins/data/public/search/aggs}/utils.ts (92%) create mode 100644 src/legacy/core_plugins/data/public/search/search_service.ts diff --git a/src/legacy/core_plugins/data/public/actions/filters/brush_event.test.js b/src/legacy/core_plugins/data/public/actions/filters/brush_event.test.js index a6fe58503cd021..743f6caee4edd0 100644 --- a/src/legacy/core_plugins/data/public/actions/filters/brush_event.test.js +++ b/src/legacy/core_plugins/data/public/actions/filters/brush_event.test.js @@ -21,7 +21,7 @@ import _ from 'lodash'; import moment from 'moment'; import expect from '@kbn/expect'; -jest.mock('../../../../../ui/public/agg_types/agg_configs', () => ({ +jest.mock('../../search/aggs', () => ({ AggConfigs: function AggConfigs() { return { createAggConfig: ({ params }) => ({ diff --git a/src/legacy/core_plugins/data/public/index.ts b/src/legacy/core_plugins/data/public/index.ts index 7fe487667f94e0..50120292a627a6 100644 --- a/src/legacy/core_plugins/data/public/index.ts +++ b/src/legacy/core_plugins/data/public/index.ts @@ -18,7 +18,7 @@ */ // /// Define plugin function -import { DataPlugin as Plugin, DataStart } from './plugin'; +import { DataPlugin as Plugin } from './plugin'; export function plugin() { return new Plugin(); @@ -27,14 +27,58 @@ export function plugin() { // /// Export types & static code /** @public types */ -export { DataStart }; +export { DataSetup, DataStart } from './plugin'; export { SavedQueryAttributes, SavedQuery, SavedQueryTimeFilter, } from '../../../../plugins/data/public'; +export { + // agg_types + AggParam, + AggParamOption, + DateRangeKey, + IAggConfig, + IAggConfigs, + IAggType, + IFieldParamType, + IMetricAggType, + IpRangeKey, + ISchemas, + OptionedParamEditorProps, + OptionedValueProp, +} from './search/types'; /** @public static code */ export * from '../common'; export { FilterStateManager } from './filter/filter_manager'; -export { getRequestInspectorStats, getResponseInspectorStats } from './search'; +export { + // agg_types TODO need to group these under a namespace or prefix + AggParamType, + AggTypeFilters, // TODO convert to interface + aggTypeFilters, + AggTypeFieldFilters, // TODO convert to interface + AggGroupNames, + aggGroupNamesMap, + BUCKET_TYPES, + CidrMask, + convertDateRangeToString, + convertIPRangeToString, + intervalOptions, // only used in Discover + isDateHistogramBucketAggConfig, + isStringType, + isType, + isValidInterval, + isValidJson, + METRIC_TYPES, + OptionedParamType, + parentPipelineType, + propFilter, + Schema, + Schemas, + siblingPipelineType, + termsAggFilter, + // search_source + getRequestInspectorStats, + getResponseInspectorStats, +} from './search'; diff --git a/src/legacy/core_plugins/data/public/plugin.ts b/src/legacy/core_plugins/data/public/plugin.ts index da35366cdff318..ebc470555d87c5 100644 --- a/src/legacy/core_plugins/data/public/plugin.ts +++ b/src/legacy/core_plugins/data/public/plugin.ts @@ -45,6 +45,8 @@ import { } from '../../../../plugins/embeddable/public/lib/triggers'; import { IUiActionsSetup, IUiActionsStart } from '../../../../plugins/ui_actions/public'; +import { SearchSetup, SearchStart, SearchService } from './search/search_service'; + export interface DataPluginSetupDependencies { data: DataPublicPluginSetup; expressions: ExpressionsSetup; @@ -56,12 +58,23 @@ export interface DataPluginStartDependencies { uiActions: IUiActionsStart; } +/** + * Interface for this plugin's returned `setup` contract. + * + * @public + */ +export interface DataSetup { + search: SearchSetup; +} + /** * Interface for this plugin's returned `start` contract. * * @public */ -export interface DataStart {} // eslint-disable-line @typescript-eslint/no-empty-interface +export interface DataStart { + search: SearchStart; +} /** * Data Plugin - public @@ -76,7 +89,10 @@ export interface DataStart {} // eslint-disable-line @typescript-eslint/no-empty */ export class DataPlugin - implements Plugin { + implements + Plugin { + private readonly search = new SearchService(); + public setup(core: CoreSetup, { data, uiActions }: DataPluginSetupDependencies) { setInjectedMetadata(core.injectedMetadata); @@ -89,6 +105,10 @@ export class DataPlugin uiActions.registerAction( valueClickAction(data.query.filterManager, data.query.timefilter.timefilter) ); + + return { + search: this.search.setup(core), + }; } public start(core: CoreStart, { data, uiActions }: DataPluginStartDependencies): DataStart { @@ -102,7 +122,9 @@ export class DataPlugin uiActions.attachAction(SELECT_RANGE_TRIGGER, SELECT_RANGE_ACTION); uiActions.attachAction(VALUE_CLICK_TRIGGER, VALUE_CLICK_ACTION); - return {}; + return { + search: this.search.start(core), + }; } public stop() {} diff --git a/src/legacy/ui/public/agg_types/__tests__/buckets/_terms_other_bucket_helper.js b/src/legacy/core_plugins/data/public/search/aggs/__tests__/buckets/_terms_other_bucket_helper.js similarity index 99% rename from src/legacy/ui/public/agg_types/__tests__/buckets/_terms_other_bucket_helper.js rename to src/legacy/core_plugins/data/public/search/aggs/__tests__/buckets/_terms_other_bucket_helper.js index acf932c1fb451b..247290731df573 100644 --- a/src/legacy/ui/public/agg_types/__tests__/buckets/_terms_other_bucket_helper.js +++ b/src/legacy/core_plugins/data/public/search/aggs/__tests__/buckets/_terms_other_bucket_helper.js @@ -24,7 +24,7 @@ import { mergeOtherBucketAggResponse, updateMissingBucket, } from '../../buckets/_terms_other_bucket_helper'; -import { Vis } from '../../../../../core_plugins/visualizations/public'; +import { Vis } from '../../../../../../../core_plugins/visualizations/public'; import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; const visConfigSingleTerm = { diff --git a/src/legacy/ui/public/agg_types/agg_config.ts b/src/legacy/core_plugins/data/public/search/aggs/agg_config.ts similarity index 93% rename from src/legacy/ui/public/agg_types/agg_config.ts rename to src/legacy/core_plugins/data/public/search/aggs/agg_config.ts index 17a8b14b57d020..769347a26c34c2 100644 --- a/src/legacy/ui/public/agg_types/agg_config.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/agg_config.ts @@ -27,17 +27,17 @@ import _ from 'lodash'; import { i18n } from '@kbn/i18n'; import { npStart } from 'ui/new_platform'; -import { AggType } from './agg_type'; +import { IAggType } from './agg_type'; import { AggGroupNames } from './agg_groups'; import { writeParams } from './agg_params'; -import { AggConfigs } from './agg_configs'; +import { IAggConfigs } from './agg_configs'; import { Schema } from './schemas'; import { ISearchSource, FetchOptions, fieldFormats, KBN_FIELD_TYPES, -} from '../../../../plugins/data/public'; +} from '../../../../../../plugins/data/public'; export interface AggConfigOptions { enabled: boolean; @@ -60,13 +60,13 @@ const unknownSchema: Schema = { group: AggGroupNames.Metrics, }; -const getTypeFromRegistry = (type: string): AggType => { +const getTypeFromRegistry = (type: string): IAggType => { // We need to inline require here, since we're having a cyclic dependency // from somewhere inside agg_types back to AggConfig. - const aggTypes = require('./agg_types').aggTypes; + const aggTypes = require('../aggs').aggTypes; const registeredType = - aggTypes.metrics.find((agg: AggType) => agg.name === type) || - aggTypes.buckets.find((agg: AggType) => agg.name === type); + aggTypes.metrics.find((agg: IAggType) => agg.name === type) || + aggTypes.buckets.find((agg: IAggType) => agg.name === type); if (!registeredType) { throw new Error('unknown type'); @@ -85,6 +85,9 @@ const getSchemaFromRegistry = (schemas: any, schema: string): Schema => { return registeredSchema; }; +// TODO need to make a more explicit interface for this +export type IAggConfig = AggConfig; + export class AggConfig { /** * Ensure that all of the objects in the list have ids, the objects @@ -122,19 +125,19 @@ export class AggConfig { ); } - public aggConfigs: AggConfigs; + public aggConfigs: IAggConfigs; public id: string; public enabled: boolean; public params: any; - public parent?: AggConfigs; + public parent?: IAggConfigs; public brandNew?: boolean; private __schema: Schema; - private __type: AggType; + private __type: IAggType; private __typeDecorations: any; private subAggs: AggConfig[] = []; - constructor(aggConfigs: AggConfigs, opts: AggConfigOptions) { + constructor(aggConfigs: IAggConfigs, opts: AggConfigOptions) { this.aggConfigs = aggConfigs; this.id = String(opts.id || AggConfig.nextId(aggConfigs.aggs as any)); this.enabled = typeof opts.enabled === 'boolean' ? opts.enabled : true; @@ -207,7 +210,7 @@ export class AggConfig { return _.get(this.params, key); } - write(aggs?: AggConfigs) { + write(aggs?: IAggConfigs) { return writeParams(this.type.params, this, aggs); } @@ -262,7 +265,7 @@ export class AggConfig { * @return {void|Object} - if the config has a dsl representation, it is * returned, else undefined is returned */ - toDsl(aggConfigs?: AggConfigs) { + toDsl(aggConfigs?: IAggConfigs) { if (this.type.hasNoDsl) return; const output = this.write(aggConfigs) as any; @@ -360,7 +363,7 @@ export class AggConfig { if (!this.type) return ''; return percentageMode - ? i18n.translate('common.ui.vis.aggConfig.percentageOfLabel', { + ? i18n.translate('data.search.aggs.percentageOfLabel', { defaultMessage: 'Percentage of {label}', values: { label: this.type.makeLabel(this) }, }) @@ -448,7 +451,7 @@ export class AggConfig { }); } - public setType(type: string | AggType) { + public setType(type: string | IAggType) { this.type = typeof type === 'string' ? getTypeFromRegistry(type) : type; } diff --git a/src/legacy/ui/public/agg_types/agg_configs.ts b/src/legacy/core_plugins/data/public/search/aggs/agg_configs.ts similarity index 98% rename from src/legacy/ui/public/agg_types/agg_configs.ts rename to src/legacy/core_plugins/data/public/search/aggs/agg_configs.ts index 47e2222abe1e8b..7e7e4944b00da9 100644 --- a/src/legacy/ui/public/agg_types/agg_configs.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/agg_configs.ts @@ -35,7 +35,7 @@ import { ISearchSource, FetchOptions, TimeRange, -} from '../../../../plugins/data/public'; +} from '../../../../../../plugins/data/public'; type Schemas = Record; @@ -55,6 +55,9 @@ function parseParentAggs(dslLvlCursor: any, dsl: any) { } } +// TODO need to make a more explicit interface for this +export type IAggConfigs = AggConfigs; + export class AggConfigs { public indexPattern: IndexPattern; public schemas: any; diff --git a/src/legacy/ui/public/agg_types/agg_groups.ts b/src/legacy/core_plugins/data/public/search/aggs/agg_groups.ts similarity index 87% rename from src/legacy/ui/public/agg_types/agg_groups.ts rename to src/legacy/core_plugins/data/public/search/aggs/agg_groups.ts index d08e875bf213e4..d21f5c8968840f 100644 --- a/src/legacy/ui/public/agg_types/agg_groups.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/agg_groups.ts @@ -28,10 +28,10 @@ export const AggGroupNames = Object.freeze({ export type AggGroupNames = $Values; export const aggGroupNamesMap = () => ({ - [AggGroupNames.Metrics]: i18n.translate('common.ui.aggTypes.aggGroups.metricsText', { + [AggGroupNames.Metrics]: i18n.translate('data.search.aggs.aggGroups.metricsText', { defaultMessage: 'Metrics', }), - [AggGroupNames.Buckets]: i18n.translate('common.ui.aggTypes.aggGroups.bucketsText', { + [AggGroupNames.Buckets]: i18n.translate('data.search.aggs.aggGroups.bucketsText', { defaultMessage: 'Buckets', }), }); diff --git a/src/legacy/ui/public/agg_types/agg_params.test.ts b/src/legacy/core_plugins/data/public/search/aggs/agg_params.test.ts similarity index 97% rename from src/legacy/ui/public/agg_types/agg_params.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/agg_params.test.ts index 25e62e06d52d70..30ab272537dad1 100644 --- a/src/legacy/ui/public/agg_types/agg_params.test.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/agg_params.test.ts @@ -21,7 +21,7 @@ import { initParams } from './agg_params'; import { BaseParamType } from './param_types/base'; import { FieldParamType } from './param_types/field'; import { OptionedParamType } from './param_types/optioned'; -import { AggParamType } from '../agg_types/param_types/agg'; +import { AggParamType } from '../aggs/param_types/agg'; jest.mock('ui/new_platform'); diff --git a/src/legacy/ui/public/agg_types/agg_params.ts b/src/legacy/core_plugins/data/public/search/aggs/agg_params.ts similarity index 97% rename from src/legacy/ui/public/agg_types/agg_params.ts rename to src/legacy/core_plugins/data/public/search/aggs/agg_params.ts index 262a57f4a5aa30..34727ff4614b95 100644 --- a/src/legacy/ui/public/agg_types/agg_params.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/agg_params.ts @@ -25,7 +25,7 @@ import { JsonParamType } from './param_types/json'; import { BaseParamType } from './param_types/base'; import { AggConfig } from './agg_config'; -import { AggConfigs } from './agg_configs'; +import { IAggConfigs } from './agg_configs'; const paramTypeMap = { field: FieldParamType, @@ -73,7 +73,7 @@ export const writeParams = < >( params: Array> = [], aggConfig: TAggConfig, - aggs?: AggConfigs, + aggs?: IAggConfigs, locals?: Record ) => { const output = { params: {} as Record }; diff --git a/src/legacy/ui/public/agg_types/agg_type.test.ts b/src/legacy/core_plugins/data/public/search/aggs/agg_type.test.ts similarity index 94% rename from src/legacy/ui/public/agg_types/agg_type.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/agg_type.test.ts index 9b34910e81e88b..6d4c2d1317f505 100644 --- a/src/legacy/ui/public/agg_types/agg_type.test.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/agg_type.test.ts @@ -18,7 +18,7 @@ */ import { AggType, AggTypeConfig } from './agg_type'; -import { AggConfig } from './agg_config'; +import { IAggConfig } from './agg_config'; import { npStart } from 'ui/new_platform'; jest.mock('ui/new_platform'); @@ -48,7 +48,7 @@ describe('AggType Class', () => { describe('makeLabel', () => { it('makes a function when the makeLabel config is not specified', () => { const makeLabel = () => 'label'; - const aggConfig = {} as AggConfig; + const aggConfig = {} as IAggConfig; const config: AggTypeConfig = { name: 'name', title: 'title', @@ -64,7 +64,7 @@ describe('AggType Class', () => { describe('getResponseAggs/getRequestAggs', () => { it('copies the value', () => { - const testConfig = (aggConfig: AggConfig) => [aggConfig]; + const testConfig = (aggConfig: IAggConfig) => [aggConfig]; const aggType = new AggType({ name: 'name', @@ -78,7 +78,7 @@ describe('AggType Class', () => { }); it('defaults to noop', () => { - const aggConfig = {} as AggConfig; + const aggConfig = {} as IAggConfig; const aggType = new AggType({ name: 'name', title: 'title', @@ -130,13 +130,13 @@ describe('AggType Class', () => { }); describe('getFormat', function() { - let aggConfig: AggConfig; + let aggConfig: IAggConfig; let field: any; beforeEach(() => { aggConfig = ({ getField: jest.fn(() => field), - } as unknown) as AggConfig; + } as unknown) as IAggConfig; }); it('returns the formatter for the aggConfig', () => { diff --git a/src/legacy/ui/public/agg_types/agg_type.ts b/src/legacy/core_plugins/data/public/search/aggs/agg_type.ts similarity index 94% rename from src/legacy/ui/public/agg_types/agg_type.ts rename to src/legacy/core_plugins/data/public/search/aggs/agg_type.ts index 7ec688277b9c43..56299839d0a6db 100644 --- a/src/legacy/ui/public/agg_types/agg_type.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/agg_type.ts @@ -23,11 +23,15 @@ import { npStart } from 'ui/new_platform'; import { initParams } from './agg_params'; import { AggConfig } from './agg_config'; -import { AggConfigs } from './agg_configs'; -import { Adapters } from '../../../../plugins/inspector/public'; +import { IAggConfigs } from './agg_configs'; +import { Adapters } from '../../../../../../plugins/inspector/public'; import { BaseParamType } from './param_types/base'; -import { AggParamType } from '../agg_types/param_types/agg'; -import { KBN_FIELD_TYPES, fieldFormats, ISearchSource } from '../../../../plugins/data/public'; +import { AggParamType } from './param_types/agg'; +import { + KBN_FIELD_TYPES, + fieldFormats, + ISearchSource, +} from '../../../../../../plugins/data/public'; export interface AggTypeConfig< TAggConfig extends AggConfig = AggConfig, @@ -48,7 +52,7 @@ export interface AggTypeConfig< decorateAggConfig?: () => any; postFlightRequest?: ( resp: any, - aggConfigs: AggConfigs, + aggConfigs: IAggConfigs, aggConfig: TAggConfig, searchSource: ISearchSource, inspectorAdapters: Adapters, @@ -66,6 +70,9 @@ const getFormat = (agg: AggConfig) => { return field ? field.format : fieldFormatsService.getDefaultInstance(KBN_FIELD_TYPES.STRING); }; +// TODO need to make a more explicit interface for this +export type IAggType = AggType; + export class AggType< TAggConfig extends AggConfig = AggConfig, TParam extends AggParamType = AggParamType @@ -178,7 +185,7 @@ export class AggType< */ postFlightRequest: ( resp: any, - aggConfigs: AggConfigs, + aggConfigs: IAggConfigs, aggConfig: TAggConfig, searchSource: ISearchSource, inspectorAdapters: Adapters, @@ -239,7 +246,7 @@ export class AggType< if (config.customLabels !== false) { params.push({ name: 'customLabel', - displayName: i18n.translate('common.ui.aggTypes.string.customLabel', { + displayName: i18n.translate('data.search.aggs.string.customLabel', { defaultMessage: 'Custom label', }), type: 'string', diff --git a/src/legacy/ui/public/agg_types/agg_types.ts b/src/legacy/core_plugins/data/public/search/aggs/agg_types.ts similarity index 73% rename from src/legacy/ui/public/agg_types/agg_types.ts rename to src/legacy/core_plugins/data/public/search/aggs/agg_types.ts index 1b05f5926ebfc9..c16eb06eeb1164 100644 --- a/src/legacy/ui/public/agg_types/agg_types.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/agg_types.ts @@ -50,8 +50,6 @@ import { bucketAvgMetricAgg } from './metrics/bucket_avg'; import { bucketMinMetricAgg } from './metrics/bucket_min'; import { bucketMaxMetricAgg } from './metrics/bucket_max'; -export { AggType } from './agg_type'; - export const aggTypes = { metrics: [ countMetricAgg, @@ -90,3 +88,27 @@ export const aggTypes = { geoTileBucketAgg, ], }; + +export { AggType } from './agg_type'; +export { AggConfig } from './agg_config'; +export { AggConfigs } from './agg_configs'; +export { FieldParamType } from './param_types'; +export { aggTypeFieldFilters } from './param_types/filter'; +export { parentPipelineAggHelper } from './metrics/lib/parent_pipeline_agg_helper'; + +// static code +export { AggParamType } from './param_types/agg'; +export { AggGroupNames, aggGroupNamesMap } from './agg_groups'; +export { intervalOptions } from './buckets/_interval_options'; // only used in Discover +export { isDateHistogramBucketAggConfig, setBounds } from './buckets/date_histogram'; +export { termsAggFilter } from './buckets/terms'; +export { isType, isStringType } from './buckets/migrate_include_exclude_format'; +export { CidrMask } from './buckets/lib/cidr_mask'; +export { convertDateRangeToString } from './buckets/date_range'; +export { convertIPRangeToString } from './buckets/ip_range'; +export { aggTypeFilters, propFilter } from './filter'; +export { OptionedParamType } from './param_types/optioned'; +export { isValidJson, isValidInterval } from './utils'; +export { BUCKET_TYPES } from './buckets/bucket_agg_types'; +export { METRIC_TYPES } from './metrics/metric_agg_types'; +export { ISchemas, Schema, Schemas } from './schemas'; diff --git a/src/legacy/ui/public/agg_types/buckets/_bucket_agg_type.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/_bucket_agg_type.ts similarity index 96% rename from src/legacy/ui/public/agg_types/buckets/_bucket_agg_type.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/_bucket_agg_type.ts index 9b7c97a8f11b6a..546d054c5af978 100644 --- a/src/legacy/ui/public/agg_types/buckets/_bucket_agg_type.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/_bucket_agg_type.ts @@ -18,7 +18,7 @@ */ import { AggConfig } from '../agg_config'; -import { KBN_FIELD_TYPES } from '../../../../../plugins/data/public'; +import { KBN_FIELD_TYPES } from '../../../../../../../plugins/data/public'; import { AggType, AggTypeConfig } from '../agg_type'; import { AggParamType } from '../param_types/agg'; diff --git a/src/legacy/ui/public/agg_types/buckets/_interval_options.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/_interval_options.ts similarity index 66% rename from src/legacy/ui/public/agg_types/buckets/_interval_options.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/_interval_options.ts index 01d0abb7a366c0..e196687607d198 100644 --- a/src/legacy/ui/public/agg_types/buckets/_interval_options.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/_interval_options.ts @@ -21,7 +21,7 @@ import { IBucketAggConfig } from './_bucket_agg_type'; export const intervalOptions = [ { - display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.autoDisplayName', { + display: i18n.translate('data.search.aggs.buckets.intervalOptions.autoDisplayName', { defaultMessage: 'Auto', }), val: 'auto', @@ -32,49 +32,49 @@ export const intervalOptions = [ }, }, { - display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.millisecondDisplayName', { + display: i18n.translate('data.search.aggs.buckets.intervalOptions.millisecondDisplayName', { defaultMessage: 'Millisecond', }), val: 'ms', }, { - display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.secondDisplayName', { + display: i18n.translate('data.search.aggs.buckets.intervalOptions.secondDisplayName', { defaultMessage: 'Second', }), val: 's', }, { - display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.minuteDisplayName', { + display: i18n.translate('data.search.aggs.buckets.intervalOptions.minuteDisplayName', { defaultMessage: 'Minute', }), val: 'm', }, { - display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.hourlyDisplayName', { + display: i18n.translate('data.search.aggs.buckets.intervalOptions.hourlyDisplayName', { defaultMessage: 'Hourly', }), val: 'h', }, { - display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.dailyDisplayName', { + display: i18n.translate('data.search.aggs.buckets.intervalOptions.dailyDisplayName', { defaultMessage: 'Daily', }), val: 'd', }, { - display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.weeklyDisplayName', { + display: i18n.translate('data.search.aggs.buckets.intervalOptions.weeklyDisplayName', { defaultMessage: 'Weekly', }), val: 'w', }, { - display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.monthlyDisplayName', { + display: i18n.translate('data.search.aggs.buckets.intervalOptions.monthlyDisplayName', { defaultMessage: 'Monthly', }), val: 'M', }, { - display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.yearlyDisplayName', { + display: i18n.translate('data.search.aggs.buckets.intervalOptions.yearlyDisplayName', { defaultMessage: 'Yearly', }), val: 'y', diff --git a/src/legacy/ui/public/agg_types/buckets/_terms_other_bucket_helper.js b/src/legacy/core_plugins/data/public/search/aggs/buckets/_terms_other_bucket_helper.js similarity index 99% rename from src/legacy/ui/public/agg_types/buckets/_terms_other_bucket_helper.js rename to src/legacy/core_plugins/data/public/search/aggs/buckets/_terms_other_bucket_helper.js index c8580183756f49..ddab360161744c 100644 --- a/src/legacy/ui/public/agg_types/buckets/_terms_other_bucket_helper.js +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/_terms_other_bucket_helper.js @@ -18,7 +18,7 @@ */ import _ from 'lodash'; -import { esFilters, esQuery } from '../../../../../plugins/data/public'; +import { esFilters, esQuery } from '../../../../../../../plugins/data/public'; import { AggGroupNames } from '../agg_groups'; /** diff --git a/src/legacy/ui/public/agg_types/buckets/bucket_agg_types.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/bucket_agg_types.ts similarity index 100% rename from src/legacy/ui/public/agg_types/buckets/bucket_agg_types.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/bucket_agg_types.ts diff --git a/src/legacy/ui/public/agg_types/buckets/create_filter/date_histogram.test.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/date_histogram.test.ts similarity index 98% rename from src/legacy/ui/public/agg_types/buckets/create_filter/date_histogram.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/date_histogram.test.ts index 9426df7d34c29e..e212132257ef68 100644 --- a/src/legacy/ui/public/agg_types/buckets/create_filter/date_histogram.test.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/date_histogram.test.ts @@ -23,7 +23,7 @@ import { intervalOptions } from '../_interval_options'; import { AggConfigs } from '../../agg_configs'; import { IBucketDateHistogramAggConfig } from '../date_histogram'; import { BUCKET_TYPES } from '../bucket_agg_types'; -import { esFilters } from '../../../../../../plugins/data/public'; +import { esFilters } from '../../../../../../../../plugins/data/public'; jest.mock('ui/new_platform'); diff --git a/src/legacy/ui/public/agg_types/buckets/create_filter/date_histogram.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/date_histogram.ts similarity index 94% rename from src/legacy/ui/public/agg_types/buckets/create_filter/date_histogram.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/date_histogram.ts index f91a92eab1c33f..e634b5daf0ac38 100644 --- a/src/legacy/ui/public/agg_types/buckets/create_filter/date_histogram.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/date_histogram.ts @@ -19,7 +19,7 @@ import moment from 'moment'; import { IBucketDateHistogramAggConfig } from '../date_histogram'; -import { esFilters } from '../../../../../../plugins/data/public'; +import { esFilters } from '../../../../../../../../plugins/data/public'; export const createFilterDateHistogram = ( agg: IBucketDateHistogramAggConfig, diff --git a/src/legacy/ui/public/agg_types/buckets/create_filter/date_range.test.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/date_range.test.ts similarity index 97% rename from src/legacy/ui/public/agg_types/buckets/create_filter/date_range.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/date_range.test.ts index 9c2c4f72704f41..e224253a6e3149 100644 --- a/src/legacy/ui/public/agg_types/buckets/create_filter/date_range.test.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/date_range.test.ts @@ -19,7 +19,7 @@ import moment from 'moment'; import { createFilterDateRange } from './date_range'; -import { fieldFormats } from '../../../../../../plugins/data/public'; +import { fieldFormats } from '../../../../../../../../plugins/data/public'; import { AggConfigs } from '../../agg_configs'; import { BUCKET_TYPES } from '../bucket_agg_types'; import { IBucketAggConfig } from '../_bucket_agg_type'; diff --git a/src/legacy/ui/public/agg_types/buckets/create_filter/date_range.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/date_range.ts similarity index 94% rename from src/legacy/ui/public/agg_types/buckets/create_filter/date_range.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/date_range.ts index 01689d954a0723..f7f2cfdb7bb61b 100644 --- a/src/legacy/ui/public/agg_types/buckets/create_filter/date_range.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/date_range.ts @@ -20,7 +20,7 @@ import moment from 'moment'; import { IBucketAggConfig } from '../_bucket_agg_type'; import { DateRangeKey } from '../date_range'; -import { esFilters } from '../../../../../../plugins/data/public'; +import { esFilters } from '../../../../../../../../plugins/data/public'; export const createFilterDateRange = (agg: IBucketAggConfig, { from, to }: DateRangeKey) => { const filter: esFilters.RangeFilterParams = {}; diff --git a/src/legacy/ui/public/agg_types/buckets/create_filter/filters.test.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/filters.test.ts similarity index 100% rename from src/legacy/ui/public/agg_types/buckets/create_filter/filters.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/filters.test.ts diff --git a/src/legacy/ui/public/agg_types/buckets/create_filter/filters.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/filters.ts similarity index 94% rename from src/legacy/ui/public/agg_types/buckets/create_filter/filters.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/filters.ts index 6b614514580b6d..715f6895374e63 100644 --- a/src/legacy/ui/public/agg_types/buckets/create_filter/filters.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/filters.ts @@ -19,7 +19,7 @@ import { get } from 'lodash'; import { IBucketAggConfig } from '../_bucket_agg_type'; -import { esFilters } from '../../../../../../plugins/data/public'; +import { esFilters } from '../../../../../../../../plugins/data/public'; export const createFilterFilters = (aggConfig: IBucketAggConfig, key: string) => { // have the aggConfig write agg dsl params diff --git a/src/legacy/ui/public/agg_types/buckets/create_filter/histogram.test.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/histogram.test.ts similarity index 97% rename from src/legacy/ui/public/agg_types/buckets/create_filter/histogram.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/histogram.test.ts index ef49636f9e0c16..1a78967261fa6e 100644 --- a/src/legacy/ui/public/agg_types/buckets/create_filter/histogram.test.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/histogram.test.ts @@ -20,7 +20,7 @@ import { createFilterHistogram } from './histogram'; import { AggConfigs } from '../../agg_configs'; import { BUCKET_TYPES } from '../bucket_agg_types'; import { IBucketAggConfig } from '../_bucket_agg_type'; -import { fieldFormats } from '../../../../../../plugins/data/public'; +import { fieldFormats } from '../../../../../../../../plugins/data/public'; jest.mock('ui/new_platform'); diff --git a/src/legacy/ui/public/agg_types/buckets/create_filter/histogram.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/histogram.ts similarity index 94% rename from src/legacy/ui/public/agg_types/buckets/create_filter/histogram.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/histogram.ts index fc587fa9ecdb6b..820f3de5ae9f0d 100644 --- a/src/legacy/ui/public/agg_types/buckets/create_filter/histogram.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/histogram.ts @@ -18,7 +18,7 @@ */ import { IBucketAggConfig } from '../_bucket_agg_type'; -import { esFilters } from '../../../../../../plugins/data/public'; +import { esFilters } from '../../../../../../../../plugins/data/public'; export const createFilterHistogram = (aggConfig: IBucketAggConfig, key: string) => { const value = parseInt(key, 10); diff --git a/src/legacy/ui/public/agg_types/buckets/create_filter/ip_range.test.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/ip_range.test.ts similarity index 97% rename from src/legacy/ui/public/agg_types/buckets/create_filter/ip_range.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/ip_range.test.ts index a9eca3bbb7a560..e92ba5cb2852a1 100644 --- a/src/legacy/ui/public/agg_types/buckets/create_filter/ip_range.test.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/ip_range.test.ts @@ -19,7 +19,7 @@ import { createFilterIpRange } from './ip_range'; import { AggConfigs } from '../../agg_configs'; -import { fieldFormats } from '../../../../../../plugins/data/public'; +import { fieldFormats } from '../../../../../../../../plugins/data/public'; import { BUCKET_TYPES } from '../bucket_agg_types'; import { IBucketAggConfig } from '../_bucket_agg_type'; diff --git a/src/legacy/ui/public/agg_types/buckets/create_filter/ip_range.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/ip_range.ts similarity index 95% rename from src/legacy/ui/public/agg_types/buckets/create_filter/ip_range.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/ip_range.ts index a513b8c7827398..d78f4579cd713d 100644 --- a/src/legacy/ui/public/agg_types/buckets/create_filter/ip_range.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/ip_range.ts @@ -20,7 +20,7 @@ import { CidrMask } from '../lib/cidr_mask'; import { IBucketAggConfig } from '../_bucket_agg_type'; import { IpRangeKey } from '../ip_range'; -import { esFilters } from '../../../../../../plugins/data/public'; +import { esFilters } from '../../../../../../../../plugins/data/public'; export const createFilterIpRange = (aggConfig: IBucketAggConfig, key: IpRangeKey) => { let range: esFilters.RangeFilterParams; diff --git a/src/legacy/ui/public/agg_types/buckets/create_filter/range.test.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/range.test.ts similarity index 97% rename from src/legacy/ui/public/agg_types/buckets/create_filter/range.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/range.test.ts index 720e952c28821b..2f74f23721813e 100644 --- a/src/legacy/ui/public/agg_types/buckets/create_filter/range.test.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/range.test.ts @@ -18,7 +18,7 @@ */ import { createFilterRange } from './range'; -import { fieldFormats } from '../../../../../../plugins/data/public'; +import { fieldFormats } from '../../../../../../../../plugins/data/public'; import { AggConfigs } from '../../agg_configs'; import { BUCKET_TYPES } from '../bucket_agg_types'; import { IBucketAggConfig } from '../_bucket_agg_type'; diff --git a/src/legacy/ui/public/agg_types/buckets/create_filter/range.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/range.ts similarity index 93% rename from src/legacy/ui/public/agg_types/buckets/create_filter/range.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/range.ts index 929827c6e3fec6..125a30a1ab1dd3 100644 --- a/src/legacy/ui/public/agg_types/buckets/create_filter/range.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/range.ts @@ -18,7 +18,7 @@ */ import { IBucketAggConfig } from '../_bucket_agg_type'; -import { esFilters } from '../../../../../../plugins/data/public'; +import { esFilters } from '../../../../../../../../plugins/data/public'; export const createFilterRange = (aggConfig: IBucketAggConfig, params: any) => { return esFilters.buildRangeFilter( diff --git a/src/legacy/ui/public/agg_types/buckets/create_filter/terms.test.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/terms.test.ts similarity index 98% rename from src/legacy/ui/public/agg_types/buckets/create_filter/terms.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/terms.test.ts index 86c0aa24f529a6..d5fd1337f2cb20 100644 --- a/src/legacy/ui/public/agg_types/buckets/create_filter/terms.test.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/terms.test.ts @@ -21,7 +21,7 @@ import { createFilterTerms } from './terms'; import { AggConfigs } from '../../agg_configs'; import { BUCKET_TYPES } from '../bucket_agg_types'; import { IBucketAggConfig } from '../_bucket_agg_type'; -import { esFilters } from '../../../../../../plugins/data/public'; +import { esFilters } from '../../../../../../../../plugins/data/public'; jest.mock('ui/new_platform'); diff --git a/src/legacy/ui/public/agg_types/buckets/create_filter/terms.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/terms.ts similarity index 95% rename from src/legacy/ui/public/agg_types/buckets/create_filter/terms.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/terms.ts index 5bd770e672786d..e0d1f91c1e16a4 100644 --- a/src/legacy/ui/public/agg_types/buckets/create_filter/terms.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/create_filter/terms.ts @@ -18,7 +18,7 @@ */ import { IBucketAggConfig } from '../_bucket_agg_type'; -import { esFilters } from '../../../../../../plugins/data/public'; +import { esFilters } from '../../../../../../../../plugins/data/public'; export const createFilterTerms = (aggConfig: IBucketAggConfig, key: string, params: any) => { const field = aggConfig.params.field; diff --git a/src/legacy/ui/public/agg_types/buckets/date_histogram.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/date_histogram.ts similarity index 95% rename from src/legacy/ui/public/agg_types/buckets/date_histogram.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/date_histogram.ts index 33672b54b1f2e0..dc0f9baa6d0cc7 100644 --- a/src/legacy/ui/public/agg_types/buckets/date_histogram.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/date_histogram.ts @@ -22,19 +22,17 @@ import moment from 'moment-timezone'; import { i18n } from '@kbn/i18n'; import { npStart } from 'ui/new_platform'; +import { timefilter } from 'ui/timefilter'; +import { TimeBuckets } from 'ui/time_buckets'; import { BucketAggType, IBucketAggConfig } from './_bucket_agg_type'; import { BUCKET_TYPES } from './bucket_agg_types'; import { createFilterDateHistogram } from './create_filter/date_histogram'; import { intervalOptions } from './_interval_options'; -import { timefilter } from '../../timefilter'; -import { dateHistogramInterval } from '../../../../core_plugins/data/public'; +import { dateHistogramInterval } from '../../../../common'; import { writeParams } from '../agg_params'; import { isMetricAggType } from '../metrics/metric_agg_type'; -import { KBN_FIELD_TYPES } from '../../../../../plugins/data/public'; - -// @ts-ignore -import { TimeBuckets } from '../../time_buckets'; +import { KBN_FIELD_TYPES } from '../../../../../../../plugins/data/public'; const detectedTimezone = moment.tz.guess(); const tzOffset = moment().format('Z'); @@ -67,7 +65,7 @@ export function isDateHistogramBucketAggConfig(agg: any): agg is IBucketDateHist export const dateHistogramBucketAgg = new BucketAggType({ name: BUCKET_TYPES.DATE_HISTOGRAM, - title: i18n.translate('common.ui.aggTypes.buckets.dateHistogramTitle', { + title: i18n.translate('data.search.aggs.buckets.dateHistogramTitle', { defaultMessage: 'Date Histogram', }), ordered: { @@ -81,7 +79,7 @@ export const dateHistogramBucketAgg = new BucketAggType { describe('getRequestAggs', () => { describe('initial aggregation creation', () => { - let aggConfigs: AggConfigs; + let aggConfigs: IAggConfigs; let geoHashGridAgg: IBucketGeoHashGridAggConfig; beforeEach(() => { diff --git a/src/legacy/ui/public/agg_types/buckets/geo_hash.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/geo_hash.ts similarity index 96% rename from src/legacy/ui/public/agg_types/buckets/geo_hash.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/geo_hash.ts index b2519df6fb175c..afd4e18dd266ca 100644 --- a/src/legacy/ui/public/agg_types/buckets/geo_hash.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/geo_hash.ts @@ -19,9 +19,9 @@ import { i18n } from '@kbn/i18n'; import { geohashColumns } from 'ui/vis/map/decode_geo_hash'; -import chrome from '../../chrome'; +import chrome from 'ui/chrome'; import { BucketAggType, IBucketAggConfig } from './_bucket_agg_type'; -import { KBN_FIELD_TYPES } from '../../../../../plugins/data/public'; +import { KBN_FIELD_TYPES } from '../../../../../../../plugins/data/public'; import { geoContains, scaleBounds, GeoBoundingBox } from './lib/geo_utils'; import { BUCKET_TYPES } from './bucket_agg_types'; @@ -68,7 +68,7 @@ function getPrecision(val: string) { const isOutsideCollar = (bounds: GeoBoundingBox, collar: MapCollar) => bounds && collar && !geoContains(collar, bounds); -const geohashGridTitle = i18n.translate('common.ui.aggTypes.buckets.geohashGridTitle', { +const geohashGridTitle = i18n.translate('data.search.aggs.buckets.geohashGridTitle', { defaultMessage: 'Geohash', }); diff --git a/src/legacy/ui/public/agg_types/buckets/geo_tile.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/geo_tile.ts similarity index 92% rename from src/legacy/ui/public/agg_types/buckets/geo_tile.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/geo_tile.ts index ef71e3947566a7..57e8f6e8c5ded4 100644 --- a/src/legacy/ui/public/agg_types/buckets/geo_tile.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/geo_tile.ts @@ -23,11 +23,11 @@ import { AggConfigOptions } from '../agg_config'; import { BucketAggType } from './_bucket_agg_type'; import { BUCKET_TYPES } from './bucket_agg_types'; -import { KBN_FIELD_TYPES } from '../../../../../plugins/data/public'; +import { KBN_FIELD_TYPES } from '../../../../../../../plugins/data/public'; import { IBucketAggConfig } from './_bucket_agg_type'; import { METRIC_TYPES } from '../metrics/metric_agg_types'; -const geotileGridTitle = i18n.translate('common.ui.aggTypes.buckets.geotileGridTitle', { +const geotileGridTitle = i18n.translate('data.search.aggs.buckets.geotileGridTitle', { defaultMessage: 'Geotile', }); diff --git a/src/legacy/ui/public/agg_types/buckets/histogram.test.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/histogram.test.ts similarity index 100% rename from src/legacy/ui/public/agg_types/buckets/histogram.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/histogram.test.ts diff --git a/src/legacy/ui/public/agg_types/buckets/histogram.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/histogram.ts similarity index 96% rename from src/legacy/ui/public/agg_types/buckets/histogram.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/histogram.ts index 44327c7c19e6db..f7e9ef45961e04 100644 --- a/src/legacy/ui/public/agg_types/buckets/histogram.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/histogram.ts @@ -24,7 +24,7 @@ import { toastNotifications } from 'ui/notify'; import { npStart } from 'ui/new_platform'; import { BucketAggType, IBucketAggConfig } from './_bucket_agg_type'; import { createFilterHistogram } from './create_filter/histogram'; -import { KBN_FIELD_TYPES } from '../../../../../plugins/data/public'; +import { KBN_FIELD_TYPES } from '../../../../../../../plugins/data/public'; import { BUCKET_TYPES } from './bucket_agg_types'; export interface AutoBounds { @@ -41,7 +41,7 @@ const getUIConfig = () => npStart.core.uiSettings; export const histogramBucketAgg = new BucketAggType({ name: BUCKET_TYPES.HISTOGRAM, - title: i18n.translate('common.ui.aggTypes.buckets.histogramTitle', { + title: i18n.translate('data.search.aggs.buckets.histogramTitle', { defaultMessage: 'Histogram', }), ordered: {}, @@ -117,7 +117,7 @@ export const histogramBucketAgg = new BucketAggType({ .catch((e: Error) => { if (e.name === 'AbortError') return; toastNotifications.addWarning( - i18n.translate('common.ui.aggTypes.histogram.missingMaxMinValuesWarning', { + i18n.translate('data.search.aggs.histogram.missingMaxMinValuesWarning', { defaultMessage: 'Unable to retrieve max and min values to auto-scale histogram buckets. This may lead to poor visualization performance.', }) diff --git a/src/legacy/ui/public/agg_types/buckets/ip_range.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/ip_range.ts similarity index 93% rename from src/legacy/ui/public/agg_types/buckets/ip_range.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/ip_range.ts index 41141dabf507c5..e5497bef491651 100644 --- a/src/legacy/ui/public/agg_types/buckets/ip_range.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/ip_range.ts @@ -25,9 +25,9 @@ import { BUCKET_TYPES } from './bucket_agg_types'; // @ts-ignore import { createFilterIpRange } from './create_filter/ip_range'; -import { KBN_FIELD_TYPES, fieldFormats } from '../../../../../plugins/data/public'; +import { KBN_FIELD_TYPES, fieldFormats } from '../../../../../../../plugins/data/public'; -const ipRangeTitle = i18n.translate('common.ui.aggTypes.buckets.ipRangeTitle', { +const ipRangeTitle = i18n.translate('data.search.aggs.buckets.ipRangeTitle', { defaultMessage: 'IPv4 Range', }); @@ -57,7 +57,7 @@ export const ipRangeBucketAgg = new BucketAggType({ return new IpRangeFormat(); }, makeLabel(aggConfig) { - return i18n.translate('common.ui.aggTypes.buckets.ipRangeLabel', { + return i18n.translate('data.search.aggs.buckets.ipRangeLabel', { defaultMessage: '{fieldName} IP ranges', values: { fieldName: aggConfig.getFieldDisplayName(), diff --git a/src/legacy/ui/public/agg_types/buckets/lib/cidr_mask.test.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/lib/cidr_mask.test.ts similarity index 100% rename from src/legacy/ui/public/agg_types/buckets/lib/cidr_mask.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/lib/cidr_mask.test.ts diff --git a/src/legacy/ui/public/agg_types/buckets/lib/cidr_mask.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/lib/cidr_mask.ts similarity index 95% rename from src/legacy/ui/public/agg_types/buckets/lib/cidr_mask.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/lib/cidr_mask.ts index aadbbc8c822768..30c4e400fb806b 100644 --- a/src/legacy/ui/public/agg_types/buckets/lib/cidr_mask.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/lib/cidr_mask.ts @@ -17,7 +17,7 @@ * under the License. */ -import { Ipv4Address } from '../../../../../../plugins/kibana_utils/public'; +import { Ipv4Address } from '../../../../../../../../plugins/kibana_utils/public'; const NUM_BITS = 32; diff --git a/src/legacy/ui/public/agg_types/buckets/lib/geo_utils.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/lib/geo_utils.ts similarity index 100% rename from src/legacy/ui/public/agg_types/buckets/lib/geo_utils.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/lib/geo_utils.ts diff --git a/src/legacy/ui/public/agg_types/buckets/migrate_include_exclude_format.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/migrate_include_exclude_format.ts similarity index 100% rename from src/legacy/ui/public/agg_types/buckets/migrate_include_exclude_format.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/migrate_include_exclude_format.ts diff --git a/src/legacy/ui/public/agg_types/buckets/range.test.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/range.test.ts similarity index 97% rename from src/legacy/ui/public/agg_types/buckets/range.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/range.test.ts index dd85c3b31939f8..4c0fa7311461ee 100644 --- a/src/legacy/ui/public/agg_types/buckets/range.test.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/range.test.ts @@ -19,7 +19,7 @@ import { AggConfigs } from '../agg_configs'; import { BUCKET_TYPES } from './bucket_agg_types'; -import { fieldFormats } from '../../../../../plugins/data/public'; +import { fieldFormats } from '../../../../../../../plugins/data/public'; jest.mock('ui/new_platform'); diff --git a/src/legacy/ui/public/agg_types/buckets/range.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/range.ts similarity index 89% rename from src/legacy/ui/public/agg_types/buckets/range.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/range.ts index f24473e0c68aaa..f35db2cc759bda 100644 --- a/src/legacy/ui/public/agg_types/buckets/range.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/range.ts @@ -19,7 +19,7 @@ import { i18n } from '@kbn/i18n'; import { BucketAggType } from './_bucket_agg_type'; -import { fieldFormats, KBN_FIELD_TYPES } from '../../../../../plugins/data/public'; +import { fieldFormats, KBN_FIELD_TYPES } from '../../../../../../../plugins/data/public'; import { RangeKey } from './range_key'; import { createFilterRange } from './create_filter/range'; import { BUCKET_TYPES } from './bucket_agg_types'; @@ -27,7 +27,7 @@ import { BUCKET_TYPES } from './bucket_agg_types'; const keyCaches = new WeakMap(); const formats = new WeakMap(); -const rangeTitle = i18n.translate('common.ui.aggTypes.buckets.rangeTitle', { +const rangeTitle = i18n.translate('data.search.aggs.buckets.rangeTitle', { defaultMessage: 'Range', }); @@ -36,7 +36,7 @@ export const rangeBucketAgg = new BucketAggType({ title: rangeTitle, createFilter: createFilterRange, makeLabel(aggConfig) { - return i18n.translate('common.ui.aggTypes.buckets.rangesLabel', { + return i18n.translate('data.search.aggs.aggTypesLabel', { defaultMessage: '{fieldName} ranges', values: { fieldName: aggConfig.getFieldDisplayName(), @@ -69,7 +69,7 @@ export const rangeBucketAgg = new BucketAggType({ const format = agg.fieldOwnFormatter(); const gte = '\u2265'; const lt = '\u003c'; - return i18n.translate('common.ui.aggTypes.buckets.ranges.rangesFormatMessage', { + return i18n.translate('data.search.aggs.aggTypes.rangesFormatMessage', { defaultMessage: '{gte} {from} and {lt} {to}', values: { gte, diff --git a/src/legacy/ui/public/agg_types/buckets/range_key.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/range_key.ts similarity index 100% rename from src/legacy/ui/public/agg_types/buckets/range_key.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/range_key.ts diff --git a/src/legacy/ui/public/agg_types/buckets/significant_terms.test.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/significant_terms.test.ts similarity index 96% rename from src/legacy/ui/public/agg_types/buckets/significant_terms.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/significant_terms.test.ts index 8db9226e41eec7..37b829bfc20fb2 100644 --- a/src/legacy/ui/public/agg_types/buckets/significant_terms.test.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/significant_terms.test.ts @@ -18,6 +18,7 @@ */ import { AggConfigs } from '../index'; +import { IAggConfigs } from '../types'; import { BUCKET_TYPES } from './bucket_agg_types'; import { significantTermsBucketAgg } from './significant_terms'; import { IBucketAggConfig } from './_bucket_agg_type'; @@ -56,7 +57,7 @@ describe('Significant Terms Agg', () => { ); }; - const testSerializeAndWrite = (aggs: AggConfigs) => { + const testSerializeAndWrite = (aggs: IAggConfigs) => { const agg = aggs.aggs[0]; const { [BUCKET_TYPES.SIGNIFICANT_TERMS]: params } = agg.toDsl(); diff --git a/src/legacy/ui/public/agg_types/buckets/significant_terms.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/significant_terms.ts similarity index 82% rename from src/legacy/ui/public/agg_types/buckets/significant_terms.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/significant_terms.ts index 38ca0768d3bc1e..bc6c63d569b110 100644 --- a/src/legacy/ui/public/agg_types/buckets/significant_terms.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/significant_terms.ts @@ -22,9 +22,9 @@ import { BucketAggType } from './_bucket_agg_type'; import { createFilterTerms } from './create_filter/terms'; import { isStringType, migrateIncludeExcludeFormat } from './migrate_include_exclude_format'; import { BUCKET_TYPES } from './bucket_agg_types'; -import { KBN_FIELD_TYPES } from '../../../../../plugins/data/public'; +import { KBN_FIELD_TYPES } from '../../../../../../../plugins/data/public'; -const significantTermsTitle = i18n.translate('common.ui.aggTypes.buckets.significantTermsTitle', { +const significantTermsTitle = i18n.translate('data.search.aggs.buckets.significantTermsTitle', { defaultMessage: 'Significant Terms', }); @@ -32,7 +32,7 @@ export const significantTermsBucketAgg = new BucketAggType({ name: BUCKET_TYPES.SIGNIFICANT_TERMS, title: significantTermsTitle, makeLabel(aggConfig) { - return i18n.translate('common.ui.aggTypes.buckets.significantTermsLabel', { + return i18n.translate('data.search.aggs.buckets.significantTermsLabel', { defaultMessage: 'Top {size} unusual terms in {fieldName}', values: { size: aggConfig.params.size, @@ -54,7 +54,7 @@ export const significantTermsBucketAgg = new BucketAggType({ }, { name: 'exclude', - displayName: i18n.translate('common.ui.aggTypes.buckets.significantTerms.excludeLabel', { + displayName: i18n.translate('data.search.aggs.buckets.significantTerms.excludeLabel', { defaultMessage: 'Exclude', }), type: 'string', @@ -64,7 +64,7 @@ export const significantTermsBucketAgg = new BucketAggType({ }, { name: 'include', - displayName: i18n.translate('common.ui.aggTypes.buckets.significantTerms.includeLabel', { + displayName: i18n.translate('data.search.aggs.buckets.significantTerms.includeLabel', { defaultMessage: 'Include', }), type: 'string', diff --git a/src/legacy/ui/public/agg_types/buckets/terms.test.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/terms.test.ts similarity index 100% rename from src/legacy/ui/public/agg_types/buckets/terms.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/terms.test.ts diff --git a/src/legacy/ui/public/agg_types/buckets/terms.ts b/src/legacy/core_plugins/data/public/search/aggs/buckets/terms.ts similarity index 85% rename from src/legacy/ui/public/agg_types/buckets/terms.ts rename to src/legacy/core_plugins/data/public/search/aggs/buckets/terms.ts index 4ced1417402b57..b41b16af122fa8 100644 --- a/src/legacy/ui/public/agg_types/buckets/terms.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/buckets/terms.ts @@ -19,19 +19,20 @@ import { noop } from 'lodash'; import { i18n } from '@kbn/i18n'; -import { - getRequestInspectorStats, - getResponseInspectorStats, -} from '../../../../core_plugins/data/public'; +import { getRequestInspectorStats, getResponseInspectorStats } from '../../../index'; import { BucketAggType } from './_bucket_agg_type'; import { BUCKET_TYPES } from './bucket_agg_types'; import { IBucketAggConfig } from './_bucket_agg_type'; import { createFilterTerms } from './create_filter/terms'; import { isStringType, migrateIncludeExcludeFormat } from './migrate_include_exclude_format'; -import { AggConfigs } from '../agg_configs'; +import { IAggConfigs } from '../agg_configs'; -import { Adapters } from '../../../../../plugins/inspector/public'; -import { ISearchSource, fieldFormats, KBN_FIELD_TYPES } from '../../../../../plugins/data/public'; +import { Adapters } from '../../../../../../../plugins/inspector/public'; +import { + ISearchSource, + fieldFormats, + KBN_FIELD_TYPES, +} from '../../../../../../../plugins/data/public'; import { buildOtherBucketAgg, @@ -68,7 +69,7 @@ const [orderAggSchema] = new Schemas([ }, ]).all; -const termsTitle = i18n.translate('common.ui.aggTypes.buckets.termsTitle', { +const termsTitle = i18n.translate('data.search.aggs.buckets.termsTitle', { defaultMessage: 'Terms', }); @@ -98,7 +99,7 @@ export const termsBucketAgg = new BucketAggType({ createFilter: createFilterTerms, postFlightRequest: async ( resp: any, - aggConfigs: AggConfigs, + aggConfigs: IAggConfigs, aggConfig: IBucketAggConfig, searchSource: ISearchSource, inspectorAdapters: Adapters, @@ -113,11 +114,11 @@ export const termsBucketAgg = new BucketAggType({ nestedSearchSource.setField('aggs', filterAgg); const request = inspectorAdapters.requests.start( - i18n.translate('common.ui.aggTypes.buckets.terms.otherBucketTitle', { + i18n.translate('data.search.aggs.buckets.terms.otherBucketTitle', { defaultMessage: 'Other bucket', }), { - description: i18n.translate('common.ui.aggTypes.buckets.terms.otherBucketDescription', { + description: i18n.translate('data.search.aggs.buckets.terms.otherBucketDescription', { defaultMessage: 'This request counts the number of documents that fall ' + 'outside the criterion of the data buckets.', @@ -212,13 +213,13 @@ export const termsBucketAgg = new BucketAggType({ default: 'desc', options: [ { - text: i18n.translate('common.ui.aggTypes.buckets.terms.orderDescendingTitle', { + text: i18n.translate('data.search.aggs.buckets.terms.orderDescendingTitle', { defaultMessage: 'Descending', }), value: 'desc', }, { - text: i18n.translate('common.ui.aggTypes.buckets.terms.orderAscendingTitle', { + text: i18n.translate('data.search.aggs.buckets.terms.orderAscendingTitle', { defaultMessage: 'Ascending', }), value: 'asc', @@ -238,10 +239,10 @@ export const termsBucketAgg = new BucketAggType({ { name: 'otherBucketLabel', type: 'string', - default: i18n.translate('common.ui.aggTypes.buckets.terms.otherBucketLabel', { + default: i18n.translate('data.search.aggs.buckets.terms.otherBucketLabel', { defaultMessage: 'Other', }), - displayName: i18n.translate('common.ui.aggTypes.otherBucket.labelForOtherBucketLabel', { + displayName: i18n.translate('data.search.aggs.otherBucket.labelForOtherBucketLabel', { defaultMessage: 'Label for other bucket', }), shouldShow: agg => agg.getParam('otherBucket'), @@ -254,13 +255,13 @@ export const termsBucketAgg = new BucketAggType({ }, { name: 'missingBucketLabel', - default: i18n.translate('common.ui.aggTypes.buckets.terms.missingBucketLabel', { + default: i18n.translate('data.search.aggs.buckets.terms.missingBucketLabel', { defaultMessage: 'Missing', description: `Default label used in charts when documents are missing a field. Visible when you create a chart with a terms aggregation and enable "Show missing values"`, }), type: 'string', - displayName: i18n.translate('common.ui.aggTypes.otherBucket.labelForMissingValuesLabel', { + displayName: i18n.translate('data.search.aggs.otherBucket.labelForMissingValuesLabel', { defaultMessage: 'Label for missing values', }), shouldShow: agg => agg.getParam('missingBucket'), @@ -268,7 +269,7 @@ export const termsBucketAgg = new BucketAggType({ }, { name: 'exclude', - displayName: i18n.translate('common.ui.aggTypes.buckets.terms.excludeLabel', { + displayName: i18n.translate('data.search.aggs.buckets.terms.excludeLabel', { defaultMessage: 'Exclude', }), type: 'string', @@ -278,7 +279,7 @@ export const termsBucketAgg = new BucketAggType({ }, { name: 'include', - displayName: i18n.translate('common.ui.aggTypes.buckets.terms.includeLabel', { + displayName: i18n.translate('data.search.aggs.buckets.terms.includeLabel', { defaultMessage: 'Include', }), type: 'string', diff --git a/src/legacy/ui/public/agg_types/filter/agg_type_filters.test.ts b/src/legacy/core_plugins/data/public/search/aggs/filter/agg_type_filters.test.ts similarity index 88% rename from src/legacy/ui/public/agg_types/filter/agg_type_filters.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/filter/agg_type_filters.test.ts index 0344f304877f24..cc1288d339692f 100644 --- a/src/legacy/ui/public/agg_types/filter/agg_type_filters.test.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/filter/agg_type_filters.test.ts @@ -17,9 +17,10 @@ * under the License. */ -import { IndexPattern } from '../../../../../plugins/data/public'; +import { IndexPattern } from '../../../../../../../plugins/data/public'; import { AggTypeFilters } from './agg_type_filters'; -import { AggConfig, AggType } from '..'; +import { AggConfig } from '..'; +import { IAggType } from '../types'; describe('AggTypeFilters', () => { let registry: AggTypeFilters; @@ -31,13 +32,13 @@ describe('AggTypeFilters', () => { }); it('should filter nothing without registered filters', async () => { - const aggTypes = [{ name: 'count' }, { name: 'sum' }] as AggType[]; + const aggTypes = [{ name: 'count' }, { name: 'sum' }] as IAggType[]; const filtered = registry.filter(aggTypes, indexPattern, aggConfig); expect(filtered).toEqual(aggTypes); }); it('should pass all aggTypes to the registered filter', async () => { - const aggTypes = [{ name: 'count' }, { name: 'sum' }] as AggType[]; + const aggTypes = [{ name: 'count' }, { name: 'sum' }] as IAggType[]; const filter = jest.fn(); registry.addFilter(filter); registry.filter(aggTypes, indexPattern, aggConfig); @@ -46,7 +47,7 @@ describe('AggTypeFilters', () => { }); it('should allow registered filters to filter out aggTypes', async () => { - const aggTypes = [{ name: 'count' }, { name: 'sum' }, { name: 'avg' }] as AggType[]; + const aggTypes = [{ name: 'count' }, { name: 'sum' }, { name: 'avg' }] as IAggType[]; let filtered = registry.filter(aggTypes, indexPattern, aggConfig); expect(filtered).toEqual(aggTypes); diff --git a/src/legacy/ui/public/agg_types/filter/agg_type_filters.ts b/src/legacy/core_plugins/data/public/search/aggs/filter/agg_type_filters.ts similarity index 92% rename from src/legacy/ui/public/agg_types/filter/agg_type_filters.ts rename to src/legacy/core_plugins/data/public/search/aggs/filter/agg_type_filters.ts index 2cc4a6e962214b..d3b38ce041d7ee 100644 --- a/src/legacy/ui/public/agg_types/filter/agg_type_filters.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/filter/agg_type_filters.ts @@ -17,12 +17,12 @@ * under the License. */ import { IndexPattern } from 'src/plugins/data/public'; -import { AggType, AggConfig } from '..'; +import { IAggConfig, IAggType } from '../types'; type AggTypeFilter = ( - aggType: AggType, + aggType: IAggType, indexPattern: IndexPattern, - aggConfig: AggConfig + aggConfig: IAggConfig ) => boolean; /** @@ -49,7 +49,7 @@ class AggTypeFilters { * @param aggConfig The aggConfig for which the returning list will be used. * @return A filtered list of the passed aggTypes. */ - public filter(aggTypes: AggType[], indexPattern: IndexPattern, aggConfig: AggConfig) { + public filter(aggTypes: IAggType[], indexPattern: IndexPattern, aggConfig: IAggConfig) { const allFilters = Array.from(this.filters); const allowedAggTypes = aggTypes.filter(aggType => { const isAggTypeAllowed = allFilters.every(filter => filter(aggType, indexPattern, aggConfig)); diff --git a/src/legacy/ui/public/agg_types/filter/index.ts b/src/legacy/core_plugins/data/public/search/aggs/filter/index.ts similarity index 100% rename from src/legacy/ui/public/agg_types/filter/index.ts rename to src/legacy/core_plugins/data/public/search/aggs/filter/index.ts diff --git a/src/legacy/ui/public/agg_types/filter/prop_filter.test.ts b/src/legacy/core_plugins/data/public/search/aggs/filter/prop_filter.test.ts similarity index 100% rename from src/legacy/ui/public/agg_types/filter/prop_filter.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/filter/prop_filter.test.ts diff --git a/src/legacy/ui/public/agg_types/filter/prop_filter.ts b/src/legacy/core_plugins/data/public/search/aggs/filter/prop_filter.ts similarity index 100% rename from src/legacy/ui/public/agg_types/filter/prop_filter.ts rename to src/legacy/core_plugins/data/public/search/aggs/filter/prop_filter.ts diff --git a/src/legacy/ui/public/agg_types/index.test.ts b/src/legacy/core_plugins/data/public/search/aggs/index.test.ts similarity index 100% rename from src/legacy/ui/public/agg_types/index.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/index.test.ts diff --git a/src/legacy/core_plugins/data/public/search/aggs/index.ts b/src/legacy/core_plugins/data/public/search/aggs/index.ts new file mode 100644 index 00000000000000..0fef7f38aae742 --- /dev/null +++ b/src/legacy/core_plugins/data/public/search/aggs/index.ts @@ -0,0 +1,52 @@ +/* + * 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. + */ + +export { aggTypes } from './agg_types'; +export { AggType } from './agg_type'; +export { AggConfig } from './agg_config'; +export { AggConfigs } from './agg_configs'; +export { FieldParamType } from './param_types'; +export { MetricAggType } from './metrics/metric_agg_type'; +export { AggTypeFilters } from './filter'; +export { aggTypeFieldFilters, AggTypeFieldFilters } from './param_types/filter'; +export { + parentPipelineAggHelper, + parentPipelineType, +} from './metrics/lib/parent_pipeline_agg_helper'; +export { + siblingPipelineAggHelper, + siblingPipelineType, +} from './metrics/lib/sibling_pipeline_agg_helper'; + +// static code +export { AggParamType } from './param_types/agg'; +export { AggGroupNames, aggGroupNamesMap } from './agg_groups'; +export { intervalOptions } from './buckets/_interval_options'; // only used in Discover +export { isDateHistogramBucketAggConfig, setBounds } from './buckets/date_histogram'; +export { termsAggFilter } from './buckets/terms'; +export { isType, isStringType } from './buckets/migrate_include_exclude_format'; +export { CidrMask } from './buckets/lib/cidr_mask'; +export { convertDateRangeToString } from './buckets/date_range'; +export { convertIPRangeToString } from './buckets/ip_range'; +export { aggTypeFilters, propFilter } from './filter'; +export { OptionedParamType } from './param_types/optioned'; +export { isValidJson, isValidInterval } from './utils'; +export { BUCKET_TYPES } from './buckets/bucket_agg_types'; +export { METRIC_TYPES } from './metrics/metric_agg_types'; +export { ISchemas, Schema, Schemas } from './schemas'; diff --git a/src/legacy/ui/public/agg_types/metrics/avg.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/avg.ts similarity index 85% rename from src/legacy/ui/public/agg_types/metrics/avg.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/avg.ts index 0222a8e5432231..b80671a43d2afa 100644 --- a/src/legacy/ui/public/agg_types/metrics/avg.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/avg.ts @@ -20,9 +20,9 @@ import { i18n } from '@kbn/i18n'; import { MetricAggType } from './metric_agg_type'; import { METRIC_TYPES } from './metric_agg_types'; -import { KBN_FIELD_TYPES } from '../../../../../plugins/data/public'; +import { KBN_FIELD_TYPES } from '../../../../../../../plugins/data/public'; -const averageTitle = i18n.translate('common.ui.aggTypes.metrics.averageTitle', { +const averageTitle = i18n.translate('data.search.aggs.metrics.averageTitle', { defaultMessage: 'Average', }); @@ -30,7 +30,7 @@ export const avgMetricAgg = new MetricAggType({ name: METRIC_TYPES.AVG, title: averageTitle, makeLabel: aggConfig => { - return i18n.translate('common.ui.aggTypes.metrics.averageLabel', { + return i18n.translate('data.search.aggs.metrics.averageLabel', { defaultMessage: 'Average {field}', values: { field: aggConfig.getFieldDisplayName() }, }); diff --git a/src/legacy/ui/public/agg_types/metrics/bucket_avg.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/bucket_avg.ts similarity index 91% rename from src/legacy/ui/public/agg_types/metrics/bucket_avg.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/bucket_avg.ts index 7142546dbd494a..9fb28f8631bc63 100644 --- a/src/legacy/ui/public/agg_types/metrics/bucket_avg.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/bucket_avg.ts @@ -25,11 +25,11 @@ import { makeNestedLabel } from './lib/make_nested_label'; import { siblingPipelineAggHelper } from './lib/sibling_pipeline_agg_helper'; import { METRIC_TYPES } from './metric_agg_types'; -const overallAverageLabel = i18n.translate('common.ui.aggTypes.metrics.overallAverageLabel', { +const overallAverageLabel = i18n.translate('data.search.aggs.metrics.overallAverageLabel', { defaultMessage: 'overall average', }); -const averageBucketTitle = i18n.translate('common.ui.aggTypes.metrics.averageBucketTitle', { +const averageBucketTitle = i18n.translate('data.search.aggs.metrics.averageBucketTitle', { defaultMessage: 'Average Bucket', }); diff --git a/src/legacy/ui/public/agg_types/metrics/bucket_max.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/bucket_max.ts similarity index 89% rename from src/legacy/ui/public/agg_types/metrics/bucket_max.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/bucket_max.ts index aa5b0521709a55..83837f0de51146 100644 --- a/src/legacy/ui/public/agg_types/metrics/bucket_max.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/bucket_max.ts @@ -24,11 +24,11 @@ import { makeNestedLabel } from './lib/make_nested_label'; import { siblingPipelineAggHelper } from './lib/sibling_pipeline_agg_helper'; import { METRIC_TYPES } from './metric_agg_types'; -const overallMaxLabel = i18n.translate('common.ui.aggTypes.metrics.overallMaxLabel', { +const overallMaxLabel = i18n.translate('data.search.aggs.metrics.overallMaxLabel', { defaultMessage: 'overall max', }); -const maxBucketTitle = i18n.translate('common.ui.aggTypes.metrics.maxBucketTitle', { +const maxBucketTitle = i18n.translate('data.search.aggs.metrics.maxBucketTitle', { defaultMessage: 'Max Bucket', }); diff --git a/src/legacy/ui/public/agg_types/metrics/bucket_min.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/bucket_min.ts similarity index 89% rename from src/legacy/ui/public/agg_types/metrics/bucket_min.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/bucket_min.ts index b5c0b8865e1068..d96197693dc2ee 100644 --- a/src/legacy/ui/public/agg_types/metrics/bucket_min.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/bucket_min.ts @@ -22,11 +22,11 @@ import { makeNestedLabel } from './lib/make_nested_label'; import { siblingPipelineAggHelper } from './lib/sibling_pipeline_agg_helper'; import { METRIC_TYPES } from './metric_agg_types'; -const overallMinLabel = i18n.translate('common.ui.aggTypes.metrics.overallMinLabel', { +const overallMinLabel = i18n.translate('data.search.aggs.metrics.overallMinLabel', { defaultMessage: 'overall min', }); -const minBucketTitle = i18n.translate('common.ui.aggTypes.metrics.minBucketTitle', { +const minBucketTitle = i18n.translate('data.search.aggs.metrics.minBucketTitle', { defaultMessage: 'Min Bucket', }); diff --git a/src/legacy/ui/public/agg_types/metrics/bucket_sum.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/bucket_sum.ts similarity index 89% rename from src/legacy/ui/public/agg_types/metrics/bucket_sum.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/bucket_sum.ts index d4faa81c4041c7..1f9392c5bec359 100644 --- a/src/legacy/ui/public/agg_types/metrics/bucket_sum.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/bucket_sum.ts @@ -23,11 +23,11 @@ import { makeNestedLabel } from './lib/make_nested_label'; import { siblingPipelineAggHelper } from './lib/sibling_pipeline_agg_helper'; import { METRIC_TYPES } from './metric_agg_types'; -const overallSumLabel = i18n.translate('common.ui.aggTypes.metrics.overallSumLabel', { +const overallSumLabel = i18n.translate('data.search.aggs.metrics.overallSumLabel', { defaultMessage: 'overall sum', }); -const sumBucketTitle = i18n.translate('common.ui.aggTypes.metrics.sumBucketTitle', { +const sumBucketTitle = i18n.translate('data.search.aggs.metrics.sumBucketTitle', { defaultMessage: 'Sum Bucket', }); diff --git a/src/legacy/ui/public/agg_types/metrics/cardinality.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/cardinality.ts similarity index 86% rename from src/legacy/ui/public/agg_types/metrics/cardinality.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/cardinality.ts index c69ffae3b48716..147e9255210887 100644 --- a/src/legacy/ui/public/agg_types/metrics/cardinality.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/cardinality.ts @@ -21,9 +21,9 @@ import { i18n } from '@kbn/i18n'; import { npStart } from 'ui/new_platform'; import { MetricAggType } from './metric_agg_type'; import { METRIC_TYPES } from './metric_agg_types'; -import { KBN_FIELD_TYPES } from '../../../../../plugins/data/public'; +import { KBN_FIELD_TYPES } from '../../../../../../../plugins/data/public'; -const uniqueCountTitle = i18n.translate('common.ui.aggTypes.metrics.uniqueCountTitle', { +const uniqueCountTitle = i18n.translate('data.search.aggs.metrics.uniqueCountTitle', { defaultMessage: 'Unique Count', }); @@ -31,7 +31,7 @@ export const cardinalityMetricAgg = new MetricAggType({ name: METRIC_TYPES.CARDINALITY, title: uniqueCountTitle, makeLabel(aggConfig) { - return i18n.translate('common.ui.aggTypes.metrics.uniqueCountLabel', { + return i18n.translate('data.search.aggs.metrics.uniqueCountLabel', { defaultMessage: 'Unique count of {field}', values: { field: aggConfig.getFieldDisplayName() }, }); diff --git a/src/legacy/ui/public/agg_types/metrics/count.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/count.ts similarity index 87% rename from src/legacy/ui/public/agg_types/metrics/count.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/count.ts index 22a939cd9a3fd0..14a9bd073ff2bc 100644 --- a/src/legacy/ui/public/agg_types/metrics/count.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/count.ts @@ -19,18 +19,18 @@ import { i18n } from '@kbn/i18n'; import { npStart } from 'ui/new_platform'; -import { KBN_FIELD_TYPES } from '../../../../../plugins/data/public'; +import { KBN_FIELD_TYPES } from '../../../../../../../plugins/data/public'; import { MetricAggType } from './metric_agg_type'; import { METRIC_TYPES } from './metric_agg_types'; export const countMetricAgg = new MetricAggType({ name: METRIC_TYPES.COUNT, - title: i18n.translate('common.ui.aggTypes.metrics.countTitle', { + title: i18n.translate('data.search.aggs.metrics.countTitle', { defaultMessage: 'Count', }), hasNoDsl: true, makeLabel() { - return i18n.translate('common.ui.aggTypes.metrics.countLabel', { + return i18n.translate('data.search.aggs.metrics.countLabel', { defaultMessage: 'Count', }); }, diff --git a/src/legacy/ui/public/agg_types/metrics/cumulative_sum.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/cumulative_sum.ts similarity index 88% rename from src/legacy/ui/public/agg_types/metrics/cumulative_sum.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/cumulative_sum.ts index bad2de8cb16dc1..a5d02459900bb0 100644 --- a/src/legacy/ui/public/agg_types/metrics/cumulative_sum.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/cumulative_sum.ts @@ -23,11 +23,11 @@ import { parentPipelineAggHelper } from './lib/parent_pipeline_agg_helper'; import { makeNestedLabel } from './lib/make_nested_label'; import { METRIC_TYPES } from './metric_agg_types'; -const cumulativeSumLabel = i18n.translate('common.ui.aggTypes.metrics.cumulativeSumLabel', { +const cumulativeSumLabel = i18n.translate('data.search.aggs.metrics.cumulativeSumLabel', { defaultMessage: 'cumulative sum', }); -const cumulativeSumTitle = i18n.translate('common.ui.aggTypes.metrics.cumulativeSumTitle', { +const cumulativeSumTitle = i18n.translate('data.search.aggs.metrics.cumulativeSumTitle', { defaultMessage: 'Cumulative Sum', }); diff --git a/src/legacy/ui/public/agg_types/metrics/derivative.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/derivative.ts similarity index 89% rename from src/legacy/ui/public/agg_types/metrics/derivative.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/derivative.ts index 42921621a29336..1169a527b0668c 100644 --- a/src/legacy/ui/public/agg_types/metrics/derivative.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/derivative.ts @@ -23,11 +23,11 @@ import { parentPipelineAggHelper } from './lib/parent_pipeline_agg_helper'; import { makeNestedLabel } from './lib/make_nested_label'; import { METRIC_TYPES } from './metric_agg_types'; -const derivativeLabel = i18n.translate('common.ui.aggTypes.metrics.derivativeLabel', { +const derivativeLabel = i18n.translate('data.search.aggs.metrics.derivativeLabel', { defaultMessage: 'derivative', }); -const derivativeTitle = i18n.translate('common.ui.aggTypes.metrics.derivativeTitle', { +const derivativeTitle = i18n.translate('data.search.aggs.metrics.derivativeTitle', { defaultMessage: 'Derivative', }); diff --git a/src/legacy/ui/public/agg_types/metrics/geo_bounds.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/geo_bounds.ts similarity index 84% rename from src/legacy/ui/public/agg_types/metrics/geo_bounds.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/geo_bounds.ts index b8ce03cdf11eca..53bc72f9ce1dac 100644 --- a/src/legacy/ui/public/agg_types/metrics/geo_bounds.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/geo_bounds.ts @@ -20,13 +20,13 @@ import { i18n } from '@kbn/i18n'; import { MetricAggType } from './metric_agg_type'; import { METRIC_TYPES } from './metric_agg_types'; -import { KBN_FIELD_TYPES } from '../../../../../plugins/data/public'; +import { KBN_FIELD_TYPES } from '../../../../../../../plugins/data/public'; -const geoBoundsTitle = i18n.translate('common.ui.aggTypes.metrics.geoBoundsTitle', { +const geoBoundsTitle = i18n.translate('data.search.aggs.metrics.geoBoundsTitle', { defaultMessage: 'Geo Bounds', }); -const geoBoundsLabel = i18n.translate('common.ui.aggTypes.metrics.geoBoundsLabel', { +const geoBoundsLabel = i18n.translate('data.search.aggs.metrics.geoBoundsLabel', { defaultMessage: 'Geo Bounds', }); diff --git a/src/legacy/ui/public/agg_types/metrics/geo_centroid.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/geo_centroid.ts similarity index 84% rename from src/legacy/ui/public/agg_types/metrics/geo_centroid.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/geo_centroid.ts index 5313e31796a5b8..a79b2b34ad1cad 100644 --- a/src/legacy/ui/public/agg_types/metrics/geo_centroid.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/geo_centroid.ts @@ -20,13 +20,13 @@ import { i18n } from '@kbn/i18n'; import { MetricAggType } from './metric_agg_type'; import { METRIC_TYPES } from './metric_agg_types'; -import { KBN_FIELD_TYPES } from '../../../../../plugins/data/public'; +import { KBN_FIELD_TYPES } from '../../../../../../../plugins/data/public'; -const geoCentroidTitle = i18n.translate('common.ui.aggTypes.metrics.geoCentroidTitle', { +const geoCentroidTitle = i18n.translate('data.search.aggs.metrics.geoCentroidTitle', { defaultMessage: 'Geo Centroid', }); -const geoCentroidLabel = i18n.translate('common.ui.aggTypes.metrics.geoCentroidLabel', { +const geoCentroidLabel = i18n.translate('data.search.aggs.metrics.geoCentroidLabel', { defaultMessage: 'Geo Centroid', }); diff --git a/src/legacy/ui/public/agg_types/metrics/lib/get_response_agg_config_class.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/lib/get_response_agg_config_class.ts similarity index 100% rename from src/legacy/ui/public/agg_types/metrics/lib/get_response_agg_config_class.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/lib/get_response_agg_config_class.ts diff --git a/src/legacy/ui/public/agg_types/metrics/lib/make_nested_label.test.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/lib/make_nested_label.test.ts similarity index 100% rename from src/legacy/ui/public/agg_types/metrics/lib/make_nested_label.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/lib/make_nested_label.test.ts diff --git a/src/legacy/ui/public/agg_types/metrics/lib/make_nested_label.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/lib/make_nested_label.ts similarity index 100% rename from src/legacy/ui/public/agg_types/metrics/lib/make_nested_label.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/lib/make_nested_label.ts diff --git a/src/legacy/ui/public/agg_types/metrics/lib/nested_agg_helpers.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/lib/nested_agg_helpers.ts similarity index 100% rename from src/legacy/ui/public/agg_types/metrics/lib/nested_agg_helpers.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/lib/nested_agg_helpers.ts diff --git a/src/legacy/ui/public/agg_types/metrics/lib/ordinal_suffix.test.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/lib/ordinal_suffix.test.ts similarity index 100% rename from src/legacy/ui/public/agg_types/metrics/lib/ordinal_suffix.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/lib/ordinal_suffix.test.ts diff --git a/src/legacy/ui/public/agg_types/metrics/lib/ordinal_suffix.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/lib/ordinal_suffix.ts similarity index 100% rename from src/legacy/ui/public/agg_types/metrics/lib/ordinal_suffix.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/lib/ordinal_suffix.ts diff --git a/src/legacy/ui/public/agg_types/metrics/lib/parent_pipeline_agg_helper.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/lib/parent_pipeline_agg_helper.ts similarity index 94% rename from src/legacy/ui/public/agg_types/metrics/lib/parent_pipeline_agg_helper.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/lib/parent_pipeline_agg_helper.ts index 4d558e50304e6e..0d1b2472bb8e21 100644 --- a/src/legacy/ui/public/agg_types/metrics/lib/parent_pipeline_agg_helper.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/lib/parent_pipeline_agg_helper.ts @@ -36,7 +36,7 @@ const metricAggFilter = [ '!geo_centroid', ]; -const metricAggTitle = i18n.translate('common.ui.aggTypes.metrics.metricAggTitle', { +const metricAggTitle = i18n.translate('data.search.aggs.metrics.metricAggTitle', { defaultMessage: 'Metric agg', }); @@ -51,7 +51,7 @@ const [metricAggSchema] = new Schemas([ ]).all; const parentPipelineType = i18n.translate( - 'common.ui.aggTypes.metrics.parentPipelineAggregationsSubtypeTitle', + 'data.search.aggs.metrics.parentPipelineAggregationsSubtypeTitle', { defaultMessage: 'Parent Pipeline Aggregations', } diff --git a/src/legacy/ui/public/agg_types/metrics/lib/parent_pipeline_agg_writer.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/lib/parent_pipeline_agg_writer.ts similarity index 94% rename from src/legacy/ui/public/agg_types/metrics/lib/parent_pipeline_agg_writer.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/lib/parent_pipeline_agg_writer.ts index 684fe721a754a2..bc0359b2a213d6 100644 --- a/src/legacy/ui/public/agg_types/metrics/lib/parent_pipeline_agg_writer.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/lib/parent_pipeline_agg_writer.ts @@ -17,13 +17,13 @@ * under the License. */ -import { AggConfigs } from '../../agg_configs'; +import { IAggConfigs } from '../../agg_configs'; import { IMetricAggConfig } from '../metric_agg_type'; export const parentPipelineAggWriter = ( agg: IMetricAggConfig, output: Record, - aggConfigs?: AggConfigs + aggConfigs?: IAggConfigs ): void => { const customMetric = agg.getParam('customMetric'); const metricAgg = agg.getParam('metricAgg'); diff --git a/src/legacy/ui/public/agg_types/metrics/lib/sibling_pipeline_agg_helper.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/lib/sibling_pipeline_agg_helper.ts similarity index 93% rename from src/legacy/ui/public/agg_types/metrics/lib/sibling_pipeline_agg_helper.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/lib/sibling_pipeline_agg_helper.ts index 9dd737bd6708e4..3956bda1812ad1 100644 --- a/src/legacy/ui/public/agg_types/metrics/lib/sibling_pipeline_agg_helper.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/lib/sibling_pipeline_agg_helper.ts @@ -47,7 +47,7 @@ const [metricAggSchema] = new Schemas([ { group: 'none', name: 'metricAgg', - title: i18n.translate('common.ui.aggTypes.metrics.metricAggTitle', { + title: i18n.translate('data.search.aggs.metrics.metricAggTitle', { defaultMessage: 'Metric agg', }), aggFilter: metricAggFilter, @@ -57,7 +57,7 @@ const [metricAggSchema] = new Schemas([ const [bucketAggSchema] = new Schemas([ { group: 'none', - title: i18n.translate('common.ui.aggTypes.metrics.bucketAggTitle', { + title: i18n.translate('data.search.aggs.metrics.bucketAggTitle', { defaultMessage: 'Bucket agg', }), name: 'bucketAgg', @@ -66,7 +66,7 @@ const [bucketAggSchema] = new Schemas([ ]).all; const siblingPipelineType = i18n.translate( - 'common.ui.aggTypes.metrics.siblingPipelineAggregationsSubtypeTitle', + 'data.search.aggs.metrics.siblingPipelineAggregationsSubtypeTitle', { defaultMessage: 'Sibling pipeline aggregations', } diff --git a/src/legacy/ui/public/agg_types/metrics/lib/sibling_pipeline_agg_writer.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/lib/sibling_pipeline_agg_writer.ts similarity index 100% rename from src/legacy/ui/public/agg_types/metrics/lib/sibling_pipeline_agg_writer.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/lib/sibling_pipeline_agg_writer.ts diff --git a/src/legacy/ui/public/agg_types/metrics/max.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/max.ts similarity index 86% rename from src/legacy/ui/public/agg_types/metrics/max.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/max.ts index 5c43511acee72c..d561788936b51e 100644 --- a/src/legacy/ui/public/agg_types/metrics/max.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/max.ts @@ -20,9 +20,9 @@ import { i18n } from '@kbn/i18n'; import { MetricAggType } from './metric_agg_type'; import { METRIC_TYPES } from './metric_agg_types'; -import { KBN_FIELD_TYPES } from '../../../../../plugins/data/public'; +import { KBN_FIELD_TYPES } from '../../../../../../../plugins/data/public'; -const maxTitle = i18n.translate('common.ui.aggTypes.metrics.maxTitle', { +const maxTitle = i18n.translate('data.search.aggs.metrics.maxTitle', { defaultMessage: 'Max', }); @@ -30,7 +30,7 @@ export const maxMetricAgg = new MetricAggType({ name: METRIC_TYPES.MAX, title: maxTitle, makeLabel(aggConfig) { - return i18n.translate('common.ui.aggTypes.metrics.maxLabel', { + return i18n.translate('data.search.aggs.metrics.maxLabel', { defaultMessage: 'Max {field}', values: { field: aggConfig.getFieldDisplayName() }, }); diff --git a/src/legacy/ui/public/agg_types/metrics/median.test.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/median.test.ts similarity index 95% rename from src/legacy/ui/public/agg_types/metrics/median.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/median.test.ts index 819c24f135cdc1..9affb0e3b28140 100644 --- a/src/legacy/ui/public/agg_types/metrics/median.test.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/median.test.ts @@ -17,13 +17,13 @@ * under the License. */ -import { AggConfigs } from '../agg_configs'; +import { AggConfigs, IAggConfigs } from '../agg_configs'; import { METRIC_TYPES } from './metric_agg_types'; jest.mock('ui/new_platform'); describe('AggTypeMetricMedianProvider class', () => { - let aggConfigs: AggConfigs; + let aggConfigs: IAggConfigs; beforeEach(() => { const field = { diff --git a/src/legacy/ui/public/agg_types/metrics/median.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/median.ts similarity index 88% rename from src/legacy/ui/public/agg_types/metrics/median.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/median.ts index 5792d4a7c2ba3b..be080aaa5ee6f3 100644 --- a/src/legacy/ui/public/agg_types/metrics/median.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/median.ts @@ -22,9 +22,9 @@ import { METRIC_TYPES } from './metric_agg_types'; // @ts-ignore import { percentilesMetricAgg } from './percentiles'; -import { KBN_FIELD_TYPES } from '../../../../../plugins/data/public'; +import { KBN_FIELD_TYPES } from '../../../../../../../plugins/data/public'; -const medianTitle = i18n.translate('common.ui.aggTypes.metrics.medianTitle', { +const medianTitle = i18n.translate('data.search.aggs.metrics.medianTitle', { defaultMessage: 'Median', }); @@ -33,7 +33,7 @@ export const medianMetricAgg = new MetricAggType({ dslName: 'percentiles', title: medianTitle, makeLabel(aggConfig) { - return i18n.translate('common.ui.aggTypes.metrics.medianLabel', { + return i18n.translate('data.search.aggs.metrics.medianLabel', { defaultMessage: 'Median {field}', values: { field: aggConfig.getFieldDisplayName() }, }); diff --git a/src/legacy/ui/public/agg_types/metrics/metric_agg_type.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/metric_agg_type.ts similarity index 92% rename from src/legacy/ui/public/agg_types/metrics/metric_agg_type.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/metric_agg_type.ts index 5cd3dffb10b9db..e7d286c187ef87 100644 --- a/src/legacy/ui/public/agg_types/metrics/metric_agg_type.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/metric_agg_type.ts @@ -23,7 +23,7 @@ import { AggType, AggTypeConfig } from '../agg_type'; import { AggParamType } from '../param_types/agg'; import { AggConfig } from '../agg_config'; import { METRIC_TYPES } from './metric_agg_types'; -import { KBN_FIELD_TYPES } from '../../../../../plugins/data/public'; +import { KBN_FIELD_TYPES } from '../../../../../../../plugins/data/public'; export interface IMetricAggConfig extends AggConfig { type: InstanceType; @@ -43,6 +43,9 @@ interface MetricAggTypeConfig subtype?: string; } +// TODO need to make a more explicit interface for this +export type IMetricAggType = MetricAggType; + export class MetricAggType extends AggType< TMetricAggConfig, MetricAggParam @@ -83,7 +86,7 @@ export class MetricAggType { const field = { diff --git a/src/legacy/ui/public/agg_types/metrics/percentile_ranks.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/percentile_ranks.ts similarity index 89% rename from src/legacy/ui/public/agg_types/metrics/percentile_ranks.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/percentile_ranks.ts index cbd46e3f5b28d4..38b47a7e97d2f2 100644 --- a/src/legacy/ui/public/agg_types/metrics/percentile_ranks.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/percentile_ranks.ts @@ -24,7 +24,7 @@ import { getResponseAggConfigClass, IResponseAggConfig } from './lib/get_respons import { getPercentileValue } from './percentiles_get_value'; import { METRIC_TYPES } from './metric_agg_types'; -import { fieldFormats, KBN_FIELD_TYPES } from '../../../../../plugins/data/public'; +import { fieldFormats, KBN_FIELD_TYPES } from '../../../../../../../plugins/data/public'; // required by the values editor @@ -41,7 +41,7 @@ const valueProps = { const customLabel = this.getParam('customLabel'); const label = customLabel || this.getFieldDisplayName(); - return i18n.translate('common.ui.aggTypes.metrics.percentileRanks.valuePropsLabel', { + return i18n.translate('data.search.aggs.metrics.percentileRanks.valuePropsLabel', { defaultMessage: 'Percentile rank {format} of "{label}"', values: { format: format.convert(this.key, 'text'), label }, }); @@ -50,11 +50,11 @@ const valueProps = { export const percentileRanksMetricAgg = new MetricAggType({ name: METRIC_TYPES.PERCENTILE_RANKS, - title: i18n.translate('common.ui.aggTypes.metrics.percentileRanksTitle', { + title: i18n.translate('data.search.aggs.metrics.percentileRanksTitle', { defaultMessage: 'Percentile Ranks', }), makeLabel(agg) { - return i18n.translate('common.ui.aggTypes.metrics.percentileRanksLabel', { + return i18n.translate('data.search.aggs.metrics.percentileRanksLabel', { defaultMessage: 'Percentile ranks of {field}', values: { field: agg.getFieldDisplayName() }, }); diff --git a/src/legacy/ui/public/agg_types/metrics/percentiles.test.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/percentiles.test.ts similarity index 95% rename from src/legacy/ui/public/agg_types/metrics/percentiles.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/percentiles.test.ts index c9f4bcc3862a03..dd1aaca973e473 100644 --- a/src/legacy/ui/public/agg_types/metrics/percentiles.test.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/percentiles.test.ts @@ -18,13 +18,13 @@ */ import { IPercentileAggConfig, percentilesMetricAgg } from './percentiles'; -import { AggConfigs } from '../agg_configs'; +import { AggConfigs, IAggConfigs } from '../agg_configs'; import { METRIC_TYPES } from './metric_agg_types'; jest.mock('ui/new_platform'); describe('AggTypesMetricsPercentilesProvider class', () => { - let aggConfigs: AggConfigs; + let aggConfigs: IAggConfigs; beforeEach(() => { const field = { diff --git a/src/legacy/ui/public/agg_types/metrics/percentiles.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/percentiles.ts similarity index 88% rename from src/legacy/ui/public/agg_types/metrics/percentiles.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/percentiles.ts index 040324d8da5df6..39dc0d0f181e92 100644 --- a/src/legacy/ui/public/agg_types/metrics/percentiles.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/percentiles.ts @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { MetricAggType } from './metric_agg_type'; import { METRIC_TYPES } from './metric_agg_types'; -import { KBN_FIELD_TYPES } from '../../../../../plugins/data/public'; +import { KBN_FIELD_TYPES } from '../../../../../../../plugins/data/public'; import { getResponseAggConfigClass, IResponseAggConfig } from './lib/get_response_agg_config_class'; import { getPercentileValue } from './percentiles_get_value'; @@ -36,7 +36,7 @@ const valueProps = { const customLabel = this.getParam('customLabel'); const label = customLabel || this.getFieldDisplayName(); - return i18n.translate('common.ui.aggTypes.metrics.percentiles.valuePropsLabel', { + return i18n.translate('data.search.aggs.metrics.percentiles.valuePropsLabel', { defaultMessage: '{percentile} percentile of {label}', values: { percentile: ordinalSuffix(this.key), label }, }); @@ -45,11 +45,11 @@ const valueProps = { export const percentilesMetricAgg = new MetricAggType({ name: METRIC_TYPES.PERCENTILES, - title: i18n.translate('common.ui.aggTypes.metrics.percentilesTitle', { + title: i18n.translate('data.search.aggs.metrics.percentilesTitle', { defaultMessage: 'Percentiles', }), makeLabel(agg) { - return i18n.translate('common.ui.aggTypes.metrics.percentilesLabel', { + return i18n.translate('data.search.aggs.metrics.percentilesLabel', { defaultMessage: 'Percentiles of {field}', values: { field: agg.getFieldDisplayName() }, }); diff --git a/src/legacy/ui/public/agg_types/metrics/percentiles_get_value.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/percentiles_get_value.ts similarity index 100% rename from src/legacy/ui/public/agg_types/metrics/percentiles_get_value.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/percentiles_get_value.ts diff --git a/src/legacy/ui/public/agg_types/metrics/serial_diff.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/serial_diff.ts similarity index 89% rename from src/legacy/ui/public/agg_types/metrics/serial_diff.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/serial_diff.ts index bb5431fbbefd9f..5af6e1952d1357 100644 --- a/src/legacy/ui/public/agg_types/metrics/serial_diff.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/serial_diff.ts @@ -23,11 +23,11 @@ import { parentPipelineAggHelper } from './lib/parent_pipeline_agg_helper'; import { makeNestedLabel } from './lib/make_nested_label'; import { METRIC_TYPES } from './metric_agg_types'; -const serialDiffTitle = i18n.translate('common.ui.aggTypes.metrics.serialDiffTitle', { +const serialDiffTitle = i18n.translate('data.search.aggs.metrics.serialDiffTitle', { defaultMessage: 'Serial Diff', }); -const serialDiffLabel = i18n.translate('common.ui.aggTypes.metrics.serialDiffLabel', { +const serialDiffLabel = i18n.translate('data.search.aggs.metrics.serialDiffLabel', { defaultMessage: 'serial diff', }); diff --git a/src/legacy/ui/public/agg_types/metrics/sibling_pipeline.test.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/sibling_pipeline.test.ts similarity index 100% rename from src/legacy/ui/public/agg_types/metrics/sibling_pipeline.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/sibling_pipeline.test.ts diff --git a/src/legacy/ui/public/agg_types/metrics/std_deviation.test.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/std_deviation.test.ts similarity index 100% rename from src/legacy/ui/public/agg_types/metrics/std_deviation.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/std_deviation.test.ts diff --git a/src/legacy/ui/public/agg_types/metrics/std_deviation.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/std_deviation.ts similarity index 85% rename from src/legacy/ui/public/agg_types/metrics/std_deviation.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/std_deviation.ts index b2e6d3b3ca4d0f..caf3bb71dd89a6 100644 --- a/src/legacy/ui/public/agg_types/metrics/std_deviation.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/std_deviation.ts @@ -22,7 +22,7 @@ import { i18n } from '@kbn/i18n'; import { MetricAggType } from './metric_agg_type'; import { METRIC_TYPES } from './metric_agg_types'; import { getResponseAggConfigClass, IResponseAggConfig } from './lib/get_response_agg_config_class'; -import { KBN_FIELD_TYPES } from '../../../../../plugins/data/public'; +import { KBN_FIELD_TYPES } from '../../../../../../../plugins/data/public'; interface ValProp { valProp: string[]; @@ -51,7 +51,7 @@ const responseAggConfigProps = { keyedDetails(this: IStdDevAggConfig, customLabel: string, fieldDisplayName: string) { const label = customLabel || - i18n.translate('common.ui.aggTypes.metrics.standardDeviation.keyDetailsLabel', { + i18n.translate('data.search.aggs.metrics.standardDeviation.keyDetailsLabel', { defaultMessage: 'Standard Deviation of {fieldDisplayName}', values: { fieldDisplayName }, }); @@ -59,14 +59,14 @@ const responseAggConfigProps = { return { std_lower: { valProp: ['std_deviation_bounds', 'lower'], - title: i18n.translate('common.ui.aggTypes.metrics.standardDeviation.lowerKeyDetailsTitle', { + title: i18n.translate('data.search.aggs.metrics.standardDeviation.lowerKeyDetailsTitle', { defaultMessage: 'Lower {label}', values: { label }, }), }, std_upper: { valProp: ['std_deviation_bounds', 'upper'], - title: i18n.translate('common.ui.aggTypes.metrics.standardDeviation.upperKeyDetailsTitle', { + title: i18n.translate('data.search.aggs.metrics.standardDeviation.upperKeyDetailsTitle', { defaultMessage: 'Upper {label}', values: { label }, }), @@ -78,11 +78,11 @@ const responseAggConfigProps = { export const stdDeviationMetricAgg = new MetricAggType({ name: METRIC_TYPES.STD_DEV, dslName: 'extended_stats', - title: i18n.translate('common.ui.aggTypes.metrics.standardDeviationTitle', { + title: i18n.translate('data.search.aggs.metrics.standardDeviationTitle', { defaultMessage: 'Standard Deviation', }), makeLabel(agg) { - return i18n.translate('common.ui.aggTypes.metrics.standardDeviationLabel', { + return i18n.translate('data.search.aggs.metrics.standardDeviationLabel', { defaultMessage: 'Standard Deviation of {field}', values: { field: agg.getFieldDisplayName() }, }); diff --git a/src/legacy/ui/public/agg_types/metrics/sum.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/sum.ts similarity index 86% rename from src/legacy/ui/public/agg_types/metrics/sum.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/sum.ts index ce79c761ce7994..f3450ba1700c81 100644 --- a/src/legacy/ui/public/agg_types/metrics/sum.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/sum.ts @@ -20,9 +20,9 @@ import { i18n } from '@kbn/i18n'; import { MetricAggType } from './metric_agg_type'; import { METRIC_TYPES } from './metric_agg_types'; -import { KBN_FIELD_TYPES } from '../../../../../plugins/data/public'; +import { KBN_FIELD_TYPES } from '../../../../../../../plugins/data/public'; -const sumTitle = i18n.translate('common.ui.aggTypes.metrics.sumTitle', { +const sumTitle = i18n.translate('data.search.aggs.metrics.sumTitle', { defaultMessage: 'Sum', }); @@ -30,7 +30,7 @@ export const sumMetricAgg = new MetricAggType({ name: METRIC_TYPES.SUM, title: sumTitle, makeLabel(aggConfig) { - return i18n.translate('common.ui.aggTypes.metrics.sumLabel', { + return i18n.translate('data.search.aggs.metrics.sumLabel', { defaultMessage: 'Sum of {field}', values: { field: aggConfig.getFieldDisplayName() }, }); diff --git a/src/legacy/ui/public/agg_types/metrics/top_hit.test.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/top_hit.test.ts similarity index 99% rename from src/legacy/ui/public/agg_types/metrics/top_hit.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/top_hit.test.ts index 3e861c052d3671..a973de4fe8659e 100644 --- a/src/legacy/ui/public/agg_types/metrics/top_hit.test.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/top_hit.test.ts @@ -21,7 +21,7 @@ import { dropRight, last } from 'lodash'; import { topHitMetricAgg } from './top_hit'; import { AggConfigs } from '../agg_configs'; import { IMetricAggConfig } from './metric_agg_type'; -import { KBN_FIELD_TYPES } from '../../../../../plugins/data/public'; +import { KBN_FIELD_TYPES } from '../../../../../../../plugins/data/public'; jest.mock('ui/new_platform'); diff --git a/src/legacy/ui/public/agg_types/metrics/top_hit.ts b/src/legacy/core_plugins/data/public/search/aggs/metrics/top_hit.ts similarity index 87% rename from src/legacy/ui/public/agg_types/metrics/top_hit.ts rename to src/legacy/core_plugins/data/public/search/aggs/metrics/top_hit.ts index 43fe33bdebeb98..81bd14ded75b06 100644 --- a/src/legacy/ui/public/agg_types/metrics/top_hit.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/metrics/top_hit.ts @@ -22,7 +22,7 @@ import { i18n } from '@kbn/i18n'; import { IMetricAggConfig, MetricAggType } from './metric_agg_type'; import { aggTypeFieldFilters } from '../param_types/filter'; import { METRIC_TYPES } from './metric_agg_types'; -import { KBN_FIELD_TYPES } from '../../../../../plugins/data/public'; +import { KBN_FIELD_TYPES } from '../../../../../../../plugins/data/public'; // @ts-ignore import { wrapWithInlineComp } from '../buckets/inline_comp_wrapper'; @@ -46,14 +46,14 @@ aggTypeFieldFilters.addFilter((field, aggConfig) => { export const topHitMetricAgg = new MetricAggType({ name: METRIC_TYPES.TOP_HITS, - title: i18n.translate('common.ui.aggTypes.metrics.topHitTitle', { + title: i18n.translate('data.search.aggs.metrics.topHitTitle', { defaultMessage: 'Top Hit', }), makeLabel(aggConfig) { - const lastPrefixLabel = i18n.translate('common.ui.aggTypes.metrics.topHit.lastPrefixLabel', { + const lastPrefixLabel = i18n.translate('data.search.aggs.metrics.topHit.lastPrefixLabel', { defaultMessage: 'Last', }); - const firstPrefixLabel = i18n.translate('common.ui.aggTypes.metrics.topHit.firstPrefixLabel', { + const firstPrefixLabel = i18n.translate('data.search.aggs.metrics.topHit.firstPrefixLabel', { defaultMessage: 'First', }); @@ -106,7 +106,7 @@ export const topHitMetricAgg = new MetricAggType({ type: 'optioned', options: [ { - text: i18n.translate('common.ui.aggTypes.metrics.topHit.minLabel', { + text: i18n.translate('data.search.aggs.metrics.topHit.minLabel', { defaultMessage: 'Min', }), isCompatible: isNumericFieldSelected, @@ -114,7 +114,7 @@ export const topHitMetricAgg = new MetricAggType({ value: 'min', }, { - text: i18n.translate('common.ui.aggTypes.metrics.topHit.maxLabel', { + text: i18n.translate('data.search.aggs.metrics.topHit.maxLabel', { defaultMessage: 'Max', }), isCompatible: isNumericFieldSelected, @@ -122,7 +122,7 @@ export const topHitMetricAgg = new MetricAggType({ value: 'max', }, { - text: i18n.translate('common.ui.aggTypes.metrics.topHit.sumLabel', { + text: i18n.translate('data.search.aggs.metrics.topHit.sumLabel', { defaultMessage: 'Sum', }), isCompatible: isNumericFieldSelected, @@ -130,7 +130,7 @@ export const topHitMetricAgg = new MetricAggType({ value: 'sum', }, { - text: i18n.translate('common.ui.aggTypes.metrics.topHit.averageLabel', { + text: i18n.translate('data.search.aggs.metrics.topHit.averageLabel', { defaultMessage: 'Average', }), isCompatible: isNumericFieldSelected, @@ -138,7 +138,7 @@ export const topHitMetricAgg = new MetricAggType({ value: 'average', }, { - text: i18n.translate('common.ui.aggTypes.metrics.topHit.concatenateLabel', { + text: i18n.translate('data.search.aggs.metrics.topHit.concatenateLabel', { defaultMessage: 'Concatenate', }), isCompatible(aggConfig: IMetricAggConfig) { @@ -174,13 +174,13 @@ export const topHitMetricAgg = new MetricAggType({ default: 'desc', options: [ { - text: i18n.translate('common.ui.aggTypes.metrics.topHit.descendingLabel', { + text: i18n.translate('data.search.aggs.metrics.topHit.descendingLabel', { defaultMessage: 'Descending', }), value: 'desc', }, { - text: i18n.translate('common.ui.aggTypes.metrics.topHit.ascendingLabel', { + text: i18n.translate('data.search.aggs.metrics.topHit.ascendingLabel', { defaultMessage: 'Ascending', }), value: 'asc', diff --git a/src/legacy/ui/public/agg_types/param_types/agg.ts b/src/legacy/core_plugins/data/public/search/aggs/param_types/agg.ts similarity index 100% rename from src/legacy/ui/public/agg_types/param_types/agg.ts rename to src/legacy/core_plugins/data/public/search/aggs/param_types/agg.ts diff --git a/src/legacy/ui/public/agg_types/param_types/base.ts b/src/legacy/core_plugins/data/public/search/aggs/param_types/base.ts similarity index 94% rename from src/legacy/ui/public/agg_types/param_types/base.ts rename to src/legacy/core_plugins/data/public/search/aggs/param_types/base.ts index 15ec44e2ca5ae7..1523cb03eb966c 100644 --- a/src/legacy/ui/public/agg_types/param_types/base.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/param_types/base.ts @@ -17,9 +17,9 @@ * under the License. */ -import { AggConfigs } from '../agg_configs'; +import { IAggConfigs } from '../agg_configs'; import { AggConfig } from '../agg_config'; -import { FetchOptions, ISearchSource } from '../../../../../plugins/data/public'; +import { FetchOptions, ISearchSource } from '../../../../../../../plugins/data/public'; export class BaseParamType { name: string; @@ -31,7 +31,7 @@ export class BaseParamType { write: ( aggConfig: TAggConfig, output: Record, - aggConfigs?: AggConfigs, + aggConfigs?: IAggConfigs, locals?: Record ) => void; serialize: (value: any, aggConfig?: TAggConfig) => any; diff --git a/src/legacy/ui/public/agg_types/param_types/field.test.ts b/src/legacy/core_plugins/data/public/search/aggs/param_types/field.test.ts similarity index 98% rename from src/legacy/ui/public/agg_types/param_types/field.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/param_types/field.test.ts index 9cea2934d74598..d0fa711d89c70f 100644 --- a/src/legacy/ui/public/agg_types/param_types/field.test.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/param_types/field.test.ts @@ -19,7 +19,7 @@ import { BaseParamType } from './base'; import { FieldParamType } from './field'; -import { ES_FIELD_TYPES, KBN_FIELD_TYPES } from '../../../../../plugins/data/public'; +import { ES_FIELD_TYPES, KBN_FIELD_TYPES } from '../../../../../../../plugins/data/public'; jest.mock('ui/new_platform'); diff --git a/src/legacy/ui/public/agg_types/param_types/field.ts b/src/legacy/core_plugins/data/public/search/aggs/param_types/field.ts similarity index 83% rename from src/legacy/ui/public/agg_types/param_types/field.ts rename to src/legacy/core_plugins/data/public/search/aggs/param_types/field.ts index d01e059c6c616b..c41c159ad0f78a 100644 --- a/src/legacy/ui/public/agg_types/param_types/field.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/param_types/field.ts @@ -19,16 +19,18 @@ // @ts-ignore import { i18n } from '@kbn/i18n'; +import { npStart } from 'ui/new_platform'; import { AggConfig } from '../agg_config'; -import { SavedObjectNotFound } from '../../../../../plugins/kibana_utils/public'; +import { SavedObjectNotFound } from '../../../../../../../plugins/kibana_utils/public'; import { BaseParamType } from './base'; -import { npStart } from '../../new_platform'; import { propFilter } from '../filter'; -import { Field, IFieldList } from '../../../../../plugins/data/public'; -import { isNestedField } from '../../../../../plugins/data/public'; +import { Field, IFieldList, isNestedField } from '../../../../../../../plugins/data/public'; const filterByType = propFilter('type'); +// TODO need to make a more explicit interface for this +export type IFieldParamType = FieldParamType; + export class FieldParamType extends BaseParamType { required = true; scriptable = true; @@ -47,15 +49,12 @@ export class FieldParamType extends BaseParamType { if (!field) { throw new TypeError( - i18n.translate( - 'common.ui.aggTypes.paramTypes.field.requiredFieldParameterErrorMessage', - { - defaultMessage: '{fieldParameter} is a required parameter', - values: { - fieldParameter: '"field"', - }, - } - ) + i18n.translate('data.search.aggs.paramTypes.field.requiredFieldParameterErrorMessage', { + defaultMessage: '{fieldParameter} is a required parameter', + values: { + fieldParameter: '"field"', + }, + }) ); } @@ -91,7 +90,7 @@ export class FieldParamType extends BaseParamType { if (!validField) { npStart.core.notifications.toasts.addDanger( i18n.translate( - 'common.ui.aggTypes.paramTypes.field.invalidSavedFieldParameterErrorMessage', + 'data.search.aggs.paramTypes.field.invalidSavedFieldParameterErrorMessage', { defaultMessage: 'Saved {fieldParameter} parameter is now invalid. Please select a new field.', diff --git a/src/legacy/ui/public/agg_types/param_types/filter/field_filters.test.ts b/src/legacy/core_plugins/data/public/search/aggs/param_types/filter/field_filters.test.ts similarity index 97% rename from src/legacy/ui/public/agg_types/param_types/filter/field_filters.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/param_types/filter/field_filters.test.ts index 384c1424080123..fb53e72b85c60c 100644 --- a/src/legacy/ui/public/agg_types/param_types/filter/field_filters.test.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/param_types/filter/field_filters.test.ts @@ -20,7 +20,7 @@ import { IndexedArray } from 'ui/indexed_array'; import { AggTypeFieldFilters } from './field_filters'; import { AggConfig } from '../../agg_config'; -import { Field } from '../../../../../../plugins/data/public'; +import { Field } from '../../../../../../../../plugins/data/public'; describe('AggTypeFieldFilters', () => { let registry: AggTypeFieldFilters; diff --git a/src/legacy/ui/public/agg_types/param_types/filter/field_filters.ts b/src/legacy/core_plugins/data/public/search/aggs/param_types/filter/field_filters.ts similarity index 100% rename from src/legacy/ui/public/agg_types/param_types/filter/field_filters.ts rename to src/legacy/core_plugins/data/public/search/aggs/param_types/filter/field_filters.ts diff --git a/src/legacy/ui/public/agg_types/param_types/filter/index.ts b/src/legacy/core_plugins/data/public/search/aggs/param_types/filter/index.ts similarity index 100% rename from src/legacy/ui/public/agg_types/param_types/filter/index.ts rename to src/legacy/core_plugins/data/public/search/aggs/param_types/filter/index.ts diff --git a/src/legacy/ui/public/agg_types/param_types/index.ts b/src/legacy/core_plugins/data/public/search/aggs/param_types/index.ts similarity index 100% rename from src/legacy/ui/public/agg_types/param_types/index.ts rename to src/legacy/core_plugins/data/public/search/aggs/param_types/index.ts diff --git a/src/legacy/ui/public/agg_types/param_types/json.test.ts b/src/legacy/core_plugins/data/public/search/aggs/param_types/json.test.ts similarity index 100% rename from src/legacy/ui/public/agg_types/param_types/json.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/param_types/json.test.ts diff --git a/src/legacy/ui/public/agg_types/param_types/json.ts b/src/legacy/core_plugins/data/public/search/aggs/param_types/json.ts similarity index 100% rename from src/legacy/ui/public/agg_types/param_types/json.ts rename to src/legacy/core_plugins/data/public/search/aggs/param_types/json.ts diff --git a/src/legacy/ui/public/agg_types/param_types/optioned.test.ts b/src/legacy/core_plugins/data/public/search/aggs/param_types/optioned.test.ts similarity index 100% rename from src/legacy/ui/public/agg_types/param_types/optioned.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/param_types/optioned.test.ts diff --git a/src/legacy/ui/public/agg_types/param_types/optioned.ts b/src/legacy/core_plugins/data/public/search/aggs/param_types/optioned.ts similarity index 100% rename from src/legacy/ui/public/agg_types/param_types/optioned.ts rename to src/legacy/core_plugins/data/public/search/aggs/param_types/optioned.ts diff --git a/src/legacy/ui/public/agg_types/param_types/string.test.ts b/src/legacy/core_plugins/data/public/search/aggs/param_types/string.test.ts similarity index 100% rename from src/legacy/ui/public/agg_types/param_types/string.test.ts rename to src/legacy/core_plugins/data/public/search/aggs/param_types/string.test.ts diff --git a/src/legacy/ui/public/agg_types/param_types/string.ts b/src/legacy/core_plugins/data/public/search/aggs/param_types/string.ts similarity index 100% rename from src/legacy/ui/public/agg_types/param_types/string.ts rename to src/legacy/core_plugins/data/public/search/aggs/param_types/string.ts diff --git a/src/legacy/ui/public/agg_types/schemas.ts b/src/legacy/core_plugins/data/public/search/aggs/schemas.ts similarity index 98% rename from src/legacy/ui/public/agg_types/schemas.ts rename to src/legacy/core_plugins/data/public/search/aggs/schemas.ts index 05723cac1869df..1aa5ebe08656b1 100644 --- a/src/legacy/ui/public/agg_types/schemas.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/schemas.ts @@ -45,7 +45,7 @@ export interface Schema { aggSettings?: any; } -class Schemas { +export class Schemas { // @ts-ignore all: IndexedArray; @@ -103,5 +103,3 @@ class Schemas { .commit(); } } - -export { Schemas }; diff --git a/src/legacy/core_plugins/data/public/search/aggs/types.ts b/src/legacy/core_plugins/data/public/search/aggs/types.ts new file mode 100644 index 00000000000000..2c918abf99fcaf --- /dev/null +++ b/src/legacy/core_plugins/data/public/search/aggs/types.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +export { IAggConfig } from './agg_config'; +export { IAggConfigs } from './agg_configs'; +export { IAggType } from './agg_type'; +export { AggParam, AggParamOption } from './agg_params'; +export { IFieldParamType } from './param_types'; +export { IMetricAggType } from './metrics/metric_agg_type'; +export { DateRangeKey } from './buckets/date_range'; +export { IpRangeKey } from './buckets/ip_range'; +export { OptionedValueProp, OptionedParamEditorProps } from './param_types/optioned'; +export { ISchemas } from './schemas'; diff --git a/src/legacy/ui/public/agg_types/utils.test.tsx b/src/legacy/core_plugins/data/public/search/aggs/utils.test.tsx similarity index 100% rename from src/legacy/ui/public/agg_types/utils.test.tsx rename to src/legacy/core_plugins/data/public/search/aggs/utils.test.tsx diff --git a/src/legacy/ui/public/agg_types/utils.ts b/src/legacy/core_plugins/data/public/search/aggs/utils.ts similarity index 92% rename from src/legacy/ui/public/agg_types/utils.ts rename to src/legacy/core_plugins/data/public/search/aggs/utils.ts index e382f821b31a90..62f07ce44ab46e 100644 --- a/src/legacy/ui/public/agg_types/utils.ts +++ b/src/legacy/core_plugins/data/public/search/aggs/utils.ts @@ -17,8 +17,8 @@ * under the License. */ -import { isValidEsInterval } from '../../../core_plugins/data/common/parse_es_interval/is_valid_es_interval'; -import { leastCommonInterval } from '../vis/lib/least_common_interval'; +import { leastCommonInterval } from 'ui/vis/lib/least_common_interval'; +import { isValidEsInterval } from '../../../common'; /** * Check a string if it's a valid JSON. diff --git a/src/legacy/core_plugins/data/public/search/expressions/esaggs.ts b/src/legacy/core_plugins/data/public/search/expressions/esaggs.ts index b4ea2cd378d61b..43927337ce5748 100644 --- a/src/legacy/core_plugins/data/public/search/expressions/esaggs.ts +++ b/src/legacy/core_plugins/data/public/search/expressions/esaggs.ts @@ -19,7 +19,7 @@ import { get, has } from 'lodash'; import { i18n } from '@kbn/i18n'; -import { AggConfigs } from 'ui/agg_types/agg_configs'; +import { AggConfigs, IAggConfigs } from 'ui/agg_types'; import { createFormat } from 'ui/visualize/loader/pipeline_helpers/utilities'; import { KibanaContext, @@ -50,7 +50,7 @@ import { serializeAggConfig } from './utils'; export interface RequestHandlerParams { searchSource: ISearchSource; - aggs: AggConfigs; + aggs: IAggConfigs; timeRange?: TimeRange; query?: Query; filters?: esFilters.Filter[]; diff --git a/src/legacy/core_plugins/data/public/search/expressions/utils.ts b/src/legacy/core_plugins/data/public/search/expressions/utils.ts index 4f104f2569a981..f0958ba20820f5 100644 --- a/src/legacy/core_plugins/data/public/search/expressions/utils.ts +++ b/src/legacy/core_plugins/data/public/search/expressions/utils.ts @@ -17,12 +17,12 @@ * under the License. */ -import { AggConfig } from 'ui/agg_types/agg_config'; -import { AggConfigs } from '../../../../../ui/public/agg_types/agg_configs'; +import { AggConfigs } from '../aggs'; +import { IAggConfig } from '../aggs/types'; import { KibanaDatatableColumnMeta } from '../../../../../../plugins/expressions/common/expression_types'; import { IndexPattern } from '../../../../../../plugins/data/public'; -export const serializeAggConfig = (aggConfig: AggConfig): KibanaDatatableColumnMeta => { +export const serializeAggConfig = (aggConfig: IAggConfig): KibanaDatatableColumnMeta => { return { type: aggConfig.type.name, indexPatternId: aggConfig.getIndexPattern().id, diff --git a/src/legacy/core_plugins/data/public/search/index.ts b/src/legacy/core_plugins/data/public/search/index.ts index c975d5772e0a8b..90e191b769a8df 100644 --- a/src/legacy/core_plugins/data/public/search/index.ts +++ b/src/legacy/core_plugins/data/public/search/index.ts @@ -17,5 +17,6 @@ * under the License. */ +export * from './aggs'; export { getRequestInspectorStats, getResponseInspectorStats } from './utils'; export { serializeAggConfig } from './expressions/utils'; diff --git a/src/legacy/core_plugins/data/public/search/search_service.ts b/src/legacy/core_plugins/data/public/search/search_service.ts new file mode 100644 index 00000000000000..45f9ff17328adb --- /dev/null +++ b/src/legacy/core_plugins/data/public/search/search_service.ts @@ -0,0 +1,93 @@ +/* + * 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 { CoreSetup, CoreStart } from '../../../../../core/public'; +import { + aggTypes, + AggType, + AggConfig, + AggConfigs, + FieldParamType, + MetricAggType, + aggTypeFieldFilters, + setBounds, + parentPipelineAggHelper, + siblingPipelineAggHelper, +} from './aggs'; + +interface AggsSetup { + types: typeof aggTypes; +} + +interface AggsStart { + types: typeof aggTypes; + AggConfig: typeof AggConfig; + AggConfigs: typeof AggConfigs; + AggType: typeof AggType; + aggTypeFieldFilters: typeof aggTypeFieldFilters; + FieldParamType: typeof FieldParamType; + MetricAggType: typeof MetricAggType; + parentPipelineAggHelper: typeof parentPipelineAggHelper; + siblingPipelineAggHelper: typeof siblingPipelineAggHelper; + setBounds: typeof setBounds; +} + +export interface SearchSetup { + aggs: AggsSetup; +} + +export interface SearchStart { + aggs: AggsStart; +} + +/** + * The contract provided here is a new platform shim for ui/agg_types. + * + * Once it has been refactored to work with new platform services, + * it will move into the existing search service in src/plugins/data/public/search + */ +export class SearchService { + public setup(core: CoreSetup): SearchSetup { + return { + aggs: { + types: aggTypes, // TODO convert to registry + // TODO add other items as needed + }, + }; + } + + public start(core: CoreStart): SearchStart { + return { + aggs: { + types: aggTypes, // TODO convert to registry + AggConfig, // TODO make static + AggConfigs, + AggType, + aggTypeFieldFilters, + FieldParamType, + MetricAggType, + parentPipelineAggHelper, // TODO make static + siblingPipelineAggHelper, // TODO make static + setBounds, // TODO make static + }, + }; + } + + public stop() {} +} diff --git a/src/legacy/core_plugins/data/public/search/types.ts b/src/legacy/core_plugins/data/public/search/types.ts index 140ceea4870997..47ea1d168f379f 100644 --- a/src/legacy/core_plugins/data/public/search/types.ts +++ b/src/legacy/core_plugins/data/public/search/types.ts @@ -17,4 +17,5 @@ * under the License. */ +export * from './aggs/types'; export * from './utils/types'; diff --git a/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts b/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts index d1e1dafe7c8783..f698a2ee361e08 100644 --- a/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts +++ b/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts @@ -55,7 +55,7 @@ export { buildVislibDimensions } from '../../../visualizations/public'; export { callAfterBindingsWorkaround } from 'ui/compat'; export { getRequestInspectorStats, getResponseInspectorStats } from '../../../data/public'; // @ts-ignore -export { intervalOptions } from 'ui/agg_types/buckets/_interval_options'; +export { intervalOptions } from 'ui/agg_types'; // @ts-ignore export { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query'; export { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal'; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg.test.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg.test.tsx index 81c866923232e8..f5ce55e82967d6 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg.test.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg.test.tsx @@ -24,7 +24,7 @@ import { act } from 'react-dom/test-utils'; import { IndexPattern } from 'src/plugins/data/public'; import { VisState } from 'src/legacy/core_plugins/visualizations/public'; -import { AggType, AggGroupNames } from '../legacy_imports'; +import { IAggType, AggGroupNames } from '../legacy_imports'; import { DefaultEditorAgg, DefaultEditorAggProps } from './agg'; import { DefaultEditorAggParams } from './agg_params'; import { AGGS_ACTION_KEYS } from './agg_group_state'; @@ -117,7 +117,7 @@ describe('DefaultEditorAgg component', () => { (defaultProps.agg as any).brandNew = false; defaultProps.agg.type = { makeLabel: () => 'Agg description', - } as AggType; + } as IAggType; const comp = mount(); act(() => { @@ -258,11 +258,11 @@ describe('DefaultEditorAgg component', () => { it('should disable min_doc_count when agg is histogram or date_histogram', () => { defaultProps.agg.type = { name: 'histogram', - } as AggType; + } as IAggType; const compHistogram = shallow(); defaultProps.agg.type = { name: 'date_histogram', - } as AggType; + } as IAggType; const compDateHistogram = shallow(); expect(compHistogram.find(DefaultEditorAggParams).props()).toHaveProperty('disabledParams', [ @@ -276,7 +276,7 @@ describe('DefaultEditorAgg component', () => { it('should set error when agg is not histogram or date_histogram', () => { defaultProps.agg.type = { name: 'aggType', - } as AggType; + } as IAggType; const comp = shallow(); expect(comp.find(DefaultEditorAggParams).prop('aggError')).toBeDefined(); @@ -285,7 +285,7 @@ describe('DefaultEditorAgg component', () => { it('should set min_doc_count to true when agg type was changed to histogram', () => { defaultProps.agg.type = { name: 'aggType', - } as AggType; + } as IAggType; const comp = mount(); comp.setProps({ agg: { ...defaultProps.agg, type: { name: 'histogram' } } }); @@ -299,7 +299,7 @@ describe('DefaultEditorAgg component', () => { it('should set min_doc_count to 0 when agg type was changed to date_histogram', () => { defaultProps.agg.type = { name: 'aggType', - } as AggType; + } as IAggType; const comp = mount(); comp.setProps({ agg: { ...defaultProps.agg, type: { name: 'date_histogram' } } }); diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg.tsx index 871bd0cdf6811f..5450c29450bac6 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg.tsx @@ -28,7 +28,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { AggConfig } from '../legacy_imports'; +import { IAggConfig } from '../legacy_imports'; import { DefaultEditorAggParams } from './agg_params'; import { DefaultEditorAggCommonProps } from './agg_common_props'; import { AGGS_ACTION_KEYS, AggsAction } from './agg_group_state'; @@ -36,7 +36,7 @@ import { RowsOrColumnsControl } from './controls/rows_or_columns'; import { RadiusRatioOptionControl } from './controls/radius_ratio_option'; export interface DefaultEditorAggProps extends DefaultEditorAggCommonProps { - agg: AggConfig; + agg: IAggConfig; aggIndex: number; aggIsTooLow: boolean; dragHandleProps: {} | null; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_add.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg_add.tsx index f5175126c31c14..d8df5b315fca00 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_add.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_add.tsx @@ -29,10 +29,10 @@ import { } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; -import { AggConfig, AggGroupNames, Schema } from '../legacy_imports'; +import { IAggConfig, AggGroupNames, Schema } from '../legacy_imports'; interface DefaultEditorAggAddProps { - group?: AggConfig[]; + group?: IAggConfig[]; groupName: string; schemas: Schema[]; stats: { diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_common_props.ts b/src/legacy/core_plugins/vis_default_editor/public/components/agg_common_props.ts index 8d803810b647a8..17d2c18d2532c8 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_common_props.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_common_props.ts @@ -18,25 +18,25 @@ */ import { VisState, VisParams } from 'src/legacy/core_plugins/visualizations/public'; -import { AggType, AggConfig, AggGroupNames, Schema } from '../legacy_imports'; +import { IAggType, IAggConfig, AggGroupNames, Schema } from '../legacy_imports'; -type AggId = AggConfig['id']; -type AggParams = AggConfig['params']; +type AggId = IAggConfig['id']; +type AggParams = IAggConfig['params']; export type AddSchema = (schemas: Schema) => void; -export type ReorderAggs = (sourceAgg: AggConfig, destinationAgg: AggConfig) => void; +export type ReorderAggs = (sourceAgg: IAggConfig, destinationAgg: IAggConfig) => void; export interface DefaultEditorCommonProps { formIsTouched: boolean; groupName: AggGroupNames; - metricAggs: AggConfig[]; + metricAggs: IAggConfig[]; state: VisState; setAggParamValue: ( aggId: AggId, paramName: T, value: AggParams[T] ) => void; - onAggTypeChange: (aggId: AggId, aggType: AggType) => void; + onAggTypeChange: (aggId: AggId, aggType: IAggType) => void; } export interface DefaultEditorAggCommonProps extends DefaultEditorCommonProps { diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group.test.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group.test.tsx index 9cbcc31bdc60eb..c36c0176439f94 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group.test.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group.test.tsx @@ -21,7 +21,7 @@ import React from 'react'; import { mount, shallow } from 'enzyme'; import { act } from 'react-dom/test-utils'; import { VisState } from 'src/legacy/core_plugins/visualizations/public'; -import { AggConfigs, AggConfig, Schema } from '../legacy_imports'; +import { IAggConfigs, IAggConfig, Schema } from '../legacy_imports'; import { DefaultEditorAggGroup, DefaultEditorAggGroupProps } from './agg_group'; import { DefaultEditorAgg } from './agg'; import { DefaultEditorAggAdd } from './agg_add'; @@ -56,7 +56,7 @@ jest.mock('./agg_add', () => ({ describe('DefaultEditorAgg component', () => { let defaultProps: DefaultEditorAggGroupProps; - let aggs: AggConfigs; + let aggs: IAggConfigs; let setTouched: jest.Mock; let setValidity: jest.Mock; let reorderAggs: jest.Mock; @@ -76,7 +76,7 @@ describe('DefaultEditorAgg component', () => { }, }, schema: { group: 'metrics' }, - } as AggConfig, + } as IAggConfig, { id: '3', params: { @@ -85,7 +85,7 @@ describe('DefaultEditorAgg component', () => { }, }, schema: { group: 'metrics' }, - } as AggConfig, + } as IAggConfig, { id: '2', params: { @@ -94,9 +94,9 @@ describe('DefaultEditorAgg component', () => { }, }, schema: { group: 'buckets' }, - } as AggConfig, + } as IAggConfig, ], - } as AggConfigs; + } as IAggConfigs; defaultProps = { formIsTouched: false, diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group.tsx index 3491414bec8095..768a9669025e48 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group.tsx @@ -30,7 +30,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { AggConfig, aggGroupNamesMap, AggGroupNames, Schema } from '../legacy_imports'; +import { IAggConfig, aggGroupNamesMap, AggGroupNames, Schema } from '../legacy_imports'; import { DefaultEditorAgg } from './agg'; import { DefaultEditorAggAdd } from './agg_add'; import { AddSchema, ReorderAggs, DefaultEditorAggCommonProps } from './agg_common_props'; @@ -69,8 +69,8 @@ function DefaultEditorAggGroup({ }: DefaultEditorAggGroupProps) { const groupNameLabel = (aggGroupNamesMap() as any)[groupName]; // e.g. buckets can have no aggs - const group: AggConfig[] = useMemo( - () => state.aggs.aggs.filter((agg: AggConfig) => agg.schema.group === groupName) || [], + const group: IAggConfig[] = useMemo( + () => state.aggs.aggs.filter((agg: IAggConfig) => agg.schema.group === groupName) || [], [groupName, state.aggs.aggs] ); @@ -151,7 +151,7 @@ function DefaultEditorAggGroup({ )} <> - {group.map((agg: AggConfig, index: number) => ( + {group.map((agg: IAggConfig, index: number) => ( { - let group: AggConfig[]; + let group: IAggConfig[]; beforeEach(() => { group = [ @@ -39,7 +39,7 @@ describe('DefaultEditorGroup helpers', () => { }, }, schema: { name: 'metric', min: 1, mustBeFirst: true }, - } as AggConfig, + } as IAggConfig, { id: '2', params: { @@ -48,7 +48,7 @@ describe('DefaultEditorGroup helpers', () => { }, }, schema: { name: 'metric', min: 2 }, - } as AggConfig, + } as IAggConfig, ]; }); diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_helper.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_helper.tsx index 87f0d00d50a1d0..d2e8e5401c0f7c 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_helper.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_helper.tsx @@ -18,12 +18,12 @@ */ import { findIndex, isEmpty } from 'lodash'; -import { AggConfig } from '../legacy_imports'; +import { IAggConfig } from '../legacy_imports'; import { AggsState } from './agg_group_state'; -const isAggRemovable = (agg: AggConfig, group: AggConfig[]) => { +const isAggRemovable = (agg: IAggConfig, group: IAggConfig[]) => { const metricCount = group.reduce( - (count, aggregation: AggConfig) => + (count, aggregation: IAggConfig) => aggregation.schema.name === agg.schema.name ? ++count : count, 0 ); @@ -31,20 +31,20 @@ const isAggRemovable = (agg: AggConfig, group: AggConfig[]) => { return metricCount > agg.schema.min; }; -const getEnabledMetricAggsCount = (group: AggConfig[]) => { +const getEnabledMetricAggsCount = (group: IAggConfig[]) => { return group.reduce( - (count, aggregation: AggConfig) => + (count, aggregation: IAggConfig) => aggregation.schema.name === 'metric' && aggregation.enabled ? ++count : count, 0 ); }; -const calcAggIsTooLow = (agg: AggConfig, aggIndex: number, group: AggConfig[]) => { +const calcAggIsTooLow = (agg: IAggConfig, aggIndex: number, group: IAggConfig[]) => { if (!agg.schema.mustBeFirst) { return false; } - const firstDifferentSchema = findIndex(group, (aggr: AggConfig) => { + const firstDifferentSchema = findIndex(group, (aggr: IAggConfig) => { return aggr.schema !== agg.schema; }); diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_state.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_state.tsx index b06ca1c2ce57a2..d022297ae72b39 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_state.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_state.tsx @@ -17,7 +17,7 @@ * under the License. */ -import { AggConfig } from '../legacy_imports'; +import { IAggConfig } from '../legacy_imports'; export enum AGGS_ACTION_KEYS { TOUCHED = 'aggsTouched', @@ -52,7 +52,7 @@ function aggGroupReducer(state: AggsState, action: AggsAction): AggsState { } } -function initAggsState(group: AggConfig[]): AggsState { +function initAggsState(group: IAggConfig[]): AggsState { return group.reduce((state, agg) => { state[agg.id] = { touched: false, valid: true }; return state; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_param_props.ts b/src/legacy/core_plugins/vis_default_editor/public/components/agg_param_props.ts index 01a41d3c412c26..fc535884c69ffd 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_param_props.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_param_props.ts @@ -19,7 +19,7 @@ import { Field } from 'src/plugins/data/public'; import { VisState } from 'src/legacy/core_plugins/visualizations/public'; -import { AggConfig, AggParam, EditorConfig } from '../legacy_imports'; +import { IAggConfig, AggParam, EditorConfig } from '../legacy_imports'; import { ComboBoxGroupedOptions } from '../utils'; // NOTE: we cannot export the interface with export { InterfaceName } @@ -27,7 +27,7 @@ import { ComboBoxGroupedOptions } from '../utils'; // https://github.com/babel/babel/issues/7641 // export interface AggParamCommonProps { - agg: AggConfig; + agg: IAggConfig; aggParam: P; disabled?: boolean; editorConfig: EditorConfig; @@ -36,7 +36,7 @@ export interface AggParamCommonProps { showValidation: boolean; state: VisState; value?: T; - metricAggs: AggConfig[]; + metricAggs: IAggConfig[]; } export interface AggParamEditorProps extends AggParamCommonProps { diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.test.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.test.tsx index d782c819c7c41f..5636059394bacb 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.test.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.test.tsx @@ -23,7 +23,7 @@ import { mount, shallow } from 'enzyme'; import { VisState } from 'src/legacy/core_plugins/visualizations/public'; import { IndexPattern } from 'src/plugins/data/public'; import { DefaultEditorAggParams, DefaultEditorAggParamsProps } from './agg_params'; -import { AggConfig, AggGroupNames } from '../legacy_imports'; +import { IAggConfig, AggGroupNames } from '../legacy_imports'; const mockEditorConfig = { useNormalizedEsInterval: { hidden: false, fixedValue: false }, @@ -97,7 +97,7 @@ describe('DefaultEditorAggParams component', () => { schema: { title: '', }, - } as any) as AggConfig, + } as any) as IAggConfig, groupName: AggGroupNames.Metrics, formIsTouched: false, indexPattern: {} as IndexPattern, diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.tsx index 47e98f175ab73f..1b450957f3b26b 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.tsx @@ -24,7 +24,7 @@ import useUnmount from 'react-use/lib/useUnmount'; import { IndexPattern } from 'src/plugins/data/public'; import { - AggConfig, + IAggConfig, AggGroupNames, editorConfigProviders, FixedParam, @@ -54,7 +54,7 @@ type EditorParamConfigType = EditorParamConfig & { }; export interface DefaultEditorAggParamsProps extends DefaultEditorCommonProps { - agg: AggConfig; + agg: IAggConfig; aggError?: string; aggIndex?: number; aggIsTooLow?: boolean; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.test.ts b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.test.ts index 6f584b43295000..ec56d22143699a 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.test.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.test.ts @@ -20,8 +20,8 @@ import { IndexPattern, Field } from 'src/plugins/data/public'; import { VisState } from 'src/legacy/core_plugins/visualizations/public'; import { - AggConfig, - AggType, + IAggConfig, + IAggType, AggGroupNames, BUCKET_TYPES, IndexedArray, @@ -42,10 +42,10 @@ jest.mock('ui/new_platform'); describe('DefaultEditorAggParams helpers', () => { describe('getAggParamsToRender', () => { - let agg: AggConfig; + let agg: IAggConfig; let editorConfig: EditorConfig; const state = {} as VisState; - const metricAggs: AggConfig[] = []; + const metricAggs: IAggConfig[] = []; const emptyParams = { basic: [], advanced: [], @@ -57,14 +57,14 @@ describe('DefaultEditorAggParams helpers', () => { params: [{ name: 'interval' }], }, schema: {}, - } as AggConfig; + } as IAggConfig; const params = getAggParamsToRender({ agg, editorConfig, metricAggs, state }); expect(params).toEqual(emptyParams); }); it('should not create any param if there is no agg type', () => { - agg = {} as AggConfig; + agg = {} as IAggConfig; const params = getAggParamsToRender({ agg, editorConfig, metricAggs, state }); expect(params).toEqual(emptyParams); @@ -75,7 +75,7 @@ describe('DefaultEditorAggParams helpers', () => { type: { params: [{ name: 'interval' }], }, - } as AggConfig; + } as IAggConfig; editorConfig = { interval: { hidden: true, @@ -94,7 +94,7 @@ describe('DefaultEditorAggParams helpers', () => { schema: { hideCustomLabel: true, }, - } as AggConfig; + } as IAggConfig; const params = getAggParamsToRender({ agg, editorConfig, metricAggs, state }); expect(params).toEqual(emptyParams); @@ -131,7 +131,7 @@ describe('DefaultEditorAggParams helpers', () => { orderBy: 'orderBy', field: 'field', }, - } as any) as AggConfig; + } as any) as IAggConfig; const params = getAggParamsToRender({ agg, editorConfig, metricAggs, state }); expect(params).toEqual({ @@ -166,14 +166,14 @@ describe('DefaultEditorAggParams helpers', () => { describe('getAggTypeOptions', () => { it('should return agg type options grouped by subtype', () => { const indexPattern = {} as IndexPattern; - const aggs = getAggTypeOptions({} as AggConfig, indexPattern, 'metrics'); + const aggs = getAggTypeOptions({} as IAggConfig, indexPattern, 'metrics'); expect(aggs).toEqual(['indexedFields']); }); }); describe('isInvalidParamsTouched', () => { - let aggType: AggType; + let aggType: IAggType; const aggTypeState = { touched: false, valid: true, diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.ts b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.ts index 21154bd7ad603e..5a9d95725c8e46 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.ts @@ -29,17 +29,17 @@ import { aggTypeFilters, aggTypeFieldFilters, aggTypes, - AggConfig, + IAggConfig, AggParam, - FieldParamType, - AggType, + IFieldParamType, + IAggType, EditorConfig, } from '../legacy_imports'; interface ParamInstanceBase { - agg: AggConfig; + agg: IAggConfig; editorConfig: EditorConfig; - metricAggs: AggConfig[]; + metricAggs: IAggConfig[]; state: VisState; } @@ -73,7 +73,7 @@ function getAggParamsToRender({ agg, editorConfig, metricAggs, state }: ParamIns } // if field param exists, compute allowed fields if (param.type === 'field') { - const availableFields: Field[] = (param as FieldParamType).getAvailableFields( + const availableFields: Field[] = (param as IFieldParamType).getAvailableFields( agg.getIndexPattern().fields ); fields = aggTypeFieldFilters.filter(availableFields, agg); @@ -117,10 +117,10 @@ function getAggParamsToRender({ agg, editorConfig, metricAggs, state }: ParamIns } function getAggTypeOptions( - agg: AggConfig, + agg: IAggConfig, indexPattern: IndexPattern, groupName: string -): ComboBoxGroupedOptions { +): ComboBoxGroupedOptions { const aggTypeOptions = aggTypeFilters.filter((aggTypes as any)[groupName], indexPattern, agg); return groupAndSortBy(aggTypeOptions as any[], 'subtype', 'title'); } @@ -135,7 +135,7 @@ function getAggTypeOptions( * @param aggParams State of aggregation parameters. */ function isInvalidParamsTouched( - aggType: AggType, + aggType: IAggType, aggTypeState: AggTypeState, aggParams: AggParamsState ) { diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_select.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg_select.tsx index 2a9c74521e5258..0ec19bfa1b843d 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_select.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_select.tsx @@ -24,20 +24,20 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { IndexPattern } from 'src/plugins/data/public'; -import { AggType, documentationLinks } from '../legacy_imports'; +import { IAggType, documentationLinks } from '../legacy_imports'; import { ComboBoxGroupedOptions } from '../utils'; import { AGG_TYPE_ACTION_KEYS, AggTypeAction } from './agg_params_state'; interface DefaultEditorAggSelectProps { aggError?: string; - aggTypeOptions: ComboBoxGroupedOptions; + aggTypeOptions: ComboBoxGroupedOptions; id: string; indexPattern: IndexPattern; showValidation: boolean; isSubAggregation: boolean; - value: AggType; + value: IAggType; onChangeAggType: React.Dispatch; - setValue: (aggType: AggType) => void; + setValue: (aggType: IAggType) => void; } function DefaultEditorAggSelect({ @@ -51,7 +51,7 @@ function DefaultEditorAggSelect({ isSubAggregation, onChangeAggType, }: DefaultEditorAggSelectProps) { - const selectedOptions: ComboBoxGroupedOptions = value + const selectedOptions: ComboBoxGroupedOptions = value ? [{ label: value.title, target: value }] : []; @@ -104,7 +104,7 @@ function DefaultEditorAggSelect({ (options: EuiComboBoxOptionProps[]) => { const selectedOption = get(options, '0.target'); if (selectedOption) { - setValue(selectedOption as AggType); + setValue(selectedOption as IAggType); } }, [setValue] diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/agg_control_props.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/agg_control_props.tsx index c8b5196d3b299b..7f04b851902de1 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/agg_control_props.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/agg_control_props.tsx @@ -18,11 +18,11 @@ */ import { VisParams } from 'src/legacy/core_plugins/visualizations/public'; -import { AggConfig } from '../../legacy_imports'; +import { IAggConfig } from '../../legacy_imports'; import { DefaultEditorAggCommonProps } from '../agg_common_props'; export interface AggControlProps { - agg: AggConfig; + agg: IAggConfig; editorStateParams: VisParams; setAggParamValue: DefaultEditorAggCommonProps['setAggParamValue']; setStateParamValue: DefaultEditorAggCommonProps['setStateParamValue']; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/agg_utils.test.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/agg_utils.test.tsx index 5c69fd0f1c0911..0b847e3747b301 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/agg_utils.test.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/agg_utils.test.tsx @@ -20,7 +20,7 @@ import React, { FunctionComponent } from 'react'; import { mount, ReactWrapper } from 'enzyme'; -import { AggConfig } from '../../legacy_imports'; +import { IAggConfig } from '../../legacy_imports'; import { safeMakeLabel, useAvailableOptions, @@ -57,7 +57,7 @@ const metricAggs = [ return 'avg'; }, }, -] as AggConfig[]; +] as IAggConfig[]; const incompatibleAggs = [ { @@ -74,7 +74,7 @@ const incompatibleAggs = [ return 'percentiles'; }, }, -] as AggConfig[]; +] as IAggConfig[]; const aggFilter = ['!top_hits', '!percentiles']; describe('Aggregations utils', () => { @@ -222,7 +222,7 @@ describe('Aggregations utils', () => { }); test('should not fail and return a safety string if makeLabel func is not exist', () => { - const label = safeMakeLabel({} as AggConfig); + const label = safeMakeLabel({} as IAggConfig); expect(label).toEqual(expect.any(String)); }); diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/field.test.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/field.test.tsx index e43304fe073478..636ef8f872d0ea 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/field.test.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/field.test.tsx @@ -26,7 +26,7 @@ import { Field } from 'src/plugins/data/public'; import { VisState } from 'src/legacy/core_plugins/visualizations/public'; import { ComboBoxGroupedOptions } from '../../utils'; import { FieldParamEditor, FieldParamEditorProps } from './field'; -import { AggConfig } from '../../legacy_imports'; +import { IAggConfig } from '../../legacy_imports'; function callComboBoxOnChange(comp: ReactWrapper, value: any = []) { const comboBoxProps: EuiComboBoxProps = comp.find(EuiComboBox).props(); @@ -64,7 +64,7 @@ describe('FieldParamEditor component', () => { ]; defaultProps = { - agg: {} as AggConfig, + agg: {} as IAggConfig, aggParam: { name: 'field', type: 'field', @@ -80,7 +80,7 @@ describe('FieldParamEditor component', () => { setValidity, setTouched, state: {} as VisState, - metricAggs: [] as AggConfig[], + metricAggs: [] as IAggConfig[], }; }); diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/field.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/field.tsx index 38c55e8fe3f240..f374353afabeca 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/field.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/field.tsx @@ -24,7 +24,7 @@ import { EuiComboBox, EuiComboBoxOptionProps, EuiFormRow } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { Field } from 'src/plugins/data/public'; -import { AggConfig, AggParam, FieldParamType } from '../../legacy_imports'; +import { AggParam, IAggConfig, IFieldParamType } from '../../legacy_imports'; import { formatListAsProse, parseCommaSeparatedList, useValidation } from './utils'; import { AggParamEditorProps } from '../agg_param_props'; import { ComboBoxGroupedOptions } from '../../utils'; @@ -126,9 +126,10 @@ function FieldParamEditor({ ); } -function getFieldTypesString(agg: AggConfig) { +function getFieldTypesString(agg: IAggConfig) { const param = - get(agg, 'type.params', []).find((p: AggParam) => p.name === 'field') || ({} as FieldParamType); + get(agg, 'type.params', []).find((p: AggParam) => p.name === 'field') || + ({} as IFieldParamType); return formatListAsProse(parseCommaSeparatedList(param.filterFieldTypes), { inclusive: false }); } diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/filter.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/filter.tsx index 38c5b552553ae2..3622b27bad4036 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/filter.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/filter.tsx @@ -22,7 +22,7 @@ import { EuiForm, EuiButtonIcon, EuiFieldText, EuiFormRow, EuiSpacer } from '@el import { i18n } from '@kbn/i18n'; import { Query, QueryStringInput } from '../../../../../../plugins/data/public'; -import { AggConfig } from '../../legacy_imports'; +import { IAggConfig } from '../../legacy_imports'; interface FilterRowProps { id: string; @@ -34,7 +34,7 @@ interface FilterRowProps { dataTestSubj: string; onChangeValue(id: string, query: Query, label: string): void; onRemoveFilter(id: string): void; - agg: AggConfig; + agg: IAggConfig; } function FilterRow({ diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/metric_agg.test.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/metric_agg.test.tsx index 9b6fd204e72077..cf7af1aa5cb3a7 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/metric_agg.test.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/metric_agg.test.tsx @@ -20,7 +20,7 @@ import React from 'react'; import { mount, shallow } from 'enzyme'; -import { AggConfig } from '../../legacy_imports'; +import { IAggConfig } from '../../legacy_imports'; import { DEFAULT_OPTIONS, aggFilter, MetricAggParamEditor } from './metric_agg'; jest.mock('./utils', () => ({ @@ -44,7 +44,7 @@ const agg = { makeLabel() { return 'cumulative_sum'; }, -} as AggConfig; +} as IAggConfig; const metricAggs = [ agg, @@ -69,7 +69,7 @@ const metricAggs = [ return 'max'; }, }, -] as AggConfig[]; +] as IAggConfig[]; describe('MetricAggParamEditor', () => { let defaultProps: Partial>; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_agg.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_agg.tsx index 6bb9ad334d1495..10679b578d54e3 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_agg.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_agg.tsx @@ -20,7 +20,7 @@ import React, { useEffect } from 'react'; import { EuiSpacer } from '@elastic/eui'; -import { AggParamType, AggConfig, AggGroupNames } from '../../legacy_imports'; +import { AggParamType, IAggConfig, AggGroupNames } from '../../legacy_imports'; import { useSubAggParamsHandlers } from './utils'; import { AggParamEditorProps } from '../agg_param_props'; import { DefaultEditorAggParams } from '../agg_params'; @@ -35,7 +35,7 @@ function OrderAggParamEditor({ setValue, setValidity, setTouched, -}: AggParamEditorProps) { +}: AggParamEditorProps) { const orderBy = agg.params.orderBy; useEffect(() => { @@ -51,7 +51,7 @@ function OrderAggParamEditor({ const { onAggTypeChange, setAggParamValue } = useSubAggParamsHandlers( agg, aggParam, - value as AggConfig, + value as IAggConfig, setValue ); @@ -63,7 +63,7 @@ function OrderAggParamEditor({ <> ) { +}: AggParamEditorProps) { useEffect(() => { // we aren't creating a custom aggConfig if (agg.params.metricAgg !== 'custom') { diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/sub_metric.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/sub_metric.tsx index 9898d943870bc6..45ff0610d88ede 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/sub_metric.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/sub_metric.tsx @@ -21,7 +21,7 @@ import React, { useEffect } from 'react'; import { EuiFormLabel, EuiSpacer } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { AggParamType, AggConfig, AggGroupNames } from '../../legacy_imports'; +import { AggParamType, IAggConfig, AggGroupNames } from '../../legacy_imports'; import { useSubAggParamsHandlers } from './utils'; import { AggParamEditorProps } from '../agg_param_props'; import { DefaultEditorAggParams } from '../agg_params'; @@ -35,7 +35,7 @@ function SubMetricParamEditor({ setValue, setValidity, setTouched, -}: AggParamEditorProps) { +}: AggParamEditorProps) { const metricTitle = i18n.translate('visDefaultEditor.controls.metrics.metricTitle', { defaultMessage: 'Metric', }); diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/test_utils.ts b/src/legacy/core_plugins/vis_default_editor/public/components/controls/test_utils.ts index 4e811f4543412a..894bc594a08d77 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/test_utils.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/test_utils.ts @@ -18,14 +18,14 @@ */ import { VisState } from 'src/legacy/core_plugins/visualizations/public'; -import { AggConfig, AggParam, EditorConfig } from '../../legacy_imports'; +import { IAggConfig, AggParam, EditorConfig } from '../../legacy_imports'; export const aggParamCommonPropsMock = { - agg: {} as AggConfig, + agg: {} as IAggConfig, aggParam: {} as AggParam, editorConfig: {} as EditorConfig, formIsTouched: false, - metricAggs: [] as AggConfig[], + metricAggs: [] as IAggConfig[], state: {} as VisState, showValidation: false, }; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/top_aggregate.test.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/top_aggregate.test.tsx index b0c3fe00606aa7..4ce0712040bd5f 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/top_aggregate.test.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/top_aggregate.test.tsx @@ -25,10 +25,10 @@ import { TopAggregateParamEditorProps, } from './top_aggregate'; import { aggParamCommonPropsMock } from './test_utils'; -import { AggConfig } from '../../legacy_imports'; +import { IAggConfig } from '../../legacy_imports'; describe('TopAggregateParamEditor', () => { - let agg: AggConfig; + let agg: IAggConfig; let aggParam: any; let defaultProps: TopAggregateParamEditorProps; let options: AggregateValueProp[]; @@ -37,17 +37,17 @@ describe('TopAggregateParamEditor', () => { options = [ { text: 'Min', - isCompatible: jest.fn((aggr: AggConfig) => aggr.params.field.type === 'number'), + isCompatible: jest.fn((aggr: IAggConfig) => aggr.params.field.type === 'number'), value: 'min', }, { text: 'Max', - isCompatible: jest.fn((aggr: AggConfig) => aggr.params.field.type === 'number'), + isCompatible: jest.fn((aggr: IAggConfig) => aggr.params.field.type === 'number'), value: 'max', }, { text: 'Average', - isCompatible: jest.fn((aggr: AggConfig) => aggr.params.field.type === 'string'), + isCompatible: jest.fn((aggr: IAggConfig) => aggr.params.field.type === 'string'), value: 'average', }, ]; @@ -69,7 +69,7 @@ describe('TopAggregateParamEditor', () => { }, }, getAggParams: jest.fn(() => [{ name: 'aggregate', options }]), - } as any) as AggConfig; + } as any) as IAggConfig; defaultProps = { ...aggParamCommonPropsMock, agg, @@ -150,7 +150,7 @@ describe('TopAggregateParamEditor', () => { type: 'string', }, }, - } as AggConfig; + } as IAggConfig; comp.setProps({ agg }); @@ -165,7 +165,7 @@ describe('TopAggregateParamEditor', () => { type: 'date', }, }, - } as AggConfig; + } as IAggConfig; comp.setProps({ agg }); @@ -179,7 +179,7 @@ describe('TopAggregateParamEditor', () => { type: 'string', }, }, - } as AggConfig; + } as IAggConfig; comp.setProps({ agg, value: undefined }); diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/top_aggregate.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/top_aggregate.tsx index 338e2fe463a806..346dfc0156f070 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/top_aggregate.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/top_aggregate.tsx @@ -23,7 +23,7 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { - AggConfig, + IAggConfig, AggParam, OptionedValueProp, OptionedParamEditorProps, @@ -32,13 +32,13 @@ import { import { AggParamEditorProps } from '../agg_param_props'; export interface AggregateValueProp extends OptionedValueProp { - isCompatible(aggConfig: AggConfig): boolean; + isCompatible(aggConfig: IAggConfig): boolean; } export type TopAggregateParamEditorProps = AggParamEditorProps & OptionedParamEditorProps; -export function getCompatibleAggs(agg: AggConfig): AggregateValueProp[] { +export function getCompatibleAggs(agg: IAggConfig): AggregateValueProp[] { const { options = [] } = agg .getAggParams() .find(({ name }: AggParam) => name === 'aggregate') as OptionedParamType; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/utils/agg_utils.ts b/src/legacy/core_plugins/vis_default_editor/public/components/controls/utils/agg_utils.ts index 4c8ba23e632680..8aeae488942cd5 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/utils/agg_utils.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/utils/agg_utils.ts @@ -20,7 +20,7 @@ import { useEffect, useCallback, useMemo } from 'react'; import { i18n } from '@kbn/i18n'; -import { AggConfig } from '../../../legacy_imports'; +import { IAggConfig } from '../../../legacy_imports'; type AggFilter = string[]; @@ -43,7 +43,7 @@ function useCompatibleAggCallback(aggFilter: AggFilter) { function useFallbackMetric( setValue: (value?: string) => void, aggFilter: AggFilter, - metricAggs?: AggConfig[], + metricAggs?: IAggConfig[], value?: string, fallbackValue?: string ) { @@ -69,7 +69,7 @@ function useFallbackMetric( */ function useAvailableOptions( aggFilter: AggFilter, - metricAggs: AggConfig[] = [], + metricAggs: IAggConfig[] = [], defaultOptions: Array<{ text: string; value: string }> = [] ) { const isCompatibleAgg = useCompatibleAggCallback(aggFilter); @@ -107,7 +107,7 @@ function useValidation(setValidity: (isValid: boolean) => void, isValid: boolean }, [isValid, setValidity]); } -function safeMakeLabel(agg: AggConfig): string { +function safeMakeLabel(agg: IAggConfig): string { try { return agg.makeLabel(); } catch (e) { @@ -118,7 +118,7 @@ function safeMakeLabel(agg: AggConfig): string { } function isCompatibleAggregation(aggFilter: string[]) { - return (agg: AggConfig) => { + return (agg: IAggConfig) => { return !aggFilter.includes(`!${agg.type.name}`); }; } diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/utils/use_handlers.ts b/src/legacy/core_plugins/vis_default_editor/public/components/controls/utils/use_handlers.ts index c2da648edcf81c..c7816d5a9d3056 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/utils/use_handlers.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/utils/use_handlers.ts @@ -19,14 +19,14 @@ import { useCallback } from 'react'; -import { AggConfig, AggParamType } from '../../../legacy_imports'; +import { IAggConfig, AggParamType } from '../../../legacy_imports'; -type SetValue = (value?: AggConfig) => void; +type SetValue = (value?: IAggConfig) => void; function useSubAggParamsHandlers( - agg: AggConfig, + agg: IAggConfig, aggParam: AggParamType, - subAgg: AggConfig, + subAgg: IAggConfig, setValue: SetValue ) { const setAggParamValue = useCallback( diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/data_tab.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/data_tab.tsx index c7597ef43dfa6f..efd17f02a0e090 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/data_tab.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/data_tab.tsx @@ -23,11 +23,11 @@ import { EuiSpacer } from '@elastic/eui'; import { VisState } from 'src/legacy/core_plugins/visualizations/public'; import { - AggConfig, + IAggConfig, AggGroupNames, ISchemas, parentPipelineType, - MetricAggType, + IMetricAggType, } from '../../legacy_imports'; import { DefaultEditorAggGroup } from '../agg_group'; import { @@ -45,7 +45,7 @@ export interface DefaultEditorDataTabProps { dispatch: React.Dispatch; formIsTouched: boolean; isTabSelected: boolean; - metricAggs: AggConfig[]; + metricAggs: IAggConfig[]; schemas: ISchemas; state: VisState; setTouched(isTouched: boolean): void; @@ -67,7 +67,7 @@ function DefaultEditorDataTab({ () => findLast( metricAggs, - ({ type }: { type: MetricAggType }) => type.subtype === parentPipelineType + ({ type }: { type: IMetricAggType }) => type.subtype === parentPipelineType ), [metricAggs] ); diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/actions.ts b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/actions.ts index 5738916d2ff805..93fa1083bebf97 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/actions.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/actions.ts @@ -18,7 +18,7 @@ */ import { Vis, VisParams } from 'src/legacy/core_plugins/visualizations/public'; -import { AggConfig, Schema } from '../../../legacy_imports'; +import { IAggConfig, Schema } from '../../../legacy_imports'; import { EditorStateActionTypes } from './constants'; export interface ActionType { @@ -26,14 +26,14 @@ export interface ActionType { payload: P; } -type AggId = AggConfig['id']; -type AggParams = AggConfig['params']; +type AggId = IAggConfig['id']; +type AggParams = IAggConfig['params']; type AddNewAgg = ActionType; type DiscardChanges = ActionType; type ChangeAggType = ActionType< EditorStateActionTypes.CHANGE_AGG_TYPE, - { aggId: AggId; value: AggConfig['type'] } + { aggId: AggId; value: IAggConfig['type'] } >; type SetAggParamValue = ActionType< EditorStateActionTypes.SET_AGG_PARAM_VALUE, @@ -50,11 +50,11 @@ type SetStateParamValue = ActionTyp type RemoveAgg = ActionType; type ReorderAggs = ActionType< EditorStateActionTypes.REORDER_AGGS, - { sourceAgg: AggConfig; destinationAgg: AggConfig } + { sourceAgg: IAggConfig; destinationAgg: IAggConfig } >; type ToggleEnabledAgg = ActionType< EditorStateActionTypes.TOGGLE_ENABLED_AGG, - { aggId: AggId; enabled: AggConfig['enabled'] } + { aggId: AggId; enabled: IAggConfig['enabled'] } >; type UpdateStateParams = ActionType< EditorStateActionTypes.UPDATE_STATE_PARAMS, @@ -75,7 +75,7 @@ export type EditorAction = export interface EditorActions { addNewAgg(schema: Schema): AddNewAgg; discardChanges(vis: Vis): DiscardChanges; - changeAggType(aggId: AggId, value: AggConfig['type']): ChangeAggType; + changeAggType(aggId: AggId, value: IAggConfig['type']): ChangeAggType; setAggParamValue( aggId: AggId, paramName: T, @@ -86,8 +86,8 @@ export interface EditorActions { value: AggParams[T] ): SetStateParamValue; removeAgg(aggId: AggId): RemoveAgg; - reorderAggs(sourceAgg: AggConfig, destinationAgg: AggConfig): ReorderAggs; - toggleEnabledAgg(aggId: AggId, enabled: AggConfig['enabled']): ToggleEnabledAgg; + reorderAggs(sourceAgg: IAggConfig, destinationAgg: IAggConfig): ReorderAggs; + toggleEnabledAgg(aggId: AggId, enabled: IAggConfig['enabled']): ToggleEnabledAgg; updateStateParams(params: VisParams): UpdateStateParams; } diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/reducers.ts b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/reducers.ts index 8e1cfd6bc9c135..851263f0ed7020 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/reducers.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/reducers.ts @@ -20,7 +20,7 @@ import { cloneDeep } from 'lodash'; import { Vis, VisState } from 'src/legacy/core_plugins/visualizations/public'; -import { AggConfigs, AggConfig, AggGroupNames, move } from '../../../legacy_imports'; +import { AggConfigs, IAggConfig, AggGroupNames, move } from '../../../legacy_imports'; import { EditorStateActionTypes } from './constants'; import { getEnabledMetricAggsCount } from '../../agg_group_helper'; import { EditorAction } from './actions'; @@ -32,7 +32,7 @@ function initEditorState(vis: Vis) { function editorStateReducer(state: VisState, action: EditorAction): VisState { switch (action.type) { case EditorStateActionTypes.ADD_NEW_AGG: { - const aggConfig = state.aggs.createAggConfig(action.payload as AggConfig, { + const aggConfig = state.aggs.createAggConfig(action.payload as IAggConfig, { addToAggConfigs: false, }); aggConfig.brandNew = true; diff --git a/src/legacy/core_plugins/vis_default_editor/public/legacy_imports.ts b/src/legacy/core_plugins/vis_default_editor/public/legacy_imports.ts index 5c617f3dc8681c..f023b808cb0a72 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/legacy_imports.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/legacy_imports.ts @@ -20,34 +20,33 @@ /* `ui/agg_types` dependencies */ export { AggType, - AggConfig, + IAggType, + IAggConfig, AggConfigs, + IAggConfigs, AggParam, AggGroupNames, aggGroupNamesMap, aggTypes, FieldParamType, + IFieldParamType, BUCKET_TYPES, METRIC_TYPES, ISchemas, Schema, termsAggFilter, } from 'ui/agg_types'; -export { aggTypeFilters, propFilter } from 'ui/agg_types/filter'; -export { aggTypeFieldFilters } from 'ui/agg_types/param_types/filter'; -export { AggParamType } from 'ui/agg_types/param_types/agg'; -export { MetricAggType } from 'ui/agg_types/metrics/metric_agg_type'; -export { parentPipelineType } from 'ui/agg_types/metrics/lib/parent_pipeline_agg_helper'; -export { siblingPipelineType } from 'ui/agg_types/metrics/lib/sibling_pipeline_agg_helper'; -export { isType, isStringType } from 'ui/agg_types/buckets/migrate_include_exclude_format'; -export { - OptionedValueProp, - OptionedParamEditorProps, - OptionedParamType, -} from 'ui/agg_types/param_types/optioned'; -export { isValidJson, isValidInterval } from 'ui/agg_types/utils'; -export { AggParamOption } from 'ui/agg_types/agg_params'; -export { CidrMask } from 'ui/agg_types/buckets/lib/cidr_mask'; +export { aggTypeFilters, propFilter } from 'ui/agg_types'; +export { aggTypeFieldFilters } from 'ui/agg_types'; +export { AggParamType } from 'ui/agg_types'; +export { MetricAggType, IMetricAggType } from 'ui/agg_types'; +export { parentPipelineType } from 'ui/agg_types'; +export { siblingPipelineType } from 'ui/agg_types'; +export { isType, isStringType } from 'ui/agg_types'; +export { OptionedValueProp, OptionedParamEditorProps, OptionedParamType } from 'ui/agg_types'; +export { isValidJson, isValidInterval } from 'ui/agg_types'; +export { AggParamOption } from 'ui/agg_types'; +export { CidrMask } from 'ui/agg_types'; export { PersistedState } from 'ui/persisted_state'; export { IndexedArray } from 'ui/indexed_array'; diff --git a/src/legacy/core_plugins/vis_default_editor/public/vis_options_props.tsx b/src/legacy/core_plugins/vis_default_editor/public/vis_options_props.tsx index f51e359d99573e..babcb59c6582e6 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/vis_options_props.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/vis_options_props.tsx @@ -17,11 +17,11 @@ * under the License. */ -import { AggConfigs, PersistedState } from './legacy_imports'; +import { IAggConfigs, PersistedState } from './legacy_imports'; import { Vis } from '../../visualizations/public'; export interface VisOptionsProps { - aggs: AggConfigs; + aggs: IAggConfigs; hasHistogramAgg: boolean; isTabSelected: boolean; stateParams: VisParamType; diff --git a/src/legacy/core_plugins/vis_default_editor/public/vis_type_agg_filter.ts b/src/legacy/core_plugins/vis_default_editor/public/vis_type_agg_filter.ts index c1832d55128176..60b675f50a3425 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/vis_type_agg_filter.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/vis_type_agg_filter.ts @@ -17,7 +17,7 @@ * under the License. */ import { IndexPattern } from 'src/plugins/data/public'; -import { AggType, AggConfig, aggTypeFilters, propFilter } from './legacy_imports'; +import { IAggType, IAggConfig, aggTypeFilters, propFilter } from './legacy_imports'; const filterByName = propFilter('name'); @@ -25,7 +25,9 @@ const filterByName = propFilter('name'); * This filter checks the defined aggFilter in the schemas of that visualization * and limits available aggregations based on that. */ -aggTypeFilters.addFilter((aggType: AggType, indexPatterns: IndexPattern, aggConfig: AggConfig) => { - const doesSchemaAllowAggType = filterByName([aggType], aggConfig.schema.aggFilter).length !== 0; - return doesSchemaAllowAggType; -}); +aggTypeFilters.addFilter( + (aggType: IAggType, indexPatterns: IndexPattern, aggConfig: IAggConfig) => { + const doesSchemaAllowAggType = filterByName([aggType], aggConfig.schema.aggFilter).length !== 0; + return doesSchemaAllowAggType; + } +); diff --git a/src/legacy/core_plugins/vis_type_table/public/legacy_imports.ts b/src/legacy/core_plugins/vis_type_table/public/legacy_imports.ts index 8a454957b7ab9d..efa6c0029e6d1d 100644 --- a/src/legacy/core_plugins/vis_type_table/public/legacy_imports.ts +++ b/src/legacy/core_plugins/vis_type_table/public/legacy_imports.ts @@ -19,7 +19,7 @@ export { npSetup, npStart } from 'ui/new_platform'; export { getFormat } from 'ui/visualize/loader/pipeline_helpers/utilities'; -export { AggConfig, AggGroupNames, Schemas } from 'ui/agg_types'; +export { IAggConfig, AggGroupNames, Schemas } from 'ui/agg_types'; // @ts-ignore export { PrivateProvider } from 'ui/private/private'; diff --git a/src/legacy/core_plugins/vis_type_table/public/table_vis_controller.test.ts b/src/legacy/core_plugins/vis_type_table/public/table_vis_controller.test.ts index 16181a3f70ff12..d8912975227bfb 100644 --- a/src/legacy/core_plugins/vis_type_table/public/table_vis_controller.test.ts +++ b/src/legacy/core_plugins/vis_type_table/public/table_vis_controller.test.ts @@ -27,7 +27,7 @@ import './table_vis.mock'; import StubIndexPattern from 'test_utils/stub_index_pattern'; import { getAngularModule } from './get_inner_angular'; import { initTableVisLegacyModule } from './table_vis_legacy_module'; -import { npStart, AggConfig, tabifyAggResponse } from './legacy_imports'; +import { npStart, IAggConfig, tabifyAggResponse } from './legacy_imports'; import { tableVisTypeDefinition } from './table_vis_type'; import { Vis } from '../../visualizations/public'; import { setup as visualizationsSetup } from '../../visualizations/public/np_ready/public/legacy'; @@ -148,7 +148,7 @@ describe('Table Vis - Controller', () => { // basically a parameterized beforeEach function initController(vis: Vis) { - vis.aggs.aggs.forEach((agg: AggConfig, i: number) => { + vis.aggs.aggs.forEach((agg: IAggConfig, i: number) => { agg.id = 'agg_' + (i + 1); }); diff --git a/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/index.test.tsx b/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/index.test.tsx index 514b957765a99e..944ed7e20d1f71 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/index.test.tsx +++ b/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/index.test.tsx @@ -27,7 +27,7 @@ import { Positions } from '../../../utils/collections'; import { ValueAxesPanel } from './value_axes_panel'; import { CategoryAxisPanel } from './category_axis_panel'; import { ChartTypes } from '../../../utils/collections'; -import { AggConfig, AggType } from '../../../legacy_imports'; +import { IAggConfig, IAggType } from '../../../legacy_imports'; import { defaultValueAxisId, valueAxis, seriesParam, categoryAxis } from './mocks'; jest.mock('ui/new_platform'); @@ -44,17 +44,17 @@ jest.mock('./value_axes_panel', () => ({ const SERIES_PARAMS = 'seriesParams'; const VALUE_AXES = 'valueAxes'; -const aggCount: AggConfig = { +const aggCount: IAggConfig = { id: '1', type: { name: 'count' }, makeLabel: () => 'Count', -} as AggConfig; +} as IAggConfig; -const aggAverage: AggConfig = { +const aggAverage: IAggConfig = { id: '2', - type: { name: 'average' } as AggType, + type: { name: 'average' } as IAggType, makeLabel: () => 'Average', -} as AggConfig; +} as IAggConfig; const createAggs = (aggs: any[]) => ({ aggs, diff --git a/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/index.tsx b/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/index.tsx index c4dcbfaa47265d..cdc8996f3fdeb5 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/index.tsx +++ b/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/index.tsx @@ -21,7 +21,7 @@ import React, { useState, useEffect, useCallback, useMemo } from 'react'; import { cloneDeep, uniq, get } from 'lodash'; import { EuiSpacer } from '@elastic/eui'; -import { AggConfig } from '../../../legacy_imports'; +import { IAggConfig } from '../../../legacy_imports'; import { BasicVislibParams, ValueAxis, SeriesParam, Axis } from '../../../types'; import { ValidationVisOptionsProps } from '../../common'; import { SeriesPanel } from './series_panel'; @@ -99,7 +99,7 @@ function MetricsAxisOptions(props: ValidationVisOptionsProps) stateParams.valueAxes.forEach((axis, axisNumber) => { let newCustomLabel = ''; - const matchingSeries: AggConfig[] = []; + const matchingSeries: IAggConfig[] = []; series.forEach((serie, seriesIndex) => { if ((axisNumber === 0 && !serie.valueAxis) || serie.valueAxis === axis.id) { diff --git a/src/legacy/core_plugins/vis_type_vislib/public/legacy_imports.ts b/src/legacy/core_plugins/vis_type_vislib/public/legacy_imports.ts index df7278f2b761ff..50a91df01de7c8 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/legacy_imports.ts +++ b/src/legacy/core_plugins/vis_type_vislib/public/legacy_imports.ts @@ -17,7 +17,7 @@ * under the License. */ -export { AggType, AggConfig, AggGroupNames, Schemas } from 'ui/agg_types'; +export { AggType, AggGroupNames, IAggConfig, IAggType, Schemas } from 'ui/agg_types'; // @ts-ignore export { SimpleEmitter } from 'ui/utils/simple_emitter'; // @ts-ignore diff --git a/src/legacy/core_plugins/visualizations/public/embeddable/query_geohash_bounds.ts b/src/legacy/core_plugins/visualizations/public/embeddable/query_geohash_bounds.ts index 46ade8ce465c00..719d69e21a826d 100644 --- a/src/legacy/core_plugins/visualizations/public/embeddable/query_geohash_bounds.ts +++ b/src/legacy/core_plugins/visualizations/public/embeddable/query_geohash_bounds.ts @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { get } from 'lodash'; import { toastNotifications } from 'ui/notify'; -import { AggConfig } from 'ui/agg_types'; +import { IAggConfig } from 'ui/agg_types'; import { timefilter } from 'ui/timefilter'; import { Vis } from '../np_ready/public'; import { esFilters, Query, SearchSource, ISearchSource } from '../../../../../plugins/data/public'; @@ -42,7 +42,7 @@ interface QueryGeohashBoundsParams { * TODO: Remove this as a part of elastic/kibana#30593 */ export async function queryGeohashBounds(vis: Vis, params: QueryGeohashBoundsParams) { - const agg = vis.getAggConfig().aggs.find((a: AggConfig) => { + const agg = vis.getAggConfig().aggs.find((a: IAggConfig) => { return get(a, 'type.dslName') === 'geohash_grid'; }); diff --git a/src/legacy/core_plugins/visualizations/public/legacy_imports.ts b/src/legacy/core_plugins/visualizations/public/legacy_imports.ts index 3088c4e67a3b76..5cff588d951b04 100644 --- a/src/legacy/core_plugins/visualizations/public/legacy_imports.ts +++ b/src/legacy/core_plugins/visualizations/public/legacy_imports.ts @@ -18,12 +18,13 @@ */ export { PersistedState } from '../../../ui/public/persisted_state'; -export { AggConfig } from '../../../ui/public/agg_types/agg_config'; -export { AggConfigs } from '../../../ui/public/agg_types/agg_configs'; export { + AggConfigs, + IAggConfig, + IAggConfigs, isDateHistogramBucketAggConfig, setBounds, -} from '../../../ui/public/agg_types/buckets/date_histogram'; +} from '../../../ui/public/agg_types'; export { createFormat } from '../../../ui/public/visualize/loader/pipeline_helpers/utilities'; export { I18nContext } from '../../../ui/public/i18n'; import chrome from '../../../ui/public/chrome'; diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy/build_pipeline.test.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy/build_pipeline.test.ts index e733bad2c01274..d1017de35474a9 100644 --- a/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy/build_pipeline.test.ts +++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy/build_pipeline.test.ts @@ -27,11 +27,11 @@ import { Schemas, } from './build_pipeline'; import { Vis, VisState } from '..'; -import { AggConfig } from '../../../legacy_imports'; +import { IAggConfig } from '../../../legacy_imports'; import { searchSourceMock } from '../../../legacy_mocks'; jest.mock('ui/new_platform'); -jest.mock('ui/agg_types/buckets/date_histogram', () => ({ +jest.mock('ui/agg_types', () => ({ setBounds: () => {}, dateHistogramBucketAgg: () => {}, isDateHistogramBucketAggConfig: () => true, @@ -367,7 +367,7 @@ describe('visualize loader pipeline helpers: build pipeline', () => { }); describe('buildVislibDimensions', () => { - let aggs: AggConfig[]; + let aggs: IAggConfig[]; let visState: any; let vis: Vis; let params: any; @@ -385,7 +385,7 @@ describe('visualize loader pipeline helpers: build pipeline', () => { name: 'metric', }, params: {}, - } as AggConfig, + } as IAggConfig, ]; params = { @@ -453,7 +453,7 @@ describe('visualize loader pipeline helpers: build pipeline', () => { it('with two numeric metrics, mixed normal and percent mode should have corresponding formatters', async () => { const aggConfig = aggs[0]; - aggs = [{ ...aggConfig } as AggConfig, { ...aggConfig, id: '5' } as AggConfig]; + aggs = [{ ...aggConfig } as IAggConfig, { ...aggConfig, id: '5' } as IAggConfig]; visState = { params: { diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy/build_pipeline.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy/build_pipeline.ts index 6749a44b4d5b37..04a296a888e87f 100644 --- a/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy/build_pipeline.ts +++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy/build_pipeline.ts @@ -23,7 +23,7 @@ import moment from 'moment'; import { SerializedFieldFormat } from 'src/plugins/expressions/public'; import { ISearchSource } from 'src/plugins/data/public'; import { - AggConfig, + IAggConfig, setBounds, isDateHistogramBucketAggConfig, createFormat, @@ -85,7 +85,7 @@ const vislibCharts: string[] = [ ]; export const getSchemas = (vis: Vis, timeRange?: any): Schemas => { - const createSchemaConfig = (accessor: number, agg: AggConfig): SchemaConfig => { + const createSchemaConfig = (accessor: number, agg: IAggConfig): SchemaConfig => { if (isDateHistogramBucketAggConfig(agg)) { agg.params.timeRange = timeRange; setBounds(agg, true); @@ -130,10 +130,10 @@ export const getSchemas = (vis: Vis, timeRange?: any): Schemas => { const schemas: Schemas = { metric: [], }; - const responseAggs = vis.aggs.getResponseAggs().filter((agg: AggConfig) => agg.enabled); + const responseAggs = vis.aggs.getResponseAggs().filter((agg: IAggConfig) => agg.enabled); const isHierarchical = vis.isHierarchical(); - const metrics = responseAggs.filter((agg: AggConfig) => agg.type.type === 'metrics'); - responseAggs.forEach((agg: AggConfig) => { + const metrics = responseAggs.filter((agg: IAggConfig) => agg.type.type === 'metrics'); + responseAggs.forEach((agg: IAggConfig) => { let skipMetrics = false; let schemaName = agg.schema ? agg.schema.name || agg.schema : null; if (typeof schemaName === 'object') { @@ -224,7 +224,7 @@ export const prepareDimension = (variable: string, data: any) => { const adjustVislibDimensionFormmaters = (vis: Vis, dimensions: { y: any[] }): void => { const visState = vis.getCurrentState(); const visConfig = visState.params; - const responseAggs = vis.aggs.getResponseAggs().filter((agg: AggConfig) => agg.enabled); + const responseAggs = vis.aggs.getResponseAggs().filter((agg: IAggConfig) => agg.enabled); (dimensions.y || []).forEach(yDimension => { const yAgg = responseAggs[yDimension.accessor]; diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/vis.d.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/vis.d.ts index 6e6a2174d6ad14..71bf9bcf983ffb 100644 --- a/src/legacy/core_plugins/visualizations/public/np_ready/public/vis.d.ts +++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/vis.d.ts @@ -18,7 +18,7 @@ */ import { VisType } from './types'; -import { AggConfigs } from '../../legacy_imports'; +import { IAggConfigs } from '../../legacy_imports'; import { Status } from './legacy/update_status'; export interface Vis { @@ -39,7 +39,7 @@ export interface VisState { title: string; type: VisType; params: VisParams; - aggs: AggConfigs; + aggs: IAggConfigs; } export declare class VisualizationController { diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/vis.js b/src/legacy/core_plugins/visualizations/public/np_ready/public/vis.js index 4f1526c20cb6f7..0c2e5012df4393 100644 --- a/src/legacy/core_plugins/visualizations/public/np_ready/public/vis.js +++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/vis.js @@ -21,7 +21,7 @@ * @name Vis * * @description This class consists of aggs, params, listeners, title, and type. - * - Aggs: Instances of AggConfig. + * - Aggs: Instances of IAggConfig. * - Params: The settings in the Options tab. * * Not to be confused with vislib/vis.js. diff --git a/src/legacy/ui/public/agg_response/tabify/_get_columns.ts b/src/legacy/ui/public/agg_response/tabify/_get_columns.ts index a3127c039049b5..4144d5be16012a 100644 --- a/src/legacy/ui/public/agg_response/tabify/_get_columns.ts +++ b/src/legacy/ui/public/agg_response/tabify/_get_columns.ts @@ -18,15 +18,15 @@ */ import { groupBy } from 'lodash'; -import { AggConfig } from '../../agg_types'; +import { IAggConfig } from '../../agg_types'; export interface AggColumn { - aggConfig: AggConfig; + aggConfig: IAggConfig; id: string; name: string; } -const getColumn = (agg: AggConfig, i: number): AggColumn => { +const getColumn = (agg: IAggConfig, i: number): AggColumn => { return { aggConfig: agg, id: `col-${i}-${agg.id}`, @@ -40,7 +40,7 @@ const getColumn = (agg: AggConfig, i: number): AggColumn => { * @param {AggConfigs} aggs - the agg configs object to which the aggregation response correlates * @param {boolean} minimalColumns - setting to true will only return a column for the last bucket/metric instead of one for each level */ -export function tabifyGetColumns(aggs: AggConfig[], minimalColumns: boolean) { +export function tabifyGetColumns(aggs: IAggConfig[], minimalColumns: boolean) { // pick the columns if (minimalColumns) { return aggs.map((agg, i) => getColumn(agg, i)); diff --git a/src/legacy/ui/public/agg_types/index.ts b/src/legacy/ui/public/agg_types/index.ts index cf2733b9a9f36a..ac5d0bed7ef153 100644 --- a/src/legacy/ui/public/agg_types/index.ts +++ b/src/legacy/ui/public/agg_types/index.ts @@ -17,15 +17,69 @@ * under the License. */ -export { aggTypes } from './agg_types'; -export { AggParam } from './agg_params'; -export { AggConfig } from './agg_config'; -export { AggConfigs } from './agg_configs'; -export { AggGroupNames, aggGroupNamesMap } from './agg_groups'; -export { FieldParamType } from './param_types'; -export { BUCKET_TYPES } from './buckets/bucket_agg_types'; -export { METRIC_TYPES } from './metrics/metric_agg_types'; -export { ISchemas, Schema, Schemas } from './schemas'; -export { AggType } from './agg_type'; -export { setBounds } from './buckets/date_histogram'; -export { termsAggFilter } from './buckets/terms'; +/** + * Nothing to see here! + * + * Agg Types have moved to the data plugin, and are being + * re-exported from ui/agg_types for backwards compatibility. + */ + +import { start as dataStart } from '../../../core_plugins/data/public/legacy'; + +// runtime contracts +export const { + types: aggTypes, + AggConfig, + AggConfigs, + AggType, + aggTypeFieldFilters, + FieldParamType, + MetricAggType, + parentPipelineAggHelper, + siblingPipelineAggHelper, + setBounds, +} = dataStart.search.aggs; + +// types +export { + IAggConfig, + IAggConfigs, + IAggType, + IFieldParamType, + IMetricAggType, + AggParam, + AggParamOption, + BUCKET_TYPES, + DateRangeKey, + IpRangeKey, + ISchemas, + METRIC_TYPES, + OptionedParamEditorProps, + OptionedValueProp, +} from '../../../core_plugins/data/public'; + +// static code +export { + AggParamType, + AggTypeFilters, + aggTypeFilters, + AggTypeFieldFilters, + AggGroupNames, + aggGroupNamesMap, + CidrMask, + convertDateRangeToString, + convertIPRangeToString, + intervalOptions, + isDateHistogramBucketAggConfig, + isStringType, + isType, + isValidInterval, + isValidJson, + OptionedParamType, + parentPipelineType, + propFilter, + Schema, + Schemas, + siblingPipelineType, + termsAggFilter, +} from '../../../core_plugins/data/public'; diff --git a/src/legacy/ui/public/time_buckets/time_buckets.js b/src/legacy/ui/public/time_buckets/time_buckets.js index 50a57d866099ec..a611de45fa8596 100644 --- a/src/legacy/ui/public/time_buckets/time_buckets.js +++ b/src/legacy/ui/public/time_buckets/time_buckets.js @@ -144,7 +144,7 @@ TimeBuckets.prototype.getDuration = function() { * generated. * * Input can be one of the following: - * - Any object from src/legacy/ui/agg_types/buckets/_interval_options.js + * - Any object from src/legacy/ui/agg_types.js * - "auto" * - Pass a valid moment unit * - a moment.duration object. diff --git a/src/legacy/ui/public/vis/__tests__/_agg_config.js b/src/legacy/ui/public/vis/__tests__/_agg_config.js index 2ccbaf6c1645e0..7dccf3eec18aa4 100644 --- a/src/legacy/ui/public/vis/__tests__/_agg_config.js +++ b/src/legacy/ui/public/vis/__tests__/_agg_config.js @@ -21,8 +21,8 @@ import sinon from 'sinon'; import expect from '@kbn/expect'; import ngMock from 'ng_mock'; import { Vis } from '../../../../core_plugins/visualizations/public'; -import { AggType } from '../../agg_types/agg_type'; -import { AggConfig } from '../../agg_types/agg_config'; +import { AggType, AggConfig } from '../../agg_types'; + import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; describe('AggConfig', function() { diff --git a/src/legacy/ui/public/vis/config/editor_config_providers.test.ts b/src/legacy/ui/public/vis/config/editor_config_providers.test.ts index 9d93930c09ebc5..d52c9119dd76a5 100644 --- a/src/legacy/ui/public/vis/config/editor_config_providers.test.ts +++ b/src/legacy/ui/public/vis/config/editor_config_providers.test.ts @@ -17,7 +17,7 @@ * under the License. */ -import { AggConfig } from 'ui/agg_types'; +import { IAggConfig } from 'ui/agg_types'; import { EditorConfigProviderRegistry } from './editor_config_providers'; import { EditorParamConfig, FixedParam, NumericIntervalParam, TimeIntervalParam } from './types'; @@ -48,7 +48,7 @@ describe('EditorConfigProvider', () => { const provider = jest.fn(() => ({})); registry.register(provider); expect(provider).not.toHaveBeenCalled(); - const aggConfig = {} as AggConfig; + const aggConfig = {} as IAggConfig; registry.getConfigForAgg(indexPattern, aggConfig); expect(provider).toHaveBeenCalledWith(indexPattern, aggConfig); }); @@ -60,7 +60,7 @@ describe('EditorConfigProvider', () => { registry.register(provider2); expect(provider).not.toHaveBeenCalled(); expect(provider2).not.toHaveBeenCalled(); - const aggConfig = {} as AggConfig; + const aggConfig = {} as IAggConfig; registry.getConfigForAgg(indexPattern, aggConfig); expect(provider).toHaveBeenCalledWith(indexPattern, aggConfig); expect(provider2).toHaveBeenCalledWith(indexPattern, aggConfig); @@ -72,7 +72,7 @@ describe('EditorConfigProvider', () => { } function getOutputConfig(reg: EditorConfigProviderRegistry) { - return reg.getConfigForAgg(indexPattern, {} as AggConfig).singleParam; + return reg.getConfigForAgg(indexPattern, {} as IAggConfig).singleParam; } it('should have hidden true if at least one config was hidden true', () => { diff --git a/src/legacy/ui/public/vis/config/editor_config_providers.ts b/src/legacy/ui/public/vis/config/editor_config_providers.ts index 1e82a3ca2762e0..ec82597d5fb19b 100644 --- a/src/legacy/ui/public/vis/config/editor_config_providers.ts +++ b/src/legacy/ui/public/vis/config/editor_config_providers.ts @@ -18,7 +18,7 @@ */ import { IndexPattern } from 'src/plugins/data/public'; -import { AggConfig } from 'ui/agg_types'; +import { IAggConfig } from 'ui/agg_types'; import { parseEsInterval } from '../../../../core_plugins/data/public'; import { TimeIntervalParam, @@ -29,7 +29,7 @@ import { } from './types'; import { leastCommonInterval, leastCommonMultiple } from '../lib'; -type EditorConfigProvider = (indexPattern: IndexPattern, aggConfig: AggConfig) => EditorConfig; +type EditorConfigProvider = (indexPattern: IndexPattern, aggConfig: IAggConfig) => EditorConfig; class EditorConfigProviderRegistry { private providers: Set = new Set(); @@ -38,7 +38,7 @@ class EditorConfigProviderRegistry { this.providers.add(configProvider); } - public getConfigForAgg(indexPattern: IndexPattern, aggConfig: AggConfig): EditorConfig { + public getConfigForAgg(indexPattern: IndexPattern, aggConfig: IAggConfig): EditorConfig { const configs = Array.from(this.providers).map(provider => provider(indexPattern, aggConfig)); return this.mergeConfigs(configs); } diff --git a/src/legacy/ui/public/visualize/loader/pipeline_helpers/utilities.ts b/src/legacy/ui/public/visualize/loader/pipeline_helpers/utilities.ts index e763eb1b90791e..d8227343159e6c 100644 --- a/src/legacy/ui/public/visualize/loader/pipeline_helpers/utilities.ts +++ b/src/legacy/ui/public/visualize/loader/pipeline_helpers/utilities.ts @@ -19,15 +19,15 @@ import { i18n } from '@kbn/i18n'; import { identity } from 'lodash'; -import { AggConfig } from 'ui/agg_types'; +import { IAggConfig } from 'ui/agg_types'; import { npStart } from 'ui/new_platform'; import { SerializedFieldFormat } from 'src/plugins/expressions/public'; import { fieldFormats } from '../../../../../../plugins/data/public'; import { Vis } from '../../../../../core_plugins/visualizations/public'; import { tabifyGetColumns } from '../../../agg_response/tabify/_get_columns'; -import { DateRangeKey, convertDateRangeToString } from '../../../agg_types/buckets/date_range'; -import { IpRangeKey, convertIPRangeToString } from '../../../agg_types/buckets/ip_range'; +import { DateRangeKey, convertDateRangeToString } from '../../../agg_types'; +import { IpRangeKey, convertIPRangeToString } from '../../../agg_types'; interface TermsFieldFormatParams { otherBucketLabel: string; @@ -62,7 +62,7 @@ const getFieldFormat = ( return new DefaultFieldFormat(); }; -export const createFormat = (agg: AggConfig): SerializedFieldFormat => { +export const createFormat = (agg: IAggConfig): SerializedFieldFormat => { const format: SerializedFieldFormat = agg.params.field ? agg.params.field.format.toJSON() : {}; const formats: Record SerializedFieldFormat> = { date_range: () => ({ id: 'date_range', params: format }), @@ -106,7 +106,7 @@ export const getFormat: FormatFactory = mapping => { const format = getFieldFormat(id, mapping.params); const gte = '\u2265'; const lt = '\u003c'; - return i18n.translate('common.ui.aggTypes.buckets.ranges.rangesFormatMessage', { + return i18n.translate('common.ui.aggTypes.rangesFormatMessage', { defaultMessage: '{gte} {from} and {lt} {to}', values: { gte, @@ -155,7 +155,7 @@ export const getFormat: FormatFactory = mapping => { } }; -export const getTableAggs = (vis: Vis): AggConfig[] => { +export const getTableAggs = (vis: Vis): IAggConfig[] => { if (!vis.aggs || !vis.aggs.getResponseAggs) { return []; } diff --git a/x-pack/legacy/plugins/lens/public/editor_frame_plugin/plugin.test.tsx b/x-pack/legacy/plugins/lens/public/editor_frame_plugin/plugin.test.tsx index da9fdd7927d605..7a6067dd5f23c2 100644 --- a/x-pack/legacy/plugins/lens/public/editor_frame_plugin/plugin.test.tsx +++ b/x-pack/legacy/plugins/lens/public/editor_frame_plugin/plugin.test.tsx @@ -14,9 +14,6 @@ import { } from './mocks'; jest.mock('ui/new_platform'); -jest.mock('ui/chrome', () => ({ - getSavedObjectsClient: jest.fn(), -})); // mock away actual dependencies to prevent all of it being loaded jest.mock('../../../../../../src/legacy/core_plugins/interpreter/public/registries', () => {}); diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations/definitions/date_histogram.test.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations/definitions/date_histogram.test.tsx index 2bd6c7106a952a..5be92e31f4934a 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations/definitions/date_histogram.test.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations/definitions/date_histogram.test.tsx @@ -14,33 +14,31 @@ import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { createMockedIndexPattern } from '../../mocks'; import { IndexPatternPrivateState } from '../../types'; -jest.mock('ui/new_platform', () => { +jest.mock(`ui/new_platform`, () => { // Due to the way we are handling shims in the NP migration, we need // to mock core here so that upstream services don't cause these // tests to fail. Ordinarly `jest.mock('ui/new_platform')` would be // sufficient, however we need to mock one of the `uiSettings` return // values for this suite, so we must manually assemble the mock. // Because babel hoists `jest` we must use an inline `require` - // to ensure the core mocks are available (`jest.doMock` doesn't + // to ensure the mocks are available (`jest.doMock` doesn't // work in this case). This mock should be able to be replaced // altogether once Lens has migrated to the new platform. - const { coreMock } = require('src/core/public/mocks'); // eslint-disable-line @typescript-eslint/no-var-requires + const { + createUiNewPlatformMock, + } = require('../../../../../../../../src/legacy/ui/public/new_platform/__mocks__/helpers'); // eslint-disable-line @typescript-eslint/no-var-requires + // This is basically duplicating what would ordinarily happen in + // `ui/new_platform/__mocks__` + const { npSetup, npStart } = createUiNewPlatformMock(); + // Override the core mock provided by `ui/new_platform` + npStart.core.uiSettings.get = (path: string) => { + if (path === 'histogram:maxBars') { + return 10; + } + }; return { - npSetup: { - core: coreMock.createSetup(), - }, - npStart: { - core: { - ...coreMock.createStart(), - uiSettings: { - get: (path: string) => { - if (path === 'histogram:maxBars') { - return 10; - } - }, - }, - }, - }, + npSetup, + npStart, }; }); diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations/definitions/date_histogram.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations/definitions/date_histogram.tsx index dbb6278352f096..ae12be90ddd058 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations/definitions/date_histogram.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations/definitions/date_histogram.tsx @@ -9,7 +9,7 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; // TODO: make this new-platform compatible -import { isValidInterval } from 'ui/agg_types/utils'; +import { isValidInterval } from 'ui/agg_types'; import { EuiForm, diff --git a/x-pack/legacy/plugins/rollup/public/legacy.ts b/x-pack/legacy/plugins/rollup/public/legacy.ts index a2738372ff346f..a70f181dc86fb7 100644 --- a/x-pack/legacy/plugins/rollup/public/legacy.ts +++ b/x-pack/legacy/plugins/rollup/public/legacy.ts @@ -6,8 +6,8 @@ import { npSetup, npStart } from 'ui/new_platform'; import { editorConfigProviders } from 'ui/vis/config'; -import { aggTypeFilters } from 'ui/agg_types/filter'; -import { aggTypeFieldFilters } from 'ui/agg_types/param_types/filter'; +import { aggTypeFilters } from 'ui/agg_types'; +import { aggTypeFieldFilters } from 'ui/agg_types'; import { addSearchStrategy } from '../../../../../src/plugins/data/public'; import { RollupPlugin } from './plugin'; import { setup as management } from '../../../../../src/legacy/core_plugins/management/public/legacy'; diff --git a/x-pack/legacy/plugins/rollup/public/legacy_imports.ts b/x-pack/legacy/plugins/rollup/public/legacy_imports.ts index 981f97963591e7..4fece0fddfa3ef 100644 --- a/x-pack/legacy/plugins/rollup/public/legacy_imports.ts +++ b/x-pack/legacy/plugins/rollup/public/legacy_imports.ts @@ -7,6 +7,6 @@ // @ts-ignore export { findIllegalCharactersInIndexName, INDEX_ILLEGAL_CHARACTERS_VISIBLE } from 'ui/indices'; -export { AggTypeFilters } from 'ui/agg_types/filter'; -export { AggTypeFieldFilters } from 'ui/agg_types/param_types/filter'; +export { AggTypeFilters } from 'ui/agg_types'; +export { AggTypeFieldFilters } from 'ui/agg_types'; export { EditorConfigProviderRegistry } from 'ui/vis/config'; diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 58d97ce263bea6..351bc9def3082f 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -77,109 +77,110 @@ }, "messages": { "common.ui.aggResponse.allDocsTitle": "すべてのドキュメント", - "common.ui.aggTypes.aggGroups.bucketsText": "バケット", - "common.ui.aggTypes.aggGroups.metricsText": "メトリック", - "common.ui.aggTypes.buckets.dateHistogramLabel": "{intervalDescription}ごとの {fieldName}", - "common.ui.aggTypes.buckets.dateHistogramTitle": "日付ヒストグラム", - "common.ui.aggTypes.buckets.dateRangeTitle": "日付範囲", - "common.ui.aggTypes.buckets.filtersTitle": "フィルター", - "common.ui.aggTypes.buckets.filterTitle": "フィルター", - "common.ui.aggTypes.buckets.geohashGridTitle": "ジオハッシュ", - "common.ui.aggTypes.buckets.geotileGridTitle": "ジオタイル", - "common.ui.aggTypes.buckets.histogramTitle": "ヒストグラム", - "common.ui.aggTypes.buckets.intervalOptions.autoDisplayName": "自動", - "common.ui.aggTypes.buckets.intervalOptions.dailyDisplayName": "日ごと", - "common.ui.aggTypes.buckets.intervalOptions.hourlyDisplayName": "1 時間ごと", - "common.ui.aggTypes.buckets.intervalOptions.millisecondDisplayName": "ミリ秒", - "common.ui.aggTypes.buckets.intervalOptions.minuteDisplayName": "分", - "common.ui.aggTypes.buckets.intervalOptions.monthlyDisplayName": "月ごと", - "common.ui.aggTypes.buckets.intervalOptions.secondDisplayName": "秒", - "common.ui.aggTypes.buckets.intervalOptions.weeklyDisplayName": "週ごと", - "common.ui.aggTypes.buckets.intervalOptions.yearlyDisplayName": "1 年ごと", - "common.ui.aggTypes.buckets.ipRangeLabel": "{fieldName} IP 範囲", - "common.ui.aggTypes.buckets.ipRangeTitle": "IPv4 範囲", - "common.ui.aggTypes.buckets.ranges.rangesFormatMessage": "{gte} {from} と {lt} {to}", - "common.ui.aggTypes.buckets.rangesLabel": "{fieldName} の範囲", - "common.ui.aggTypes.buckets.rangeTitle": "範囲", - "common.ui.aggTypes.buckets.significantTerms.excludeLabel": "除外", - "common.ui.aggTypes.buckets.significantTerms.includeLabel": "含める", - "common.ui.aggTypes.buckets.significantTermsLabel": "{fieldName} のトップ {size} の珍しいアイテム", - "common.ui.aggTypes.buckets.significantTermsTitle": "重要な用語", - "common.ui.aggTypes.buckets.terms.excludeLabel": "除外", - "common.ui.aggTypes.buckets.terms.includeLabel": "含める", - "common.ui.aggTypes.buckets.terms.missingBucketLabel": "欠測値", - "common.ui.aggTypes.buckets.terms.orderAscendingTitle": "昇順", - "common.ui.aggTypes.buckets.terms.orderDescendingTitle": "降順", - "common.ui.aggTypes.buckets.terms.otherBucketDescription": "このリクエストは、データバケットの基準外のドキュメントの数をカウントします。", - "common.ui.aggTypes.buckets.terms.otherBucketLabel": "その他", - "common.ui.aggTypes.buckets.terms.otherBucketTitle": "他のバケット", - "common.ui.aggTypes.buckets.termsTitle": "用語", - "common.ui.aggTypes.histogram.missingMaxMinValuesWarning": "自動スケールヒストグラムバケットから最高値と最低値を取得できません。これによりビジュアライゼーションのパフォーマンスが低下する可能性があります。", - "common.ui.aggTypes.metrics.averageBucketTitle": "平均バケット", - "common.ui.aggTypes.metrics.averageLabel": "平均 {field}", - "common.ui.aggTypes.metrics.averageTitle": "平均", - "common.ui.aggTypes.metrics.bucketAggTitle": "バケット集約", - "common.ui.aggTypes.metrics.countLabel": "カウント", - "common.ui.aggTypes.metrics.countTitle": "カウント", - "common.ui.aggTypes.metrics.cumulativeSumLabel": "累積合計", - "common.ui.aggTypes.metrics.cumulativeSumTitle": "累積合計", - "common.ui.aggTypes.metrics.derivativeLabel": "派生", - "common.ui.aggTypes.metrics.derivativeTitle": "派生", - "common.ui.aggTypes.metrics.geoBoundsLabel": "境界", - "common.ui.aggTypes.metrics.geoBoundsTitle": "境界", - "common.ui.aggTypes.metrics.geoCentroidLabel": "ジオセントロイド", - "common.ui.aggTypes.metrics.geoCentroidTitle": "ジオセントロイド", - "common.ui.aggTypes.metrics.maxBucketTitle": "最高バケット", - "common.ui.aggTypes.metrics.maxLabel": "最高 {field}", - "common.ui.aggTypes.metrics.maxTitle": "最高", - "common.ui.aggTypes.metrics.medianLabel": "中央 {field}", - "common.ui.aggTypes.metrics.medianTitle": "中央", - "common.ui.aggTypes.metrics.metricAggregationsSubtypeTitle": "メトリック集約", - "common.ui.aggTypes.metrics.metricAggTitle": "メトリック集約", - "common.ui.aggTypes.metrics.minBucketTitle": "最低バケット", - "common.ui.aggTypes.metrics.minLabel": "最低 {field}", - "common.ui.aggTypes.metrics.minTitle": "最低", - "common.ui.aggTypes.metrics.movingAvgLabel": "移動平均", - "common.ui.aggTypes.metrics.movingAvgTitle": "移動平均", - "common.ui.aggTypes.metrics.overallAverageLabel": "全体平均", - "common.ui.aggTypes.metrics.overallMaxLabel": "全体最高", - "common.ui.aggTypes.metrics.overallMinLabel": "全体最低", - "common.ui.aggTypes.metrics.overallSumLabel": "全体合計", - "common.ui.aggTypes.metrics.parentPipelineAggregationsSubtypeTitle": "親パイプライン集約", - "common.ui.aggTypes.metrics.percentileRanks.valuePropsLabel": "「{label}」の {format} のパーセンタイル順位", - "common.ui.aggTypes.metrics.percentileRanksLabel": "{field} のパーセンタイル順位", - "common.ui.aggTypes.metrics.percentileRanksTitle": "パーセンタイル順位", - "common.ui.aggTypes.metrics.percentiles.valuePropsLabel": "{label} の {percentile} パーセンタイル", - "common.ui.aggTypes.metrics.percentilesLabel": "{field} のパーセンタイル", - "common.ui.aggTypes.metrics.percentilesTitle": "パーセンタイル", - "common.ui.aggTypes.metrics.serialDiffLabel": "差分の推移", - "common.ui.aggTypes.metrics.serialDiffTitle": "差分の推移", - "common.ui.aggTypes.metrics.siblingPipelineAggregationsSubtypeTitle": "シブリングパイプラインアグリゲーション", - "common.ui.aggTypes.metrics.standardDeviation.keyDetailsLabel": "{fieldDisplayName} の標準偏差", - "common.ui.aggTypes.metrics.standardDeviation.lowerKeyDetailsTitle": "下の{label}", - "common.ui.aggTypes.metrics.standardDeviation.upperKeyDetailsTitle": "上の{label}", - "common.ui.aggTypes.metrics.standardDeviationLabel": "{field} の標準偏差", - "common.ui.aggTypes.metrics.standardDeviationTitle": "標準偏差", - "common.ui.aggTypes.metrics.sumBucketTitle": "合計バケット", - "common.ui.aggTypes.metrics.sumLabel": "{field} の合計", - "common.ui.aggTypes.metrics.sumTitle": "合計", - "common.ui.aggTypes.metrics.topHit.ascendingLabel": "昇順", - "common.ui.aggTypes.metrics.topHit.averageLabel": "平均", - "common.ui.aggTypes.metrics.topHit.concatenateLabel": "連結", - "common.ui.aggTypes.metrics.topHit.descendingLabel": "降順", - "common.ui.aggTypes.metrics.topHit.firstPrefixLabel": "最初", - "common.ui.aggTypes.metrics.topHit.lastPrefixLabel": "最後", - "common.ui.aggTypes.metrics.topHit.maxLabel": "最高", - "common.ui.aggTypes.metrics.topHit.minLabel": "最低", - "common.ui.aggTypes.metrics.topHit.sumLabel": "合計", - "common.ui.aggTypes.metrics.topHitTitle": "トップヒット", - "common.ui.aggTypes.metrics.uniqueCountLabel": "{field} のユニークカウント", - "common.ui.aggTypes.metrics.uniqueCountTitle": "ユニークカウント", - "common.ui.aggTypes.otherBucket.labelForMissingValuesLabel": "欠測値のラベル", - "common.ui.aggTypes.otherBucket.labelForOtherBucketLabel": "他のバケットのラベル", - "common.ui.aggTypes.paramTypes.field.invalidSavedFieldParameterErrorMessage": "保存された {fieldParameter} パラメーターが無効になりました。新しいフィールドを選択してください。", - "common.ui.aggTypes.paramTypes.field.requiredFieldParameterErrorMessage": "{fieldParameter} は必須パラメーターです", - "common.ui.aggTypes.string.customLabel": "カスタムラベル", + "common.ui.aggTypes.rangesFormatMessage": "{gte} {from} と {lt} {to}", + "data.search.aggs.aggGroups.bucketsText": "バケット", + "data.search.aggs.aggGroups.metricsText": "メトリック", + "data.search.aggs.buckets.dateHistogramLabel": "{intervalDescription}ごとの {fieldName}", + "data.search.aggs.buckets.dateHistogramTitle": "日付ヒストグラム", + "data.search.aggs.buckets.dateRangeTitle": "日付範囲", + "data.search.aggs.buckets.filtersTitle": "フィルター", + "data.search.aggs.buckets.filterTitle": "フィルター", + "data.search.aggs.buckets.geohashGridTitle": "ジオハッシュ", + "data.search.aggs.buckets.geotileGridTitle": "ジオタイル", + "data.search.aggs.buckets.histogramTitle": "ヒストグラム", + "data.search.aggs.buckets.intervalOptions.autoDisplayName": "自動", + "data.search.aggs.buckets.intervalOptions.dailyDisplayName": "日ごと", + "data.search.aggs.buckets.intervalOptions.hourlyDisplayName": "1 時間ごと", + "data.search.aggs.buckets.intervalOptions.millisecondDisplayName": "ミリ秒", + "data.search.aggs.buckets.intervalOptions.minuteDisplayName": "分", + "data.search.aggs.buckets.intervalOptions.monthlyDisplayName": "月ごと", + "data.search.aggs.buckets.intervalOptions.secondDisplayName": "秒", + "data.search.aggs.buckets.intervalOptions.weeklyDisplayName": "週ごと", + "data.search.aggs.buckets.intervalOptions.yearlyDisplayName": "1 年ごと", + "data.search.aggs.buckets.ipRangeLabel": "{fieldName} IP 範囲", + "data.search.aggs.buckets.ipRangeTitle": "IPv4 範囲", + "data.search.aggs.aggTypes.rangesFormatMessage": "{gte} {from} と {lt} {to}", + "data.search.aggs.aggTypesLabel": "{fieldName} の範囲", + "data.search.aggs.buckets.rangeTitle": "範囲", + "data.search.aggs.buckets.significantTerms.excludeLabel": "除外", + "data.search.aggs.buckets.significantTerms.includeLabel": "含める", + "data.search.aggs.buckets.significantTermsLabel": "{fieldName} のトップ {size} の珍しいアイテム", + "data.search.aggs.buckets.significantTermsTitle": "重要な用語", + "data.search.aggs.buckets.terms.excludeLabel": "除外", + "data.search.aggs.buckets.terms.includeLabel": "含める", + "data.search.aggs.buckets.terms.missingBucketLabel": "欠測値", + "data.search.aggs.buckets.terms.orderAscendingTitle": "昇順", + "data.search.aggs.buckets.terms.orderDescendingTitle": "降順", + "data.search.aggs.buckets.terms.otherBucketDescription": "このリクエストは、データバケットの基準外のドキュメントの数をカウントします。", + "data.search.aggs.buckets.terms.otherBucketLabel": "その他", + "data.search.aggs.buckets.terms.otherBucketTitle": "他のバケット", + "data.search.aggs.buckets.termsTitle": "用語", + "data.search.aggs.histogram.missingMaxMinValuesWarning": "自動スケールヒストグラムバケットから最高値と最低値を取得できません。これによりビジュアライゼーションのパフォーマンスが低下する可能性があります。", + "data.search.aggs.metrics.averageBucketTitle": "平均バケット", + "data.search.aggs.metrics.averageLabel": "平均 {field}", + "data.search.aggs.metrics.averageTitle": "平均", + "data.search.aggs.metrics.bucketAggTitle": "バケット集約", + "data.search.aggs.metrics.countLabel": "カウント", + "data.search.aggs.metrics.countTitle": "カウント", + "data.search.aggs.metrics.cumulativeSumLabel": "累積合計", + "data.search.aggs.metrics.cumulativeSumTitle": "累積合計", + "data.search.aggs.metrics.derivativeLabel": "派生", + "data.search.aggs.metrics.derivativeTitle": "派生", + "data.search.aggs.metrics.geoBoundsLabel": "境界", + "data.search.aggs.metrics.geoBoundsTitle": "境界", + "data.search.aggs.metrics.geoCentroidLabel": "ジオセントロイド", + "data.search.aggs.metrics.geoCentroidTitle": "ジオセントロイド", + "data.search.aggs.metrics.maxBucketTitle": "最高バケット", + "data.search.aggs.metrics.maxLabel": "最高 {field}", + "data.search.aggs.metrics.maxTitle": "最高", + "data.search.aggs.metrics.medianLabel": "中央 {field}", + "data.search.aggs.metrics.medianTitle": "中央", + "data.search.aggs.metrics.metricAggregationsSubtypeTitle": "メトリック集約", + "data.search.aggs.metrics.metricAggTitle": "メトリック集約", + "data.search.aggs.metrics.minBucketTitle": "最低バケット", + "data.search.aggs.metrics.minLabel": "最低 {field}", + "data.search.aggs.metrics.minTitle": "最低", + "data.search.aggs.metrics.movingAvgLabel": "移動平均", + "data.search.aggs.metrics.movingAvgTitle": "移動平均", + "data.search.aggs.metrics.overallAverageLabel": "全体平均", + "data.search.aggs.metrics.overallMaxLabel": "全体最高", + "data.search.aggs.metrics.overallMinLabel": "全体最低", + "data.search.aggs.metrics.overallSumLabel": "全体合計", + "data.search.aggs.metrics.parentPipelineAggregationsSubtypeTitle": "親パイプライン集約", + "data.search.aggs.metrics.percentileRanks.valuePropsLabel": "「{label}」の {format} のパーセンタイル順位", + "data.search.aggs.metrics.percentileRanksLabel": "{field} のパーセンタイル順位", + "data.search.aggs.metrics.percentileRanksTitle": "パーセンタイル順位", + "data.search.aggs.metrics.percentiles.valuePropsLabel": "{label} の {percentile} パーセンタイル", + "data.search.aggs.metrics.percentilesLabel": "{field} のパーセンタイル", + "data.search.aggs.metrics.percentilesTitle": "パーセンタイル", + "data.search.aggs.metrics.serialDiffLabel": "差分の推移", + "data.search.aggs.metrics.serialDiffTitle": "差分の推移", + "data.search.aggs.metrics.siblingPipelineAggregationsSubtypeTitle": "シブリングパイプラインアグリゲーション", + "data.search.aggs.metrics.standardDeviation.keyDetailsLabel": "{fieldDisplayName} の標準偏差", + "data.search.aggs.metrics.standardDeviation.lowerKeyDetailsTitle": "下の{label}", + "data.search.aggs.metrics.standardDeviation.upperKeyDetailsTitle": "上の{label}", + "data.search.aggs.metrics.standardDeviationLabel": "{field} の標準偏差", + "data.search.aggs.metrics.standardDeviationTitle": "標準偏差", + "data.search.aggs.metrics.sumBucketTitle": "合計バケット", + "data.search.aggs.metrics.sumLabel": "{field} の合計", + "data.search.aggs.metrics.sumTitle": "合計", + "data.search.aggs.metrics.topHit.ascendingLabel": "昇順", + "data.search.aggs.metrics.topHit.averageLabel": "平均", + "data.search.aggs.metrics.topHit.concatenateLabel": "連結", + "data.search.aggs.metrics.topHit.descendingLabel": "降順", + "data.search.aggs.metrics.topHit.firstPrefixLabel": "最初", + "data.search.aggs.metrics.topHit.lastPrefixLabel": "最後", + "data.search.aggs.metrics.topHit.maxLabel": "最高", + "data.search.aggs.metrics.topHit.minLabel": "最低", + "data.search.aggs.metrics.topHit.sumLabel": "合計", + "data.search.aggs.metrics.topHitTitle": "トップヒット", + "data.search.aggs.metrics.uniqueCountLabel": "{field} のユニークカウント", + "data.search.aggs.metrics.uniqueCountTitle": "ユニークカウント", + "data.search.aggs.otherBucket.labelForMissingValuesLabel": "欠測値のラベル", + "data.search.aggs.otherBucket.labelForOtherBucketLabel": "他のバケットのラベル", + "data.search.aggs.paramTypes.field.invalidSavedFieldParameterErrorMessage": "保存された {fieldParameter} パラメーターが無効になりました。新しいフィールドを選択してください。", + "data.search.aggs.paramTypes.field.requiredFieldParameterErrorMessage": "{fieldParameter} は必須パラメーターです", + "data.search.aggs.string.customLabel": "カスタムラベル", "common.ui.chrome.bigUrlWarningNotificationMessage": "{advancedSettingsLink}で{storeInSessionStorageParam}オプションを有効にするか、オンスクリーンビジュアルを簡素化してください。", "common.ui.chrome.bigUrlWarningNotificationMessage.advancedSettingsLinkText": "高度な設定", "common.ui.chrome.bigUrlWarningNotificationTitle": "URLが大きく、Kibanaの動作が停止する可能性があります", @@ -375,7 +376,7 @@ "common.ui.stateManagement.unableToStoreHistoryInSessionErrorMessage": "セッションがいっぱいで安全に削除できるアイテムが見つからないため、Kibana は履歴アイテムを保存できません。\n\nこれは大抵新規タブに移動することで解決されますが、より大きな問題が原因である可能性もあります。このメッセージが定期的に表示される場合は、{gitHubIssuesUrl} で問題を報告してください。", "common.ui.url.replacementFailedErrorMessage": "置換に失敗、未解決の表現式: {expr}", "common.ui.url.savedObjectIsMissingNotificationMessage": "保存されたオブジェクトがありません", - "common.ui.vis.aggConfig.percentageOfLabel": "{label} のパーセンテージ", + "data.search.aggs.percentageOfLabel": "{label} のパーセンテージ", "common.ui.vis.defaultFeedbackMessage": "フィードバックがありますか?{link} で問題を報告してください。", "common.ui.vis.kibanaMap.leaflet.fitDataBoundsAriaLabel": "データバウンドを合わせる", "common.ui.vis.kibanaMap.zoomWarning": "ズームレベルが最大に達しました。完全にズームインするには、Elasticsearch と Kibana の {defaultDistribution} にアップグレードしてください。{ems} でより多くのズームレベルが利用できます。または、独自のマップサーバーを構成できます。詳細は { wms } または { configSettings} をご覧ください。", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 5d62e15be2b9f3..066bafd990fe37 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -77,109 +77,110 @@ }, "messages": { "common.ui.aggResponse.allDocsTitle": "所有文档", - "common.ui.aggTypes.aggGroups.bucketsText": "存储桶", - "common.ui.aggTypes.aggGroups.metricsText": "指标", - "common.ui.aggTypes.buckets.dateHistogramLabel": "{fieldName}/{intervalDescription}", - "common.ui.aggTypes.buckets.dateHistogramTitle": "Date Histogram", - "common.ui.aggTypes.buckets.dateRangeTitle": "日期范围", - "common.ui.aggTypes.buckets.filtersTitle": "筛选", - "common.ui.aggTypes.buckets.filterTitle": "筛选", - "common.ui.aggTypes.buckets.geohashGridTitle": "Geohash", - "common.ui.aggTypes.buckets.geotileGridTitle": "地理磁贴", - "common.ui.aggTypes.buckets.histogramTitle": "Histogram", - "common.ui.aggTypes.buckets.intervalOptions.autoDisplayName": "自动", - "common.ui.aggTypes.buckets.intervalOptions.dailyDisplayName": "每日", - "common.ui.aggTypes.buckets.intervalOptions.hourlyDisplayName": "每小时", - "common.ui.aggTypes.buckets.intervalOptions.millisecondDisplayName": "毫秒", - "common.ui.aggTypes.buckets.intervalOptions.minuteDisplayName": "分钟", - "common.ui.aggTypes.buckets.intervalOptions.monthlyDisplayName": "每月", - "common.ui.aggTypes.buckets.intervalOptions.secondDisplayName": "秒", - "common.ui.aggTypes.buckets.intervalOptions.weeklyDisplayName": "每周", - "common.ui.aggTypes.buckets.intervalOptions.yearlyDisplayName": "每年", - "common.ui.aggTypes.buckets.ipRangeLabel": "{fieldName} IP 范围", - "common.ui.aggTypes.buckets.ipRangeTitle": "IPv4 范围", - "common.ui.aggTypes.buckets.ranges.rangesFormatMessage": "{gte} {from} 且 {lt} {to}", - "common.ui.aggTypes.buckets.rangesLabel": "{fieldName} 范围", - "common.ui.aggTypes.buckets.rangeTitle": "范围", - "common.ui.aggTypes.buckets.significantTerms.excludeLabel": "排除", - "common.ui.aggTypes.buckets.significantTerms.includeLabel": "包括", - "common.ui.aggTypes.buckets.significantTermsLabel": "{fieldName} 中排名前 {size} 的罕见词", - "common.ui.aggTypes.buckets.significantTermsTitle": "重要词", - "common.ui.aggTypes.buckets.terms.excludeLabel": "排除", - "common.ui.aggTypes.buckets.terms.includeLabel": "包括", - "common.ui.aggTypes.buckets.terms.missingBucketLabel": "缺失", - "common.ui.aggTypes.buckets.terms.orderAscendingTitle": "升序", - "common.ui.aggTypes.buckets.terms.orderDescendingTitle": "降序", - "common.ui.aggTypes.buckets.terms.otherBucketDescription": "此请求计数不符合数据存储桶条件的文档数目。", - "common.ui.aggTypes.buckets.terms.otherBucketLabel": "其他", - "common.ui.aggTypes.buckets.terms.otherBucketTitle": "其他存储桶", - "common.ui.aggTypes.buckets.termsTitle": "词", - "common.ui.aggTypes.histogram.missingMaxMinValuesWarning": "无法检索最大值和最小值以自动缩放直方图存储桶。这可能会导致可视化性能低下。", - "common.ui.aggTypes.metrics.averageBucketTitle": "平均存储桶", - "common.ui.aggTypes.metrics.averageLabel": "{field}平均值", - "common.ui.aggTypes.metrics.averageTitle": "平均值", - "common.ui.aggTypes.metrics.bucketAggTitle": "存储桶聚合", - "common.ui.aggTypes.metrics.countLabel": "计数", - "common.ui.aggTypes.metrics.countTitle": "计数", - "common.ui.aggTypes.metrics.cumulativeSumLabel": "累计和", - "common.ui.aggTypes.metrics.cumulativeSumTitle": "累计和", - "common.ui.aggTypes.metrics.derivativeLabel": "导数", - "common.ui.aggTypes.metrics.derivativeTitle": "导数", - "common.ui.aggTypes.metrics.geoBoundsLabel": "地理边界", - "common.ui.aggTypes.metrics.geoBoundsTitle": "地理边界", - "common.ui.aggTypes.metrics.geoCentroidLabel": "地理重心", - "common.ui.aggTypes.metrics.geoCentroidTitle": "地理重心", - "common.ui.aggTypes.metrics.maxBucketTitle": "最大存储桶", - "common.ui.aggTypes.metrics.maxLabel": "{field}最大值", - "common.ui.aggTypes.metrics.maxTitle": "最大值", - "common.ui.aggTypes.metrics.medianLabel": "{field}中值", - "common.ui.aggTypes.metrics.medianTitle": "中值", - "common.ui.aggTypes.metrics.metricAggregationsSubtypeTitle": "指标聚合", - "common.ui.aggTypes.metrics.metricAggTitle": "指标聚合", - "common.ui.aggTypes.metrics.minBucketTitle": "最小存储桶", - "common.ui.aggTypes.metrics.minLabel": "{field}最小值", - "common.ui.aggTypes.metrics.minTitle": "最小值", - "common.ui.aggTypes.metrics.movingAvgLabel": "移动平均值", - "common.ui.aggTypes.metrics.movingAvgTitle": "移动平均值", - "common.ui.aggTypes.metrics.overallAverageLabel": "总体平均值", - "common.ui.aggTypes.metrics.overallMaxLabel": "总体最大值", - "common.ui.aggTypes.metrics.overallMinLabel": "总体最大值", - "common.ui.aggTypes.metrics.overallSumLabel": "总和", - "common.ui.aggTypes.metrics.parentPipelineAggregationsSubtypeTitle": "父级管道聚合", - "common.ui.aggTypes.metrics.percentileRanks.valuePropsLabel": "“{label}” 的百分位数排名 {format}", - "common.ui.aggTypes.metrics.percentileRanksLabel": "“{field}” 的百分位数排名", - "common.ui.aggTypes.metrics.percentileRanksTitle": "百分位数排名", - "common.ui.aggTypes.metrics.percentiles.valuePropsLabel": "“{label}” 的 {percentile} 百分位数", - "common.ui.aggTypes.metrics.percentilesLabel": "“{field}” 的百分位数", - "common.ui.aggTypes.metrics.percentilesTitle": "百分位数", - "common.ui.aggTypes.metrics.serialDiffLabel": "序列差异", - "common.ui.aggTypes.metrics.serialDiffTitle": "序列差异", - "common.ui.aggTypes.metrics.siblingPipelineAggregationsSubtypeTitle": "同级管道聚合", - "common.ui.aggTypes.metrics.standardDeviation.keyDetailsLabel": "“{fieldDisplayName}” 的标准偏差", - "common.ui.aggTypes.metrics.standardDeviation.lowerKeyDetailsTitle": "下{label}", - "common.ui.aggTypes.metrics.standardDeviation.upperKeyDetailsTitle": "上{label}", - "common.ui.aggTypes.metrics.standardDeviationLabel": "“{field}” 的标准偏差", - "common.ui.aggTypes.metrics.standardDeviationTitle": "标准偏差", - "common.ui.aggTypes.metrics.sumBucketTitle": "求和存储桶", - "common.ui.aggTypes.metrics.sumLabel": "“{field}” 的和", - "common.ui.aggTypes.metrics.sumTitle": "和", - "common.ui.aggTypes.metrics.topHit.ascendingLabel": "升序", - "common.ui.aggTypes.metrics.topHit.averageLabel": "平均值", - "common.ui.aggTypes.metrics.topHit.concatenateLabel": "连接", - "common.ui.aggTypes.metrics.topHit.descendingLabel": "降序", - "common.ui.aggTypes.metrics.topHit.firstPrefixLabel": "第一", - "common.ui.aggTypes.metrics.topHit.lastPrefixLabel": "最后", - "common.ui.aggTypes.metrics.topHit.maxLabel": "最大值", - "common.ui.aggTypes.metrics.topHit.minLabel": "最小值", - "common.ui.aggTypes.metrics.topHit.sumLabel": "和", - "common.ui.aggTypes.metrics.topHitTitle": "最高命中结果", - "common.ui.aggTypes.metrics.uniqueCountLabel": "“{field}” 的唯一计数", - "common.ui.aggTypes.metrics.uniqueCountTitle": "唯一计数", - "common.ui.aggTypes.otherBucket.labelForMissingValuesLabel": "缺失值的标签", - "common.ui.aggTypes.otherBucket.labelForOtherBucketLabel": "其他存储桶的标签", - "common.ui.aggTypes.paramTypes.field.invalidSavedFieldParameterErrorMessage": "已保存的 {fieldParameter} 参数现在无效。请选择新字段。", - "common.ui.aggTypes.paramTypes.field.requiredFieldParameterErrorMessage": "{fieldParameter} 是必需字段", - "common.ui.aggTypes.string.customLabel": "定制标签", + "common.ui.aggTypes.rangesFormatMessage": "{gte} {from} 且 {lt} {to}", + "data.search.aggs.aggGroups.bucketsText": "存储桶", + "data.search.aggs.aggGroups.metricsText": "指标", + "data.search.aggs.buckets.dateHistogramLabel": "{fieldName}/{intervalDescription}", + "data.search.aggs.buckets.dateHistogramTitle": "Date Histogram", + "data.search.aggs.buckets.dateRangeTitle": "日期范围", + "data.search.aggs.buckets.filtersTitle": "筛选", + "data.search.aggs.buckets.filterTitle": "筛选", + "data.search.aggs.buckets.geohashGridTitle": "Geohash", + "data.search.aggs.buckets.geotileGridTitle": "地理磁贴", + "data.search.aggs.buckets.histogramTitle": "Histogram", + "data.search.aggs.buckets.intervalOptions.autoDisplayName": "自动", + "data.search.aggs.buckets.intervalOptions.dailyDisplayName": "每日", + "data.search.aggs.buckets.intervalOptions.hourlyDisplayName": "每小时", + "data.search.aggs.buckets.intervalOptions.millisecondDisplayName": "毫秒", + "data.search.aggs.buckets.intervalOptions.minuteDisplayName": "分钟", + "data.search.aggs.buckets.intervalOptions.monthlyDisplayName": "每月", + "data.search.aggs.buckets.intervalOptions.secondDisplayName": "秒", + "data.search.aggs.buckets.intervalOptions.weeklyDisplayName": "每周", + "data.search.aggs.buckets.intervalOptions.yearlyDisplayName": "每年", + "data.search.aggs.buckets.ipRangeLabel": "{fieldName} IP 范围", + "data.search.aggs.buckets.ipRangeTitle": "IPv4 范围", + "data.search.aggs.aggTypes.rangesFormatMessage": "{gte} {from} 且 {lt} {to}", + "data.search.aggs.aggTypesLabel": "{fieldName} 范围", + "data.search.aggs.buckets.rangeTitle": "范围", + "data.search.aggs.buckets.significantTerms.excludeLabel": "排除", + "data.search.aggs.buckets.significantTerms.includeLabel": "包括", + "data.search.aggs.buckets.significantTermsLabel": "{fieldName} 中排名前 {size} 的罕见词", + "data.search.aggs.buckets.significantTermsTitle": "重要词", + "data.search.aggs.buckets.terms.excludeLabel": "排除", + "data.search.aggs.buckets.terms.includeLabel": "包括", + "data.search.aggs.buckets.terms.missingBucketLabel": "缺失", + "data.search.aggs.buckets.terms.orderAscendingTitle": "升序", + "data.search.aggs.buckets.terms.orderDescendingTitle": "降序", + "data.search.aggs.buckets.terms.otherBucketDescription": "此请求计数不符合数据存储桶条件的文档数目。", + "data.search.aggs.buckets.terms.otherBucketLabel": "其他", + "data.search.aggs.buckets.terms.otherBucketTitle": "其他存储桶", + "data.search.aggs.buckets.termsTitle": "词", + "data.search.aggs.histogram.missingMaxMinValuesWarning": "无法检索最大值和最小值以自动缩放直方图存储桶。这可能会导致可视化性能低下。", + "data.search.aggs.metrics.averageBucketTitle": "平均存储桶", + "data.search.aggs.metrics.averageLabel": "{field}平均值", + "data.search.aggs.metrics.averageTitle": "平均值", + "data.search.aggs.metrics.bucketAggTitle": "存储桶聚合", + "data.search.aggs.metrics.countLabel": "计数", + "data.search.aggs.metrics.countTitle": "计数", + "data.search.aggs.metrics.cumulativeSumLabel": "累计和", + "data.search.aggs.metrics.cumulativeSumTitle": "累计和", + "data.search.aggs.metrics.derivativeLabel": "导数", + "data.search.aggs.metrics.derivativeTitle": "导数", + "data.search.aggs.metrics.geoBoundsLabel": "地理边界", + "data.search.aggs.metrics.geoBoundsTitle": "地理边界", + "data.search.aggs.metrics.geoCentroidLabel": "地理重心", + "data.search.aggs.metrics.geoCentroidTitle": "地理重心", + "data.search.aggs.metrics.maxBucketTitle": "最大存储桶", + "data.search.aggs.metrics.maxLabel": "{field}最大值", + "data.search.aggs.metrics.maxTitle": "最大值", + "data.search.aggs.metrics.medianLabel": "{field}中值", + "data.search.aggs.metrics.medianTitle": "中值", + "data.search.aggs.metrics.metricAggregationsSubtypeTitle": "指标聚合", + "data.search.aggs.metrics.metricAggTitle": "指标聚合", + "data.search.aggs.metrics.minBucketTitle": "最小存储桶", + "data.search.aggs.metrics.minLabel": "{field}最小值", + "data.search.aggs.metrics.minTitle": "最小值", + "data.search.aggs.metrics.movingAvgLabel": "移动平均值", + "data.search.aggs.metrics.movingAvgTitle": "移动平均值", + "data.search.aggs.metrics.overallAverageLabel": "总体平均值", + "data.search.aggs.metrics.overallMaxLabel": "总体最大值", + "data.search.aggs.metrics.overallMinLabel": "总体最大值", + "data.search.aggs.metrics.overallSumLabel": "总和", + "data.search.aggs.metrics.parentPipelineAggregationsSubtypeTitle": "父级管道聚合", + "data.search.aggs.metrics.percentileRanks.valuePropsLabel": "“{label}” 的百分位数排名 {format}", + "data.search.aggs.metrics.percentileRanksLabel": "“{field}” 的百分位数排名", + "data.search.aggs.metrics.percentileRanksTitle": "百分位数排名", + "data.search.aggs.metrics.percentiles.valuePropsLabel": "“{label}” 的 {percentile} 百分位数", + "data.search.aggs.metrics.percentilesLabel": "“{field}” 的百分位数", + "data.search.aggs.metrics.percentilesTitle": "百分位数", + "data.search.aggs.metrics.serialDiffLabel": "序列差异", + "data.search.aggs.metrics.serialDiffTitle": "序列差异", + "data.search.aggs.metrics.siblingPipelineAggregationsSubtypeTitle": "同级管道聚合", + "data.search.aggs.metrics.standardDeviation.keyDetailsLabel": "“{fieldDisplayName}” 的标准偏差", + "data.search.aggs.metrics.standardDeviation.lowerKeyDetailsTitle": "下{label}", + "data.search.aggs.metrics.standardDeviation.upperKeyDetailsTitle": "上{label}", + "data.search.aggs.metrics.standardDeviationLabel": "“{field}” 的标准偏差", + "data.search.aggs.metrics.standardDeviationTitle": "标准偏差", + "data.search.aggs.metrics.sumBucketTitle": "求和存储桶", + "data.search.aggs.metrics.sumLabel": "“{field}” 的和", + "data.search.aggs.metrics.sumTitle": "和", + "data.search.aggs.metrics.topHit.ascendingLabel": "升序", + "data.search.aggs.metrics.topHit.averageLabel": "平均值", + "data.search.aggs.metrics.topHit.concatenateLabel": "连接", + "data.search.aggs.metrics.topHit.descendingLabel": "降序", + "data.search.aggs.metrics.topHit.firstPrefixLabel": "第一", + "data.search.aggs.metrics.topHit.lastPrefixLabel": "最后", + "data.search.aggs.metrics.topHit.maxLabel": "最大值", + "data.search.aggs.metrics.topHit.minLabel": "最小值", + "data.search.aggs.metrics.topHit.sumLabel": "和", + "data.search.aggs.metrics.topHitTitle": "最高命中结果", + "data.search.aggs.metrics.uniqueCountLabel": "“{field}” 的唯一计数", + "data.search.aggs.metrics.uniqueCountTitle": "唯一计数", + "data.search.aggs.otherBucket.labelForMissingValuesLabel": "缺失值的标签", + "data.search.aggs.otherBucket.labelForOtherBucketLabel": "其他存储桶的标签", + "data.search.aggs.paramTypes.field.invalidSavedFieldParameterErrorMessage": "已保存的 {fieldParameter} 参数现在无效。请选择新字段。", + "data.search.aggs.paramTypes.field.requiredFieldParameterErrorMessage": "{fieldParameter} 是必需字段", + "data.search.aggs.string.customLabel": "定制标签", "common.ui.chrome.bigUrlWarningNotificationMessage": "在{advancedSettingsLink}中启用“{storeInSessionStorageParam}”选项或简化屏幕视觉效果。", "common.ui.chrome.bigUrlWarningNotificationMessage.advancedSettingsLinkText": "高级设置", "common.ui.chrome.bigUrlWarningNotificationTitle": "URL 过长,Kibana 可能无法工作", @@ -375,7 +376,7 @@ "common.ui.stateManagement.unableToStoreHistoryInSessionErrorMessage": "Kibana 无法将历史记录项存储在您的会话中,因为其已满,并且似乎没有任何可安全删除的项。\n\n通常可通过移至新的标签页来解决此问题,但这会导致更大的问题。如果您有规律地看到此消息,请在 {gitHubIssuesUrl} 提交问题。", "common.ui.url.replacementFailedErrorMessage": "替换失败,未解析的表达式:{expr}", "common.ui.url.savedObjectIsMissingNotificationMessage": "已保存对象缺失", - "common.ui.vis.aggConfig.percentageOfLabel": "{label} 的百分比", + "data.search.aggs.percentageOfLabel": "{label} 的百分比", "common.ui.vis.defaultFeedbackMessage": "想反馈?请在“{link}中创建问题。", "common.ui.vis.kibanaMap.leaflet.fitDataBoundsAriaLabel": "适应数据边界", "common.ui.vis.kibanaMap.zoomWarning": "已达到缩放级别最大数目。要一直放大,请升级到 Elasticsearch 和 Kibana 的 {defaultDistribution}。您可以通过 {ems} 免费使用其他缩放级别。或者,您可以配置自己的地图服务器。请前往 { wms } 或 { configSettings} 以获取详细信息。", diff --git a/x-pack/plugins/watcher/public/legacy/time_buckets.js b/x-pack/plugins/watcher/public/legacy/time_buckets.js index 8b7e4be784fe72..5d5e9e8dcb1a4a 100644 --- a/x-pack/plugins/watcher/public/legacy/time_buckets.js +++ b/x-pack/plugins/watcher/public/legacy/time_buckets.js @@ -130,7 +130,7 @@ TimeBuckets.prototype.getDuration = function() { * generated. * * Input can be one of the following: - * - Any object from src/legacy/ui/agg_types/buckets/_interval_options.js + * - Any object from src/plugins/data/public/search/aggs/buckets/_interval_options.ts * - "auto" * - Pass a valid moment unit * - a moment.duration object. From 8a90e6748969569548250bda4b91f5c6724e1620 Mon Sep 17 00:00:00 2001 From: Frank Hassanabad Date: Tue, 4 Feb 2020 18:10:05 -0700 Subject: [PATCH 16/22] [SIEM][Detection Engine] critical blocker, wrong ilm policy, need to match beats ilm policy ## Summary Need to match ILM policy of auditbeat and we almost forgot this and it would be bad for shipping if we did not have best practices for ILM. ### Checklist Use ~~strikethroughs~~ to remove checklist items you don't feel are applicable to this PR. ~~- [ ] This was checked for cross-browser compatibility, [including a check against IE11](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility)~~ ~~- [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md)~~ ~~- [ ] [Documentation](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#writing-documentation) was added for features that require explanation or tutorials~~ ~~- [ ] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios~~ ~~- [ ] This was checked for [keyboard-only and screenreader accessibility](https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Accessibility#Accessibility_testing_checklist)~~ ### For maintainers ~~- [ ] This was checked for breaking API changes and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)~~ ~~- [ ] This includes a feature addition or change that requires a release note and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)~~ ### Checklist Use ~~strikethroughs~~ to remove checklist items you don't feel are applicable to this PR. - [ ] This was checked for cross-browser compatibility, [including a check against IE11](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md) - [ ] [Documentation](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#writing-documentation) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios - [ ] This was checked for [keyboard-only and screenreader accessibility](https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Accessibility#Accessibility_testing_checklist) ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process) - [ ] This includes a feature addition or change that requires a release note and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process) --- .../lib/detection_engine/routes/index/signals_policy.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/signals_policy.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/signals_policy.json index 640d8e14190cd0..4fc7eebd4373c2 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/signals_policy.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/signals_policy.json @@ -5,8 +5,8 @@ "min_age": "0ms", "actions": { "rollover": { - "max_size": "10gb", - "max_age": "7d" + "max_size": "50gb", + "max_age": "30d" } } } From fac68730548685d87364db696ae6c3e16fc94f43 Mon Sep 17 00:00:00 2001 From: Frank Hassanabad Date: Tue, 4 Feb 2020 18:19:36 -0700 Subject: [PATCH 17/22] [SIEM][Detection Engine] Final final rule changes (#56806) ## Summary * Final, final, Rule changes ### Checklist Use ~~strikethroughs~~ to remove checklist items you don't feel are applicable to this PR. ~~- [ ] This was checked for cross-browser compatibility, [including a check against IE11](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility)~~ ~~- [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md)~~ ~~- [ ] [Documentation](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#writing-documentation) was added for features that require explanation or tutorials~~ ~~- [ ] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios~~ ~~- [ ] This was checked for [keyboard-only and screenreader accessibility](https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Accessibility#Accessibility_testing_checklist)~~ ### For maintainers ~~- [ ] This was checked for breaking API changes and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)~~ ~~- [ ] This includes a feature addition or change that requires a release note and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)~~ --- NOTICE.txt | 2 - .../403_response_to_a_post.json | 6 +- .../405_response_method_not_allowed.json | 6 +- ..._security_adversary_behavior_detected.json | 6 +- ...dpoint_security_cred_dumping_detected.json | 8 +- ...point_security_cred_dumping_prevented.json | 8 +- ...t_security_cred_manipulation_detected.json | 8 +- ..._security_cred_manipulation_prevented.json | 11 +- ...ic_endpoint_security_exploit_detected.json | 6 +- ...c_endpoint_security_exploit_prevented.json | 6 +- ...ic_endpoint_security_malware_detected.json | 6 +- ...c_endpoint_security_malware_prevented.json | 6 +- ...nt_security_permission_theft_detected.json | 6 +- ...t_security_permission_theft_prevented.json | 6 +- ...t_security_process_injection_detected.json | 6 +- ..._security_process_injection_prevented.json | 6 +- ...endpoint_security_ransomware_detected.json | 6 +- ...ndpoint_security_ransomware_prevented.json | 6 +- ...den_file_attribute_with_via_attribexe.json | 4 +- .../eql_adobe_hijack_persistence.json | 2 +- .../eql_audio_capture_via_powershell.json | 36 ---- .../eql_audio_capture_via_soundrecorder.json | 36 ---- .../eql_bypass_uac_event_viewer.json | 36 ---- .../eql_bypass_uac_via_cmstp.json | 36 ---- .../eql_bypass_uac_via_sdclt.json | 36 ---- .../eql_clearing_windows_event_logs.json | 4 +- ...delete_volume_usn_journal_with_fsutil.json | 2 +- ...deleting_backup_catalogs_with_wbadmin.json | 2 +- .../eql_direct_outbound_smb_connection.json | 2 +- ...ble_windows_firewall_rules_with_netsh.json | 2 +- .../eql_dll_search_order_hijack.json | 51 ----- ...coding_or_decoding_files_via_certutil.json | 2 +- .../eql_local_scheduled_task_commands.json | 2 +- .../eql_local_service_commands.json | 2 +- ...ql_modification_of_boot_configuration.json | 36 ---- ...ql_msbuild_making_network_connections.json | 4 +- .../eql_mshta_making_network_connections.json | 4 +- .../eql_msxsl_making_network_connections.json | 36 ---- .../eql_psexec_lateral_movement_command.json | 4 +- ...ql_suspicious_ms_office_child_process.json | 2 +- ...l_suspicious_ms_outlook_child_process.json | 2 +- ...l_suspicious_pdf_reader_child_process.json | 36 ---- .../eql_system_shells_via_services.json | 2 +- ...usual_network_connection_via_rundll32.json | 2 +- .../eql_unusual_parentchild_relationship.json | 2 +- ...ql_unusual_process_network_connection.json | 2 +- .../eql_user_account_creation.json | 2 +- ...eql_user_added_to_administrator_group.json | 36 ---- ...ume_shadow_copy_deletion_via_vssadmin.json | 2 +- ..._volume_shadow_copy_deletion_via_wmic.json | 4 +- ...l_windows_script_executing_powershell.json | 2 +- .../eql_wmic_command_lateral_movement.json | 39 ---- .../rules/prepackaged_rules/index.ts | 186 +++++++----------- .../linux_hping_activity.json | 6 +- .../linux_iodine_activity.json | 4 +- .../linux_kernel_module_activity.json | 4 +- .../linux_ldso_process_activity.json | 22 --- .../linux_mknod_activity.json | 6 +- .../linux_netcat_network_connection.json | 6 +- .../linux_nmap_activity.json | 6 +- .../linux_nping_activity.json | 6 +- ...nux_process_started_in_temp_directory.json | 4 +- .../linux_shell_activity_by_web_server.json | 4 +- .../linux_socat_activity.json | 6 +- .../linux_strace_activity.json | 2 +- .../linux_tcpdump_activity.json | 4 +- .../linux_whoami_commmand.json | 4 +- .../network_dns_directly_to_the_internet.json | 8 +- ...fer_protocol_activity_to_the_internet.json | 8 +- ...hat_protocol_activity_to_the_internet.json | 8 +- .../network_nat_traversal_port_activity.json | 8 +- .../network_port_26_activity.json | 10 +- ...rk_port_8000_activity_to_the_internet.json | 6 +- ..._to_point_tunneling_protocol_activity.json | 10 +- ...k_proxy_port_activity_to_the_internet.json | 8 +- ...te_desktop_protocol_from_the_internet.json | 8 +- ...mote_desktop_protocol_to_the_internet.json | 8 +- ...mote_procedure_call_from_the_internet.json | 6 +- ...remote_procedure_call_to_the_internet.json | 6 +- ...file_sharing_activity_to_the_internet.json | 6 +- .../network_smtp_to_the_internet.json | 8 +- ..._server_port_activity_to_the_internet.json | 8 +- ...rk_ssh_secure_shell_from_the_internet.json | 8 +- ...work_ssh_secure_shell_to_the_internet.json | 8 +- .../network_telnet_port_activity.json | 8 +- .../network_tor_activity_to_the_internet.json | 8 +- ...l_network_computing_from_the_internet.json | 8 +- ...ual_network_computing_to_the_internet.json | 8 +- .../rules/prepackaged_rules/notice.ts | 2 - .../prepackaged_rules/null_user_agent.json | 4 +- .../prepackaged_rules/sqlmap_user_agent.json | 5 +- ...rvice_bits_connecting_to_the_internet.json | 51 ----- ...s_certutil_connecting_to_the_internet.json | 36 ---- ...and_prompt_connecting_to_the_internet.json | 2 +- ...nd_shell_started_by_internet_explorer.json | 36 ---- ...s_command_shell_started_by_powershell.json | 4 +- ...dows_command_shell_started_by_svchost.json | 4 +- ...ws_defense_evasion_via_filter_manager.json | 5 +- ...dows_execution_via_compiled_html_file.json | 2 +- ...dows_execution_via_connection_manager.json | 37 ---- ...dows_execution_via_net_com_assemblies.json | 40 ---- .../windows_execution_via_regsvr32.json | 2 +- ...ution_via_trusted_developer_utilities.json | 3 +- ...le_program_connecting_to_the_internet.json | 2 +- ...isc_lolbin_connecting_to_the_internet.json | 2 +- ...ommand_activity_by_the_system_account.json | 36 ---- ..._persistence_via_application_shimming.json | 3 +- ...escalation_via_accessibility_features.json | 3 +- ...rocess_discovery_via_tasklist_command.json | 3 +- .../windows_process_execution_via_wmi.json | 39 ---- ...er_program_connecting_to_the_internet.json | 2 +- ...windows_signed_binary_proxy_execution.json | 2 +- ...igned_binary_proxy_execution_download.json | 54 ----- ...uspicious_process_started_by_a_script.json | 4 +- .../windows_whoami_command_activity.json | 2 +- 115 files changed, 312 insertions(+), 1094 deletions(-) delete mode 100644 x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_audio_capture_via_powershell.json delete mode 100644 x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_audio_capture_via_soundrecorder.json delete mode 100644 x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_bypass_uac_event_viewer.json delete mode 100644 x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_bypass_uac_via_cmstp.json delete mode 100644 x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_bypass_uac_via_sdclt.json delete mode 100644 x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_dll_search_order_hijack.json delete mode 100644 x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_modification_of_boot_configuration.json delete mode 100644 x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_msxsl_making_network_connections.json delete mode 100644 x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_suspicious_pdf_reader_child_process.json delete mode 100644 x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_user_added_to_administrator_group.json delete mode 100644 x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_wmic_command_lateral_movement.json delete mode 100644 x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_ldso_process_activity.json delete mode 100644 x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_background_intelligent_transfer_service_bits_connecting_to_the_internet.json delete mode 100644 x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_certutil_connecting_to_the_internet.json delete mode 100644 x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_shell_started_by_internet_explorer.json delete mode 100644 x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_connection_manager.json delete mode 100644 x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_net_com_assemblies.json delete mode 100644 x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_net_command_activity_by_the_system_account.json delete mode 100644 x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_process_execution_via_wmi.json delete mode 100644 x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_signed_binary_proxy_execution_download.json diff --git a/NOTICE.txt b/NOTICE.txt index e0c5d94eff6b3d..69be6db72cff2c 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -162,8 +162,6 @@ which is available under a "MIT" license. The files based on this license are: - windows_priv_escalation_via_accessibility_features.json - windows_persistence_via_application_shimming.json - windows_execution_via_trusted_developer_utilities.json -- windows_execution_via_net_com_assemblies.json -- windows_execution_via_connection_manager.json MIT License diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/403_response_to_a_post.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/403_response_to_a_post.json index c685d96cdf57b6..fd46a09d4ced0c 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/403_response_to_a_post.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/403_response_to_a_post.json @@ -1,13 +1,13 @@ { - "description": "A POST request to web application returned a 403 response which indicates the web application declined to process the request because the action requested was disallowed.", + "description": "A POST request to web application returned a 403 response, which indicates the web application declined to process the request because the action requested was not allowed", "false_positives": [ - "Security scans and tests may result in these errors. Misconfigured or buggy applications may produce large numbers of these errors. If the source is unexpected, or the user is unauthorized, or the request is unusual, these may be suspicious or malicious activity." + "Security scans and tests may result in these errors. Misconfigured or buggy applications may produce large numbers of these errors. If the source is unexpected, the user unauthorized, or the request unusual, these may indicate suspicious or malicious activity." ], "index": [ "apm-*-transaction*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Web Application Suspicious Activity: POST Request Declined", "query": "http.response.status_code:403 and http.request.method:post", "references": [ diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/405_response_method_not_allowed.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/405_response_method_not_allowed.json index 64264452d468be..a6235c889902bf 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/405_response_method_not_allowed.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/405_response_method_not_allowed.json @@ -1,13 +1,13 @@ { - "description": "A request to web application returned a 405 response which indicates the web application declined to process the request because the HTTP method was not allowed for the resource.", + "description": "A request to web application returned a 405 response which indicates the web application declined to process the request because the HTTP method is not allowed for the resource", "false_positives": [ - "Security scans and tests may result in these errors. Misconfigured or buggy applications may produce large numbers of these errors. If the source is unexpected, or the user is unauthorized, or the request is unusual, these may be suspicious or malicious activity." + "Security scans and tests may result in these errors. Misconfigured or buggy applications may produce large numbers of these errors. If the source is unexpected, the user unauthorized, or the request unusual, these may indicate suspicious or malicious activity." ], "index": [ "apm-*-transaction*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Web Application Suspicious Activity: Unauthorized Method", "query": "http.response.status_code:405", "references": [ diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_adversary_behavior_detected.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_adversary_behavior_detected.json index 56d142fdf3ef8e..397db1367f402f 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_adversary_behavior_detected.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_adversary_behavior_detected.json @@ -1,10 +1,12 @@ { - "description": "Elastic Endpoint Security Alert - Adversary behavior detected.", + "description": "Elastic Endpoint detected an Adversary Behavior. Click the Elastic Endpoint icon in the event.module column or the link in the rule.reference column in the External Alerts tab of the SIEM Detections page for additional information.", + "from": "now-660s", "index": [ "endgame-*" ], + "interval": "10m", "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Adversary Behavior - Detected - Elastic Endpoint", "query": "event.kind:alert and event.module:endgame and event.action:rules_engine_event", "risk_score": 47, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_dumping_detected.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_dumping_detected.json index 6805696ce6bc9e..fdd875e95b3d37 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_dumping_detected.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_dumping_detected.json @@ -1,11 +1,13 @@ { - "description": "Elastic Endpoint Security Alert - Credential dumping detected.", + "description": "Elastic Endpoint detected Credential Dumping. Click the Elastic Endpoint icon in the event.module column or the link in the rule.reference column in the External Alerts tab of the SIEM Detections page for additional information.", + "from": "now-660s", "index": [ "endgame-*" ], + "interval": "10m", "language": "kuery", - "max_signals": 33, - "name": "Cred Dumping - Detected - Elastic Endpoint", + "max_signals": 100, + "name": "Credential Dumping - Detected - Elastic Endpoint", "query": "event.kind:alert and event.module:endgame and event.action:cred_theft_event and endgame.metadata.type:detection", "risk_score": 73, "rule_id": "571afc56-5ed9-465d-a2a9-045f099f6e7e", diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_dumping_prevented.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_dumping_prevented.json index 68c0f5cad82521..8ed63c55ef2139 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_dumping_prevented.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_dumping_prevented.json @@ -1,11 +1,13 @@ { - "description": "Elastic Endpoint Security Alert - Credential dumping prevented.", + "description": "Elastic Endpoint prevented Credential Dumping. Click the Elastic Endpoint icon in the event.module column or the link in the rule.reference column in the External Alerts tab of the SIEM Detections page for additional information.", + "from": "now-660s", "index": [ "endgame-*" ], + "interval": "10m", "language": "kuery", - "max_signals": 33, - "name": "Cred Dumping - Prevented - Elastic Endpoint", + "max_signals": 100, + "name": "Credential Dumping - Prevented - Elastic Endpoint", "query": "event.kind:alert and event.module:endgame and event.action:cred_theft_event and endgame.metadata.type:prevention", "risk_score": 47, "rule_id": "db8c33a8-03cd-4988-9e2c-d0a4863adb13", diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_manipulation_detected.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_manipulation_detected.json index 0d0d9c71a2ec18..98c4e5341d9e8b 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_manipulation_detected.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_manipulation_detected.json @@ -1,11 +1,13 @@ { - "description": "Elastic Endpoint Security Alert - Credential manipulation detected.", + "description": "Elastic Endpoint detected Credential Manipulation. Click the Elastic Endpoint icon in the event.module column or the link in the rule.reference column in the External Alerts tab of the SIEM Detections page for additional information.", + "from": "now-660s", "index": [ "endgame-*" ], + "interval": "10m", "language": "kuery", - "max_signals": 33, - "name": "Cred Manipulation - Detected - Elastic Endpoint", + "max_signals": 100, + "name": "Credential Manipulation - Detected - Elastic Endpoint", "query": "event.kind:alert and event.module:endgame and event.action:token_manipulation_event and endgame.metadata.type:detection", "risk_score": 73, "rule_id": "c0be5f31-e180-48ed-aa08-96b36899d48f", diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_manipulation_prevented.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_manipulation_prevented.json index df49c80e3097b4..4234e3d955794c 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_manipulation_prevented.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_manipulation_prevented.json @@ -1,17 +1,20 @@ { - "description": "Elastic Endpoint Security Alert - Credential manipulation prevented.", + "description": "Elastic Endpoint prevented Credential Manipulation. Click the Elastic Endpoint icon in the event.module column or the link in the rule.reference column in the External Alerts tab of the SIEM Detections page for additional information.", + "from": "now-660s", "index": [ "endgame-*" ], + "interval": "10m", "language": "kuery", - "max_signals": 33, - "name": "Cred Manipulation - Prevented - Elastic Endpoint", + "max_signals": 100, + "name": "Credential Manipulation - Prevented - Elastic Endpoint", "query": "event.kind:alert and event.module:endgame and event.action:token_manipulation_event and endgame.metadata.type:prevention", "risk_score": 47, "rule_id": "c9e38e64-3f4c-4bf3-ad48-0e61a60ea1fa", "severity": "medium", "tags": [ - "Elastic" + "Elastic", + "Endpoint" ], "type": "query", "version": 1 diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_exploit_detected.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_exploit_detected.json index 9c3896a70b3a02..9971075d7e6178 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_exploit_detected.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_exploit_detected.json @@ -1,10 +1,12 @@ { - "description": "Elastic Endpoint Security Alert - Exploit detected.", + "description": "Elastic Endpoint detected an Exploit. Click the Elastic Endpoint icon in the event.module column or the link in the rule.reference column in the External Alerts tab of the SIEM Detections page for additional information.", + "from": "now-660s", "index": [ "endgame-*" ], + "interval": "10m", "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Exploit - Detected - Elastic Endpoint", "query": "event.kind:alert and event.module:endgame and event.action:exploit_event and endgame.metadata.type:detection", "risk_score": 73, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_exploit_prevented.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_exploit_prevented.json index 4632ae6a1487bf..233552fc1de13a 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_exploit_prevented.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_exploit_prevented.json @@ -1,10 +1,12 @@ { - "description": "Elastic Endpoint Security Alert - Exploit prevented.", + "description": "Elastic Endpoint prevented an Exploit. Click the Elastic Endpoint icon in the event.module column or the link in the rule.reference column in the External Alerts tab of the SIEM Detections page for additional information.", + "from": "now-660s", "index": [ "endgame-*" ], + "interval": "10m", "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Exploit - Prevented - Elastic Endpoint", "query": "event.kind:alert and event.module:endgame and event.action:exploit_event and endgame.metadata.type:prevention", "risk_score": 47, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_malware_detected.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_malware_detected.json index 68831392942d45..64d686fb984c95 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_malware_detected.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_malware_detected.json @@ -1,10 +1,12 @@ { - "description": "Elastic Endpoint Security Alert - Malware detected.", + "description": "Elastic Endpoint detected Malware. Click the Elastic Endpoint icon in the event.module column or the link in the rule.reference column in the External Alerts tab of the SIEM Detections page for additional information.", + "from": "now-660s", "index": [ "endgame-*" ], + "interval": "10m", "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Malware - Detected - Elastic Endpoint", "query": "event.kind:alert and event.module:endgame and event.action:file_classification_event and endgame.metadata.type:detection", "risk_score": 99, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_malware_prevented.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_malware_prevented.json index 56b41df2a33496..72f2134f23ab22 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_malware_prevented.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_malware_prevented.json @@ -1,10 +1,12 @@ { - "description": "Elastic Endpoint Security Alert - Malware prevented.", + "description": "Elastic Endpoint prevented Malware. Click the Elastic Endpoint icon in the event.module column or the link in the rule.reference column in the External Alerts tab of the SIEM Detections page for additional information.", + "from": "now-660s", "index": [ "endgame-*" ], + "interval": "10m", "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Malware - Prevented - Elastic Endpoint", "query": "event.kind:alert and event.module:endgame and event.action:file_classification_event and endgame.metadata.type:prevention", "risk_score": 73, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_permission_theft_detected.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_permission_theft_detected.json index 268dc9cf891214..3755dd4cd5dacf 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_permission_theft_detected.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_permission_theft_detected.json @@ -1,10 +1,12 @@ { - "description": "Elastic Endpoint Security Alert - Permission theft detected.", + "description": "Elastic Endpoint detected Permission Theft. Click the Elastic Endpoint icon in the event.module column or the link in the rule.reference column in the External Alerts tab of the SIEM Detections page for additional information.", + "from": "now-660s", "index": [ "endgame-*" ], + "interval": "10m", "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Permission Theft - Detected - Elastic Endpoint", "query": "event.kind:alert and event.module:endgame and event.action:token_protection_event and endgame.metadata.type:detection", "risk_score": 73, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_permission_theft_prevented.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_permission_theft_prevented.json index 6deda3d0453b2a..d8694075863729 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_permission_theft_prevented.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_permission_theft_prevented.json @@ -1,10 +1,12 @@ { - "description": "Elastic Endpoint Security Alert - Permission theft prevented.", + "description": "Elastic Endpoint prevented Permission Theft. Click the Elastic Endpoint icon in the event.module column or the link in the rule.reference column in the External Alerts tab of the SIEM Detections page for additional information.", + "from": "now-660s", "index": [ "endgame-*" ], + "interval": "10m", "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Permission Theft - Prevented - Elastic Endpoint", "query": "event.kind:alert and event.module:endgame and event.action:token_protection_event and endgame.metadata.type:prevention", "risk_score": 47, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_process_injection_detected.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_process_injection_detected.json index 25a03e611fe3e7..1078cf69394e26 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_process_injection_detected.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_process_injection_detected.json @@ -1,10 +1,12 @@ { - "description": "Elastic Endpoint Security Alert - Process injection detected.", + "description": "Elastic Endpoint detected Process Injection. Click the Elastic Endpoint icon in the event.module column or the link in the rule.reference column in the External Alerts tab of the SIEM Detections page for additional information.", + "from": "now-660s", "index": [ "endgame-*" ], + "interval": "10m", "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Process Injection - Detected - Elastic Endpoint", "query": "event.kind:alert and event.module:endgame and event.action:kernel_shellcode_event and endgame.metadata.type:detection", "risk_score": 73, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_process_injection_prevented.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_process_injection_prevented.json index 6c549d70a9d41a..8b68fc6925f9bf 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_process_injection_prevented.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_process_injection_prevented.json @@ -1,10 +1,12 @@ { - "description": "Elastic Endpoint Security Alert - Process injection prevented.", + "description": "Elastic Endpoint prevented Process Injection. Click the Elastic Endpoint icon in the event.module column or the link in the rule.reference column in the External Alerts tab of the SIEM Detections page for additional information.", + "from": "now-660s", "index": [ "endgame-*" ], + "interval": "10m", "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Process Injection - Prevented - Elastic Endpoint", "query": "event.kind:alert and event.module:endgame and event.action:kernel_shellcode_event and endgame.metadata.type:prevention", "risk_score": 47, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_ransomware_detected.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_ransomware_detected.json index 4a118cf8ab861c..a332c7011e94bf 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_ransomware_detected.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_ransomware_detected.json @@ -1,10 +1,12 @@ { - "description": "Elastic Endpoint Security Alert - Ransomware detected.", + "description": "Elastic Endpoint detected Ransomware. Click the Elastic Endpoint icon in the event.module column or the link in the rule.reference column in the External Alerts tab of the SIEM Detections page for additional information.", + "from": "now-660s", "index": [ "endgame-*" ], + "interval": "10m", "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Ransomware - Detected - Elastic Endpoint", "query": "event.kind:alert and event.module:endgame and event.action:ransomware_event and endgame.metadata.type:detection", "risk_score": 99, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_ransomware_prevented.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_ransomware_prevented.json index 8b48e8f4c17580..087c91d2105cef 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_ransomware_prevented.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_ransomware_prevented.json @@ -1,10 +1,12 @@ { - "description": "Elastic Endpoint Security Alert - Ransomware prevented.", + "description": "Elastic Endpoint prevented Ransomware. Click the Elastic Endpoint icon in the event.module column or the link in the rule.reference column in the External Alerts tab of the SIEM Detections page for additional information.", + "from": "now-660s", "index": [ "endgame-*" ], + "interval": "10m", "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Ransomware - Prevented - Elastic Endpoint", "query": "event.kind:alert and event.module:endgame and event.action:ransomware_event and endgame.metadata.type:prevention", "risk_score": 73, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_adding_the_hidden_file_attribute_with_via_attribexe.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_adding_the_hidden_file_attribute_with_via_attribexe.json index 374691f670b740..43aead33925c12 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_adding_the_hidden_file_attribute_with_via_attribexe.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_adding_the_hidden_file_attribute_with_via_attribexe.json @@ -1,10 +1,10 @@ { - "description": "Adversaries can add the 'hidden' attribute to files to hide them from the user in an attempt to evade detection", + "description": "Adversaries can add the 'hidden' attribute to files to hide them from the user in an attempt to evade detection.", "index": [ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Adding Hidden File Attribute via Attrib", "query": " event.action:\"Process Create (rule: ProcessCreate)\" and process.name:\"attrib.exe\" and process.args:\"+h\"", "risk_score": 21, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_adobe_hijack_persistence.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_adobe_hijack_persistence.json index 47f171dd7be0ef..387726168cb10c 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_adobe_hijack_persistence.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_adobe_hijack_persistence.json @@ -4,7 +4,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Adobe Hijack Persistence", "query": "file.path:(\"C:\\Program Files (x86)\\Adobe\\Acrobat Reader DC\\Reader\\AcroCEF\\RdrCEF.exe\" or \"C:\\Program Files\\Adobe\\Acrobat Reader DC\\Reader\\AcroCEF\\RdrCEF.exe\") and event.action:\"File created (rule: FileCreate)\" and not process.name:msiexeec.exe", "risk_score": 21, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_audio_capture_via_powershell.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_audio_capture_via_powershell.json deleted file mode 100644 index 7ec960eea63028..00000000000000 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_audio_capture_via_powershell.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "description": "An adversary can leverage a computer's peripheral devices or applications to capture audio recordings for the purpose of listening into sensitive conversations to gather information.", - "index": [ - "winlogbeat-*" - ], - "language": "kuery", - "max_signals": 33, - "name": "Audio Capture via PowerShell", - "query": "event.action:\"Process Create (rule: ProcessCreate)\" and process.name:\"powershell.exe\" and process.args:\"WindowsAudioDevice-Powershell-Cmdlet\"", - "risk_score": 21, - "rule_id": "b27b9f47-0a20-4807-8377-7f899b4fbada", - "severity": "low", - "tags": [ - "Elastic", - "Windows" - ], - "threat": [ - { - "framework": "MITRE ATT&CK", - "tactic": { - "id": "TA0003", - "name": "Collection", - "reference": "https://attack.mitre.org/tactics/TA0009/" - }, - "technique": [ - { - "id": "T1123", - "name": "Audio Capture", - "reference": "https://attack.mitre.org/techniques/T1123/" - } - ] - } - ], - "type": "query", - "version": 1 -} diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_audio_capture_via_soundrecorder.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_audio_capture_via_soundrecorder.json deleted file mode 100644 index 87bdfc4980124f..00000000000000 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_audio_capture_via_soundrecorder.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "description": "An adversary can leverage a computer's peripheral devices or applications to capture audio recordings for the purpose of listening into sensitive conversations to gather information.", - "index": [ - "winlogbeat-*" - ], - "language": "kuery", - "max_signals": 33, - "name": "Audio Capture via SoundRecorder", - "query": "event.action:\"Process Create (rule: ProcessCreate)\" and process.name:\"SoundRecorder.exe\" and process.args:\"/FILE\"", - "risk_score": 21, - "rule_id": "f8e06892-ed10-4452-892e-2c5a38d552f1", - "severity": "low", - "tags": [ - "Elastic", - "Windows" - ], - "threat": [ - { - "framework": "MITRE ATT&CK", - "tactic": { - "id": "TA0003", - "name": "Collection", - "reference": "https://attack.mitre.org/tactics/TA0009/" - }, - "technique": [ - { - "id": "T1123", - "name": "Audio Capture", - "reference": "https://attack.mitre.org/techniques/T1123/" - } - ] - } - ], - "type": "query", - "version": 1 -} diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_bypass_uac_event_viewer.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_bypass_uac_event_viewer.json deleted file mode 100644 index 2fa63fa51f7c12..00000000000000 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_bypass_uac_event_viewer.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "description": "Identifies User Account Control (UAC) bypass via eventvwr.exe. Attackers bypass UAC to stealthily execute code with elevated permissions.", - "index": [ - "winlogbeat-*" - ], - "language": "kuery", - "max_signals": 33, - "name": "Bypass UAC via Event Viewer", - "query": "process.parent.name:eventvwr.exe and event.action:\"Process Create (rule: ProcessCreate)\" and not process.executable:(\"C:\\Windows\\System32\\mmc.exe\" or \"C:\\Windows\\SysWOW64\\mmc.exe\")", - "risk_score": 21, - "rule_id": "59547add-a400-4baa-aa0c-66c72efdb77f", - "severity": "low", - "tags": [ - "Elastic", - "Windows" - ], - "threat": [ - { - "framework": "MITRE ATT&CK", - "tactic": { - "id": "TA0004", - "name": "Privilege Escalation", - "reference": "https://attack.mitre.org/tactics/TA0004/" - }, - "technique": [ - { - "id": "T1088", - "name": "Bypass User Account Control", - "reference": "https://attack.mitre.org/techniques/T1088/" - } - ] - } - ], - "type": "query", - "version": 1 -} diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_bypass_uac_via_cmstp.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_bypass_uac_via_cmstp.json deleted file mode 100644 index fdc716dcb3ebeb..00000000000000 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_bypass_uac_via_cmstp.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "description": "Identifies User Account Control (UAC) bypass via cmstp.exe. Attackers bypass UAC to stealthily execute code with elevated permissions.", - "index": [ - "winlogbeat-*" - ], - "language": "kuery", - "max_signals": 33, - "name": "Bypass UAC via Cmstp", - "query": "event.action:\"Process Create (rule: ProcessCreate)\" and process.parent.name:\"cmstp.exe\" and process.parent.args:(\"/s\" and \"/au\")", - "risk_score": 21, - "rule_id": "2f7403da-1a4c-46bb-8ecc-c1a596e10cd0", - "severity": "low", - "tags": [ - "Elastic", - "Windows" - ], - "threat": [ - { - "framework": "MITRE ATT&CK", - "tactic": { - "id": "TA0004", - "name": "Privilege Escalation", - "reference": "https://attack.mitre.org/tactics/TA0004/" - }, - "technique": [ - { - "id": "T1088", - "name": "Bypass User Account Control", - "reference": "https://attack.mitre.org/techniques/T1088/" - } - ] - } - ], - "type": "query", - "version": 1 -} diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_bypass_uac_via_sdclt.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_bypass_uac_via_sdclt.json deleted file mode 100644 index 484a01e0211abb..00000000000000 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_bypass_uac_via_sdclt.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "description": "Identifies User Account Control (UAC) bypass via sdclt.exe. Attackers bypass UAC to stealthily execute code with elevated permissions.", - "index": [ - "winlogbeat-*" - ], - "language": "kuery", - "max_signals": 33, - "name": "Bypass UAC via Sdclt", - "query": " event.action:\"Process Create (rule: ProcessCreate)\" and process.name:\"sdclt.exe\" and process.args:\"/kickoffelev\" and not process.executable:(\"C:\\Windows\\System32\\sdclt.exe\" or \"C:\\Windows\\System32\\control.exe\" or \"C:\\Windows\\SysWOW64\\sdclt.exe\" or \"C:\\Windows\\SysWOW64\\control.exe\")", - "risk_score": 21, - "rule_id": "f68d83a1-24cb-4b8d-825b-e8af400b9670", - "severity": "low", - "tags": [ - "Elastic", - "Windows" - ], - "threat": [ - { - "framework": "MITRE ATT&CK", - "tactic": { - "id": "TA0004", - "name": "Privilege Escalation", - "reference": "https://attack.mitre.org/tactics/TA0004/" - }, - "technique": [ - { - "id": "T1088", - "name": "Bypass User Account Control", - "reference": "https://attack.mitre.org/techniques/T1088/" - } - ] - } - ], - "type": "query", - "version": 1 -} diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_clearing_windows_event_logs.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_clearing_windows_event_logs.json index e9729ff102619a..135e81148475f9 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_clearing_windows_event_logs.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_clearing_windows_event_logs.json @@ -1,10 +1,10 @@ { - "description": "Identifies attempts to clear Windows event log stores. This is often done by attackers in an attempt evade detection or destroy forensic evidence on a system.", + "description": "Identifies attempts to clear Windows event log stores. This is often done by attackers in an attempt to evade detection or destroy forensic evidence on a system.", "index": [ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Clearing Windows Event Logs", "query": "event.action:\"Process Create (rule: ProcessCreate)\" and (process.name:\"wevtutil.exe\" and process.args:\"cl\") or (process.name:\"powershell.exe\" and process.args:\"Clear-EventLog\")", "risk_score": 21, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_delete_volume_usn_journal_with_fsutil.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_delete_volume_usn_journal_with_fsutil.json index 479bb4a2a6d7c6..815e2abd0fc96b 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_delete_volume_usn_journal_with_fsutil.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_delete_volume_usn_journal_with_fsutil.json @@ -4,7 +4,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Delete Volume USN Journal with Fsutil", "query": "event.action:\"Process Create (rule: ProcessCreate)\" and process.name:\"fsutil.exe\" and process.args:(\"usn\" and \"deletejournal\")", "risk_score": 21, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_deleting_backup_catalogs_with_wbadmin.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_deleting_backup_catalogs_with_wbadmin.json index 204925e4b677b4..d990e071b21230 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_deleting_backup_catalogs_with_wbadmin.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_deleting_backup_catalogs_with_wbadmin.json @@ -4,7 +4,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Deleting Backup Catalogs with Wbadmin", "query": "event.action:\"Process Create (rule: ProcessCreate)\" and process.name:\"wbadmin.exe\" and process.args:(\"delete\" and \"catalog\")", "risk_score": 21, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_direct_outbound_smb_connection.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_direct_outbound_smb_connection.json index b6398a9985e7e4..9d1cebb32c8654 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_direct_outbound_smb_connection.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_direct_outbound_smb_connection.json @@ -4,7 +4,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Direct Outbound SMB Connection", "query": " event.action:\"Network connection detected (rule: NetworkConnect)\" and destination.port:445 and not process.pid:4 and not destination.ip:(\"127.0.0.1\" or \"::1\")", "risk_score": 47, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_disable_windows_firewall_rules_with_netsh.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_disable_windows_firewall_rules_with_netsh.json index 32b43cc24e91b2..7ead979f27bb10 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_disable_windows_firewall_rules_with_netsh.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_disable_windows_firewall_rules_with_netsh.json @@ -4,7 +4,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Disable Windows Firewall Rules via Netsh", "query": "event.action:\"Process Create (rule: ProcessCreate)\" and process.name:\"netsh.exe\" and process.args:(\"firewall\" and \"set\" and \"disable\") or process.args:(\"advfirewall\" and \"state\" and \"off\")", "risk_score": 47, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_dll_search_order_hijack.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_dll_search_order_hijack.json deleted file mode 100644 index 5740453b6ae6d8..00000000000000 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_dll_search_order_hijack.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "description": "Detects writing DLL files to known locations associated with Windows files vulnerable to DLL search order hijacking.", - "index": [ - "winlogbeat-*" - ], - "language": "kuery", - "max_signals": 33, - "name": "DLL Search Order Hijack", - "query": " event.action:\"File created (rule: FileCreate)\" and not winlog.user.identifier:(\"S-1-5-18\" or \"S-1-5-19\" or \"S-1-5-20\") and file.path:(\"C\\Windows\\ehome\\cryptbase.dll\" or \"C\\Windows\\System32\\Sysprep\\cryptbase.dll\" or \"C\\Windows\\System32\\Sysprep\\cryptsp.dll\" or \"C\\Windows\\System32\\Sysprep\\rpcrtremote.dll\" or \"C\\Windows\\System32\\Sysprep\\uxtheme.dll\" or \"C\\Windows\\System32\\Sysprep\\dwmapi.dll\" or \"C\\Windows\\System32\\Sysprep\\shcore.dll\" or \"C\\Windows\\System32\\Sysprep\\oleacc.dll\" or \"C\\Windows\\System32\\ntwdblib.dll\") ", - "risk_score": 47, - "rule_id": "73fbc44c-c3cd-48a8-a473-f4eb2065c716", - "severity": "medium", - "tags": [ - "Elastic", - "Windows" - ], - "threat": [ - { - "framework": "MITRE ATT&CK", - "tactic": { - "id": "TA0004", - "name": "Privilege Escalation", - "reference": "https://attack.mitre.org/tactics/TA0004/" - }, - "technique": [ - { - "id": "T1088", - "name": "Bypass User Account Control", - "reference": "https://attack.mitre.org/techniques/T1088/" - } - ] - }, - { - "framework": "MITRE ATT&CK", - "tactic": { - "id": "TA0005", - "name": "Defense Evasion", - "reference": "https://attack.mitre.org/tactics/TA0005/" - }, - "technique": [ - { - "id": "T1088", - "name": "Bypass User Account Control", - "reference": "https://attack.mitre.org/techniques/T1088/" - } - ] - } - ], - "type": "query", - "version": 1 -} diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_encoding_or_decoding_files_via_certutil.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_encoding_or_decoding_files_via_certutil.json index 37e1c26885a157..2cb92f0a26c900 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_encoding_or_decoding_files_via_certutil.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_encoding_or_decoding_files_via_certutil.json @@ -4,7 +4,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Encoding or Decoding Files via CertUtil", "query": "event.action:\"Process Create (rule: ProcessCreate)\" and process.name:\"certutil.exe\" and process.args:(\"-encode\" or \"/encode\" or \"-decode\" or \"/decode\")", "risk_score": 47, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_local_scheduled_task_commands.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_local_scheduled_task_commands.json index dc4991f86a0f54..e7f46b46c2ce2e 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_local_scheduled_task_commands.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_local_scheduled_task_commands.json @@ -7,7 +7,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Local Scheduled Task Commands", "query": " event.action:\"Process Create (rule: ProcessCreate)\" and process.name:schtasks.exe and process.args:(\"/create\" or \"-create\" or \"/S\" or \"-s\" or \"/run\" or \"-run\" or \"/change\" or \"-change\")", "risk_score": 21, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_local_service_commands.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_local_service_commands.json index eb6f2377376f28..b018435ea0214f 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_local_service_commands.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_local_service_commands.json @@ -4,7 +4,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Local Service Commands", "query": "event.action:\"Process Create (rule: ProcessCreate)\" and process.name:sc.exe and process.args:(\"create\" or \"config\" or \"failure\" or \"start\")", "risk_score": 21, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_modification_of_boot_configuration.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_modification_of_boot_configuration.json deleted file mode 100644 index 26bd65b897c63a..00000000000000 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_modification_of_boot_configuration.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "description": "Identifies use of bcdedit.exe to delete boot configuration data. This tactic is sometimes used as by malware or an attacker as a destructive technique.", - "index": [ - "winlogbeat-*" - ], - "language": "kuery", - "max_signals": 33, - "name": "Modification of Boot Configuration", - "query": "event.action:\"Process Create (rule: ProcessCreate)\" and process.name:\"bcdedit.exe\" and process.args:\"set\" and process.args:( (\"bootstatuspolicy\" and \"ignoreallfailures\") or (\"recoveryenabled\" and \"no\") ) ", - "risk_score": 73, - "rule_id": "b9ab2f7f-f719-4417-9599-e0252fffe2d8", - "severity": "high", - "tags": [ - "Elastic", - "Windows" - ], - "threat": [ - { - "framework": "MITRE ATT&CK", - "tactic": { - "id": "TA0005", - "name": "Defense Evasion", - "reference": "https://attack.mitre.org/tactics/TA0005/" - }, - "technique": [ - { - "id": "T1107", - "name": "File Deletion", - "reference": "https://attack.mitre.org/techniques/T1107/" - } - ] - } - ], - "type": "query", - "version": 1 -} diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_msbuild_making_network_connections.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_msbuild_making_network_connections.json index d40ffed523c6a4..7d84e0bda06e58 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_msbuild_making_network_connections.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_msbuild_making_network_connections.json @@ -4,9 +4,9 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "MsBuild Making Network Connections", - "query": " event.action:\"Network connection detected (rule: NetworkConnect)\" and process.name:msbuild.exe and not destination.ip:(\"127.0.0.1\" or \"::1\")", + "query": " event.action:\"Network connection detected (rule: NetworkConnect)\" and process.name:MSBuild.exe and not destination.ip:(\"127.0.0.1\" or \"::1\")", "risk_score": 47, "rule_id": "0e79980b-4250-4a50-a509-69294c14e84b", "severity": "medium", diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_mshta_making_network_connections.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_mshta_making_network_connections.json index 7905d80c6e8c29..44141b08fb8f0a 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_mshta_making_network_connections.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_mshta_making_network_connections.json @@ -4,9 +4,9 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Network Connection via Mshta", - "query": "event.action:\"Network connection detected (rule: NetworkConnect)\" and process.name:\"mshta.exe\" and not process.name:\"mshta.exe\"", + "query": "event.action:\"Network connection detected (rule: NetworkConnect)\" and process.name:\"mshta.exe\"", "references": [ "https://www.fireeye.com/blog/threat-research/2017/05/cyber-espionage-apt32.html" ], diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_msxsl_making_network_connections.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_msxsl_making_network_connections.json deleted file mode 100644 index 16ef15589f48f7..00000000000000 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_msxsl_making_network_connections.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "description": "Identifies msxsl.exe making a network connection. This may indicate adversarial activity as msxsl.exe is often leveraged by adversaries to execute malicious scripts and evade detection.", - "index": [ - "winlogbeat-*" - ], - "language": "kuery", - "max_signals": 33, - "name": "Network Connection via MsXsl", - "query": "process.name:msxsl.exe and event.action:\"Network connection detected (rule: NetworkConnect)\" and not destination.ip:10.0.0.0/8 and not destination.ip:172.16.0.0/12 and not destination.ip:192.168.0.0/16", - "risk_score": 47, - "rule_id": "d7351b03-135d-43ba-8b36-cc9b07854525", - "severity": "medium", - "tags": [ - "Elastic", - "Windows" - ], - "threat": [ - { - "framework": "MITRE ATT&CK", - "tactic": { - "id": "TA0002", - "name": "Execution", - "reference": "https://attack.mitre.org/tactics/TA0002/" - }, - "technique": [ - { - "id": "T1220", - "name": "XSL Script Processing", - "reference": "https://attack.mitre.org/techniques/T1220/" - } - ] - } - ], - "type": "query", - "version": 1 -} diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_psexec_lateral_movement_command.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_psexec_lateral_movement_command.json index fd210005118b84..580f73c25a4a27 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_psexec_lateral_movement_command.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_psexec_lateral_movement_command.json @@ -7,9 +7,9 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "PsExec Network Connection", - "query": "process.name:psexec.exe and event.action:\"Network connection detected (rule: NetworkConnect)\" ", + "query": "process.name:PsExec.exe and event.action:\"Network connection detected (rule: NetworkConnect)\" ", "risk_score": 21, "rule_id": "55d551c6-333b-4665-ab7e-5d14a59715ce", "severity": "low", diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_suspicious_ms_office_child_process.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_suspicious_ms_office_child_process.json index a5d71e23a1215a..95aabc49b53026 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_suspicious_ms_office_child_process.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_suspicious_ms_office_child_process.json @@ -4,7 +4,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Suspicious MS Office Child Process", "query": " event.action:\"Process Create (rule: ProcessCreate)\" and process.parent.name:(\"winword.exe\" or \"excel.exe\" or \"powerpnt.exe\" or \"eqnedt32.exe\" or \"fltldr.exe\" or \"mspub.exe\" or \"msaccess.exe\") and process.name:(\"arp.exe\" or \"dsquery.exe\" or \"dsget.exe\" or \"gpresult.exe\" or \"hostname.exe\" or \"ipconfig.exe\" or \"nbtstat.exe\" or \"net.exe\" or \"net1.exe\" or \"netsh.exe\" or \"netstat.exe\" or \"nltest.exe\" or \"ping.exe\" or \"qprocess.exe\" or \"quser.exe\" or \"qwinsta.exe\" or \"reg.exe\" or \"sc.exe\" or \"systeminfo.exe\" or \"tasklist.exe\" or \"tracert.exe\" or \"whoami.exe\" or \"bginfo.exe\" or \"cdb.exe\" or \"cmstp.exe\" or \"csi.exe\" or \"dnx.exe\" or \"fsi.exe\" or \"ieexec.exe\" or \"iexpress.exe\" or \"installutil.exe\" or \"Microsoft.Workflow.Compiler.exe\" or \"msbuild.exe\" or \"mshta.exe\" or \"msxsl.exe\" or \"odbcconf.exe\" or \"rcsi.exe\" or \"regsvr32.exe\" or \"xwizard.exe\" or \"atbroker.exe\" or \"forfiles.exe\" or \"schtasks.exe\" or \"regasm.exe\" or \"regsvcs.exe\" or \"cmd.exe\" or \"cscript.exe\" or \"powershell.exe\" or \"pwsh.exe\" or \"wmic.exe\" or \"wscript.exe\" or \"bitsadmin.exe\" or \"certutil.exe\" or \"ftp.exe\") ", "risk_score": 21, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_suspicious_ms_outlook_child_process.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_suspicious_ms_outlook_child_process.json index 86716d66080492..f31228d0130f89 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_suspicious_ms_outlook_child_process.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_suspicious_ms_outlook_child_process.json @@ -4,7 +4,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Suspicious MS Outlook Child Process", "query": " event.action:\"Process Create (rule: ProcessCreate)\" and process.parent.name:\"outlook.exe\" and process.name:(\"arp.exe\" or \"dsquery.exe\" or \"dsget.exe\" or \"gpresult.exe\" or \"hostname.exe\" or \"ipconfig.exe\" or \"nbtstat.exe\" or \"net.exe\" or \"net1.exe\" or \"netsh.exe\" or \"netstat.exe\" or \"nltest.exe\" or \"ping.exe\" or \"qprocess.exe\" or \"quser.exe\" or \"qwinsta.exe\" or \"reg.exe\" or \"sc.exe\" or \"systeminfo.exe\" or \"tasklist.exe\" or \"tracert.exe\" or \"whoami.exe\" or \"bginfo.exe\" or \"cdb.exe\" or \"cmstp.exe\" or \"csi.exe\" or \"dnx.exe\" or \"fsi.exe\" or \"ieexec.exe\" or \"iexpress.exe\" or \"installutil.exe\" or \"Microsoft.Workflow.Compiler.exe\" or \"msbuild.exe\" or \"mshta.exe\" or \"msxsl.exe\" or \"odbcconf.exe\" or \"rcsi.exe\" or \"regsvr32.exe\" or \"xwizard.exe\" or \"atbroker.exe\" or \"forfiles.exe\" or \"schtasks.exe\" or \"regasm.exe\" or \"regsvcs.exe\" or \"cmd.exe\" or \"cscript.exe\" or \"powershell.exe\" or \"pwsh.exe\" or \"wmic.exe\" or \"wscript.exe\" or \"bitsadmin.exe\" or \"certutil.exe\" or \"ftp.exe\") ", "risk_score": 21, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_suspicious_pdf_reader_child_process.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_suspicious_pdf_reader_child_process.json deleted file mode 100644 index b0fbccf1b67a70..00000000000000 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_suspicious_pdf_reader_child_process.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "description": "Identifies suspicious child processes of PDF reader applications. These child processes are often launched via exploitation of PDF applications or social engineering.", - "index": [ - "winlogbeat-*" - ], - "language": "kuery", - "max_signals": 33, - "name": "Suspicious PDF Reader Child Process", - "query": " event.action:\"Process Create (rule: ProcessCreate)\" and process.parent.name:(\"acrord32.exe\" or \"rdrcef.exe\" or \"foxitphantomPDF.exe\" or \"foxitreader.exe\") and process.name:(\"arp.exe\" or \"dsquery.exe\" or \"dsget.exe\" or \"gpresult.exe\" or \"hostname.exe\" or \"ipconfig.exe\" or \"nbtstat.exe\" or \"net.exe\" or \"net1.exe\" or \"netsh.exe\" or \"netstat.exe\" or \"nltest.exe\" or \"ping.exe\" or \"qprocess.exe\" or \"quser.exe\" or \"qwinsta.exe\" or \"reg.exe\" or \"sc.exe\" or \"systeminfo.exe\" or \"tasklist.exe\" or \"tracert.exe\" or \"whoami.exe\" or \"bginfo.exe\" or \"cdb.exe\" or \"cmstp.exe\" or \"csi.exe\" or \"dnx.exe\" or \"fsi.exe\" or \"ieexec.exe\" or \"iexpress.exe\" or \"installutil.exe\" or \"Microsoft.Workflow.Compiler.exe\" or \"msbuild.exe\" or \"mshta.exe\" or \"msxsl.exe\" or \"odbcconf.exe\" or \"rcsi.exe\" or \"regsvr32.exe\" or \"xwizard.exe\" or \"atbroker.exe\" or \"forfiles.exe\" or \"schtasks.exe\" or \"regasm.exe\" or \"regsvcs.exe\" or \"cmd.exe\" or \"cscript.exe\" or \"powershell.exe\" or \"pwsh.exe\" or \"wmic.exe\" or \"wscript.exe\" or \"bitsadmin.exe\" or \"certutil.exe\" or \"ftp.exe\") ", - "risk_score": 73, - "rule_id": "afcac7b1-d092-43ff-a136-aa7accbda38f", - "severity": "high", - "tags": [ - "Elastic", - "Windows" - ], - "threat": [ - { - "framework": "MITRE ATT&CK", - "tactic": { - "id": "TA0002", - "name": "Execution", - "reference": "https://attack.mitre.org/tactics/TA0002/" - }, - "technique": [ - { - "id": "T1193", - "name": "Spearphishing Attachment", - "reference": "https://attack.mitre.org/techniques/T1193/" - } - ] - } - ], - "type": "query", - "version": 1 -} diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_system_shells_via_services.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_system_shells_via_services.json index 984b522596c1e0..a38232f37843eb 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_system_shells_via_services.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_system_shells_via_services.json @@ -4,7 +4,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "System Shells via Services", "query": " event.action:\"Process Create (rule: ProcessCreate)\" and process.parent.name:\"services.exe\" and process.name:(\"cmd.exe\" or \"powershell.exe\")", "risk_score": 47, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_unusual_network_connection_via_rundll32.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_unusual_network_connection_via_rundll32.json index 03b9bebb655c3a..820c69cb3c8093 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_unusual_network_connection_via_rundll32.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_unusual_network_connection_via_rundll32.json @@ -4,7 +4,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Unusual Network Connection via RunDLL32", "query": "process.name:rundll32.exe and event.action:\"Network connection detected (rule: NetworkConnect)\" and not destination.ip:10.0.0.0/8 and not destination.ip:172.16.0.0/12 and not destination.ip:192.168.0.0/16", "risk_score": 21, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_unusual_parentchild_relationship.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_unusual_parentchild_relationship.json index 72eb17863e0d3b..21d3d2741378a5 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_unusual_parentchild_relationship.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_unusual_parentchild_relationship.json @@ -4,7 +4,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Unusual Parent-Child Relationship ", "query": " event.action:\"Process Create (rule: ProcessCreate)\" and process.parent.executable:* and ( (process.name:\"smss.exe\" and not process.parent.name:(\"System\" or \"smss.exe\")) or (process.name:\"csrss.exe\" and not process.parent.name:(\"smss.exe\" or \"svchost.exe\")) or (process.name:\"wininit.exe\" and not process.parent.name:\"smss.exe\") or (process.name:\"winlogon.exe\" and not process.parent.name:\"smss.exe\") or (process.name:\"lsass.exe\" and not process.parent.name:\"wininit.exe\") or (process.name:\"LogonUI.exe\" and not process.parent.name:(\"winlogon.exe\" or \"wininit.exe\")) or (process.name:\"services.exe\" and not process.parent.name:\"wininit.exe\") or (process.name:\"svchost.exe\" and not process.parent.name:(\"services.exe\" or \"MsMpEng.exe\")) or (process.name:\"spoolsv.exe\" and not process.parent.name:\"services.exe\") or (process.name:\"taskhost.exe\" and not process.parent.name:(\"services.exe\" or \"svchost.exe\")) or (process.name:\"taskhostw.exe\" and not process.parent.name:(\"services.exe\" or \"svchost.exe\")) or (process.name:\"userinit.exe\" and not process.parent.name:(\"dwm.exe\" or \"winlogon.exe\")) )", "risk_score": 47, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_unusual_process_network_connection.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_unusual_process_network_connection.json index 8ca16198ff1752..ee861e19341afa 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_unusual_process_network_connection.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_unusual_process_network_connection.json @@ -4,7 +4,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Unusual Process Network Connection", "query": " event.action:\"Network connection detected (rule: NetworkConnect)\" and process.name:(bginfo.exe or cdb.exe or cmstp.exe or csi.exe or dnx.exe or fsi.exe or ieexec.exe or iexpress.exe or Microsoft.Workflow.Compiler.exe or odbcconf.exe or rcsi.exe or xwizard.exe)", "risk_score": 21, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_user_account_creation.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_user_account_creation.json index dee3d18bd5eda5..5a7aeab224548a 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_user_account_creation.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_user_account_creation.json @@ -4,7 +4,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "User Account Creation", "query": " event.action:\"Process Create (rule: ProcessCreate)\" and process.name:(\"net.exe\" or \"net1.exe\") and not process.parent.name:\"net.exe\" and process.args:(\"user\" and (\"/add\" or \"/ad\")) ", "risk_score": 21, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_user_added_to_administrator_group.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_user_added_to_administrator_group.json deleted file mode 100644 index 4ed6a06b18d3b0..00000000000000 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_user_added_to_administrator_group.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "description": "Identifies attempts to add a user to an administrative group with the \"net.exe\" command. This is sometimes done by attackers to increase access of a compromised account or create new account.", - "index": [ - "winlogbeat-*" - ], - "language": "kuery", - "max_signals": 33, - "name": "User Added to Administrator Group", - "query": " event.action:\"Process Create (rule: ProcessCreate)\" and process.name:(\"net.exe\" or \"net1.exe\") and not process.parent.name:\"net.exe\" and process.args:(\"group\" and \"admin\" and \"/add\") ", - "risk_score": 47, - "rule_id": "4426de6f-6103-44aa-a77e-49d672836c27", - "severity": "medium", - "tags": [ - "Elastic", - "Windows" - ], - "threat": [ - { - "framework": "MITRE ATT&CK", - "tactic": { - "id": "TA0003", - "name": "Persistence", - "reference": "https://attack.mitre.org/tactics/TA0003/" - }, - "technique": [ - { - "id": "T1098", - "name": "Account Manipulation", - "reference": "https://attack.mitre.org/techniques/T1098/" - } - ] - } - ], - "type": "query", - "version": 1 -} diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_volume_shadow_copy_deletion_via_vssadmin.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_volume_shadow_copy_deletion_via_vssadmin.json index cdeeb1563dfde5..80c0dd962c099f 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_volume_shadow_copy_deletion_via_vssadmin.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_volume_shadow_copy_deletion_via_vssadmin.json @@ -4,7 +4,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Volume Shadow Copy Deletion via VssAdmin", "query": " event.action:\"Process Create (rule: ProcessCreate)\" and process.name:\"vssadmin.exe\" and process.args:(\"delete\" and \"shadows\") ", "risk_score": 73, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_volume_shadow_copy_deletion_via_wmic.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_volume_shadow_copy_deletion_via_wmic.json index 9465cf84d73f4b..d90aca1e2eaf41 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_volume_shadow_copy_deletion_via_wmic.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_volume_shadow_copy_deletion_via_wmic.json @@ -4,9 +4,9 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Volume Shadow Copy Deletion via WMIC", - "query": " event.action:\"Process Create (rule: ProcessCreate)\" and process.name:\"wmic.exe\" and process.args:(\"shadowcopy\" and \"delete\")", + "query": " event.action:\"Process Create (rule: ProcessCreate)\" and process.name:\"WMIC.exe\" and process.args:(\"shadowcopy\" and \"delete\")", "risk_score": 73, "rule_id": "dc9c1f74-dac3-48e3-b47f-eb79db358f57", "severity": "high", diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_windows_script_executing_powershell.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_windows_script_executing_powershell.json index f3df1276de53d5..8f6e97cdd7bdbe 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_windows_script_executing_powershell.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_windows_script_executing_powershell.json @@ -4,7 +4,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Windows Script Executing PowerShell", "query": "event.action:\"Process Create (rule: ProcessCreate)\" and process.parent.name:(\"wscript.exe\" or \"cscript.exe\") and process.name:\"powershell.exe\"", "risk_score": 21, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_wmic_command_lateral_movement.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_wmic_command_lateral_movement.json deleted file mode 100644 index a50d9e64f2e2b5..00000000000000 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_wmic_command_lateral_movement.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "description": "Identifies use of wmic.exe to run commands on remote hosts. This could be indicative of adversary lateral movement but will be noisy if commonly done by admins.", - "false_positives": [ - "The WMIC utility provides a command-line interface for WMI, which can be used for an array of administrative capabilities. It's important to baseline your environment to determine any abnormal use of this tool." - ], - "index": [ - "winlogbeat-*" - ], - "language": "kuery", - "max_signals": 33, - "name": "WMIC Command Lateral Movement", - "query": " event.action:\"Process Create (rule: ProcessCreate)\" and process.name:\"wmic.exe\" and process.args:(\"/node\" or \"-node\") and process.args:(\"call\" or \"set\")", - "risk_score": 21, - "rule_id": "9616587f-6396-42d0-bd31-ef8dbd806210", - "severity": "low", - "tags": [ - "Elastic", - "Windows" - ], - "threat": [ - { - "framework": "MITRE ATT&CK", - "tactic": { - "id": "TA0008", - "name": "Lateral Movement", - "reference": "https://attack.mitre.org/tactics/TA0008/" - }, - "technique": [ - { - "id": "T1047", - "name": "Windows Management Instrumentation", - "reference": "https://attack.mitre.org/techniques/T1047/" - } - ] - } - ], - "type": "query", - "version": 1 -} diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/index.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/index.ts index b454501e9f563f..d9841948f35a56 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/index.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/index.ts @@ -26,99 +26,79 @@ import rule16 from './elastic_endpoint_security_ransomware_detected.json'; import rule17 from './elastic_endpoint_security_ransomware_prevented.json'; import rule18 from './eql_adding_the_hidden_file_attribute_with_via_attribexe.json'; import rule19 from './eql_adobe_hijack_persistence.json'; -import rule20 from './eql_audio_capture_via_powershell.json'; -import rule21 from './eql_audio_capture_via_soundrecorder.json'; -import rule22 from './eql_bypass_uac_event_viewer.json'; -import rule23 from './eql_bypass_uac_via_cmstp.json'; -import rule24 from './eql_bypass_uac_via_sdclt.json'; -import rule25 from './eql_clearing_windows_event_logs.json'; -import rule26 from './eql_delete_volume_usn_journal_with_fsutil.json'; -import rule27 from './eql_deleting_backup_catalogs_with_wbadmin.json'; -import rule28 from './eql_direct_outbound_smb_connection.json'; -import rule29 from './eql_disable_windows_firewall_rules_with_netsh.json'; -import rule30 from './eql_dll_search_order_hijack.json'; -import rule31 from './eql_encoding_or_decoding_files_via_certutil.json'; -import rule32 from './eql_local_scheduled_task_commands.json'; -import rule33 from './eql_local_service_commands.json'; -import rule34 from './eql_modification_of_boot_configuration.json'; -import rule35 from './eql_msbuild_making_network_connections.json'; -import rule36 from './eql_mshta_making_network_connections.json'; -import rule37 from './eql_msxsl_making_network_connections.json'; -import rule38 from './eql_psexec_lateral_movement_command.json'; -import rule39 from './eql_suspicious_ms_office_child_process.json'; -import rule40 from './eql_suspicious_ms_outlook_child_process.json'; -import rule41 from './eql_suspicious_pdf_reader_child_process.json'; -import rule42 from './eql_system_shells_via_services.json'; -import rule43 from './eql_unusual_network_connection_via_rundll32.json'; -import rule44 from './eql_unusual_parentchild_relationship.json'; -import rule45 from './eql_unusual_process_network_connection.json'; -import rule46 from './eql_user_account_creation.json'; -import rule47 from './eql_user_added_to_administrator_group.json'; -import rule48 from './eql_volume_shadow_copy_deletion_via_vssadmin.json'; -import rule49 from './eql_volume_shadow_copy_deletion_via_wmic.json'; -import rule50 from './eql_windows_script_executing_powershell.json'; -import rule51 from './eql_wmic_command_lateral_movement.json'; -import rule52 from './linux_hping_activity.json'; -import rule53 from './linux_iodine_activity.json'; -import rule54 from './linux_kernel_module_activity.json'; -import rule55 from './linux_ldso_process_activity.json'; -import rule56 from './linux_mknod_activity.json'; -import rule57 from './linux_netcat_network_connection.json'; -import rule58 from './linux_nmap_activity.json'; -import rule59 from './linux_nping_activity.json'; -import rule60 from './linux_process_started_in_temp_directory.json'; -import rule61 from './linux_shell_activity_by_web_server.json'; -import rule62 from './linux_socat_activity.json'; -import rule63 from './linux_strace_activity.json'; -import rule64 from './linux_tcpdump_activity.json'; -import rule65 from './linux_whoami_commmand.json'; -import rule66 from './network_dns_directly_to_the_internet.json'; -import rule67 from './network_ftp_file_transfer_protocol_activity_to_the_internet.json'; -import rule68 from './network_irc_internet_relay_chat_protocol_activity_to_the_internet.json'; -import rule69 from './network_nat_traversal_port_activity.json'; -import rule70 from './network_port_26_activity.json'; -import rule71 from './network_port_8000_activity_to_the_internet.json'; -import rule72 from './network_pptp_point_to_point_tunneling_protocol_activity.json'; -import rule73 from './network_proxy_port_activity_to_the_internet.json'; -import rule74 from './network_rdp_remote_desktop_protocol_from_the_internet.json'; -import rule75 from './network_rdp_remote_desktop_protocol_to_the_internet.json'; -import rule76 from './network_rpc_remote_procedure_call_from_the_internet.json'; -import rule77 from './network_rpc_remote_procedure_call_to_the_internet.json'; -import rule78 from './network_smb_windows_file_sharing_activity_to_the_internet.json'; -import rule79 from './network_smtp_to_the_internet.json'; -import rule80 from './network_sql_server_port_activity_to_the_internet.json'; -import rule81 from './network_ssh_secure_shell_from_the_internet.json'; -import rule82 from './network_ssh_secure_shell_to_the_internet.json'; -import rule83 from './network_telnet_port_activity.json'; -import rule84 from './network_tor_activity_to_the_internet.json'; -import rule85 from './network_vnc_virtual_network_computing_from_the_internet.json'; -import rule86 from './network_vnc_virtual_network_computing_to_the_internet.json'; -import rule87 from './null_user_agent.json'; -import rule88 from './sqlmap_user_agent.json'; -import rule89 from './windows_background_intelligent_transfer_service_bits_connecting_to_the_internet.json'; -import rule90 from './windows_certutil_connecting_to_the_internet.json'; -import rule91 from './windows_command_prompt_connecting_to_the_internet.json'; -import rule92 from './windows_command_shell_started_by_internet_explorer.json'; -import rule93 from './windows_command_shell_started_by_powershell.json'; -import rule94 from './windows_command_shell_started_by_svchost.json'; -import rule95 from './windows_defense_evasion_via_filter_manager.json'; -import rule96 from './windows_execution_via_compiled_html_file.json'; -import rule97 from './windows_execution_via_connection_manager.json'; -import rule98 from './windows_execution_via_net_com_assemblies.json'; -import rule99 from './windows_execution_via_regsvr32.json'; -import rule100 from './windows_execution_via_trusted_developer_utilities.json'; -import rule101 from './windows_html_help_executable_program_connecting_to_the_internet.json'; -import rule102 from './windows_misc_lolbin_connecting_to_the_internet.json'; -import rule103 from './windows_net_command_activity_by_the_system_account.json'; -import rule104 from './windows_persistence_via_application_shimming.json'; -import rule105 from './windows_priv_escalation_via_accessibility_features.json'; -import rule106 from './windows_process_discovery_via_tasklist_command.json'; -import rule107 from './windows_process_execution_via_wmi.json'; -import rule108 from './windows_register_server_program_connecting_to_the_internet.json'; -import rule109 from './windows_signed_binary_proxy_execution.json'; -import rule110 from './windows_signed_binary_proxy_execution_download.json'; -import rule111 from './windows_suspicious_process_started_by_a_script.json'; -import rule112 from './windows_whoami_command_activity.json'; +import rule20 from './eql_clearing_windows_event_logs.json'; +import rule21 from './eql_delete_volume_usn_journal_with_fsutil.json'; +import rule22 from './eql_deleting_backup_catalogs_with_wbadmin.json'; +import rule23 from './eql_direct_outbound_smb_connection.json'; +import rule24 from './eql_disable_windows_firewall_rules_with_netsh.json'; +import rule25 from './eql_encoding_or_decoding_files_via_certutil.json'; +import rule26 from './eql_local_scheduled_task_commands.json'; +import rule27 from './eql_local_service_commands.json'; +import rule28 from './eql_msbuild_making_network_connections.json'; +import rule29 from './eql_mshta_making_network_connections.json'; +import rule30 from './eql_psexec_lateral_movement_command.json'; +import rule31 from './eql_suspicious_ms_office_child_process.json'; +import rule32 from './eql_suspicious_ms_outlook_child_process.json'; +import rule33 from './eql_system_shells_via_services.json'; +import rule34 from './eql_unusual_network_connection_via_rundll32.json'; +import rule35 from './eql_unusual_parentchild_relationship.json'; +import rule36 from './eql_unusual_process_network_connection.json'; +import rule37 from './eql_user_account_creation.json'; +import rule38 from './eql_volume_shadow_copy_deletion_via_vssadmin.json'; +import rule39 from './eql_volume_shadow_copy_deletion_via_wmic.json'; +import rule40 from './eql_windows_script_executing_powershell.json'; +import rule41 from './linux_hping_activity.json'; +import rule42 from './linux_iodine_activity.json'; +import rule43 from './linux_kernel_module_activity.json'; +import rule44 from './linux_mknod_activity.json'; +import rule45 from './linux_netcat_network_connection.json'; +import rule46 from './linux_nmap_activity.json'; +import rule47 from './linux_nping_activity.json'; +import rule48 from './linux_process_started_in_temp_directory.json'; +import rule49 from './linux_shell_activity_by_web_server.json'; +import rule50 from './linux_socat_activity.json'; +import rule51 from './linux_strace_activity.json'; +import rule52 from './linux_tcpdump_activity.json'; +import rule53 from './linux_whoami_commmand.json'; +import rule54 from './network_dns_directly_to_the_internet.json'; +import rule55 from './network_ftp_file_transfer_protocol_activity_to_the_internet.json'; +import rule56 from './network_irc_internet_relay_chat_protocol_activity_to_the_internet.json'; +import rule57 from './network_nat_traversal_port_activity.json'; +import rule58 from './network_port_26_activity.json'; +import rule59 from './network_port_8000_activity_to_the_internet.json'; +import rule60 from './network_pptp_point_to_point_tunneling_protocol_activity.json'; +import rule61 from './network_proxy_port_activity_to_the_internet.json'; +import rule62 from './network_rdp_remote_desktop_protocol_from_the_internet.json'; +import rule63 from './network_rdp_remote_desktop_protocol_to_the_internet.json'; +import rule64 from './network_rpc_remote_procedure_call_from_the_internet.json'; +import rule65 from './network_rpc_remote_procedure_call_to_the_internet.json'; +import rule66 from './network_smb_windows_file_sharing_activity_to_the_internet.json'; +import rule67 from './network_smtp_to_the_internet.json'; +import rule68 from './network_sql_server_port_activity_to_the_internet.json'; +import rule69 from './network_ssh_secure_shell_from_the_internet.json'; +import rule70 from './network_ssh_secure_shell_to_the_internet.json'; +import rule71 from './network_telnet_port_activity.json'; +import rule72 from './network_tor_activity_to_the_internet.json'; +import rule73 from './network_vnc_virtual_network_computing_from_the_internet.json'; +import rule74 from './network_vnc_virtual_network_computing_to_the_internet.json'; +import rule75 from './null_user_agent.json'; +import rule76 from './sqlmap_user_agent.json'; +import rule77 from './windows_command_prompt_connecting_to_the_internet.json'; +import rule78 from './windows_command_shell_started_by_powershell.json'; +import rule79 from './windows_command_shell_started_by_svchost.json'; +import rule80 from './windows_defense_evasion_via_filter_manager.json'; +import rule81 from './windows_execution_via_compiled_html_file.json'; +import rule82 from './windows_execution_via_regsvr32.json'; +import rule83 from './windows_execution_via_trusted_developer_utilities.json'; +import rule84 from './windows_html_help_executable_program_connecting_to_the_internet.json'; +import rule85 from './windows_misc_lolbin_connecting_to_the_internet.json'; +import rule86 from './windows_persistence_via_application_shimming.json'; +import rule87 from './windows_priv_escalation_via_accessibility_features.json'; +import rule88 from './windows_process_discovery_via_tasklist_command.json'; +import rule89 from './windows_register_server_program_connecting_to_the_internet.json'; +import rule90 from './windows_signed_binary_proxy_execution.json'; +import rule91 from './windows_suspicious_process_started_by_a_script.json'; +import rule92 from './windows_whoami_command_activity.json'; export const rawRules = [ rule1, rule2, @@ -212,24 +192,4 @@ export const rawRules = [ rule90, rule91, rule92, - rule93, - rule94, - rule95, - rule96, - rule97, - rule98, - rule99, - rule100, - rule101, - rule102, - rule103, - rule104, - rule105, - rule106, - rule107, - rule108, - rule109, - rule110, - rule111, - rule112, ]; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_hping_activity.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_hping_activity.json index 517e16fb3d284b..c4b14389c0f759 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_hping_activity.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_hping_activity.json @@ -1,5 +1,5 @@ { - "description": "Hping ran on a Linux host. Hping is FOSS command-line packet analyzer and has the ability to construct network packets for a wide variety of network security testing applications including scanning and firewall auditing.", + "description": "Hping ran on a Linux host. Hping is a FOSS command-line packet analyzer and has the ability to construct network packets for a wide variety of network security testing applications, including scanning and firewall auditing.", "false_positives": [ "Normal use of hping is uncommon apart from security testing and research. Use by non-security engineers is very uncommon." ], @@ -7,9 +7,9 @@ "auditbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Hping Process Activity", - "query": "process.name: hping and event.action:executed", + "query": "process.name: (hping3 or hping2 or hping) and event.action:executed", "references": [ "https://en.wikipedia.org/wiki/Hping" ], diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_iodine_activity.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_iodine_activity.json index 49f18ef9871a17..b8455a4d2b21d4 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_iodine_activity.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_iodine_activity.json @@ -1,5 +1,5 @@ { - "description": "Iodine is a tool for tunneling Internet protocol version 4 (IPV4) traffic over the DNS protocol in order to circumvent firewalls, network security groups or network access lists while evading detection.", + "description": "Iodine is a tool for tunneling Internet protocol version 4 (IPV4) traffic over the DNS protocol to circumvent firewalls, network security groups, and network access lists while evading detection.", "false_positives": [ "Normal use of Iodine is uncommon apart from security testing and research. Use by non-security engineers is very uncommon." ], @@ -7,7 +7,7 @@ "auditbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Potential DNS Tunneling via Iodine", "query": "process.name: (iodine or iodined) and event.action:executed", "references": [ diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_kernel_module_activity.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_kernel_module_activity.json index 8c94694ca4d040..f1d12de674488e 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_kernel_module_activity.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_kernel_module_activity.json @@ -1,5 +1,5 @@ { - "description": "Identifies loadable kernel module errors, often indicative of potential persistence attempts.", + "description": "Identifies loadable kernel module errors, which are often indicative of potential persistence attempts.", "false_positives": [ "Security tools and device drivers may run these programs in order to load legitimate kernel modules. Use of these programs by ordinary users is uncommon." ], @@ -7,7 +7,7 @@ "auditbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Persistence via Kernel Module Modification", "query": "process.name: (insmod or kmod or modprobe or rmod) and event.action:executed", "references": [ diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_ldso_process_activity.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_ldso_process_activity.json deleted file mode 100644 index 82a2a16080160f..00000000000000 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_ldso_process_activity.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "description": "The dynamic linker, ld.so, runs in a privileged context and can be used to escape restrictive environments by spawning a shell in order to elevate privileges or move laterally.", - "false_positives": [ - "ld.so is a dual-use tool that can be used for benign or malicious activity. Some normal use of this command may originate from developers or administrators. Use of ld.so by non-engineers or ordinary users is uncommon." - ], - "index": [ - "auditbeat-*" - ], - "language": "kuery", - "max_signals": 33, - "name": "Ld.so Process Activity", - "query": "process.name:ld.so and event.action:executed", - "risk_score": 21, - "rule_id": "3f31a31c-f7cf-4268-a0df-ec1a98099e7f", - "severity": "low", - "tags": [ - "Elastic", - "Linux" - ], - "type": "query", - "version": 1 -} diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_mknod_activity.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_mknod_activity.json index 8f4e1f40fad122..b0d4c29dc00d30 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_mknod_activity.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_mknod_activity.json @@ -1,13 +1,13 @@ { - "description": "The Linux mknod program is sometimes used in the command payload of remote command injection (RCI) and other exploits to export a command shell when the traditional version of netcat is not available to the payload.", + "description": "The Linux mknod program is sometimes used in the command payload of a remote command injection (RCI) and other exploits. It is used to export a command shell when the traditional version of netcat is not available to the payload.", "false_positives": [ - "Mknod is a Linux system program. Some normal use of this program, at varying levels of frequency, may originate from scripts, automation tools and frameworks. Usage by web servers is more likely to be suspicious." + "Mknod is a Linux system program. Some normal use of this program, at varying levels of frequency, may originate from scripts, automation tools, and frameworks. Usage by web servers is more likely to be suspicious." ], "index": [ "auditbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Mknod Process Activity", "query": "process.name: mknod and event.action:executed", "references": [ diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_netcat_network_connection.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_netcat_network_connection.json index b06a342d249774..6ab1c1285c0d77 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_netcat_network_connection.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_netcat_network_connection.json @@ -1,13 +1,13 @@ { - "description": "A netcat process is engaging in network activity on a Linux host. Netcat is often used as a persistence mechanism by exporting a reverse shell or by serving a shell on a listening port. Netcat is also sometimes used for data exfiltration. ", + "description": "A netcat process is engaging in network activity on a Linux host. Netcat is often used as a persistence mechanism by exporting a reverse shell or by serving a shell on a listening port. Netcat is also sometimes used for data exfiltration.", "false_positives": [ - "Netcat is a dual-use tool that can be used for benign or malicious activity. Netcat is included in some Linux distributions so its presence is not necessarily suspicious. Some normal use of this program, while uncommon, may originate from scripts, automation tools and frameworks." + "Netcat is a dual-use tool that can be used for benign or malicious activity. Netcat is included in some Linux distributions so its presence is not necessarily suspicious. Some normal use of this program, while uncommon, may originate from scripts, automation tools, and frameworks." ], "index": [ "auditbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Netcat Network Activity", "query": "process.name: (nc or ncat or netcat or netcat.openbsd or netcat.traditional) and event.action: (connected-to or bound-socket or socket_opened)", "references": [ diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_nmap_activity.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_nmap_activity.json index 406cd8e026e7a2..5d7169219a6f1b 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_nmap_activity.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_nmap_activity.json @@ -1,13 +1,13 @@ { - "description": "Nmap was executed on a Linux host. Nmap is a FOSS tool for network scanning and security testing. It can map and discover networks, identify listening services and operating systems. It is sometimes used to gather information in support of exploitation, execution or lateral movement.", + "description": "Nmap was executed on a Linux host. Nmap is a FOSS tool for network scanning and security testing. It can map and discover networks, and identify listening services and operating systems. It is sometimes used to gather information in support of exploitation, execution or lateral movement.", "false_positives": [ - "Security testing tools and frameworks may run nmap in the course of security auditing. Some normal use of this command may originate from security engineers and network or server administrators. Use of nmap by ordinary users is uncommon." + "Security testing tools and frameworks may run `Nmap` in the course of security auditing. Some normal use of this command may originate from security engineers and network or server administrators. Use of nmap by ordinary users is uncommon." ], "index": [ "auditbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Nmap Process Activity", "query": "process.name: nmap", "references": [ diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_nping_activity.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_nping_activity.json index de53e05e70fa39..6a713d22e3219c 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_nping_activity.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_nping_activity.json @@ -1,13 +1,13 @@ { - "description": "Nping ran on a Linux host. Nping is part of the Nmap tool suite and has the ability to construct raw packets for a wide variety of security testing applications including denial of service testing.", + "description": "Nping ran on a Linux host. Nping is part of the Nmap tool suite and has the ability to construct raw packets for a wide variety of security testing applications, including denial of service testing.", "false_positives": [ - "Some normal use of this command may originate from security engineers and network or server administrators but this is usually not routine or unannounced. Use of nping by non-engineers or ordinary users is uncommon." + "Some normal use of this command may originate from security engineers and network or server administrators, but this is usually not routine or unannounced. Use of `Nping` by non-engineers or ordinary users is uncommon." ], "index": [ "auditbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Nping Process Activity", "query": "process.name: nping and event.action:executed", "references": [ diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_process_started_in_temp_directory.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_process_started_in_temp_directory.json index 4ed021a4c864df..c80bb4eb416151 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_process_started_in_temp_directory.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_process_started_in_temp_directory.json @@ -1,13 +1,13 @@ { "description": "Identifies processes running in a temporary folder. This is sometimes done by adversaries to hide malware.", "false_positives": [ - "Build systems like Jenkins may start processes in the /tmp directory. These can be exempted by name or by username." + "Build systems, like Jenkins, may start processes in the `/tmp` directory. These can be exempted by name or by username." ], "index": [ "auditbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Unusual Process Execution - Temp", "query": "process.working_directory: /tmp and event.action:executed", "risk_score": 47, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_shell_activity_by_web_server.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_shell_activity_by_web_server.json index ac817762fdb713..eff3dd0ab14006 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_shell_activity_by_web_server.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_shell_activity_by_web_server.json @@ -7,9 +7,9 @@ "auditbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Potential Shell via Web Server", - "query": "process.name: bash and (user.name: apache or www) and event.action:executed", + "query": "process.name: bash and user.name: (apache or www or \"wwww-data\") and event.action:executed", "references": [ "https://pentestlab.blog/tag/web-shell/" ], diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_socat_activity.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_socat_activity.json index 481a99518d4ed3..56fb41dc5f78f5 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_socat_activity.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_socat_activity.json @@ -1,13 +1,13 @@ { - "description": "A Socat process is running on a Linux host. Socat is often used as a persistence mechanism by exporting a reverse shell or by serving a shell on a listening port. Socat is also sometimes used for lateral movement. ", + "description": "A Socat process is running on a Linux host. Socat is often used as a persistence mechanism by exporting a reverse shell, or by serving a shell on a listening port. Socat is also sometimes used for lateral movement.", "false_positives": [ - "Socat is a dual-use tool that can be used for benign or malicious activity. Some normal use of this program, at varying levels of frequency, may originate from scripts, automation tools and frameworks. Usage by web servers is more likely to be suspicious." + "Socat is a dual-use tool that can be used for benign or malicious activity. Some normal use of this program, at varying levels of frequency, may originate from scripts, automation tools, and frameworks. Usage by web servers is more likely to be suspicious." ], "index": [ "auditbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Socat Process Activity", "query": "process.name:socat and not process.args:\"-V\" and event.action:executed", "references": [ diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_strace_activity.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_strace_activity.json index f5488ae49d0fb5..fdf52e7c728c6b 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_strace_activity.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_strace_activity.json @@ -7,7 +7,7 @@ "auditbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Strace Process Activity", "query": "process.name: strace and event.action:executed", "references": [ diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_tcpdump_activity.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_tcpdump_activity.json index b6dc7f1689770c..908e892026ee32 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_tcpdump_activity.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_tcpdump_activity.json @@ -1,5 +1,5 @@ { - "description": "The Tcpdump program ran on a Linux host. Tcpdump is a network monitoring or packet 'sniffing' tool that can be used to capture insecure credentials or data in motion. Sniffing can also be used to discover details of network services as a prelude to lateral movement or defense evasion.", + "description": "The Tcpdump program ran on a Linux host. Tcpdump is a network monitoring or packet sniffing tool that can be used to capture insecure credentials or data in motion. Sniffing can also be used to discover details of network services as a prelude to lateral movement or defense evasion.", "false_positives": [ "Some normal use of this command may originate from server or network administrators engaged in network troubleshooting." ], @@ -7,7 +7,7 @@ "auditbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Network Sniffing via Tcpdump", "query": "process.name: tcpdump and event.action:executed", "risk_score": 21, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_whoami_commmand.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_whoami_commmand.json index 91c6d2bcc9f954..052ff34d15dcdb 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_whoami_commmand.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_whoami_commmand.json @@ -1,5 +1,5 @@ { - "description": "The whoami application was executed on a Linux host. This is often used by tools and persistence mechanisms to test for privileged access.", + "description": "The whoami application was executed on a Linux host. This is often used by tools and persistence mechanisms to test for privileged access.", "false_positives": [ "Security testing tools and frameworks may run this command. Some normal use of this command may originate from automation tools and frameworks." ], @@ -7,7 +7,7 @@ "auditbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "User Discovery via Whoami", "query": "process.name: whoami and event.action:executed", "risk_score": 21, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_dns_directly_to_the_internet.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_dns_directly_to_the_internet.json index 3d1b07a267eca1..72e2ca14904173 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_dns_directly_to_the_internet.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_dns_directly_to_the_internet.json @@ -1,16 +1,16 @@ { - "description": "This signal detects internal network client sending DNS traffic directly to the Internet.\nThis is atypical behavior for a managed network and can be indicative of malware,\nexfiltration, command and control or simply misconfiguration. This also impacts your\norganization's ability to provide enterprise monitoring and logging of DNS and opens\nyour network to a variety of abuses or malicious communications.\n", + "description": "This rule detects when an internal network client sends DNS traffic directly to the Internet.\nThis is atypical behavior for a managed network, and can be indicative of malware,\nexfiltration, command and control, or, simply, misconfiguration. This DNS activity also impacts your\norganization's ability to provide enterprise monitoring and logging of DNS, and opens\nyour network to a variety of abuses and malicious communications.\n", "false_positives": [ - "DNS servers should be excluded from this rule as this is expected behavior for them. Endpoints usually query local DNS servers defined in their DHCP scopes but this may be overridden if a user configures their endpoint to use a remote DNS server. This is uncommon in managed enterprise networks because it would tend to break intra-net name resolution when split horizon DNS is utilized. Some consumer VPN services and browser plug-ins may send DNS traffic to remote Internet destinations; in that case, such devices or networks can be excluded from this rule if this is expected behavior." + "Exclude DNS servers from this rule as this is expected behavior. Endpoints usually query local DNS servers defined in their DHCP scopes, but this may be overridden if a user configures their endpoint to use a remote DNS server. This is uncommon in managed enterprise networks because it could break intranet name resolution when split horizon DNS is utilized. Some consumer VPN services and browser plug-ins may send DNS traffic to remote Internet destinations. In that case, such devices or networks can be excluded from this rule when this is expected behavior." ], "index": [ "auditbeat-*", - "endgame-*", "filebeat-*", "packetbeat-*", "winlogbeat-*" ], "language": "kuery", + "max_signals": 100, "name": "DNS Activity to the Internet", "query": "destination.port:53 and (\n network.direction: outbound or (\n source.ip:(10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16) and\n not destination.ip:( 169.254.169.254/32 or 127.0.0.53/32 or 10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16 or 224.0.0.251 or ff02\\:\\:fb or 255.255.255.255 )\n )\n)\n", "references": [ @@ -22,7 +22,7 @@ "severity": "medium", "tags": [ "Elastic", - "network" + "Network" ], "threat": [ { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_ftp_file_transfer_protocol_activity_to_the_internet.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_ftp_file_transfer_protocol_activity_to_the_internet.json index ef7b39412c808c..54daf8a2091a75 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_ftp_file_transfer_protocol_activity_to_the_internet.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_ftp_file_transfer_protocol_activity_to_the_internet.json @@ -1,16 +1,16 @@ { - "description": "This signal detects events that may indicate the use of FTP network connections to the Internet.\nThe File Transfer Protocol (FTP) has been around in its current form since the\n1980's. It can be an efficient and normal procedure on your network to send and\nreceive files. Because it is common and efficient, adversaries will also often\nuse this protocol to ex-filtrate data from your network or download new tools.\nAdditionally, FTP is a plain-text protocol which may expose your user name and\npassword, if intercepted. FTP activity involving servers subject to regulations or compliance standards may be unauthorized.\n", + "description": "This rule detects events that may indicate the use of FTP network connections to the Internet.\nThe File Transfer Protocol (FTP) has been around in its current form since the\n1980s. It can be a common and efficient procedure on your network to send and\nreceive files. Because of this, adversaries will also often use this protocol\nto exfiltrate data from your network or download new tools. Additionally, FTP\nis a plain-text protocol which, if intercepted, may expose usernames and\npasswords. FTP activity involving servers subject to regulations or compliance\nstandards may be unauthorized.\n", "false_positives": [ - "FTP servers should be excluded from this rule as this is expected behavior for them. Some business work-flows may use FTP for data exchange. These work-flows often have expected characteristics such as users, sources and destinations. FTP activity involving an unusual source or destination may be more suspicious. FTP activity involving a production server that has no known associated FTP work-flow or business requirement is often suspicious. NEW NEW" + "FTP servers should be excluded from this rule as this is expected behavior. Some business workflows may use FTP for data exchange. These workflows often have expected characteristics such as users, sources, and destinations. FTP activity involving an unusual source or destination may be more suspicious. FTP activity involving a production server that has no known associated FTP workflow or business requirement is often suspicious." ], "index": [ "auditbeat-*", - "endgame-*", "filebeat-*", "packetbeat-*", "winlogbeat-*" ], "language": "kuery", + "max_signals": 100, "name": "FTP (File Transfer Protocol) Activity to the Internet", "query": "network.transport: tcp and destination.port: (20 or 21) and (\n network.direction: outbound or (\n source.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16) and\n not destination.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16)\n )\n)\n", "risk_score": 21, @@ -18,7 +18,7 @@ "severity": "low", "tags": [ "Elastic", - "network" + "Network" ], "threat": [ { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_irc_internet_relay_chat_protocol_activity_to_the_internet.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_irc_internet_relay_chat_protocol_activity_to_the_internet.json index 2700eae9774820..d01006a225886c 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_irc_internet_relay_chat_protocol_activity_to_the_internet.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_irc_internet_relay_chat_protocol_activity_to_the_internet.json @@ -1,16 +1,16 @@ { - "description": "This signal detects events that use common ports for IRC to the Internet. IRC (Internet Relay Chat)\nis a common protocol that can be used chat and file transfer. This protocol\nalso makes a good candidate for remote control of malware and data transfer in\nand out of a network.\n", + "description": "This rule detects events that use common ports for Internet Relay Chat (IRC) to the Internet.\nIRC is a common protocol that can be used for chat and file transfers. This\nprotocol is also a good candidate for remote control of malware and data\ntransfers to and from a network.\n", "false_positives": [ - "IRC activity may be normal behavior for developers and engineers but is unusual for non-engineering end users. IRC activity involving an unusual source or destination may be more suspicious. IRC activity involving a production server is often suspicious. Because these ports are in the ephemeral range, this rule may false under certain conditions such as when a NATted web server replies to a client which has used a port in the range by coincidence. In this case, such servers can be excluded if desired. Some legacy applications may use these ports but this is very uncommon and usually appears only in local traffic using private IPs which this rule does not match." + "IRC activity may be normal behavior for developers and engineers but is unusual for non-engineering end users. IRC activity involving an unusual source or destination may be more suspicious. IRC activity involving a production server is often suspicious. Because these ports are in the ephemeral range, this rule may false under certain conditions, such as when a NAT-ed web server replies to a client which has used a port in the range by coincidence. In this case, these servers can be excluded. Some legacy applications may use these ports, but this is very uncommon and usually only appears in local traffic using private IPs, which does not match this rule's conditions." ], "index": [ "auditbeat-*", - "endgame-*", "filebeat-*", "packetbeat-*", "winlogbeat-*" ], "language": "kuery", + "max_signals": 100, "name": "IRC (Internet Relay Chat) Protocol Activity to the Internet", "query": "network.transport: tcp and destination.port:(6667 or 6697) and (\n network.direction: outbound or (\n source.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16) and\n not destination.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16)\n )\n)\n", "risk_score": 47, @@ -18,7 +18,7 @@ "severity": "medium", "tags": [ "Elastic", - "network" + "Network" ], "threat": [ { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_nat_traversal_port_activity.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_nat_traversal_port_activity.json index e87e296017a36e..c66a9e9d77fe4b 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_nat_traversal_port_activity.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_nat_traversal_port_activity.json @@ -1,16 +1,16 @@ { - "description": "This signal detects events that could be describing IPSEC NAT Traversal traffic.\nIPSEC is a VPN technology that allows one system to talk to another using\nencrypted tunnels. NAT Traversal enables these tunnels to communicate over\nthe Internet where one of the sides is behind a NAT router gateway. This may\nbe common on your network, but this technique is also used by threat actors\nto avoid detection.\n", + "description": "This rule detects events that could be describing IPSEC NAT Traversal traffic.\nIPSEC is a VPN technology that allows one system to talk to another using\nencrypted tunnels. NAT Traversal enables these tunnels to communicate over the\nInternet where one of the sides is behind a NAT router gateway. This may be\ncommon on your network, but this technique is also used by threat actors to\navoid detection.\n", "false_positives": [ - "Some networks may utilize these protocols but usage that is unfamiliar to local network administrators can be unexpected and suspicious. Because this port is in the ephemeral range, this rule may false under certain conditions such as when a application server with a public IP address replies to a client which has used a UDP port in the range by coincidence. This is uncommon but such servers can be excluded if desired." + "Some networks may utilize these protocols but usage that is unfamiliar to local network administrators can be unexpected and suspicious. Because this port is in the ephemeral range, this rule may false under certain conditions, such as when an application server with a public IP address replies to a client which has used a UDP port in the range by coincidence. This is uncommon but such servers can be excluded." ], "index": [ "auditbeat-*", - "endgame-*", "filebeat-*", "packetbeat-*", "winlogbeat-*" ], "language": "kuery", + "max_signals": 100, "name": "IPSEC NAT Traversal Port Activity", "query": "network.transport: udp and destination.port: 4500", "risk_score": 21, @@ -18,7 +18,7 @@ "severity": "low", "tags": [ "Elastic", - "network" + "Network" ], "threat": [ { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_port_26_activity.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_port_26_activity.json index 352fc5e44dc806..7b261418985329 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_port_26_activity.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_port_26_activity.json @@ -1,18 +1,18 @@ { - "description": "This signal detects events that may indicate use of SMTP on TCP port 26. This\nport is commonly used by several popular mail transfer agents to deconflict\nwith the default SMTP port 25. This port has also been used by a malware family\ncalled BadPatch for command and control of Windows systems.\n", + "description": "This rule detects events that may indicate use of SMTP on TCP port 26. This\nport is commonly used by several popular mail transfer agents to deconflict\nwith the default SMTP port 25. This port has also been used by a malware family\ncalled BadPatch for command and control of Windows systems.\n", "false_positives": [ - "Servers that process email traffic may cause false positives and should be excluded from this rule as this is expected behavior for them." + "Servers that process email traffic may cause false positives and should be excluded from this rule as this is expected behavior." ], "index": [ "auditbeat-*", - "endgame-*", "filebeat-*", "packetbeat-*", "winlogbeat-*" ], "language": "kuery", + "max_signals": 100, "name": "SMTP on Port 26/TCP", - "query": "network.transport: tcp and destination.port: 26", + "query": "network.transport: tcp and destination.port: 26\n", "references": [ "https://unit42.paloaltonetworks.com/unit42-badpatch/", "https://isc.sans.edu/forums/diary/Next+up+whats+up+with+TCP+port+26/25564/" @@ -22,7 +22,7 @@ "severity": "low", "tags": [ "Elastic", - "network" + "Network" ], "threat": [ { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_port_8000_activity_to_the_internet.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_port_8000_activity_to_the_internet.json index 2b3d08a7c80d98..7551119cd5a844 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_port_8000_activity_to_the_internet.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_port_8000_activity_to_the_internet.json @@ -1,16 +1,16 @@ { "description": "TCP Port 8000 is commonly used for development environments of web server\nsoftware. It generally should not be exposed directly to the Internet. If you are\nrunning software like this on the Internet, you should consider placing it behind\na reverse proxy.\n", "false_positives": [ - "Because this port is in the ephemeral range, this rule may false under certain conditions such as when a NATed web server replies to a client which has used a port in the range by coincidence. In this case, such servers can be excluded if desired. Some applications may use this port but this is very uncommon and usually appears in local traffic using private IPs which this rule does not match. Some cloud environments, particularly development environments, may use this port when VPNs or direct connects are not in use and cloud instances are accessed across the Internet." + "Because this port is in the ephemeral range, this rule may false under certain conditions, such as when a NATed web server replies to a client which has used a port in the range by coincidence. In this case, such servers can be excluded. Some applications may use this port but this is very uncommon and usually appears in local traffic using private IPs, which this rule does not match. Some cloud environments, particularly development environments, may use this port when VPNs or direct connects are not in use and cloud instances are accessed across the Internet." ], "index": [ "auditbeat-*", - "endgame-*", "filebeat-*", "packetbeat-*", "winlogbeat-*" ], "language": "kuery", + "max_signals": 100, "name": "TCP Port 8000 Activity to the Internet", "query": "network.transport: tcp and destination.port: 8000 and (\n network.direction: outbound or (\n source.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16) and\n not destination.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16)\n )\n)\n", "risk_score": 21, @@ -18,7 +18,7 @@ "severity": "low", "tags": [ "Elastic", - "network" + "Network" ], "threat": [ { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_pptp_point_to_point_tunneling_protocol_activity.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_pptp_point_to_point_tunneling_protocol_activity.json index b008ca2c2bee6c..eeb38f756c67a6 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_pptp_point_to_point_tunneling_protocol_activity.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_pptp_point_to_point_tunneling_protocol_activity.json @@ -1,24 +1,24 @@ { - "description": "This signal detects events that may indicate use of a PPTP VPN connection. Some threat actors use these types of connections to tunnel their traffic while avoiding detection.", + "description": "This rule detects events that may indicate use of a PPTP VPN connection. Some\nthreat actors use these types of connections to tunnel their traffic while\navoiding detection.\n", "false_positives": [ - "Some networks may utilize PPTP protocols but this is uncommon as more modern VPN technologies are available. Usage that is unfamiliar to local network administrators can be unexpected and suspicious. Torrenting applications may use this port. Because this port is in the ephemeral range, this rule may false under certain conditions such as when an application server with replies to a client which has used this port by coincidence. This is uncommon but such servers can be excluded if desired." + "Some networks may utilize PPTP protocols but this is uncommon as more modern VPN technologies are available. Usage that is unfamiliar to local network administrators can be unexpected and suspicious. Torrenting applications may use this port. Because this port is in the ephemeral range, this rule may false under certain conditions, such as when an application server replies to a client that used this port by coincidence. This is uncommon but such servers can be excluded." ], "index": [ "auditbeat-*", - "endgame-*", "filebeat-*", "packetbeat-*", "winlogbeat-*" ], "language": "kuery", + "max_signals": 100, "name": "PPTP (Point to Point Tunneling Protocol) Activity", - "query": "network.transport: tcp and destination.port: 1723", + "query": "network.transport: tcp and destination.port: 1723\n", "risk_score": 21, "rule_id": "d2053495-8fe7-4168-b3df-dad844046be3", "severity": "low", "tags": [ "Elastic", - "network" + "Network" ], "threat": [ { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_proxy_port_activity_to_the_internet.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_proxy_port_activity_to_the_internet.json index f7c6ffddcaf9ee..981a7bdffcfed0 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_proxy_port_activity_to_the_internet.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_proxy_port_activity_to_the_internet.json @@ -1,16 +1,16 @@ { - "description": "This signal detects events that may describe network events of proxy use to the\nInternet. It includes popular HTTP proxy ports and SOCKS proxy ports. Typically\nenvironments will use an internal IP address for a proxy server. It can also\nbe used to circumvent network controls and detection mechanisms.\n", + "description": "This rule detects events that may describe network events of proxy use to the\nInternet. It includes popular HTTP proxy ports and SOCKS proxy ports. Typically,\nenvironments will use an internal IP address for a proxy server. It can also\nbe used to circumvent network controls and detection mechanisms.\n", "false_positives": [ - "Some proxied applications may use these ports but this usually occurs in local traffic using private IPs which this rule does not match. Proxies are widely used as a security technology but in enterprise environments this is usually local traffic which this rule does not match. Internet proxy services using these ports can be white-listed if desired. Some screen recording applications may use these ports. Proxy port activity involving an unusual source or destination may be more suspicious. Some cloud environments may use this port when VPNs or direct connects are not in use and cloud instances are accessed across the Internet. Because these ports are in the ephemeral range, this rule may false under certain conditions such as when a NATed web server replies to a client which has used a port in the range by coincidence. In this case, such servers can be excluded if desired." + "Some proxied applications may use these ports but this usually occurs in local traffic using private IPs\n which this rule does not match. Proxies are widely used as a security technology but in enterprise environments\n this is usually local traffic which this rule does not match. Internet proxy services using these ports can be\n white-listed if desired. Some screen recording applications may use these ports. Proxy port activity involving\n an unusual source or destination may be more suspicious. Some cloud environments may use this port when VPNs or\n direct connects are not in use and cloud instances are accessed across the Internet. Because these ports are in\n the ephemeral range, this rule may false under certain conditions such as when a NATed web server replies to a\n client which has used a port in the range by coincidence. In this case, such servers can be excluded if desired." ], "index": [ "auditbeat-*", - "endgame-*", "filebeat-*", "packetbeat-*", "winlogbeat-*" ], "language": "kuery", + "max_signals": 100, "name": "Proxy Port Activity to the Internet", "query": "network.transport: tcp and destination.port: (3128 or 8080 or 1080) and (\n network.direction: outbound or (\n source.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16) and\n not destination.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16)\n )\n)\n", "risk_score": 47, @@ -18,7 +18,7 @@ "severity": "medium", "tags": [ "Elastic", - "network" + "Network" ], "threat": [ { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rdp_remote_desktop_protocol_from_the_internet.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rdp_remote_desktop_protocol_from_the_internet.json index e3853c30e6ad9c..504df93f2f8ed1 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rdp_remote_desktop_protocol_from_the_internet.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rdp_remote_desktop_protocol_from_the_internet.json @@ -1,16 +1,16 @@ { - "description": "This signal detects network events that may indicate the use of RDP traffic\nfrom the Internet. RDP is commonly used by system administrators to remotely\ncontrol a system for maintenance or to use shared resources. It should almost\nnever be directly exposed to the Internet, as it is frequently targeted and\nexploited by threat actors as an initial access or back-door vector.\n", + "description": "This rule detects network events that may indicate the use of RDP traffic\nfrom the Internet. RDP is commonly used by system administrators to remotely\ncontrol a system for maintenance or to use shared resources. It should almost\nnever be directly exposed to the Internet, as it is frequently targeted and\nexploited by threat actors as an initial access or back-door vector.\n", "false_positives": [ - "Some network security policies allow RDP directly from the Internet but usage that is unfamiliar to server or network owners can be unexpected and suspicious. RDP services may be exposed directly to the Internet in some networks such as cloud environments. In such cases, only RDP gateways, bastions or jump servers may be expected expose RDP directly to the Internet and can be exempted from this rule. RDP may be required by some work-flows such as remote access and support for specialized software products and servers. Such work-flows are usually known and not unexpected." + " Some network security policies allow RDP directly from the Internet but usage that is unfamiliar to\n server or network owners can be unexpected and suspicious. RDP services may be exposed directly to the\n Internet in some networks such as cloud environments. In such cases, only RDP gateways, bastions or jump\n servers may be expected expose RDP directly to the Internet and can be exempted from this rule. RDP may\n be required by some work-flows such as remote access and support for specialized software products and\n servers. Such work-flows are usually known and not unexpected." ], "index": [ "auditbeat-*", - "endgame-*", "filebeat-*", "packetbeat-*", "winlogbeat-*" ], "language": "kuery", + "max_signals": 100, "name": "RDP (Remote Desktop Protocol) from the Internet", "query": "network.transport: tcp and destination.port: 3389 and (\n network.direction: inbound or (\n not source.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16)\n and destination.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16)\n )\n)\n", "risk_score": 47, @@ -18,7 +18,7 @@ "severity": "medium", "tags": [ "Elastic", - "network" + "Network" ], "threat": [ { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rdp_remote_desktop_protocol_to_the_internet.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rdp_remote_desktop_protocol_to_the_internet.json index 55b9716af9346d..2d9fa6ba06dfdc 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rdp_remote_desktop_protocol_to_the_internet.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rdp_remote_desktop_protocol_to_the_internet.json @@ -1,16 +1,16 @@ { - "description": "This signal detects network events that may indicate the use of RDP traffic\nto the Internet. RDP is commonly used by system administrators to remotely\ncontrol a system for maintenance or to use shared resources. It should almost\nnever be directly exposed to the Internet, as it is frequently targeted and\nexploited by threat actors as an initial access or back-door vector.\n", + "description": "This rule detects network events that may indicate the use of RDP traffic\nto the Internet. RDP is commonly used by system administrators to remotely\ncontrol a system for maintenance or to use shared resources. It should almost\nnever be directly exposed to the Internet, as it is frequently targeted and\nexploited by threat actors as an initial access or back-door vector.\n", "false_positives": [ - "RDP connections may be made directly to Internet destinations in order to access Windows cloud server instances but such connections are usually made only by engineers. In such cases, only RDP gateways, bastions or jump servers may be expected Internet destinations and can be exempted from this rule. RDP may be required by some work-flows such as remote access and support for specialized software products and servers. Such work-flows are usually known and not unexpected. Usage that is unfamiliar to server or network owners can be unexpected and suspicious." + "RDP connections may be made directly to Internet destinations in order to access\n Windows cloud server instances but such connections are usually made only by engineers.\n In such cases, only RDP gateways, bastions or jump servers may be expected Internet\n destinations and can be exempted from this rule. RDP may be required by some work-flows\n such as remote access and support for specialized software products and servers. Such\n work-flows are usually known and not unexpected. Usage that is unfamiliar to server or\n network owners can be unexpected and suspicious." ], "index": [ "auditbeat-*", - "endgame-*", "filebeat-*", "packetbeat-*", "winlogbeat-*" ], "language": "kuery", + "max_signals": 100, "name": "RDP (Remote Desktop Protocol) to the Internet", "query": "network.transport: tcp and destination.port: 3389 and (\n network.direction: outbound or (\n source.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16) and\n not destination.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16)\n )\n)\n", "risk_score": 21, @@ -18,7 +18,7 @@ "severity": "low", "tags": [ "Elastic", - "network" + "Network" ], "threat": [ { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rpc_remote_procedure_call_from_the_internet.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rpc_remote_procedure_call_from_the_internet.json index 1570d3d155feaf..d50c79db81ba5c 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rpc_remote_procedure_call_from_the_internet.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rpc_remote_procedure_call_from_the_internet.json @@ -1,13 +1,13 @@ { - "description": "This signal detects network events that may indicate the use of RPC traffic\nfrom the Internet. RPC is commonly used by system administrators to remotely\ncontrol a system for maintenance or to use shared resources. It should almost\nnever be directly exposed to the Internet, as it is frequently targeted and\nexploited by threat actors as an initial access or back-door vector.\n", + "description": "This rule detects network events that may indicate the use of RPC traffic\nfrom the Internet. RPC is commonly used by system administrators to remotely\ncontrol a system for maintenance or to use shared resources. It should almost\nnever be directly exposed to the Internet, as it is frequently targeted and\nexploited by threat actors as an initial access or back-door vector.\n", "index": [ "auditbeat-*", - "endgame-*", "filebeat-*", "packetbeat-*", "winlogbeat-*" ], "language": "kuery", + "max_signals": 100, "name": "RPC (Remote Procedure Call) from the Internet", "query": "network.transport: tcp and destination.port: 135 and (\n network.direction: inbound or (\n not source.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16) and\n destination.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16)\n )\n)\n", "risk_score": 73, @@ -15,7 +15,7 @@ "severity": "high", "tags": [ "Elastic", - "network" + "Network" ], "threat": [ { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rpc_remote_procedure_call_to_the_internet.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rpc_remote_procedure_call_to_the_internet.json index 91db97dabdd46f..ade7b661a79091 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rpc_remote_procedure_call_to_the_internet.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rpc_remote_procedure_call_to_the_internet.json @@ -1,13 +1,13 @@ { - "description": "This signal detects network events that may indicate the use of RPC traffic\nto the Internet. RPC is commonly used by system administrators to remotely\ncontrol a system for maintenance or to use shared resources. It should almost\nnever be directly exposed to the Internet, as it is frequently targeted and\nexploited by threat actors as an initial access or back-door vector.\n", + "description": "This rule detects network events that may indicate the use of RPC traffic\nto the Internet. RPC is commonly used by system administrators to remotely\ncontrol a system for maintenance or to use shared resources. It should almost\nnever be directly exposed to the Internet, as it is frequently targeted and\nexploited by threat actors as an initial access or back-door vector.\n", "index": [ "auditbeat-*", - "endgame-*", "filebeat-*", "packetbeat-*", "winlogbeat-*" ], "language": "kuery", + "max_signals": 100, "name": "RPC (Remote Procedure Call) to the Internet", "query": "network.transport: tcp and destination.port: 135 and (\n network.direction: outbound or (\n source.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16) and\n not destination.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16)\n )\n)\n", "risk_score": 73, @@ -15,7 +15,7 @@ "severity": "high", "tags": [ "Elastic", - "network" + "Network" ], "threat": [ { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_smb_windows_file_sharing_activity_to_the_internet.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_smb_windows_file_sharing_activity_to_the_internet.json index 991c626c11d33a..62c2fafb7404ff 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_smb_windows_file_sharing_activity_to_the_internet.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_smb_windows_file_sharing_activity_to_the_internet.json @@ -1,13 +1,13 @@ { - "description": "This signal detects network events that may indicate the use of Windows\nfile sharing (also called SMB or CIFS) traffic to the Internet. SMB is commonly\nused within networks to share files, printers, and other system resources amongst\ntrusted systems. It should almost never be directly exposed to the Internet, as\nit is frequently targeted and exploited by threat actors as an initial access\nor back-door vector or for data exfiltration.\n", + "description": "This rule detects network events that may indicate the use of Windows\nfile sharing (also called SMB or CIFS) traffic to the Internet. SMB is commonly\nused within networks to share files, printers, and other system resources amongst\ntrusted systems. It should almost never be directly exposed to the Internet, as\nit is frequently targeted and exploited by threat actors as an initial access\nor back-door vector or for data exfiltration.\n", "index": [ "auditbeat-*", - "endgame-*", "filebeat-*", "packetbeat-*", "winlogbeat-*" ], "language": "kuery", + "max_signals": 100, "name": "SMB (Windows File Sharing) Activity to the Internet", "query": "network.transport: tcp and destination.port: (139 or 445) and (\n network.direction: outbound or (\n source.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16) and\n not destination.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16)\n )\n)\n", "risk_score": 73, @@ -15,7 +15,7 @@ "severity": "high", "tags": [ "Elastic", - "network" + "Network" ], "threat": [ { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_smtp_to_the_internet.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_smtp_to_the_internet.json index 68daf71d9992a4..02fca5603910e9 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_smtp_to_the_internet.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_smtp_to_the_internet.json @@ -1,16 +1,16 @@ { - "description": "This signal detects events that may describe SMTP traffic from internal\nhosts to a host across the Internet. In an enterprise network, there is typically\na dedicate host that is internal that could perform this function. It is also\nfrequently abused by threat actors for command and control or data exfiltration.\n", + "description": "This rule detects events that may describe SMTP traffic from internal\nhosts to a host across the Internet. In an enterprise network, there is typically\na dedicated internal host that performs this function. It is also\nfrequently abused by threat actors for command and control, or data exfiltration.\n", "false_positives": [ - "NATed servers that process email traffic may false and should be excluded from this rule as this is expected behavior for them. Consumer and / or personal devices may send email traffic to remote Internet destinations; in that case, such devices or networks can be excluded from this rule if this is expected behavior." + "NATed servers that process email traffic may false and should be excluded from this rule as this is expected behavior for them. Consumer and personal devices may send email traffic to remote Internet destinations. In this case, such devices or networks can be excluded from this rule if this is expected behavior." ], "index": [ "auditbeat-*", - "endgame-*", "filebeat-*", "packetbeat-*", "winlogbeat-*" ], "language": "kuery", + "max_signals": 100, "name": "SMTP to the Internet", "query": "network.transport: tcp and destination.port: (25 or 465 or 587) and (\n network.direction: outbound or (\n source.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16) and\n not destination.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16)\n )\n)\n", "risk_score": 21, @@ -18,7 +18,7 @@ "severity": "low", "tags": [ "Elastic", - "network" + "Network" ], "threat": [ { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_sql_server_port_activity_to_the_internet.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_sql_server_port_activity_to_the_internet.json index df779d47246a5d..67e6a08ddf7918 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_sql_server_port_activity_to_the_internet.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_sql_server_port_activity_to_the_internet.json @@ -1,16 +1,16 @@ { - "description": "This signal detects events that may describe database traffic\n(MS SQL, Oracle, MySQL, and Postgresql) across the Internet. Databases\nshould almost never be directly exposed to the Internet, as they are\nfrequently targeted by threat actors to gain initial access to network resources.\n", + "description": "This rule detects events that may describe database traffic\n(MS SQL, Oracle, MySQL, and Postgresql) across the Internet. Databases\nshould almost never be directly exposed to the Internet, as they are\nfrequently targeted by threat actors to gain initial access to network resources.\n", "false_positives": [ - "Because these ports are in the ephemeral range, this rule may false under certain conditions such as when a NATed web server replies to a client which has used a port in the range by coincidence. In this case, such servers can be excluded if desired. Some cloud environments may use this port when VPNs or direct connects are not in use and database instances are accessed directly across the Internet." + "Because these ports are in the ephemeral range, this rule may false under certain conditions\n such as when a NATed web server replies to a client which has used a port in the range by\n coincidence. In this case, such servers can be excluded if desired. Some cloud environments may\n use this port when VPNs or direct connects are not in use and database instances are accessed\n directly across the Internet." ], "index": [ "auditbeat-*", - "endgame-*", "filebeat-*", "packetbeat-*", "winlogbeat-*" ], "language": "kuery", + "max_signals": 100, "name": "SQL Traffic to the Internet", "query": "network.transport: tcp and destination.port: (1433 or 1521 or 3336 or 5432) and (\n network.direction: outbound or (\n source.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16) and\n not destination.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16)\n )\n)\n", "risk_score": 47, @@ -18,7 +18,7 @@ "severity": "medium", "tags": [ "Elastic", - "network" + "Network" ], "threat": [ { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_ssh_secure_shell_from_the_internet.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_ssh_secure_shell_from_the_internet.json index 6c278700450b19..052600a0db68a1 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_ssh_secure_shell_from_the_internet.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_ssh_secure_shell_from_the_internet.json @@ -1,16 +1,16 @@ { - "description": "This signal detects network events that may indicate the use of SSH traffic\nfrom the Internet. SSH is commonly used by system administrators to remotely\ncontrol a system using the command line shell. If it is exposed to the Internet,\nit should be done with strong security controls as it is frequently targeted and\nexploited by threat actors as an initial access or back-door vector.\n", + "description": "This rule detects network events that may indicate the use of SSH traffic\nfrom the Internet. SSH is commonly used by system administrators to remotely\ncontrol a system using the command line shell. If it is exposed to the Internet,\nit should be done with strong security controls as it is frequently targeted and\nexploited by threat actors as an initial access or back-door vector.\n", "false_positives": [ - "Some network security policies allow SSH directly from the Internet but usage that is unfamiliar to server or network owners can be unexpected and suspicious. SSH services may be exposed directly to the Internet in some networks such as cloud environments. In such cases, only SSH gateways, bastions or jump servers may be expected expose SSH directly to the Internet and can be exempted from this rule. SSH may be required by some work-flows such as remote access and support for specialized software products and servers. Such work-flows are usually known and not unexpected." + "Some network security policies allow SSH directly from the Internet but usage that is\n unfamiliar to server or network owners can be unexpected and suspicious. SSH services may\n be exposed directly to the Internet in some networks such as cloud environments. In such\n cases, only SSH gateways, bastions or jump servers may be expected expose SSH directly to\n the Internet and can be exempted from this rule. SSH may be required by some work-flows\n such as remote access and support for specialized software products and servers. Such\n work-flows are usually known and not unexpected." ], "index": [ "auditbeat-*", - "endgame-*", "filebeat-*", "packetbeat-*", "winlogbeat-*" ], "language": "kuery", + "max_signals": 100, "name": "SSH (Secure Shell) from the Internet", "query": "network.transport: tcp and destination.port:22 and (\n network.direction: inbound or (\n not source.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16) and\n destination.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16)\n )\n)\n", "risk_score": 47, @@ -18,7 +18,7 @@ "severity": "medium", "tags": [ "Elastic", - "network" + "Network" ], "threat": [ { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_ssh_secure_shell_to_the_internet.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_ssh_secure_shell_to_the_internet.json index 63f2dbc8a34f12..e3c3135c9240d5 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_ssh_secure_shell_to_the_internet.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_ssh_secure_shell_to_the_internet.json @@ -1,16 +1,16 @@ { - "description": "This signal detects network events that may indicate the use of SSH traffic\nfrom the Internet. SSH is commonly used by system administrators to remotely\ncontrol a system using the command line shell. If it is exposed to the Internet,\nit should be done with strong security controls as it is frequently targeted and\nexploited by threat actors as an initial access or back-door vector.\n", + "description": "This rule detects network events that may indicate the use of SSH traffic\nfrom the Internet. SSH is commonly used by system administrators to remotely\ncontrol a system using the command line shell. If it is exposed to the Internet,\nit should be done with strong security controls as it is frequently targeted and\nexploited by threat actors as an initial access or back-door vector.\n", "false_positives": [ - "SSH connections may be made directly to Internet destinations in order to access Linux cloud server instances but such connections are usually made only by engineers. In such cases, only SSH gateways, bastions or jump servers may be expected Internet destinations and can be exempted from this rule. SSH may be required by some work-flows such as remote access and support for specialized software products and servers. Such work-flows are usually known and not unexpected. Usage that is unfamiliar to server or network owners can be unexpected and suspicious." + "SSH connections may be made directly to Internet destinations in order to access Linux\n cloud server instances but such connections are usually made only by engineers. In such cases,\n only SSH gateways, bastions or jump servers may be expected Internet destinations and can be\n exempted from this rule. SSH may be required by some work-flows such as remote access and support\n for specialized software products and servers. Such work-flows are usually known and not unexpected.\n Usage that is unfamiliar to server or network owners can be unexpected and suspicious." ], "index": [ "auditbeat-*", - "endgame-*", "filebeat-*", "packetbeat-*", "winlogbeat-*" ], "language": "kuery", + "max_signals": 100, "name": "SSH (Secure Shell) to the Internet", "query": "network.transport: tcp and destination.port:22 and (\n network.direction: outbound or (\n source.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16) and\n not destination.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16)\n )\n)\n", "risk_score": 21, @@ -18,7 +18,7 @@ "severity": "low", "tags": [ "Elastic", - "network" + "Network" ], "threat": [ { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_telnet_port_activity.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_telnet_port_activity.json index 0d28f0ea53d9a3..c05791c8a107d8 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_telnet_port_activity.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_telnet_port_activity.json @@ -1,16 +1,16 @@ { - "description": "This signal detects network events that may indicate the use of Telnet traffic.\nTelnet is commonly used by system administrators to remotely control older or embed ed\nsystems using the command line shell. It should almost never be directly exposed to\nthe Internet, as it is frequently targeted and exploited by threat actors as an\ninitial access or back-door vector. As a plain-text protocol, it may also expose\n", + "description": "This rule detects network events that may indicate the use of Telnet traffic.\nTelnet is commonly used by system administrators to remotely control older or embed ed\nsystems using the command line shell. It should almost never be directly exposed to\nthe Internet, as it is frequently targeted and exploited by threat actors as an\ninitial access or back-door vector. As a plain-text protocol, it may also expose\nusernames and passwords to anyone capable of observing the traffic.\n", "false_positives": [ - "IoT (Internet of Things) devices and networks may use telnet and can be excluded if desired. Some business work-flows may use Telnet for administration of older devices. These often have a predictable behavior. Telnet activity involving an unusual source or destination may be more suspicious. Telnet activity involving a production server that has no known associated Telnet work-flow or business requirement is often suspicious." + "IoT (Internet of Things) devices and networks may use telnet and can be excluded if\n desired. Some business work-flows may use Telnet for administration of older devices. These\n often have a predictable behavior. Telnet activity involving an unusual source or destination\n may be more suspicious. Telnet activity involving a production server that has no known\n associated Telnet work-flow or business requirement is often suspicious." ], "index": [ "auditbeat-*", - "endgame-*", "filebeat-*", "packetbeat-*", "winlogbeat-*" ], "language": "kuery", + "max_signals": 100, "name": "Telnet Port Activity", "query": "network.transport: tcp and destination.port: 23", "risk_score": 47, @@ -18,7 +18,7 @@ "severity": "medium", "tags": [ "Elastic", - "network" + "Network" ], "threat": [ { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_tor_activity_to_the_internet.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_tor_activity_to_the_internet.json index 80893e9404f021..64397716eded26 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_tor_activity_to_the_internet.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_tor_activity_to_the_internet.json @@ -1,16 +1,16 @@ { - "description": "This signal detects network events that may indicate the use of Tor traffic\nto the Internet. Tor is a network protocol that sends traffic through a\nseries of encrypted tunnels used to conceal a user's location and usage.\nTor may be used by threat actors as an alternate communication pathway to\nconceal the actor's identity and avoid detection.\n", + "description": "This rule detects network events that may indicate the use of Tor traffic\nto the Internet. Tor is a network protocol that sends traffic through a\nseries of encrypted tunnels used to conceal a user's location and usage.\nTor may be used by threat actors as an alternate communication pathway to\nconceal the actor's identity and avoid detection.\n", "false_positives": [ - "Tor client activity is uncommon in managed enterprise networks but may be common in unmanaged or public networks where few security policies apply. Because these ports are in the ephemeral range, this rule may false under certain conditions such as when a NATed web server replies to a client which has used one of these ports by coincidence. In this case, such servers can be excluded if desired." + "Tor client activity is uncommon in managed enterprise networks but may be common\n in unmanaged or public networks where few security policies apply. Because these ports\n are in the ephemeral range, this rule may false under certain conditions such as when a\n NATed web server replies to a client which has used one of these ports by coincidence.\n In this case, such servers can be excluded if desired." ], "index": [ "auditbeat-*", - "endgame-*", "filebeat-*", "packetbeat-*", "winlogbeat-*" ], "language": "kuery", + "max_signals": 100, "name": "Tor Activity to the Internet", "query": "network.transport: tcp and destination.port: (9001 or 9030) and (\n network.direction: outbound or (\n source.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16) and\n not destination.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16)\n )\n)\n", "risk_score": 47, @@ -18,7 +18,7 @@ "severity": "medium", "tags": [ "Elastic", - "network" + "Network" ], "threat": [ { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_vnc_virtual_network_computing_from_the_internet.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_vnc_virtual_network_computing_from_the_internet.json index e64138dd053fa6..dc4fbb281f7622 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_vnc_virtual_network_computing_from_the_internet.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_vnc_virtual_network_computing_from_the_internet.json @@ -1,16 +1,16 @@ { - "description": "This signal detects network events that may indicate the use of VNC traffic\nfrom the Internet. VNC is commonly used by system administrators to remotely\ncontrol a system for maintenance or to use shared resources. It should almost\nnever be directly exposed to the Internet, as it is frequently targeted and\nexploited by threat actors as an initial access or back-door vector.\n", + "description": "This rule detects network events that may indicate the use of VNC traffic\nfrom the Internet. VNC is commonly used by system administrators to remotely\ncontrol a system for maintenance or to use shared resources. It should almost\nnever be directly exposed to the Internet, as it is frequently targeted and\nexploited by threat actors as an initial access or back-door vector.\n", "false_positives": [ - "VNC connections may be received directly to Linux cloud server instances but such connections are usually made only by engineers. VNC is less common than SSH or RDP but may be required by some work-flows such as remote access and support for specialized software products or servers. Such work-flows are usually known and not unexpected. Usage that is unfamiliar to server or network owners can be unexpected and suspicious." + "VNC connections may be received directly to Linux cloud server instances but\n such connections are usually made only by engineers. VNC is less common than SSH\n or RDP but may be required by some work-flows such as remote access and support\n for specialized software products or servers. Such work-flows are usually known\n and not unexpected. Usage that is unfamiliar to server or network owners can be\n unexpected and suspicious." ], "index": [ "auditbeat-*", - "endgame-*", "filebeat-*", "packetbeat-*", "winlogbeat-*" ], "language": "kuery", + "max_signals": 100, "name": "VNC (Virtual Network Computing) from the Internet", "query": "network.transport: tcp and (destination.port >= 5800 and destination.port <= 5810) and (\n network.direction: inbound or (\n not source.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16) and\n destination.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16)\n )\n)\n", "risk_score": 73, @@ -18,7 +18,7 @@ "severity": "high", "tags": [ "Elastic", - "network" + "Network" ], "threat": [ { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_vnc_virtual_network_computing_to_the_internet.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_vnc_virtual_network_computing_to_the_internet.json index 8c43419c3ead55..7da5db39d9bfe3 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_vnc_virtual_network_computing_to_the_internet.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_vnc_virtual_network_computing_to_the_internet.json @@ -1,16 +1,16 @@ { - "description": "This signal detects network events that may indicate the use of VNC traffic\nto the Internet. VNC is commonly used by system administrators to remotely\ncontrol a system for maintenance or to use shared resources. It should almost\nnever be directly exposed to the Internet, as it is frequently targeted and\nexploited by threat actors as an initial access or back-door vector.\n", + "description": "This rule detects network events that may indicate the use of VNC traffic\nto the Internet. VNC is commonly used by system administrators to remotely\ncontrol a system for maintenance or to use shared resources. It should almost\nnever be directly exposed to the Internet, as it is frequently targeted and\nexploited by threat actors as an initial access or back-door vector.", "false_positives": [ - "VNC connections may be made directly to Linux cloud server instances but such connections are usually made only by engineers. VNC is less common than SSH or RDP but may be required by some work flows such as remote access and support for specialized software products or servers. Such work-flows are usually known and not unexpected. Usage that is unfamiliar to server or network owners can be unexpected and suspicious." + "VNC connections may be made directly to Linux cloud server instances but such\n connections are usually made only by engineers. VNC is less common than SSH or RDP\n but may be required by some work flows such as remote access and support for\n specialized software products or servers. Such work-flows are usually known and not\n unexpected. Usage that is unfamiliar to server or network owners can be unexpected\n and suspicious." ], "index": [ "auditbeat-*", - "endgame-*", "filebeat-*", "packetbeat-*", "winlogbeat-*" ], "language": "kuery", + "max_signals": 100, "name": "VNC (Virtual Network Computing) to the Internet", "query": "network.transport: tcp and (destination.port >= 5800 and destination.port <= 5810) and (\n network.direction: outbound or (\n source.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16) and\n not destination.ip: (10.0.0.0/8 or 172.16.0.0/12 or 192.168.0.0/16)\n )\n)\n", "risk_score": 47, @@ -18,7 +18,7 @@ "severity": "medium", "tags": [ "Elastic", - "network" + "Network" ], "threat": [ { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/notice.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/notice.ts index cd24d823b8cd62..a597220db752fe 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/notice.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/notice.ts @@ -9,8 +9,6 @@ * - windows_priv_escalation_via_accessibility_features.json * - windows_persistence_via_application_shimming.json * - windows_execution_via_trusted_developer_utilities.json - * - windows_execution_via_net_com_assemblies.json - * - windows_execution_via_connection_manager.json * * MIT License * diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/null_user_agent.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/null_user_agent.json index 7975c30a4ea386..c08d910a3b3557 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/null_user_agent.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/null_user_agent.json @@ -1,7 +1,7 @@ { "description": "A request to a web application server contained no identifying user agent string.", "false_positives": [ - "Some normal applications and scripts may contain no user agent. Most legitimate web requests from the Internet contain a user agent string. Requests from web browsers almost always contain a user agent string. If the source is unexpected, or the user is unauthorized, or the request is unusual, these may be suspicious or malicious activity." + "Some normal applications and scripts may contain no user agent. Most legitimate web requests from the Internet contain a user agent string. Requests from web browsers almost always contain a user agent string. If the source is unexpected, the user unauthorized, or the request unusual, these may indicate suspicious or malicious activity." ], "filters": [ { @@ -25,7 +25,7 @@ "apm-*-transaction*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Web Application Suspicious Activity: No User Agent", "query": "url.path: *", "references": [ diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/sqlmap_user_agent.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/sqlmap_user_agent.json index 44e112d09a45b4..5c03c3a76e4a7c 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/sqlmap_user_agent.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/sqlmap_user_agent.json @@ -1,12 +1,13 @@ { - "description": "This is an example of how to detect an unwanted web client user agent. This search matches the user agent for sqlmap 1.3.11 which is a popular FOSS tool for testing web applications for SQL injection vulnerabilities. ", + "description": "This is an example of how to detect an unwanted web client user agent. This search matches the user agent for sqlmap 1.3.11, which is a popular FOSS tool for testing web applications for SQL injection vulnerabilities.", "false_positives": [ - "This signal does not indicate that a SQL injection attack occurred, only that the sqlmap tool was used. Security scans and tests may result in these errors. If the source is not an authorized security tester, this is generally suspicious or malicious activity." + "This rule does not indicate that a SQL injection attack occurred, only that the `sqlmap` tool was used. Security scans and tests may result in these errors. If the source is not an authorized security tester, this is generally suspicious or malicious activity." ], "index": [ "apm-*-transaction*" ], "language": "kuery", + "max_signals": 100, "name": "Web Application Suspicious Activity: sqlmap User Agent", "query": "user_agent.original:\"sqlmap/1.3.11#stable (http://sqlmap.org)\"", "references": [ diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_background_intelligent_transfer_service_bits_connecting_to_the_internet.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_background_intelligent_transfer_service_bits_connecting_to_the_internet.json deleted file mode 100644 index 9b3784345b013a..00000000000000 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_background_intelligent_transfer_service_bits_connecting_to_the_internet.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "description": "Adversaries may abuse the Background Intelligent Transfer Service (BITS) to download, execute, or clean up after performing a malicious action.", - "index": [ - "winlogbeat-*" - ], - "language": "kuery", - "max_signals": 33, - "name": "Background Intelligent Transfer Service (BITS) connecting to the Internet", - "query": "process.name:bitsadmin.exe and event.action:\"Network connection detected (rule: NetworkConnect)\" and not destination.ip:10.0.0.0/8 and not destination.ip:172.16.0.0/12 and not destination.ip:192.168.0.0/16", - "risk_score": 21, - "rule_id": "7edadee3-98ae-472c-b1c4-8c0a2c4877cc", - "severity": "low", - "tags": [ - "Elastic", - "Windows" - ], - "threat": [ - { - "framework": "MITRE ATT&CK", - "tactic": { - "id": "TA0005", - "name": "Defense Evasion", - "reference": "https://attack.mitre.org/tactics/TA0005/" - }, - "technique": [ - { - "id": "T1197", - "name": "BITS Jobs", - "reference": "https://attack.mitre.org/techniques/T1197/" - } - ] - }, - { - "framework": "MITRE ATT&CK", - "tactic": { - "id": "TA0003", - "name": "Persistence", - "reference": "https://attack.mitre.org/tactics/TA0003/" - }, - "technique": [ - { - "id": "T1197", - "name": "BITS Jobs", - "reference": "https://attack.mitre.org/techniques/T1197/" - } - ] - } - ], - "type": "query", - "version": 1 -} diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_certutil_connecting_to_the_internet.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_certutil_connecting_to_the_internet.json deleted file mode 100644 index 0a960fc427d7b2..00000000000000 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_certutil_connecting_to_the_internet.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "description": "Identifies certutil.exe making a network connection. Adversaries could abuse certutil.exe to download a certificate, or malware, from a remote URL.", - "index": [ - "winlogbeat-*" - ], - "language": "kuery", - "max_signals": 33, - "name": "Certutil Network Connection", - "query": "process.name:certutil.exe and event.action:\"Network connection detected (rule: NetworkConnect)\" and not destination.ip:10.0.0.0/8 and not destination.ip:172.16.0.0/12 and not destination.ip:192.168.0.0/16", - "risk_score": 21, - "rule_id": "1a2cf526-6784-4c51-a2b9-f0adcc05d85c", - "severity": "low", - "tags": [ - "Elastic", - "Windows" - ], - "threat": [ - { - "framework": "MITRE ATT&CK", - "tactic": { - "id": "TA0011", - "name": "Command and Control", - "reference": "https://attack.mitre.org/tactics/TA0011/" - }, - "technique": [ - { - "id": "T1105", - "name": "Remote File Copy", - "reference": "https://attack.mitre.org/techniques/T1105/" - } - ] - } - ], - "type": "query", - "version": 1 -} diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_prompt_connecting_to_the_internet.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_prompt_connecting_to_the_internet.json index 87dbd4cd707770..7ab8034ef4083b 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_prompt_connecting_to_the_internet.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_prompt_connecting_to_the_internet.json @@ -7,7 +7,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Command Prompt Network Connection", "query": "process.name:cmd.exe and event.action:\"Network connection detected (rule: NetworkConnect)\" and not destination.ip:10.0.0.0/8 and not destination.ip:172.16.0.0/12 and not destination.ip:192.168.0.0/16", "risk_score": 21, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_shell_started_by_internet_explorer.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_shell_started_by_internet_explorer.json deleted file mode 100644 index a214ab4544b97e..00000000000000 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_shell_started_by_internet_explorer.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "description": "Identifies a suspicious parent child process relationship with cmd.exe spawning form Internet Explorer.", - "index": [ - "winlogbeat-*" - ], - "language": "kuery", - "max_signals": 33, - "name": "Internet Explorer spawning cmd.exe", - "query": "process.parent.name:iexplore.exe and process.name:cmd.exe", - "risk_score": 21, - "rule_id": "7a6e1e81-deae-4cf6-b807-9a768fff3c06", - "severity": "low", - "tags": [ - "Elastic", - "Windows" - ], - "threat": [ - { - "framework": "MITRE ATT&CK", - "tactic": { - "id": "TA0002", - "name": "Execution", - "reference": "https://attack.mitre.org/tactics/TA0002/" - }, - "technique": [ - { - "id": "T1059", - "name": "Command-Line Interface", - "reference": "https://attack.mitre.org/techniques/T1059/" - } - ] - } - ], - "type": "query", - "version": 1 -} diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_shell_started_by_powershell.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_shell_started_by_powershell.json index 187cc9d344902f..d914fd2e91a077 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_shell_started_by_powershell.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_shell_started_by_powershell.json @@ -4,8 +4,8 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, - "name": "PowerShell spawning cmd.exe", + "max_signals": 100, + "name": "PowerShell spawning Cmd", "query": "process.parent.name:powershell.exe and process.name:cmd.exe", "risk_score": 21, "rule_id": "0f616aee-8161-4120-857e-742366f5eeb3", diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_shell_started_by_svchost.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_shell_started_by_svchost.json index 81114bf8b87668..b7f0c54fedf622 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_shell_started_by_svchost.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_shell_started_by_svchost.json @@ -4,8 +4,8 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, - "name": "Svchost spawning cmd.exe", + "max_signals": 100, + "name": "Svchost spawning Cmd", "query": "process.parent.name:svchost.exe and process.name:cmd.exe", "risk_score": 21, "rule_id": "fd7a6052-58fa-4397-93c3-4795249ccfa2", diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_defense_evasion_via_filter_manager.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_defense_evasion_via_filter_manager.json index 7c999c1fc1e03a..86242fd1081a1a 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_defense_evasion_via_filter_manager.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_defense_evasion_via_filter_manager.json @@ -4,15 +4,14 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Potential Evasion via Filter Manager", - "query": "event.code:1 and process.name:fltmc.exe", + "query": "event.code:1 and process.name:fltMC.exe", "risk_score": 21, "rule_id": "06dceabf-adca-48af-ac79-ffdf4c3b1e9a", "severity": "low", "tags": [ "Elastic", - "D-SA", "Windows" ], "threat": [ diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_compiled_html_file.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_compiled_html_file.json index 62c8942dda9c3c..7789b0723b3fc3 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_compiled_html_file.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_compiled_html_file.json @@ -7,7 +7,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Process Activity via Compiled HTML File", "query": "event.code:1 and process.name:hh.exe", "risk_score": 21, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_connection_manager.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_connection_manager.json deleted file mode 100644 index 657487232fe81c..00000000000000 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_connection_manager.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "description": "Various Windows utilities may be used to execute commands, possibly without invoking cmd.exe, including the Program Compatibility Assistant (pcalua.exe) or forfiles.exe.", - "index": [ - "winlogbeat-*" - ], - "language": "kuery", - "max_signals": 33, - "name": "Indirect Command Execution", - "query": "event.code:1 and process.parent.name:pcalua.exe or (process.name:bash.exe or process.name:forfiles.exe or process.name:pcalua.exe)", - "risk_score": 21, - "rule_id": "f2728299-167a-489c-913c-2e0955ac3c40", - "severity": "low", - "tags": [ - "Elastic", - "D-SA", - "Windows" - ], - "threat": [ - { - "framework": "MITRE ATT&CK", - "tactic": { - "id": "TA0005", - "name": "Defense Evasion", - "reference": "https://attack.mitre.org/tactics/TA0005/" - }, - "technique": [ - { - "id": "T1202", - "name": "Indirect Command Execution", - "reference": "https://attack.mitre.org/techniques/T1202/" - } - ] - } - ], - "type": "query", - "version": 1 -} diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_net_com_assemblies.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_net_com_assemblies.json deleted file mode 100644 index 80d91fa5153427..00000000000000 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_net_com_assemblies.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "description": "Adversaries can use Regsvcs.exe and Regasm.exe to proxy execution of code through a trusted Windows utility.", - "false_positives": [ - "Administrators may use the command prompt for regular administrative tasks. It's important to baseline your environment for network connections being made from the command prompt to determine any abnormal use of this tool." - ], - "index": [ - "winlogbeat-*" - ], - "language": "kuery", - "max_signals": 33, - "name": "Execution via Regsvcs/Regasm", - "query": "event.code:1 and (process.name:regasm.exe or process.name:regsvcs.exe)", - "risk_score": 21, - "rule_id": "5c12412f-602c-4120-8c4f-69d723dbba04", - "severity": "low", - "tags": [ - "Elastic", - "D-SA", - "Windows" - ], - "threat": [ - { - "framework": "MITRE ATT&CK", - "tactic": { - "id": "TA0002", - "name": "Execution", - "reference": "https://attack.mitre.org/tactics/TA0002/" - }, - "technique": [ - { - "id": "T1121", - "name": "Regsvcs/Regasm", - "reference": "https://attack.mitre.org/techniques/T1121/" - } - ] - } - ], - "type": "query", - "version": 1 -} diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_regsvr32.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_regsvr32.json index 6b2c54d5279630..e8e7ddfc168dcc 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_regsvr32.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_regsvr32.json @@ -4,7 +4,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Suspicious Script Object Execution", "query": "event.code: 1 and scrobj.dll and (process.name:certutil.exe or process.name:regsvr32.exe or process.name:rundll32.exe)", "risk_score": 21, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_trusted_developer_utilities.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_trusted_developer_utilities.json index e722d311b86c7a..bd2376a0897f49 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_trusted_developer_utilities.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_trusted_developer_utilities.json @@ -7,7 +7,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Trusted Developer Application Usage", "query": "event.code:1 and (process.name:MSBuild.exe or process.name:msxsl.exe)", "risk_score": 21, @@ -15,7 +15,6 @@ "severity": "low", "tags": [ "Elastic", - "D-SA", "Windows" ], "threat": [ diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_html_help_executable_program_connecting_to_the_internet.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_html_help_executable_program_connecting_to_the_internet.json index 2b4d774281b847..32fa953388be30 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_html_help_executable_program_connecting_to_the_internet.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_html_help_executable_program_connecting_to_the_internet.json @@ -4,7 +4,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Network Connection via Compiled HTML File", "query": "process.name:hh.exe and event.action:\"Network connection detected (rule: NetworkConnect)\" and not destination.ip:10.0.0.0/8 and not destination.ip:172.16.0.0/12 and not destination.ip:192.168.0.0/16", "risk_score": 21, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_misc_lolbin_connecting_to_the_internet.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_misc_lolbin_connecting_to_the_internet.json index 8a4cb75588bff5..0015371f030670 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_misc_lolbin_connecting_to_the_internet.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_misc_lolbin_connecting_to_the_internet.json @@ -4,7 +4,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Network Connection via Signed Binary", "query": "(process.name:expand.exe or process.name:extrac.exe or process.name:ieexec.exe or process.name:makecab.exe) and event.action:\"Network connection detected (rule: NetworkConnect)\" and not destination.ip:10.0.0.0/8 and not destination.ip:172.16.0.0/12 and not destination.ip:192.168.0.0/16", "risk_score": 21, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_net_command_activity_by_the_system_account.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_net_command_activity_by_the_system_account.json deleted file mode 100644 index 5b3257daec8fbe..00000000000000 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_net_command_activity_by_the_system_account.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "description": "Identifies attempts to create new users via the SYSTEM account.", - "index": [ - "winlogbeat-*" - ], - "language": "kuery", - "max_signals": 33, - "name": "Net command via SYSTEM account", - "query": "process.name: (net.exe or net1.exe) and user.name:SYSTEM", - "risk_score": 21, - "rule_id": "c3f5dc81-a8b4-4144-95a7-d0a818d7355d", - "severity": "low", - "tags": [ - "Elastic", - "Windows" - ], - "threat": [ - { - "framework": "MITRE ATT&CK", - "tactic": { - "id": "TA0003", - "name": "Persistence", - "reference": "https://attack.mitre.org/tactics/TA0003/" - }, - "technique": [ - { - "id": "T1136", - "name": "Create Account", - "reference": "https://attack.mitre.org/techniques/T1136/" - } - ] - } - ], - "type": "query", - "version": 1 -} diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_persistence_via_application_shimming.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_persistence_via_application_shimming.json index 2c10382cdbc7c0..6eaac7b9e6cabf 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_persistence_via_application_shimming.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_persistence_via_application_shimming.json @@ -4,7 +4,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Potential Application Shimming via Sdbinst", "query": "event.code:1 and process.name:sdbinst.exe", "risk_score": 21, @@ -12,7 +12,6 @@ "severity": "low", "tags": [ "Elastic", - "D-SA", "Windows" ], "threat": [ diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_priv_escalation_via_accessibility_features.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_priv_escalation_via_accessibility_features.json index 23d05aaf526e3a..b2463633b0c5da 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_priv_escalation_via_accessibility_features.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_priv_escalation_via_accessibility_features.json @@ -4,7 +4,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Potential Modification of Accessibility Binaries", "query": "event.code:1 and process.parent.name:winlogon.exe and (process.name:atbroker.exe or process.name:displayswitch.exe or process.name:magnify.exe or process.name:narrator.exe or process.name:osk.exe or process.name:sethc.exe or process.name:utilman.exe)", "risk_score": 21, @@ -12,7 +12,6 @@ "severity": "low", "tags": [ "Elastic", - "D-SA", "Windows" ], "threat": [ diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_process_discovery_via_tasklist_command.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_process_discovery_via_tasklist_command.json index 5f5215ddff8c63..a0542ef59d8cd3 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_process_discovery_via_tasklist_command.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_process_discovery_via_tasklist_command.json @@ -7,7 +7,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Process Discovery via Tasklist", "query": "event.code:1 and process.name:tasklist.exe", "risk_score": 21, @@ -15,7 +15,6 @@ "severity": "low", "tags": [ "Elastic", - "D-SA", "Windows" ], "threat": [ diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_process_execution_via_wmi.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_process_execution_via_wmi.json deleted file mode 100644 index 6d6343330a7ff9..00000000000000 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_process_execution_via_wmi.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "description": "Identifies use of scrcons.exe, which is a Windows Management Instrumentation (WMI) Standard Event Consumer scripting application.", - "false_positives": [ - " Windows Management Instrumentation (WMI) processes can be used for an array of administrative capabilities. It's important to baseline your environment to determine any abnormal use of this tool." - ], - "index": [ - "winlogbeat-*" - ], - "language": "kuery", - "max_signals": 33, - "name": "Execution via Scrcons", - "query": "process.name:scrcons.exe", - "risk_score": 21, - "rule_id": "7e6cd4b9-6346-4683-b3e6-6a3e66f3208f", - "severity": "low", - "tags": [ - "Elastic", - "Windows" - ], - "threat": [ - { - "framework": "MITRE ATT&CK", - "tactic": { - "id": "TA0002", - "name": "Execution", - "reference": "https://attack.mitre.org/tactics/TA0002/" - }, - "technique": [ - { - "id": "T1047", - "name": "Windows Management Instrumentation", - "reference": "https://attack.mitre.org/techniques/T1047/" - } - ] - } - ], - "type": "query", - "version": 1 -} diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_register_server_program_connecting_to_the_internet.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_register_server_program_connecting_to_the_internet.json index b35e016be15d7a..d0f2e809c1aa7f 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_register_server_program_connecting_to_the_internet.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_register_server_program_connecting_to_the_internet.json @@ -7,7 +7,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Network Connection via Regsvr", "query": "(process.name:regsvr32.exe or process.name:regsvr64.exe) and event.action:\"Network connection detected (rule: NetworkConnect)\" and not destination.ip:169.254.169.254/32 and not destination.ip:10.0.0.0/8 and not destination.ip:172.16.0.0/12 and not destination.ip:192.168.0.0/16", "risk_score": 21, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_signed_binary_proxy_execution.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_signed_binary_proxy_execution.json index cf5135cc490eb0..be4ccef2a0887b 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_signed_binary_proxy_execution.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_signed_binary_proxy_execution.json @@ -7,7 +7,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Execution via Signed Binary", "query": "event.code:1 and http and (process.name:certutil.exe or process.name:msiexec.exe)", "risk_score": 21, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_signed_binary_proxy_execution_download.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_signed_binary_proxy_execution_download.json deleted file mode 100644 index 117a40d0fdcee7..00000000000000 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_signed_binary_proxy_execution_download.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "description": "Binaries signed with trusted digital certificates can execute on Windows systems protected by digital signature validation. Adversaries may use these binaries to 'live off the land' and execute malicious files that could bypass application whitelisting and signature validation.", - "false_positives": [ - "Security testing may produce events like this. Activity of this kind performed by non-engineers and ordinary users is unusual." - ], - "index": [ - "winlogbeat-*" - ], - "language": "kuery", - "max_signals": 33, - "name": "Potential Download via Signed Binary", - "query": " event.code:3 and http and (process.name:certutil.exe or process.name:replace.exe)", - "risk_score": 21, - "rule_id": "68ecc190-cce2-4021-b976-c7c846ac0a00", - "severity": "low", - "tags": [ - "Elastic", - "Windows" - ], - "threat": [ - { - "framework": "MITRE ATT&CK", - "tactic": { - "id": "TA0005", - "name": "Defense Evasion", - "reference": "https://attack.mitre.org/tactics/TA0005/" - }, - "technique": [ - { - "id": "T1218", - "name": "Signed Binary Proxy Execution", - "reference": "https://attack.mitre.org/techniques/T1218/" - } - ] - }, - { - "framework": "MITRE ATT&CK", - "tactic": { - "id": "TA0002", - "name": "Execution", - "reference": "https://attack.mitre.org/tactics/TA0002/" - }, - "technique": [ - { - "id": "T1218", - "name": "Signed Binary Proxy Execution", - "reference": "https://attack.mitre.org/techniques/T1218/" - } - ] - } - ], - "type": "query", - "version": 1 -} diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_suspicious_process_started_by_a_script.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_suspicious_process_started_by_a_script.json index 3691c59d784fb7..235a04f8063fcc 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_suspicious_process_started_by_a_script.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_suspicious_process_started_by_a_script.json @@ -7,8 +7,8 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, - "name": "Suspicious Process Spawning from Script Interpreter", + "max_signals": 100, + "name": "Suspicious Process spawning from Script Interpreter", "query": "(process.parent.name:cmd.exe or process.parent.name:cscript.exe or process.parent.name:mshta.exe or process.parent.name:powershell.exe or process.parent.name:rundll32.exe or process.parent.name:wscript.exe or process.parent.name:wmiprvse.exe) and (process.name:bitsadmin.exe or process.name:certutil.exe or mshta.exe or process.name:nslookup.exe or process.name:schtasks.exe) and event.code:1", "risk_score": 21, "rule_id": "89db767d-99f9-479f-8052-9205fd3090c4", diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_whoami_command_activity.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_whoami_command_activity.json index 3618d304dc32a3..678160f945ba0a 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_whoami_command_activity.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_whoami_command_activity.json @@ -7,7 +7,7 @@ "winlogbeat-*" ], "language": "kuery", - "max_signals": 33, + "max_signals": 100, "name": "Whoami Process Activity", "query": "process.name:whoami.exe and event.code:1", "risk_score": 21, From ff41f4e56f1dfe9a3d2fcd9ccd508de6eb9b1104 Mon Sep 17 00:00:00 2001 From: Corey Robertson Date: Tue, 4 Feb 2020 21:25:43 -0500 Subject: [PATCH 18/22] Only change handlers as the element changes (#56782) Co-authored-by: Elastic Machine --- .../public/components/element_wrapper/index.js | 6 ++---- .../components/element_wrapper/lib/handlers.js | 4 ++-- .../canvas/public/state/actions/elements.js | 4 ++-- .../canvas/public/state/reducers/elements.js | 15 ++++++++++++++- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/x-pack/legacy/plugins/canvas/public/components/element_wrapper/index.js b/x-pack/legacy/plugins/canvas/public/components/element_wrapper/index.js index 60c7e731691fac..85882377b76849 100644 --- a/x-pack/legacy/plugins/canvas/public/components/element_wrapper/index.js +++ b/x-pack/legacy/plugins/canvas/public/components/element_wrapper/index.js @@ -58,12 +58,10 @@ function selectorFactory(dispatch) { export const ElementWrapper = compose( connectAdvanced(selectorFactory), withPropsOnChange( - (props, nextProps) => - !isEqual(props.element, nextProps.element) || - !isEqual(props.selectedPage, nextProps.selectedPage), + (props, nextProps) => !isEqual(props.element, nextProps.element), props => { const { element, createHandlers } = props; - const handlers = createHandlers(element, props.selectedPage); + const handlers = createHandlers(element); // this removes element and createHandlers from passed props return { handlers }; } diff --git a/x-pack/legacy/plugins/canvas/public/components/element_wrapper/lib/handlers.js b/x-pack/legacy/plugins/canvas/public/components/element_wrapper/lib/handlers.js index d71c5ead2c8021..8ea90974e2c53d 100644 --- a/x-pack/legacy/plugins/canvas/public/components/element_wrapper/lib/handlers.js +++ b/x-pack/legacy/plugins/canvas/public/components/element_wrapper/lib/handlers.js @@ -16,7 +16,7 @@ export const createHandlers = dispatch => { let oldElement; let completeFn = () => {}; - return (element, pageId) => { + return element => { // reset isComplete when element changes if (!isEqual(oldElement, element)) { isComplete = false; @@ -25,7 +25,7 @@ export const createHandlers = dispatch => { return { setFilter(text) { - dispatch(setFilter(text, element.id, pageId, true)); + dispatch(setFilter(text, element.id, true)); }, getFilter() { diff --git a/x-pack/legacy/plugins/canvas/public/state/actions/elements.js b/x-pack/legacy/plugins/canvas/public/state/actions/elements.js index 7b7e87b027af53..8b49d16e87b217 100644 --- a/x-pack/legacy/plugins/canvas/public/state/actions/elements.js +++ b/x-pack/legacy/plugins/canvas/public/state/actions/elements.js @@ -254,9 +254,9 @@ export const removeElements = createThunk( export const setFilter = createThunk( 'setFilter', - ({ dispatch }, filter, elementId, pageId, doRender = true) => { + ({ dispatch }, filter, elementId, doRender = true) => { const _setFilter = createAction('setFilter'); - dispatch(_setFilter({ filter, elementId, pageId })); + dispatch(_setFilter({ filter, elementId })); if (doRender === true) { dispatch(fetchAllRenderables()); diff --git a/x-pack/legacy/plugins/canvas/public/state/reducers/elements.js b/x-pack/legacy/plugins/canvas/public/state/reducers/elements.js index c7e8a5c2ff2d81..630694a860aad4 100644 --- a/x-pack/legacy/plugins/canvas/public/state/reducers/elements.js +++ b/x-pack/legacy/plugins/canvas/public/state/reducers/elements.js @@ -87,6 +87,18 @@ const trimElement = ({ id, position, expression, filter }) => ({ ...(filter !== void 0 && { filter }), }); +const getPageWithElementId = (workpad, elementId) => { + const matchingPage = workpad.pages.find(page => + page.elements.map(element => element.id).includes(elementId) + ); + + if (matchingPage) { + return matchingPage.id; + } + + return undefined; +}; + export const elementsReducer = handleActions( { // TODO: This takes the entire element, which is not necessary, it could just take the id. @@ -95,7 +107,8 @@ export const elementsReducer = handleActions( return assignNodeProperties(workpadState, pageId, elementId, { expression }); }, [actions.setFilter]: (workpadState, { payload }) => { - const { filter, pageId, elementId } = payload; + const { filter, elementId } = payload; + const pageId = getPageWithElementId(workpadState, elementId); return assignNodeProperties(workpadState, pageId, elementId, { filter }); }, [actions.setMultiplePositions]: (workpadState, { payload }) => From 117bfb5cc72fdb85afa411fa349b5e1735861147 Mon Sep 17 00:00:00 2001 From: Andrew Cholakian Date: Tue, 4 Feb 2020 22:07:37 -0600 Subject: [PATCH 19/22] Improve pull request template proposal (#56756) Looking through Kibana PRs many currently ignore the check boxes or just delete them. The goal here is to make the process easier, delete some unused options and align the checkboxes with what's most useful. We've had some discussions on the Uptime team about ways the PR template could be potentially improved. These changes are based on an extended discussion we had on the topic. We'd love to hear if other teams would be OK with these recommended changes. The changes here are: * Allow authors to just delete unnecessary items rather than strike through. Adding all the `~~` in markdown is painful * Remove the unnecessary checkbox for release notes, the build bot catches this and blocks merges without that being set. * Add a checkbox for testing in various browser sizes / mobile responsive devices * Move IE checkbox to the bottom of the list since it's seldom checked and makes the checklist seem daunting --- .github/PULL_REQUEST_TEMPLATE.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 5a80a11c5cbea1..4cc0c8016f1d0a 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -4,16 +4,15 @@ Summarize your PR. If it involves visual changes include a screenshot or gif. ### Checklist -Use ~~strikethroughs~~ to remove checklist items you don't feel are applicable to this PR. +Delete any items that are not applicable to this PR. -- [ ] This was checked for cross-browser compatibility, [including a check against IE11](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md) - [ ] [Documentation](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#writing-documentation) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios - [ ] This was checked for [keyboard-only and screenreader accessibility](https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Accessibility#Accessibility_testing_checklist) +- [ ] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server) +- [ ] This was checked for cross-browser compatibility, [including a check against IE11](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process) -- [ ] This includes a feature addition or change that requires a release note and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process) - From 4d7c7b55f7df813b69b3a75d78f1bf1234ddf384 Mon Sep 17 00:00:00 2001 From: Aleh Zasypkin Date: Wed, 5 Feb 2020 10:29:21 +0100 Subject: [PATCH 20/22] Properly handle password change for users authenticated with provider other than `basic`. (#55206) --- .../server/alerts_client_factory.test.ts | 2 +- .../plugins/reporting/server/lib/get_user.ts | 19 +--- .../routes/lib/authorized_user_pre_routing.ts | 2 +- x-pack/legacy/plugins/security/index.js | 2 +- .../common/model/authenticated_user.mock.ts | 1 + .../common/model/authenticated_user.ts | 5 + .../account_management_page.test.tsx | 6 +- .../authentication/authenticator.test.ts | 71 +----------- .../server/authentication/authenticator.ts | 23 ++-- .../server/authentication/index.test.ts | 75 ++++++------- .../security/server/authentication/index.ts | 20 +--- .../server/authentication/providers/base.ts | 17 ++- .../server/authentication/providers/basic.ts | 5 + .../authentication/providers/kerberos.test.ts | 10 +- .../authentication/providers/kerberos.ts | 5 + .../authentication/providers/oidc.test.ts | 6 +- .../server/authentication/providers/oidc.ts | 7 +- .../authentication/providers/pki.test.ts | 12 +- .../server/authentication/providers/pki.ts | 5 + .../authentication/providers/saml.test.ts | 6 +- .../server/authentication/providers/saml.ts | 7 +- .../authentication/providers/token.test.ts | 10 +- .../server/authentication/providers/token.ts | 7 +- .../routes/authentication/common.test.ts | 13 +-- .../server/routes/authentication/common.ts | 8 +- .../routes/users/change_password.test.ts | 106 +++++++++++++++--- .../server/routes/users/change_password.ts | 77 +++++++------ .../apis/security/basic_login.js | 2 + .../apis/security/kerberos_login.ts | 2 + .../apis/authorization_code_flow/oidc_auth.js | 2 + .../apis/implicit_flow/oidc_auth.ts | 1 + .../apis/security/pki_auth.ts | 3 + .../apis/security/saml_login.ts | 2 + 33 files changed, 284 insertions(+), 255 deletions(-) diff --git a/x-pack/legacy/plugins/alerting/server/alerts_client_factory.test.ts b/x-pack/legacy/plugins/alerting/server/alerts_client_factory.test.ts index 754e02a3f1e5ec..14c685237bf92c 100644 --- a/x-pack/legacy/plugins/alerting/server/alerts_client_factory.test.ts +++ b/x-pack/legacy/plugins/alerting/server/alerts_client_factory.test.ts @@ -86,7 +86,7 @@ test('getUserName() returns a name when security is enabled', async () => { factory.create(KibanaRequest.from(fakeRequest), fakeRequest); const constructorCall = jest.requireMock('./alerts_client').AlertsClient.mock.calls[0][0]; - securityPluginSetup.authc.getCurrentUser.mockResolvedValueOnce({ username: 'bob' }); + securityPluginSetup.authc.getCurrentUser.mockReturnValueOnce({ username: 'bob' }); const userNameResult = await constructorCall.getUserName(); expect(userNameResult).toEqual('bob'); }); diff --git a/x-pack/legacy/plugins/reporting/server/lib/get_user.ts b/x-pack/legacy/plugins/reporting/server/lib/get_user.ts index 350004ddb78f80..ab02dfe0743f02 100644 --- a/x-pack/legacy/plugins/reporting/server/lib/get_user.ts +++ b/x-pack/legacy/plugins/reporting/server/lib/get_user.ts @@ -6,27 +6,14 @@ import { Legacy } from 'kibana'; import { KibanaRequest } from '../../../../../../src/core/server'; -import { Logger, ServerFacade } from '../../types'; +import { ServerFacade } from '../../types'; import { ReportingSetupDeps } from '../plugin'; -export function getUserFactory( - server: ServerFacade, - security: ReportingSetupDeps['security'], - logger: Logger -) { +export function getUserFactory(server: ServerFacade, security: ReportingSetupDeps['security']) { /* * Legacy.Request because this is called from routing middleware */ return async (request: Legacy.Request) => { - if (!security) { - return null; - } - - try { - return await security.authc.getCurrentUser(KibanaRequest.from(request)); - } catch (err) { - logger.error(err, ['getUser']); - return null; - } + return security?.authc.getCurrentUser(KibanaRequest.from(request)) ?? null; }; } diff --git a/x-pack/legacy/plugins/reporting/server/routes/lib/authorized_user_pre_routing.ts b/x-pack/legacy/plugins/reporting/server/routes/lib/authorized_user_pre_routing.ts index 874027251570c3..57c3fcee222da9 100644 --- a/x-pack/legacy/plugins/reporting/server/routes/lib/authorized_user_pre_routing.ts +++ b/x-pack/legacy/plugins/reporting/server/routes/lib/authorized_user_pre_routing.ts @@ -22,7 +22,7 @@ export const authorizedUserPreRoutingFactory = function authorizedUserPreRouting plugins: ReportingSetupDeps, logger: Logger ) { - const getUser = getUserFactory(server, plugins.security, logger); + const getUser = getUserFactory(server, plugins.security); const config = server.config(); return async function authorizedUserPreRouting(request: Legacy.Request) { diff --git a/x-pack/legacy/plugins/security/index.js b/x-pack/legacy/plugins/security/index.js index 4988c30a1398b0..9016398463b5f7 100644 --- a/x-pack/legacy/plugins/security/index.js +++ b/x-pack/legacy/plugins/security/index.js @@ -130,7 +130,7 @@ export const security = kibana => ); server.expose({ - getUser: request => securityPlugin.authc.getCurrentUser(KibanaRequest.from(request)), + getUser: async request => securityPlugin.authc.getCurrentUser(KibanaRequest.from(request)), }); initLoginView(securityPlugin, server); diff --git a/x-pack/plugins/security/common/model/authenticated_user.mock.ts b/x-pack/plugins/security/common/model/authenticated_user.mock.ts index 3a93efc57b5f60..220b284e76591f 100644 --- a/x-pack/plugins/security/common/model/authenticated_user.mock.ts +++ b/x-pack/plugins/security/common/model/authenticated_user.mock.ts @@ -15,6 +15,7 @@ export function mockAuthenticatedUser(user: Partial = {}) { enabled: true, authentication_realm: { name: 'native1', type: 'native' }, lookup_realm: { name: 'native1', type: 'native' }, + authentication_provider: 'basic', ...user, }; } diff --git a/x-pack/plugins/security/common/model/authenticated_user.ts b/x-pack/plugins/security/common/model/authenticated_user.ts index 1b660ae919c090..6465b4a23eb48a 100644 --- a/x-pack/plugins/security/common/model/authenticated_user.ts +++ b/x-pack/plugins/security/common/model/authenticated_user.ts @@ -26,6 +26,11 @@ export interface AuthenticatedUser extends User { * The name and type of the Realm where the user information were retrieved from. */ lookup_realm: UserRealm; + + /** + * Name of the Kibana authentication provider that used to authenticate user. + */ + authentication_provider: string; } export function canUserChangePassword(user: AuthenticatedUser) { diff --git a/x-pack/plugins/security/public/account_management/account_management_page.test.tsx b/x-pack/plugins/security/public/account_management/account_management_page.test.tsx index b7cf8e6dd14181..4caf3d25e887bb 100644 --- a/x-pack/plugins/security/public/account_management/account_management_page.test.tsx +++ b/x-pack/plugins/security/public/account_management/account_management_page.test.tsx @@ -10,6 +10,7 @@ import { AuthenticatedUser } from '../../common/model'; import { AccountManagementPage } from './account_management_page'; import { coreMock } from 'src/core/public/mocks'; +import { mockAuthenticatedUser } from '../../common/model/authenticated_user.mock'; import { securityMock } from '../mocks'; import { userAPIClientMock } from '../management/users/index.mock'; @@ -19,11 +20,10 @@ interface Options { realm?: string; } const createUser = ({ withFullName = true, withEmail = true, realm = 'native' }: Options = {}) => { - return { + return mockAuthenticatedUser({ full_name: withFullName ? 'Casey Smith' : '', username: 'csmith', email: withEmail ? 'csmith@domain.com' : '', - enabled: true, roles: [], authentication_realm: { type: realm, @@ -33,7 +33,7 @@ const createUser = ({ withFullName = true, withEmail = true, realm = 'native' }: type: realm, name: realm, }, - }; + }); }; function getSecuritySetupMock({ currentUser }: { currentUser: AuthenticatedUser }) { diff --git a/x-pack/plugins/security/server/authentication/authenticator.test.ts b/x-pack/plugins/security/server/authentication/authenticator.test.ts index dd580c890bf94e..8be1762133db67 100644 --- a/x-pack/plugins/security/server/authentication/authenticator.test.ts +++ b/x-pack/plugins/security/server/authentication/authenticator.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -jest.mock('./providers/basic', () => ({ BasicAuthenticationProvider: jest.fn() })); +jest.mock('./providers/basic'); import Boom from 'boom'; import { duration, Duration } from 'moment'; @@ -225,75 +225,6 @@ describe('Authenticator', () => { expect(mockSessionStorage.set).not.toHaveBeenCalled(); expect(mockSessionStorage.clear).toHaveBeenCalled(); }); - - describe('stateless login', () => { - it('does not create session even if authentication provider returns state', async () => { - const user = mockAuthenticatedUser(); - const request = httpServerMock.createKibanaRequest(); - const authorization = `Basic ${Buffer.from('foo:bar').toString('base64')}`; - - mockBasicAuthenticationProvider.login.mockResolvedValue( - AuthenticationResult.succeeded(user, { state: { authorization } }) - ); - - const authenticationResult = await authenticator.login(request, { - provider: 'basic', - value: {}, - stateless: true, - }); - expect(authenticationResult.succeeded()).toBe(true); - expect(authenticationResult.user).toEqual(user); - - expect(mockBasicAuthenticationProvider.login).toHaveBeenCalledWith(request, {}, null); - expect(mockSessionStorage.get).not.toHaveBeenCalled(); - expect(mockSessionStorage.set).not.toHaveBeenCalled(); - expect(mockSessionStorage.clear).not.toHaveBeenCalled(); - }); - - it('does not clear session even if provider asked to do so.', async () => { - const user = mockAuthenticatedUser(); - const request = httpServerMock.createKibanaRequest(); - - mockBasicAuthenticationProvider.login.mockResolvedValue( - AuthenticationResult.succeeded(user, { state: null }) - ); - - const authenticationResult = await authenticator.login(request, { - provider: 'basic', - value: {}, - stateless: true, - }); - expect(authenticationResult.succeeded()).toBe(true); - expect(authenticationResult.user).toEqual(user); - - expect(mockBasicAuthenticationProvider.login).toHaveBeenCalledWith(request, {}, null); - expect(mockSessionStorage.get).not.toHaveBeenCalled(); - expect(mockSessionStorage.set).not.toHaveBeenCalled(); - expect(mockSessionStorage.clear).not.toHaveBeenCalled(); - }); - - it('does not clear session even if provider failed with 401.', async () => { - const request = httpServerMock.createKibanaRequest(); - - const failureReason = Boom.unauthorized(); - mockBasicAuthenticationProvider.login.mockResolvedValue( - AuthenticationResult.failed(failureReason) - ); - - const authenticationResult = await authenticator.login(request, { - provider: 'basic', - value: {}, - stateless: true, - }); - expect(authenticationResult.failed()).toBe(true); - expect(authenticationResult.error).toBe(failureReason); - - expect(mockBasicAuthenticationProvider.login).toHaveBeenCalledWith(request, {}, null); - expect(mockSessionStorage.get).not.toHaveBeenCalled(); - expect(mockSessionStorage.set).not.toHaveBeenCalled(); - expect(mockSessionStorage.clear).not.toHaveBeenCalled(); - }); - }); }); describe('`authenticate` method', () => { diff --git a/x-pack/plugins/security/server/authentication/authenticator.ts b/x-pack/plugins/security/server/authentication/authenticator.ts index be952a154cee49..ea7792e902ec1c 100644 --- a/x-pack/plugins/security/server/authentication/authenticator.ts +++ b/x-pack/plugins/security/server/authentication/authenticator.ts @@ -80,13 +80,6 @@ export interface ProviderLoginAttempt { * Login attempt can have any form and defined by the specific provider. */ value: unknown; - - /** - * Indicates whether login attempt should be performed in a "stateless" manner. If `true` provider - * performing login will neither be able to retrieve or update existing state if any nor persist - * any new state it may produce as a result of the login attempt. It's `false` by default. - */ - stateless?: boolean; } export interface AuthenticatorOptions { @@ -107,12 +100,12 @@ const providerMap = new Map< providerSpecificOptions?: AuthenticationProviderSpecificOptions ) => BaseAuthenticationProvider >([ - ['basic', BasicAuthenticationProvider], - ['kerberos', KerberosAuthenticationProvider], - ['saml', SAMLAuthenticationProvider], - ['token', TokenAuthenticationProvider], - ['oidc', OIDCAuthenticationProvider], - ['pki', PKIAuthenticationProvider], + [BasicAuthenticationProvider.type, BasicAuthenticationProvider], + [KerberosAuthenticationProvider.type, KerberosAuthenticationProvider], + [SAMLAuthenticationProvider.type, SAMLAuthenticationProvider], + [TokenAuthenticationProvider.type, TokenAuthenticationProvider], + [OIDCAuthenticationProvider.type, OIDCAuthenticationProvider], + [PKIAuthenticationProvider.type, PKIAuthenticationProvider], ]); function assertRequest(request: KibanaRequest) { @@ -254,7 +247,7 @@ export class Authenticator { // If we detect an existing session that belongs to a different provider than the one requested // to perform a login we should clear such session. - let existingSession = attempt.stateless ? null : await this.getSessionValue(sessionStorage); + let existingSession = await this.getSessionValue(sessionStorage); if (existingSession && existingSession.provider !== attempt.provider) { this.logger.debug( `Clearing existing session of another ("${existingSession.provider}") provider.` @@ -281,7 +274,7 @@ export class Authenticator { (authenticationResult.failed() && getErrorStatusCode(authenticationResult.error) === 401); if (existingSession && shouldClearSession) { sessionStorage.clear(); - } else if (!attempt.stateless && authenticationResult.shouldUpdateState()) { + } else if (authenticationResult.shouldUpdateState()) { const { idleTimeoutExpiration, lifespanExpiration } = this.calculateExpiry(existingSession); sessionStorage.set({ state: authenticationResult.state, diff --git a/x-pack/plugins/security/server/authentication/index.test.ts b/x-pack/plugins/security/server/authentication/index.test.ts index 0c1095b56e6e24..d0de6d571b7a04 100644 --- a/x-pack/plugins/security/server/authentication/index.test.ts +++ b/x-pack/plugins/security/server/authentication/index.test.ts @@ -10,7 +10,6 @@ jest.mock('./api_keys'); jest.mock('./authenticator'); import Boom from 'boom'; -import { errors } from 'elasticsearch'; import { first } from 'rxjs/operators'; import { @@ -27,7 +26,6 @@ import { AuthToolkit, IClusterClient, CoreSetup, - ElasticsearchErrorHelpers, KibanaRequest, LoggerFactory, ScopedClusterClient, @@ -289,67 +287,66 @@ describe('setupAuthentication()', () => { }); describe('getCurrentUser()', () => { - let getCurrentUser: (r: KibanaRequest) => Promise; + let getCurrentUser: (r: KibanaRequest) => AuthenticatedUser | null; beforeEach(async () => { getCurrentUser = (await setupAuthentication(mockSetupAuthenticationParams)).getCurrentUser; }); - it('returns `null` if Security is disabled', async () => { + it('returns `null` if Security is disabled', () => { mockSetupAuthenticationParams.license.isEnabled.mockReturnValue(false); - await expect(getCurrentUser(httpServerMock.createKibanaRequest())).resolves.toBe(null); + expect(getCurrentUser(httpServerMock.createKibanaRequest())).toBe(null); }); - it('fails if `authenticate` call fails', async () => { - const failureReason = new Error('Something went wrong'); - mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(failureReason); + it('returns user from the auth state.', () => { + const mockUser = mockAuthenticatedUser(); - await expect(getCurrentUser(httpServerMock.createKibanaRequest())).rejects.toBe( - failureReason - ); + const mockAuthGet = mockSetupAuthenticationParams.http.auth.get as jest.Mock; + mockAuthGet.mockReturnValue({ state: mockUser }); + + const mockRequest = httpServerMock.createKibanaRequest(); + expect(getCurrentUser(mockRequest)).toBe(mockUser); + expect(mockAuthGet).toHaveBeenCalledTimes(1); + expect(mockAuthGet).toHaveBeenCalledWith(mockRequest); }); - it('returns result of `authenticate` call.', async () => { - const mockUser = mockAuthenticatedUser(); - mockScopedClusterClient.callAsCurrentUser.mockResolvedValue(mockUser); + it('returns null if auth state is not available.', () => { + const mockAuthGet = mockSetupAuthenticationParams.http.auth.get as jest.Mock; + mockAuthGet.mockReturnValue({}); - await expect(getCurrentUser(httpServerMock.createKibanaRequest())).resolves.toBe(mockUser); + const mockRequest = httpServerMock.createKibanaRequest(); + expect(getCurrentUser(mockRequest)).toBeNull(); + expect(mockAuthGet).toHaveBeenCalledTimes(1); + expect(mockAuthGet).toHaveBeenCalledWith(mockRequest); }); }); describe('isAuthenticated()', () => { - let isAuthenticated: (r: KibanaRequest) => Promise; + let isAuthenticated: (r: KibanaRequest) => boolean; beforeEach(async () => { isAuthenticated = (await setupAuthentication(mockSetupAuthenticationParams)).isAuthenticated; }); - it('returns `true` if Security is disabled', async () => { - mockSetupAuthenticationParams.license.isEnabled.mockReturnValue(false); - - await expect(isAuthenticated(httpServerMock.createKibanaRequest())).resolves.toBe(true); - }); + it('returns `true` if request is authenticated', () => { + const mockIsAuthenticated = mockSetupAuthenticationParams.http.auth + .isAuthenticated as jest.Mock; + mockIsAuthenticated.mockReturnValue(true); - it('returns `true` if `authenticate` succeeds.', async () => { - const mockUser = mockAuthenticatedUser(); - mockScopedClusterClient.callAsCurrentUser.mockResolvedValue(mockUser); - - await expect(isAuthenticated(httpServerMock.createKibanaRequest())).resolves.toBe(true); - }); - - it('returns `false` if `authenticate` fails with 401.', async () => { - const failureReason = ElasticsearchErrorHelpers.decorateNotAuthorizedError(new Error()); - mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(failureReason); - - await expect(isAuthenticated(httpServerMock.createKibanaRequest())).resolves.toBe(false); + const mockRequest = httpServerMock.createKibanaRequest(); + expect(isAuthenticated(mockRequest)).toBe(true); + expect(mockIsAuthenticated).toHaveBeenCalledTimes(1); + expect(mockIsAuthenticated).toHaveBeenCalledWith(mockRequest); }); - it('fails if `authenticate` call fails with unknown reason', async () => { - const failureReason = new errors.BadRequest(); - mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(failureReason); + it('returns `false` if request is not authenticated', () => { + const mockIsAuthenticated = mockSetupAuthenticationParams.http.auth + .isAuthenticated as jest.Mock; + mockIsAuthenticated.mockReturnValue(false); - await expect(isAuthenticated(httpServerMock.createKibanaRequest())).rejects.toBe( - failureReason - ); + const mockRequest = httpServerMock.createKibanaRequest(); + expect(isAuthenticated(mockRequest)).toBe(false); + expect(mockIsAuthenticated).toHaveBeenCalledTimes(1); + expect(mockIsAuthenticated).toHaveBeenCalledWith(mockRequest); }); }); diff --git a/x-pack/plugins/security/server/authentication/index.ts b/x-pack/plugins/security/server/authentication/index.ts index 1002ad7709b804..4b73430ff13c48 100644 --- a/x-pack/plugins/security/server/authentication/index.ts +++ b/x-pack/plugins/security/server/authentication/index.ts @@ -55,14 +55,12 @@ export async function setupAuthentication({ * Retrieves currently authenticated user associated with the specified request. * @param request */ - const getCurrentUser = async (request: KibanaRequest) => { + const getCurrentUser = (request: KibanaRequest) => { if (!license.isEnabled()) { return null; } - return (await clusterClient - .asScoped(request) - .callAsCurrentUser('shield.authenticate')) as AuthenticatedUser; + return (http.auth.get(request).state ?? null) as AuthenticatedUser | null; }; const isValid = (sessionValue: ProviderSession) => { @@ -180,18 +178,6 @@ export async function setupAuthentication({ apiKeys.create(request, params), invalidateAPIKey: (request: KibanaRequest, params: InvalidateAPIKeyParams) => apiKeys.invalidate(request, params), - isAuthenticated: async (request: KibanaRequest) => { - try { - await getCurrentUser(request); - } catch (err) { - // Don't swallow server errors. - if (getErrorStatusCode(err) !== 401) { - throw err; - } - return false; - } - - return true; - }, + isAuthenticated: (request: KibanaRequest) => http.auth.isAuthenticated(request), }; } diff --git a/x-pack/plugins/security/server/authentication/providers/base.ts b/x-pack/plugins/security/server/authentication/providers/base.ts index 12253f8d8f548c..a40732768810d9 100644 --- a/x-pack/plugins/security/server/authentication/providers/base.ts +++ b/x-pack/plugins/security/server/authentication/providers/base.ts @@ -11,6 +11,7 @@ import { IClusterClient, Headers, } from '../../../../../../src/core/server'; +import { deepFreeze } from '../../../../../../src/core/utils'; import { AuthenticatedUser } from '../../../common/model'; import { AuthenticationResult } from '../authentication_result'; import { DeauthenticationResult } from '../deauthentication_result'; @@ -35,6 +36,11 @@ export type AuthenticationProviderSpecificOptions = Record; * Base class that all authentication providers should extend. */ export abstract class BaseAuthenticationProvider { + /** + * Type of the provider. + */ + static readonly type: string; + /** * Logger instance bound to a specific provider context. */ @@ -85,8 +91,13 @@ export abstract class BaseAuthenticationProvider { * @param [authHeaders] Optional `Headers` dictionary to send with the request. */ protected async getUser(request: KibanaRequest, authHeaders: Headers = {}) { - return (await this.options.client - .asScoped({ headers: { ...request.headers, ...authHeaders } }) - .callAsCurrentUser('shield.authenticate')) as AuthenticatedUser; + return deepFreeze({ + ...(await this.options.client + .asScoped({ headers: { ...request.headers, ...authHeaders } }) + .callAsCurrentUser('shield.authenticate')), + // We use `this.constructor` trick to get access to the static `type` field of the specific + // `BaseAuthenticationProvider` subclass. + authentication_provider: (this.constructor as any).type, + } as AuthenticatedUser); } } diff --git a/x-pack/plugins/security/server/authentication/providers/basic.ts b/x-pack/plugins/security/server/authentication/providers/basic.ts index 07d141b4e1b2b3..a8e4e8705a7a8d 100644 --- a/x-pack/plugins/security/server/authentication/providers/basic.ts +++ b/x-pack/plugins/security/server/authentication/providers/basic.ts @@ -34,6 +34,11 @@ interface ProviderState { * Provider that supports request authentication via Basic HTTP Authentication. */ export class BasicAuthenticationProvider extends BaseAuthenticationProvider { + /** + * Type of the provider. + */ + static readonly type = 'basic'; + /** * Performs initial login request using username and password. * @param request Request instance. diff --git a/x-pack/plugins/security/server/authentication/providers/kerberos.test.ts b/x-pack/plugins/security/server/authentication/providers/kerberos.test.ts index e609afb6ae3f30..e4b4df3feeae21 100644 --- a/x-pack/plugins/security/server/authentication/providers/kerberos.test.ts +++ b/x-pack/plugins/security/server/authentication/providers/kerberos.test.ts @@ -155,7 +155,7 @@ describe('KerberosAuthenticationProvider', () => { expect(request.headers.authorization).toBe('negotiate spnego'); expect(authenticationResult.succeeded()).toBe(true); - expect(authenticationResult.user).toBe(user); + expect(authenticationResult.user).toEqual({ ...user, authentication_provider: 'kerberos' }); expect(authenticationResult.authHeaders).toEqual({ authorization: 'Bearer some-token' }); expect(authenticationResult.authResponseHeaders).toBeUndefined(); expect(authenticationResult.state).toEqual({ @@ -193,7 +193,7 @@ describe('KerberosAuthenticationProvider', () => { expect(request.headers.authorization).toBe('negotiate spnego'); expect(authenticationResult.succeeded()).toBe(true); - expect(authenticationResult.user).toBe(user); + expect(authenticationResult.user).toEqual({ ...user, authentication_provider: 'kerberos' }); expect(authenticationResult.authHeaders).toEqual({ authorization: 'Bearer some-token' }); expect(authenticationResult.authResponseHeaders).toEqual({ 'WWW-Authenticate': 'Negotiate response-token', @@ -337,7 +337,7 @@ describe('KerberosAuthenticationProvider', () => { expect(request.headers).not.toHaveProperty('authorization'); expect(authenticationResult.succeeded()).toBe(true); expect(authenticationResult.authHeaders).toEqual({ authorization }); - expect(authenticationResult.user).toBe(user); + expect(authenticationResult.user).toEqual({ ...user, authentication_provider: 'kerberos' }); expect(authenticationResult.state).toBeUndefined(); }); @@ -370,7 +370,7 @@ describe('KerberosAuthenticationProvider', () => { expect(authenticationResult.succeeded()).toBe(true); expect(authenticationResult.authHeaders).toEqual({ authorization: 'Bearer newfoo' }); - expect(authenticationResult.user).toEqual(user); + expect(authenticationResult.user).toEqual({ ...user, authentication_provider: 'kerberos' }); expect(authenticationResult.state).toEqual({ accessToken: 'newfoo', refreshToken: 'newbar' }); expect(request.headers).not.toHaveProperty('authorization'); }); @@ -437,7 +437,7 @@ describe('KerberosAuthenticationProvider', () => { expect(request.headers.authorization).toBe('Bearer some-valid-token'); expect(authenticationResult.succeeded()).toBe(true); expect(authenticationResult.authHeaders).toBeUndefined(); - expect(authenticationResult.user).toBe(user); + expect(authenticationResult.user).toEqual({ ...user, authentication_provider: 'kerberos' }); expect(authenticationResult.state).toBeUndefined(); }); diff --git a/x-pack/plugins/security/server/authentication/providers/kerberos.ts b/x-pack/plugins/security/server/authentication/providers/kerberos.ts index 767eab7b4311d9..b8e3b7bc237901 100644 --- a/x-pack/plugins/security/server/authentication/providers/kerberos.ts +++ b/x-pack/plugins/security/server/authentication/providers/kerberos.ts @@ -43,6 +43,11 @@ const WWWAuthenticateHeaderName = 'WWW-Authenticate'; * Provider that supports Kerberos request authentication. */ export class KerberosAuthenticationProvider extends BaseAuthenticationProvider { + /** + * Type of the provider. + */ + static readonly type = 'kerberos'; + /** * Performs Kerberos request authentication. * @param request Request instance. diff --git a/x-pack/plugins/security/server/authentication/providers/oidc.test.ts b/x-pack/plugins/security/server/authentication/providers/oidc.test.ts index dd4f6820f89f32..dae37749558591 100644 --- a/x-pack/plugins/security/server/authentication/providers/oidc.test.ts +++ b/x-pack/plugins/security/server/authentication/providers/oidc.test.ts @@ -311,7 +311,7 @@ describe('OIDCAuthenticationProvider', () => { expect(request.headers).not.toHaveProperty('authorization'); expect(authenticationResult.succeeded()).toBe(true); expect(authenticationResult.authHeaders).toEqual({ authorization }); - expect(authenticationResult.user).toBe(user); + expect(authenticationResult.user).toEqual({ ...user, authentication_provider: 'oidc' }); expect(authenticationResult.state).toBeUndefined(); }); @@ -380,7 +380,7 @@ describe('OIDCAuthenticationProvider', () => { expect(authenticationResult.authHeaders).toEqual({ authorization: 'Bearer new-access-token', }); - expect(authenticationResult.user).toBe(user); + expect(authenticationResult.user).toEqual({ ...user, authentication_provider: 'oidc' }); expect(authenticationResult.state).toEqual({ accessToken: 'new-access-token', refreshToken: 'new-refresh-token', @@ -492,7 +492,7 @@ describe('OIDCAuthenticationProvider', () => { expect(request.headers.authorization).toBe('Bearer some-valid-token'); expect(authenticationResult.succeeded()).toBe(true); expect(authenticationResult.authHeaders).toBeUndefined(); - expect(authenticationResult.user).toBe(user); + expect(authenticationResult.user).toEqual({ ...user, authentication_provider: 'oidc' }); expect(authenticationResult.state).toBeUndefined(); }); diff --git a/x-pack/plugins/security/server/authentication/providers/oidc.ts b/x-pack/plugins/security/server/authentication/providers/oidc.ts index 37371236453796..f13a2ec05231a2 100644 --- a/x-pack/plugins/security/server/authentication/providers/oidc.ts +++ b/x-pack/plugins/security/server/authentication/providers/oidc.ts @@ -6,9 +6,9 @@ import Boom from 'boom'; import type from 'type-detect'; -import { canRedirectRequest } from '../'; import { KibanaRequest } from '../../../../../../src/core/server'; import { AuthenticationResult } from '../authentication_result'; +import { canRedirectRequest } from '../can_redirect_request'; import { DeauthenticationResult } from '../deauthentication_result'; import { Tokens, TokenPair } from '../tokens'; import { @@ -62,6 +62,11 @@ interface ProviderState extends Partial { * Provider that supports authentication using an OpenID Connect realm in Elasticsearch. */ export class OIDCAuthenticationProvider extends BaseAuthenticationProvider { + /** + * Type of the provider. + */ + static readonly type = 'oidc'; + /** * Specifies Elasticsearch OIDC realm name that Kibana should use. */ diff --git a/x-pack/plugins/security/server/authentication/providers/pki.test.ts b/x-pack/plugins/security/server/authentication/providers/pki.test.ts index 76442733e7368e..a2dda88c4680c3 100644 --- a/x-pack/plugins/security/server/authentication/providers/pki.test.ts +++ b/x-pack/plugins/security/server/authentication/providers/pki.test.ts @@ -200,7 +200,7 @@ describe('PKIAuthenticationProvider', () => { expect(request.headers).not.toHaveProperty('authorization'); expect(authenticationResult.succeeded()).toBe(true); - expect(authenticationResult.user).toBe(user); + expect(authenticationResult.user).toEqual({ ...user, authentication_provider: 'pki' }); expect(authenticationResult.authHeaders).toEqual({ authorization: 'Bearer access-token' }); expect(authenticationResult.authResponseHeaders).toBeUndefined(); expect(authenticationResult.state).toEqual({ @@ -242,7 +242,7 @@ describe('PKIAuthenticationProvider', () => { expect(request.headers).not.toHaveProperty('authorization'); expect(authenticationResult.succeeded()).toBe(true); - expect(authenticationResult.user).toBe(user); + expect(authenticationResult.user).toEqual({ ...user, authentication_provider: 'pki' }); expect(authenticationResult.authHeaders).toEqual({ authorization: 'Bearer access-token' }); expect(authenticationResult.authResponseHeaders).toBeUndefined(); expect(authenticationResult.state).toEqual({ @@ -287,7 +287,7 @@ describe('PKIAuthenticationProvider', () => { expect(request.headers).not.toHaveProperty('authorization'); expect(authenticationResult.succeeded()).toBe(true); - expect(authenticationResult.user).toBe(user); + expect(authenticationResult.user).toEqual({ ...user, authentication_provider: 'pki' }); expect(authenticationResult.authHeaders).toEqual({ authorization: 'Bearer access-token' }); expect(authenticationResult.authResponseHeaders).toBeUndefined(); expect(authenticationResult.state).toEqual({ @@ -331,7 +331,7 @@ describe('PKIAuthenticationProvider', () => { expect(request.headers).not.toHaveProperty('authorization'); expect(authenticationResult.succeeded()).toBe(true); - expect(authenticationResult.user).toBe(user); + expect(authenticationResult.user).toEqual({ ...user, authentication_provider: 'pki' }); expect(authenticationResult.authHeaders).toEqual({ authorization: 'Bearer access-token' }); expect(authenticationResult.authResponseHeaders).toBeUndefined(); expect(authenticationResult.state).toEqual({ @@ -448,7 +448,7 @@ describe('PKIAuthenticationProvider', () => { expect(authenticationResult.authHeaders).toEqual({ authorization: `Bearer ${state.accessToken}`, }); - expect(authenticationResult.user).toBe(user); + expect(authenticationResult.user).toEqual({ ...user, authentication_provider: 'pki' }); expect(authenticationResult.state).toBeUndefined(); }); @@ -491,7 +491,7 @@ describe('PKIAuthenticationProvider', () => { expect(request.headers.authorization).toBe('Bearer some-valid-token'); expect(authenticationResult.succeeded()).toBe(true); expect(authenticationResult.authHeaders).toBeUndefined(); - expect(authenticationResult.user).toBe(user); + expect(authenticationResult.user).toEqual({ ...user, authentication_provider: 'pki' }); expect(authenticationResult.state).toBeUndefined(); }); diff --git a/x-pack/plugins/security/server/authentication/providers/pki.ts b/x-pack/plugins/security/server/authentication/providers/pki.ts index c7d431422a2485..6d5aa9f01f2ea3 100644 --- a/x-pack/plugins/security/server/authentication/providers/pki.ts +++ b/x-pack/plugins/security/server/authentication/providers/pki.ts @@ -44,6 +44,11 @@ function getRequestAuthenticationScheme(request: KibanaRequest) { * Provider that supports PKI request authentication. */ export class PKIAuthenticationProvider extends BaseAuthenticationProvider { + /** + * Type of the provider. + */ + static readonly type = 'pki'; + /** * Performs PKI request authentication. * @param request Request instance. diff --git a/x-pack/plugins/security/server/authentication/providers/saml.test.ts b/x-pack/plugins/security/server/authentication/providers/saml.test.ts index a5d1010a1bec80..c4fdf0b25061b7 100644 --- a/x-pack/plugins/security/server/authentication/providers/saml.test.ts +++ b/x-pack/plugins/security/server/authentication/providers/saml.test.ts @@ -635,7 +635,7 @@ describe('SAMLAuthenticationProvider', () => { expect(request.headers).not.toHaveProperty('authorization'); expect(authenticationResult.succeeded()).toBe(true); expect(authenticationResult.authHeaders).toEqual({ authorization }); - expect(authenticationResult.user).toBe(user); + expect(authenticationResult.user).toEqual({ ...user, authentication_provider: 'saml' }); expect(authenticationResult.state).toBeUndefined(); }); @@ -696,7 +696,7 @@ describe('SAMLAuthenticationProvider', () => { expect(authenticationResult.authHeaders).toEqual({ authorization: 'Bearer new-access-token', }); - expect(authenticationResult.user).toBe(user); + expect(authenticationResult.user).toEqual({ ...user, authentication_provider: 'saml' }); expect(authenticationResult.state).toEqual({ username: 'user', accessToken: 'new-access-token', @@ -842,7 +842,7 @@ describe('SAMLAuthenticationProvider', () => { expect(request.headers.authorization).toBe('Bearer some-valid-token'); expect(authenticationResult.succeeded()).toBe(true); expect(authenticationResult.authHeaders).toBeUndefined(); - expect(authenticationResult.user).toBe(user); + expect(authenticationResult.user).toEqual({ ...user, authentication_provider: 'saml' }); expect(authenticationResult.state).toBeUndefined(); }); diff --git a/x-pack/plugins/security/server/authentication/providers/saml.ts b/x-pack/plugins/security/server/authentication/providers/saml.ts index faa19239fcc3b1..a817159fcd445c 100644 --- a/x-pack/plugins/security/server/authentication/providers/saml.ts +++ b/x-pack/plugins/security/server/authentication/providers/saml.ts @@ -10,8 +10,8 @@ import { KibanaRequest } from '../../../../../../src/core/server'; import { AuthenticationResult } from '../authentication_result'; import { DeauthenticationResult } from '../deauthentication_result'; import { AuthenticationProviderOptions, BaseAuthenticationProvider } from './base'; +import { canRedirectRequest } from '../can_redirect_request'; import { Tokens, TokenPair } from '../tokens'; -import { canRedirectRequest } from '..'; /** * The state supported by the provider (for the SAML handshake or established session). @@ -66,6 +66,11 @@ export function isSAMLRequestQuery(query: any): query is { SAMLRequest: string } * Provider that supports SAML request authentication. */ export class SAMLAuthenticationProvider extends BaseAuthenticationProvider { + /** + * Type of the provider. + */ + static readonly type = 'saml'; + /** * Specifies Elasticsearch SAML realm name that Kibana should use. */ diff --git a/x-pack/plugins/security/server/authentication/providers/token.test.ts b/x-pack/plugins/security/server/authentication/providers/token.test.ts index 3d377140cb42e2..0a55219e25d910 100644 --- a/x-pack/plugins/security/server/authentication/providers/token.test.ts +++ b/x-pack/plugins/security/server/authentication/providers/token.test.ts @@ -48,7 +48,7 @@ describe('TokenAuthenticationProvider', () => { const authenticationResult = await provider.login(request, credentials); expect(authenticationResult.succeeded()).toBe(true); - expect(authenticationResult.user).toEqual(user); + expect(authenticationResult.user).toEqual({ ...user, authentication_provider: 'token' }); expect(authenticationResult.state).toEqual(tokenPair); expect(authenticationResult.authHeaders).toEqual({ authorization }); }); @@ -140,7 +140,7 @@ describe('TokenAuthenticationProvider', () => { const authenticationResult = await provider.authenticate(request); expect(authenticationResult.succeeded()).toBe(true); - expect(authenticationResult.user).toEqual(user); + expect(authenticationResult.user).toEqual({ ...user, authentication_provider: 'token' }); expect(authenticationResult.authHeaders).toBeUndefined(); expect(authenticationResult.state).toBeUndefined(); }); @@ -158,7 +158,7 @@ describe('TokenAuthenticationProvider', () => { const authenticationResult = await provider.authenticate(request, tokenPair); expect(authenticationResult.succeeded()).toBe(true); - expect(authenticationResult.user).toEqual(user); + expect(authenticationResult.user).toEqual({ ...user, authentication_provider: 'token' }); expect(authenticationResult.state).toBeUndefined(); expect(authenticationResult.authHeaders).toEqual({ authorization }); expect(request.headers).not.toHaveProperty('authorization'); @@ -192,7 +192,7 @@ describe('TokenAuthenticationProvider', () => { sinon.assert.calledOnce(mockOptions.tokens.refresh); expect(authenticationResult.succeeded()).toBe(true); - expect(authenticationResult.user).toEqual(user); + expect(authenticationResult.user).toEqual({ ...user, authentication_provider: 'token' }); expect(authenticationResult.state).toEqual({ accessToken: 'newfoo', refreshToken: 'newbar' }); expect(authenticationResult.authHeaders).toEqual({ authorization: 'Bearer newfoo' }); expect(request.headers).not.toHaveProperty('authorization'); @@ -231,7 +231,7 @@ describe('TokenAuthenticationProvider', () => { const authenticationResult = await provider.authenticate(request, tokenPair); expect(authenticationResult.succeeded()).toBe(true); - expect(authenticationResult.user).toEqual(user); + expect(authenticationResult.user).toEqual({ ...user, authentication_provider: 'token' }); expect(authenticationResult.state).toBeUndefined(); expect(authenticationResult.authHeaders).toBeUndefined(); expect(request.headers.authorization).toEqual('Bearer foo-from-header'); diff --git a/x-pack/plugins/security/server/authentication/providers/token.ts b/x-pack/plugins/security/server/authentication/providers/token.ts index c5f8f07e50b11c..03fd003e2cbde2 100644 --- a/x-pack/plugins/security/server/authentication/providers/token.ts +++ b/x-pack/plugins/security/server/authentication/providers/token.ts @@ -9,8 +9,8 @@ import { KibanaRequest } from '../../../../../../src/core/server'; import { AuthenticationResult } from '../authentication_result'; import { DeauthenticationResult } from '../deauthentication_result'; import { BaseAuthenticationProvider } from './base'; +import { canRedirectRequest } from '../can_redirect_request'; import { Tokens, TokenPair } from '../tokens'; -import { canRedirectRequest } from '..'; /** * Describes the parameters that are required by the provider to process the initial login request. @@ -29,6 +29,11 @@ type ProviderState = TokenPair; * Provider that supports token-based request authentication. */ export class TokenAuthenticationProvider extends BaseAuthenticationProvider { + /** + * Type of the provider. + */ + static readonly type = 'token'; + /** * Performs initial login request using username and password. * @param request Request instance. diff --git a/x-pack/plugins/security/server/routes/authentication/common.test.ts b/x-pack/plugins/security/server/routes/authentication/common.test.ts index 5d5868d4cc5936..4666b5abad756b 100644 --- a/x-pack/plugins/security/server/routes/authentication/common.test.ts +++ b/x-pack/plugins/security/server/routes/authentication/common.test.ts @@ -176,20 +176,9 @@ describe('Common authentication routes', () => { expect(routeConfig.validate).toBe(false); }); - it('returns 500 if cannot retrieve current user due to unhandled exception.', async () => { - const unhandledException = new Error('Something went wrong.'); - authc.getCurrentUser.mockRejectedValue(unhandledException); - - const response = await routeHandler(mockContext, mockRequest, kibanaResponseFactory); - - expect(response.status).toBe(500); - expect(response.payload).toEqual(unhandledException); - expect(authc.getCurrentUser).toHaveBeenCalledWith(mockRequest); - }); - it('returns current user.', async () => { const mockUser = mockAuthenticatedUser(); - authc.getCurrentUser.mockResolvedValue(mockUser); + authc.getCurrentUser.mockReturnValue(mockUser); const response = await routeHandler(mockContext, mockRequest, kibanaResponseFactory); diff --git a/x-pack/plugins/security/server/routes/authentication/common.ts b/x-pack/plugins/security/server/routes/authentication/common.ts index cb4ec196459eee..c9856e9dff7f1e 100644 --- a/x-pack/plugins/security/server/routes/authentication/common.ts +++ b/x-pack/plugins/security/server/routes/authentication/common.ts @@ -59,7 +59,7 @@ export function defineCommonRoutes({ router, authc, basePath, logger }: RouteDef for (const path of ['/internal/security/me', '/api/security/v1/me']) { router.get( { path, validate: false }, - createLicensedRouteHandler(async (context, request, response) => { + createLicensedRouteHandler((context, request, response) => { if (path === '/api/security/v1/me') { logger.warn( `The "${basePath.serverBasePath}${path}" endpoint is deprecated and will be removed in the next major version.`, @@ -67,11 +67,7 @@ export function defineCommonRoutes({ router, authc, basePath, logger }: RouteDef ); } - try { - return response.ok({ body: (await authc.getCurrentUser(request)) as any }); - } catch (error) { - return response.customError(wrapIntoCustomErrorResponse(error)); - } + return response.ok({ body: authc.getCurrentUser(request)! }); }) ); } diff --git a/x-pack/plugins/security/server/routes/users/change_password.test.ts b/x-pack/plugins/security/server/routes/users/change_password.test.ts index 80a25e03ede62a..34509edc2e9d23 100644 --- a/x-pack/plugins/security/server/routes/users/change_password.test.ts +++ b/x-pack/plugins/security/server/routes/users/change_password.test.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { errors } from 'elasticsearch'; import { ObjectType } from '@kbn/config-schema'; import { IClusterClient, @@ -13,6 +14,7 @@ import { RequestHandler, RequestHandlerContext, RouteConfig, + ScopeableRequest, } from '../../../../../../src/core/server'; import { LICENSE_CHECK_STATE } from '../../../../licensing/server'; import { Authentication, AuthenticationResult } from '../../authentication'; @@ -38,10 +40,7 @@ describe('Change password', () => { let routeConfig: RouteConfig; let mockContext: RequestHandlerContext; - function checkPasswordChangeAPICall( - username: string, - request: ReturnType - ) { + function checkPasswordChangeAPICall(username: string, request: ScopeableRequest) { expect(mockClusterClient.asScoped).toHaveBeenCalledTimes(1); expect(mockClusterClient.asScoped).toHaveBeenCalledWith(request); expect(mockScopedClusterClient.callAsCurrentUser).toHaveBeenCalledTimes(1); @@ -55,8 +54,14 @@ describe('Change password', () => { router = httpServiceMock.createRouter(); authc = authenticationMock.create(); - authc.getCurrentUser.mockResolvedValue(mockAuthenticatedUser({ username: 'user' })); + authc.getCurrentUser.mockReturnValue(mockAuthenticatedUser({ username: 'user' })); authc.login.mockResolvedValue(AuthenticationResult.succeeded(mockAuthenticatedUser())); + authc.getSessionInfo.mockResolvedValue({ + now: Date.now(), + idleTimeoutExpiration: null, + lifespanExpiration: null, + provider: 'basic', + }); mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient(); mockClusterClient = elasticsearchServiceMock.createClusterClient(); @@ -122,14 +127,24 @@ describe('Change password', () => { }); it('returns 403 if old password is wrong.', async () => { - const loginFailureReason = new Error('Something went wrong.'); - authc.login.mockResolvedValue(AuthenticationResult.failed(loginFailureReason)); + const changePasswordFailure = new (errors.AuthenticationException as any)('Unauthorized', { + body: { error: { header: { 'WWW-Authenticate': 'Negotiate' } } }, + }); + mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(changePasswordFailure); const response = await routeHandler(mockContext, mockRequest, kibanaResponseFactory); expect(response.status).toBe(403); - expect(response.payload).toEqual(loginFailureReason); - expect(mockScopedClusterClient.callAsCurrentUser).not.toHaveBeenCalled(); + expect(response.payload).toEqual(changePasswordFailure); + + expect(mockScopedClusterClient.callAsCurrentUser).toHaveBeenCalledTimes(1); + expect(mockClusterClient.asScoped).toHaveBeenCalledTimes(1); + expect(mockClusterClient.asScoped).toHaveBeenCalledWith({ + headers: { + ...mockRequest.headers, + authorization: `Basic ${Buffer.from(`${username}:old-password`).toString('base64')}`, + }, + }); }); it(`returns 401 if user can't authenticate with new password.`, async () => { @@ -148,10 +163,15 @@ describe('Change password', () => { expect(response.status).toBe(401); expect(response.payload).toEqual(loginFailureReason); - checkPasswordChangeAPICall(username, mockRequest); + checkPasswordChangeAPICall(username, { + headers: { + ...mockRequest.headers, + authorization: `Basic ${Buffer.from(`${username}:old-password`).toString('base64')}`, + }, + }); }); - it('returns 500 if password update request fails.', async () => { + it('returns 500 if password update request fails with non-401 error.', async () => { const failureReason = new Error('Request failed.'); mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(failureReason); @@ -160,7 +180,12 @@ describe('Change password', () => { expect(response.status).toBe(500); expect(response.payload).toEqual(failureReason); - checkPasswordChangeAPICall(username, mockRequest); + checkPasswordChangeAPICall(username, { + headers: { + ...mockRequest.headers, + authorization: `Basic ${Buffer.from(`${username}:old-password`).toString('base64')}`, + }, + }); }); it('successfully changes own password if provided old password is correct.', async () => { @@ -169,7 +194,62 @@ describe('Change password', () => { expect(response.status).toBe(204); expect(response.payload).toBeUndefined(); - checkPasswordChangeAPICall(username, mockRequest); + checkPasswordChangeAPICall(username, { + headers: { + ...mockRequest.headers, + authorization: `Basic ${Buffer.from(`${username}:old-password`).toString('base64')}`, + }, + }); + + expect(authc.login).toHaveBeenCalledTimes(1); + expect(authc.login).toHaveBeenCalledWith(mockRequest, { + provider: 'basic', + value: { username, password: 'new-password' }, + }); + }); + + it('successfully changes own password if provided old password is correct for non-basic provider.', async () => { + const mockUser = mockAuthenticatedUser({ + username: 'user', + authentication_provider: 'token', + }); + authc.getCurrentUser.mockReturnValue(mockUser); + authc.login.mockResolvedValue(AuthenticationResult.succeeded(mockUser)); + + const response = await routeHandler(mockContext, mockRequest, kibanaResponseFactory); + + expect(response.status).toBe(204); + expect(response.payload).toBeUndefined(); + + checkPasswordChangeAPICall(username, { + headers: { + ...mockRequest.headers, + authorization: `Basic ${Buffer.from(`${username}:old-password`).toString('base64')}`, + }, + }); + + expect(authc.login).toHaveBeenCalledTimes(1); + expect(authc.login).toHaveBeenCalledWith(mockRequest, { + provider: 'token', + value: { username, password: 'new-password' }, + }); + }); + + it('successfully changes own password but does not re-login if current session does not exist.', async () => { + authc.getSessionInfo.mockResolvedValue(null); + const response = await routeHandler(mockContext, mockRequest, kibanaResponseFactory); + + expect(response.status).toBe(204); + expect(response.payload).toBeUndefined(); + + checkPasswordChangeAPICall(username, { + headers: { + ...mockRequest.headers, + authorization: `Basic ${Buffer.from(`${username}:old-password`).toString('base64')}`, + }, + }); + + expect(authc.login).not.toHaveBeenCalled(); }); }); diff --git a/x-pack/plugins/security/server/routes/users/change_password.ts b/x-pack/plugins/security/server/routes/users/change_password.ts index b9d04b4bd1e0e5..fc3ca4573d5003 100644 --- a/x-pack/plugins/security/server/routes/users/change_password.ts +++ b/x-pack/plugins/security/server/routes/users/change_password.ts @@ -5,7 +5,8 @@ */ import { schema } from '@kbn/config-schema'; -import { wrapIntoCustomErrorResponse } from '../../errors'; +import { canUserChangePassword } from '../../../common/model'; +import { getErrorStatusCode, wrapIntoCustomErrorResponse } from '../../errors'; import { createLicensedRouteHandler } from '../licensed_route_handler'; import { RouteDefinitionParams } from '..'; @@ -13,7 +14,6 @@ export function defineChangeUserPasswordRoutes({ authc, router, clusterClient, - config, }: RouteDefinitionParams) { router.post( { @@ -27,54 +27,65 @@ export function defineChangeUserPasswordRoutes({ }, }, createLicensedRouteHandler(async (context, request, response) => { - const username = request.params.username; - const { password, newPassword } = request.body; - const isCurrentUser = username === (await authc.getCurrentUser(request))!.username; + const { username } = request.params; + const { password: currentPassword, newPassword } = request.body; - // We should prefer `token` over `basic` if possible. - const providerToLoginWith = config.authc.providers.includes('token') ? 'token' : 'basic'; + const currentUser = authc.getCurrentUser(request); + const isUserChangingOwnPassword = + currentUser && currentUser.username === username && canUserChangePassword(currentUser); + const currentSession = isUserChangingOwnPassword ? await authc.getSessionInfo(request) : null; - // If user tries to change own password, let's check if old password is valid first by trying - // to login. - if (isCurrentUser) { - try { - const authenticationResult = await authc.login(request, { - provider: providerToLoginWith, - value: { username, password }, - // We shouldn't alter authentication state just yet. - stateless: true, - }); - - if (!authenticationResult.succeeded()) { - return response.forbidden({ body: authenticationResult.error }); - } - } catch (error) { - return response.customError(wrapIntoCustomErrorResponse(error)); - } - } + // If user is changing their own password they should provide a proof of knowledge their + // current password via sending it in `Authorization: Basic base64(username:current password)` + // HTTP header no matter how they logged in to Kibana. + const scopedClusterClient = clusterClient.asScoped( + isUserChangingOwnPassword + ? { + headers: { + ...request.headers, + authorization: `Basic ${Buffer.from(`${username}:${currentPassword}`).toString( + 'base64' + )}`, + }, + } + : request + ); try { - await clusterClient.asScoped(request).callAsCurrentUser('shield.changePassword', { + await scopedClusterClient.callAsCurrentUser('shield.changePassword', { username, body: { password: newPassword }, }); + } catch (error) { + // This may happen only if user's credentials are rejected meaning that current password + // isn't correct. + if (isUserChangingOwnPassword && getErrorStatusCode(error) === 401) { + return response.forbidden({ body: error }); + } + + return response.customError(wrapIntoCustomErrorResponse(error)); + } - // Now we authenticate user with the new password again updating current session if any. - if (isCurrentUser) { + // If user previously had an active session and changed their own password we should re-login + // user with the new password and update session. We check this since it's possible to update + // password even if user is authenticated via HTTP headers and hence doesn't have an active + // session and in such cases we shouldn't create a new one. + if (isUserChangingOwnPassword && currentSession) { + try { const authenticationResult = await authc.login(request, { - provider: providerToLoginWith, + provider: currentUser!.authentication_provider, value: { username, password: newPassword }, }); if (!authenticationResult.succeeded()) { return response.unauthorized({ body: authenticationResult.error }); } + } catch (error) { + return response.customError(wrapIntoCustomErrorResponse(error)); } - - return response.noContent(); - } catch (error) { - return response.customError(wrapIntoCustomErrorResponse(error)); } + + return response.noContent(); }) ); } diff --git a/x-pack/test/api_integration/apis/security/basic_login.js b/x-pack/test/api_integration/apis/security/basic_login.js index 62deedad6c35c2..d4b41603944f6f 100644 --- a/x-pack/test/api_integration/apis/security/basic_login.js +++ b/x-pack/test/api_integration/apis/security/basic_login.js @@ -126,6 +126,7 @@ export default function({ getService }) { 'enabled', 'authentication_realm', 'lookup_realm', + 'authentication_provider', ]); expect(apiResponse.body.username).to.be(validUsername); }); @@ -165,6 +166,7 @@ export default function({ getService }) { 'enabled', 'authentication_realm', 'lookup_realm', + 'authentication_provider', ]); expect(apiResponse.body.username).to.be(validUsername); }); diff --git a/x-pack/test/kerberos_api_integration/apis/security/kerberos_login.ts b/x-pack/test/kerberos_api_integration/apis/security/kerberos_login.ts index 203f90c55aa82b..570d7026cf99e0 100644 --- a/x-pack/test/kerberos_api_integration/apis/security/kerberos_login.ts +++ b/x-pack/test/kerberos_api_integration/apis/security/kerberos_login.ts @@ -74,6 +74,7 @@ export default function({ getService }: FtrProviderContext) { expect(user.username).to.eql(username); expect(user.authentication_realm).to.eql({ name: 'reserved', type: 'reserved' }); + expect(user.authentication_provider).to.eql('basic'); }); describe('initiating SPNEGO', () => { @@ -129,6 +130,7 @@ export default function({ getService }: FtrProviderContext) { enabled: true, authentication_realm: { name: 'kerb1', type: 'kerberos' }, lookup_realm: { name: 'kerb1', type: 'kerberos' }, + authentication_provider: 'kerberos', }); }); diff --git a/x-pack/test/oidc_api_integration/apis/authorization_code_flow/oidc_auth.js b/x-pack/test/oidc_api_integration/apis/authorization_code_flow/oidc_auth.js index 57bcd1b041c494..094537fd614366 100644 --- a/x-pack/test/oidc_api_integration/apis/authorization_code_flow/oidc_auth.js +++ b/x-pack/test/oidc_api_integration/apis/authorization_code_flow/oidc_auth.js @@ -173,6 +173,7 @@ export default function({ getService }) { 'enabled', 'authentication_realm', 'lookup_realm', + 'authentication_provider', ]); expect(apiResponse.body.username).to.be('user1'); @@ -222,6 +223,7 @@ export default function({ getService }) { 'enabled', 'authentication_realm', 'lookup_realm', + 'authentication_provider', ]); expect(apiResponse.body.username).to.be('user2'); diff --git a/x-pack/test/oidc_api_integration/apis/implicit_flow/oidc_auth.ts b/x-pack/test/oidc_api_integration/apis/implicit_flow/oidc_auth.ts index 1f5a64835416aa..7d013e97732f9f 100644 --- a/x-pack/test/oidc_api_integration/apis/implicit_flow/oidc_auth.ts +++ b/x-pack/test/oidc_api_integration/apis/implicit_flow/oidc_auth.ts @@ -142,6 +142,7 @@ export default function({ getService }: FtrProviderContext) { 'enabled', 'authentication_realm', 'lookup_realm', + 'authentication_provider', ]); expect(apiResponse.body.username).to.be('user1'); diff --git a/x-pack/test/pki_api_integration/apis/security/pki_auth.ts b/x-pack/test/pki_api_integration/apis/security/pki_auth.ts index 186ed824b3b6c7..1ae7488fcf3790 100644 --- a/x-pack/test/pki_api_integration/apis/security/pki_auth.ts +++ b/x-pack/test/pki_api_integration/apis/security/pki_auth.ts @@ -90,6 +90,7 @@ export default function({ getService }: FtrProviderContext) { expect(user.username).to.eql(username); expect(user.authentication_realm).to.eql({ name: 'reserved', type: 'reserved' }); + expect(user.authentication_provider).to.eql('basic'); }); it('should properly set cookie and authenticate user', async () => { @@ -118,6 +119,7 @@ export default function({ getService }: FtrProviderContext) { }, authentication_realm: { name: 'pki1', type: 'pki' }, lookup_realm: { name: 'pki1', type: 'pki' }, + authentication_provider: 'pki', }); // Cookie should be accepted. @@ -160,6 +162,7 @@ export default function({ getService }: FtrProviderContext) { }, authentication_realm: { name: 'pki1', type: 'pki' }, lookup_realm: { name: 'pki1', type: 'pki' }, + authentication_provider: 'pki', }); checkCookieIsSet(request.cookie(response.headers['set-cookie'][0])!); diff --git a/x-pack/test/saml_api_integration/apis/security/saml_login.ts b/x-pack/test/saml_api_integration/apis/security/saml_login.ts index 0436d59906ea87..6ede8aadeb5a7b 100644 --- a/x-pack/test/saml_api_integration/apis/security/saml_login.ts +++ b/x-pack/test/saml_api_integration/apis/security/saml_login.ts @@ -56,6 +56,7 @@ export default function({ getService }: FtrProviderContext) { 'enabled', 'authentication_realm', 'lookup_realm', + 'authentication_provider', ]); expect(apiResponse.body.username).to.be('a@b.c'); @@ -88,6 +89,7 @@ export default function({ getService }: FtrProviderContext) { expect(user.username).to.eql(username); expect(user.authentication_realm).to.eql({ name: 'reserved', type: 'reserved' }); + expect(user.authentication_provider).to.eql('basic'); }); describe('capture URL fragment', () => { From a0b73cf2996863491b75f002d2eaddc86f26c6a2 Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Wed, 5 Feb 2020 13:43:09 +0100 Subject: [PATCH 21/22] improve validation on tuncate field formater editor (#56521) Co-authored-by: Elastic Machine --- .../__snapshots__/truncate.test.js.snap | 1 + .../editors/truncate/truncate.js | 11 +++- .../editors/truncate/truncate.test.js | 56 +++++++++++++++++++ .../field_formats/converters/truncate.test.ts | 7 +++ 4 files changed, 73 insertions(+), 2 deletions(-) diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/__snapshots__/truncate.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/__snapshots__/truncate.test.js.snap index c0954491a2a470..729487dfae5d79 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/__snapshots__/truncate.test.js.snap +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/__snapshots__/truncate.test.js.snap @@ -21,6 +21,7 @@ exports[`TruncateFormatEditor should render normally 1`] = ` > diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.js index fdae8627ead69a..9a9b6c954b78d0 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.js +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.js @@ -38,7 +38,7 @@ export class TruncateFormatEditor extends DefaultFormatEditor { } render() { - const { formatParams } = this.props; + const { formatParams, onError } = this.props; const { error, samples } = this.state; return ( @@ -55,8 +55,15 @@ export class TruncateFormatEditor extends DefaultFormatEditor { > { - this.onChange({ fieldLength: e.target.value ? Number(e.target.value) : null }); + if (e.target.checkValidity()) { + this.onChange({ + fieldLength: e.target.value ? Number(e.target.value) : null, + }); + } else { + onError(e.target.validationMessage); + } }} isInvalid={!!error} /> diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.test.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.test.js index e98dd4edca386c..7ab6f2a9cbeb0d 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.test.js +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.test.js @@ -19,6 +19,7 @@ import React from 'react'; import { shallow } from 'enzyme'; +import { EuiFieldNumber } from '@elastic/eui'; import { TruncateFormatEditor } from './truncate'; @@ -34,6 +35,11 @@ const onChange = jest.fn(); const onError = jest.fn(); describe('TruncateFormatEditor', () => { + beforeEach(() => { + onChange.mockClear(); + onError.mockClear(); + }); + it('should have a formatId', () => { expect(TruncateFormatEditor.formatId).toEqual('truncate'); }); @@ -50,4 +56,54 @@ describe('TruncateFormatEditor', () => { ); expect(component).toMatchSnapshot(); }); + + it('should fire error, when input is invalid', async () => { + const component = shallow( + + ); + const input = component.find(EuiFieldNumber); + + const changeEvent = { + target: { + value: '123.3', + checkValidity: () => false, + validationMessage: 'Error!', + }, + }; + await input.invoke('onChange')(changeEvent); + + expect(onError).toBeCalledWith(changeEvent.target.validationMessage); + expect(onChange).not.toBeCalled(); + }); + + it('should fire change, when input changed and is valid', async () => { + const component = shallow( + + ); + const input = component.find(EuiFieldNumber); + + const changeEvent = { + target: { + value: '123', + checkValidity: () => true, + validationMessage: null, + }, + }; + onError.mockClear(); + await input.invoke('onChange')(changeEvent); + expect(onError).not.toBeCalled(); + expect(onChange).toBeCalledWith({ fieldLength: 123 }); + }); }); diff --git a/src/plugins/data/common/field_formats/converters/truncate.test.ts b/src/plugins/data/common/field_formats/converters/truncate.test.ts index 472d9673346d7d..3a0abc918fa98f 100644 --- a/src/plugins/data/common/field_formats/converters/truncate.test.ts +++ b/src/plugins/data/common/field_formats/converters/truncate.test.ts @@ -43,4 +43,11 @@ describe('String TruncateFormat', () => { expect(truncate.convert('This is some text')).toBe('This is some text'); }); + + test('does not truncate whole text when non integer is passed in', () => { + // https://github.com/elastic/kibana/issues/29648 + const truncate = new TruncateFormat({ fieldLength: 3.2 }, jest.fn()); + + expect(truncate.convert('This is some text')).toBe('Thi...'); + }); }); From 3cb85d407027a118103ff02c90747673529f1af1 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Wed, 5 Feb 2020 13:53:34 +0100 Subject: [PATCH 22/22] [Uptime] Kuery Bar Filters break overview page (#56793) * update filter * fix status panel not using filter group --- .../components/connected/charts/ping_histogram.tsx | 9 +++++---- .../connected/charts/snapshot_container.tsx | 11 +++++++---- .../connected/pages/overview_container.ts | 11 ++++++++++- .../uptime/public/hooks/update_kuery_string.ts | 14 -------------- .../plugins/uptime/public/pages/overview.tsx | 14 ++++++++++++-- .../plugins/uptime/public/state/selectors/index.ts | 7 ++++++- 6 files changed, 40 insertions(+), 26 deletions(-) diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/charts/ping_histogram.tsx b/x-pack/legacy/plugins/uptime/public/components/connected/charts/ping_histogram.tsx index cbdd921a36e81b..50f91be4ff09f3 100644 --- a/x-pack/legacy/plugins/uptime/public/components/connected/charts/ping_histogram.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/connected/charts/ping_histogram.tsx @@ -19,7 +19,7 @@ import { useUrlParams } from '../../../hooks'; type Props = ResponsiveWrapperProps & Pick & - DispatchProps & { lastRefresh: number; monitorId?: string }; + DispatchProps & { lastRefresh: number; monitorId?: string; esKuery?: string }; const PingHistogramContainer: React.FC = ({ data, @@ -28,6 +28,7 @@ const PingHistogramContainer: React.FC = ({ lastRefresh, height, loading, + esKuery, }) => { const [getUrlParams] = useUrlParams(); const { @@ -36,12 +37,11 @@ const PingHistogramContainer: React.FC = ({ dateRangeStart: dateStart, dateRangeEnd: dateEnd, statusFilter, - filters, } = getUrlParams(); useEffect(() => { - loadData({ monitorId, dateStart, dateEnd, statusFilter, filters }); - }, [loadData, dateStart, dateEnd, monitorId, filters, statusFilter, lastRefresh]); + loadData({ monitorId, dateStart, dateEnd, statusFilter, filters: esKuery }); + }, [loadData, dateStart, dateEnd, monitorId, statusFilter, lastRefresh, esKuery]); return ( = ({ height, lastRefresh, loading, + esKuery, loadSnapshotCount, }: Props) => { const [getUrlParams] = useUrlParams(); - const { dateRangeStart, dateRangeEnd, statusFilter, filters } = getUrlParams(); + const { dateRangeStart, dateRangeEnd, statusFilter } = getUrlParams(); useEffect(() => { - loadSnapshotCount(dateRangeStart, dateRangeEnd, filters, statusFilter); - }, [dateRangeStart, dateRangeEnd, filters, lastRefresh, loadSnapshotCount, statusFilter]); + loadSnapshotCount(dateRangeStart, dateRangeEnd, esKuery, statusFilter); + }, [dateRangeStart, dateRangeEnd, esKuery, lastRefresh, loadSnapshotCount, statusFilter]); return ; }; @@ -66,11 +68,12 @@ export const Container: React.FC = ({ */ const mapStateToProps = ({ snapshot: { count, loading }, - ui: { lastRefresh }, + ui: { lastRefresh, esKuery }, }: AppState): StoreProps => ({ count, lastRefresh, loading, + esKuery, }); /** diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/pages/overview_container.ts b/x-pack/legacy/plugins/uptime/public/components/connected/pages/overview_container.ts index 406fab8f5bf010..cbd1fae77c5183 100644 --- a/x-pack/legacy/plugins/uptime/public/components/connected/pages/overview_container.ts +++ b/x-pack/legacy/plugins/uptime/public/components/connected/pages/overview_container.ts @@ -8,7 +8,16 @@ import { connect } from 'react-redux'; import { OverviewPageComponent } from '../../../pages/overview'; import { selectIndexPattern } from '../../../state/selectors'; import { AppState } from '../../../state'; +import { setEsKueryString } from '../../../state/actions'; + +interface DispatchProps { + setEsKueryFilters: typeof setEsKueryString; +} + +const mapDispatchToProps = (dispatch: any): DispatchProps => ({ + setEsKueryFilters: (esFilters: string) => dispatch(setEsKueryString(esFilters)), +}); const mapStateToProps = (state: AppState) => ({ indexPattern: selectIndexPattern(state) }); -export const OverviewPage = connect(mapStateToProps)(OverviewPageComponent); +export const OverviewPage = connect(mapStateToProps, mapDispatchToProps)(OverviewPageComponent); diff --git a/x-pack/legacy/plugins/uptime/public/hooks/update_kuery_string.ts b/x-pack/legacy/plugins/uptime/public/hooks/update_kuery_string.ts index 8c9eec3abe2239..8a4ae01a72b4be 100644 --- a/x-pack/legacy/plugins/uptime/public/hooks/update_kuery_string.ts +++ b/x-pack/legacy/plugins/uptime/public/hooks/update_kuery_string.ts @@ -6,20 +6,8 @@ import { combineFiltersAndUserSearch, stringifyKueries } from '../lib/helper'; import { esKuery } from '../../../../../../src/plugins/data/common/es_query'; -import { store } from '../state'; -import { setEsKueryString } from '../state/actions'; import { IIndexPattern } from '../../../../../../src/plugins/data/common/index_patterns'; -const updateEsQueryForFilterGroup = (filterQueryString: string, indexPattern: IIndexPattern) => { - // Update EsQuery in Redux to be used in FilterGroup - const searchDSL: string = filterQueryString - ? JSON.stringify( - esKuery.toElasticsearchQuery(esKuery.fromKueryExpression(filterQueryString), indexPattern) - ) - : ''; - store.dispatch(setEsKueryString(searchDSL)); -}; - const getKueryString = (urlFilters: string): string => { let kueryString = ''; // We are using try/catch here because this is user entered value @@ -56,8 +44,6 @@ export const useUpdateKueryString = ( esFilters = JSON.stringify(elasticsearchQuery); } - updateEsQueryForFilterGroup(filterQueryString, indexPattern); - return [esFilters]; } catch (err) { return [urlFilters, err]; diff --git a/x-pack/legacy/plugins/uptime/public/pages/overview.tsx b/x-pack/legacy/plugins/uptime/public/pages/overview.tsx index df6ffba6154e5c..ce5fb619aca025 100644 --- a/x-pack/legacy/plugins/uptime/public/pages/overview.tsx +++ b/x-pack/legacy/plugins/uptime/public/pages/overview.tsx @@ -5,7 +5,7 @@ */ import { EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui'; -import React, { useContext } from 'react'; +import React, { useContext, useEffect } from 'react'; import styled from 'styled-components'; import { EmptyState, @@ -27,6 +27,7 @@ interface OverviewPageProps { autocomplete: DataPublicPluginStart['autocomplete']; setBreadcrumbs: UMUpdateBreadcrumbs; indexPattern: IIndexPattern; + setEsKueryFilters: (esFilters: string) => void; } type Props = OverviewPageProps; @@ -40,7 +41,12 @@ const EuiFlexItemStyled = styled(EuiFlexItem)` } `; -export const OverviewPageComponent = ({ autocomplete, setBreadcrumbs, indexPattern }: Props) => { +export const OverviewPageComponent = ({ + autocomplete, + setBreadcrumbs, + indexPattern, + setEsKueryFilters, +}: Props) => { const { colors } = useContext(UptimeThemeContext); const [getUrlParams] = useUrlParams(); const { absoluteDateRangeStart, absoluteDateRangeEnd, ...params } = getUrlParams(); @@ -60,6 +66,10 @@ export const OverviewPageComponent = ({ autocomplete, setBreadcrumbs, indexPatte const [esFilters, error] = useUpdateKueryString(indexPattern, search, urlFilters); + useEffect(() => { + setEsKueryFilters(esFilters ?? ''); + }, [esFilters, setEsKueryFilters]); + const sharedProps = { dateRangeStart, dateRangeEnd, diff --git a/x-pack/legacy/plugins/uptime/public/state/selectors/index.ts b/x-pack/legacy/plugins/uptime/public/state/selectors/index.ts index fe6a7a1b7eade5..25498cc0cb0eea 100644 --- a/x-pack/legacy/plugins/uptime/public/state/selectors/index.ts +++ b/x-pack/legacy/plugins/uptime/public/state/selectors/index.ts @@ -34,5 +34,10 @@ export const selectIndexPattern = ({ indexPattern }: AppState) => { }; export const selectPingHistogram = ({ ping, ui }: AppState) => { - return { data: ping.pingHistogram, loading: ping.loading, lastRefresh: ui.lastRefresh }; + return { + data: ping.pingHistogram, + loading: ping.loading, + lastRefresh: ui.lastRefresh, + esKuery: ui.esKuery, + }; };