Merge branch 'master' into xpack-es-to-kbn-archiver-apm

This commit is contained in:
Kibana Machine 2021-06-21 09:28:21 -04:00 committed by GitHub
commit 14957b2069
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
780 changed files with 11154 additions and 6478 deletions

View file

@ -6,7 +6,7 @@ if [[ ! "${DISABLE_CI_STATS_SHIPPING:-}" ]]; then
echo "--- Ship Kibana Distribution Metrics to CI Stats"
node scripts/ship_ci_stats \
--metrics target/optimizer_bundle_metrics.json \
--metrics packages/kbn-ui-shared-deps/target/metrics.json
--metrics node_modules/@kbn/ui-shared-deps/shared_built_assets/metrics.json
fi
echo "--- Upload Build Artifacts"

View file

@ -37,7 +37,7 @@ snapshots.js
/packages/kbn-test/src/functional_test_runner/__tests__/fixtures/
/packages/kbn-test/src/functional_test_runner/lib/config/__tests__/fixtures/
/packages/kbn-ui-framework/dist
/packages/kbn-ui-shared-deps/flot_charts
/packages/kbn-ui-shared-deps/src/flot_charts
/packages/kbn-monaco/src/painless/antlr
# Bazel

View file

@ -875,6 +875,16 @@ module.exports = {
},
},
/**
* Cases overrides
*/
{
files: ['x-pack/plugins/cases/**/*.{js,mjs,ts,tsx}'],
rules: {
'no-duplicate-imports': 'error',
},
},
/**
* Security Solution overrides
*/
@ -1461,7 +1471,7 @@ module.exports = {
},
},
{
files: ['packages/kbn-ui-shared-deps/flot_charts/**/*.js'],
files: ['packages/kbn-ui-shared-deps/src/flot_charts/**/*.js'],
env: {
jquery: true,
},

1
.github/CODEOWNERS vendored
View file

@ -76,6 +76,7 @@
/src/plugins/apm_oss/ @elastic/apm-ui
/src/apm.js @elastic/kibana-core @vigneshshanmugam
/packages/kbn-apm-config-loader/ @elastic/kibana-core @vigneshshanmugam
/src/core/types/elasticsearch @elastic/apm-ui
#CC# /src/plugins/apm_oss/ @elastic/apm-ui
#CC# /x-pack/plugins/observability/ @elastic/apm-ui

View file

@ -11,7 +11,7 @@
"uiActionsExamples": "examples/ui_action_examples",
"share": "src/plugins/share",
"home": "src/plugins/home",
"flot": "packages/kbn-ui-shared-deps/flot_charts",
"flot": "packages/kbn-ui-shared-deps/src/flot_charts",
"charts": "src/plugins/charts",
"esUi": "src/plugins/es_ui_shared",
"devTools": "src/plugins/dev_tools",

View file

@ -87,6 +87,7 @@ yarn kbn watch-bazel
- @kbn/monaco
- @kbn/rule-data-utils
- @kbn/securitysolution-es-utils
- @kbn/securitysolution-hook-utils
- @kbn/securitysolution-io-ts-alerting-types
- @kbn/securitysolution-io-ts-list-types
- @kbn/securitysolution-io-ts-types
@ -101,5 +102,6 @@ yarn kbn watch-bazel
- @kbn/std
- @kbn/telemetry-utils
- @kbn/tinymath
- @kbn/ui-shared-deps
- @kbn/utility-types
- @kbn/utils

View file

@ -165,6 +165,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [SavedObjectsDeleteOptions](./kibana-plugin-core-server.savedobjectsdeleteoptions.md) | |
| [SavedObjectsExportByObjectOptions](./kibana-plugin-core-server.savedobjectsexportbyobjectoptions.md) | Options for the [export by objects API](./kibana-plugin-core-server.savedobjectsexporter.exportbyobjects.md) |
| [SavedObjectsExportByTypeOptions](./kibana-plugin-core-server.savedobjectsexportbytypeoptions.md) | Options for the [export by type API](./kibana-plugin-core-server.savedobjectsexporter.exportbytypes.md) |
| [SavedObjectsExportExcludedObject](./kibana-plugin-core-server.savedobjectsexportexcludedobject.md) | |
| [SavedObjectsExportResultDetails](./kibana-plugin-core-server.savedobjectsexportresultdetails.md) | Structure of the export result details entry |
| [SavedObjectsExportTransformContext](./kibana-plugin-core-server.savedobjectsexporttransformcontext.md) | Context passed down to a [export transform function](./kibana-plugin-core-server.savedobjectsexporttransform.md) |
| [SavedObjectsFindOptions](./kibana-plugin-core-server.savedobjectsfindoptions.md) | |

View file

@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [SavedObjectsExportExcludedObject](./kibana-plugin-core-server.savedobjectsexportexcludedobject.md) &gt; [id](./kibana-plugin-core-server.savedobjectsexportexcludedobject.id.md)
## SavedObjectsExportExcludedObject.id property
id of the excluded object
<b>Signature:</b>
```typescript
id: string;
```

View file

@ -0,0 +1,21 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [SavedObjectsExportExcludedObject](./kibana-plugin-core-server.savedobjectsexportexcludedobject.md)
## SavedObjectsExportExcludedObject interface
<b>Signature:</b>
```typescript
export interface SavedObjectsExportExcludedObject
```
## Properties
| Property | Type | Description |
| --- | --- | --- |
| [id](./kibana-plugin-core-server.savedobjectsexportexcludedobject.id.md) | <code>string</code> | id of the excluded object |
| [reason](./kibana-plugin-core-server.savedobjectsexportexcludedobject.reason.md) | <code>string</code> | optional cause of the exclusion |
| [type](./kibana-plugin-core-server.savedobjectsexportexcludedobject.type.md) | <code>string</code> | type of the excluded object |

View file

@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [SavedObjectsExportExcludedObject](./kibana-plugin-core-server.savedobjectsexportexcludedobject.md) &gt; [reason](./kibana-plugin-core-server.savedobjectsexportexcludedobject.reason.md)
## SavedObjectsExportExcludedObject.reason property
optional cause of the exclusion
<b>Signature:</b>
```typescript
reason?: string;
```

View file

@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [SavedObjectsExportExcludedObject](./kibana-plugin-core-server.savedobjectsexportexcludedobject.md) &gt; [type](./kibana-plugin-core-server.savedobjectsexportexcludedobject.type.md)
## SavedObjectsExportExcludedObject.type property
type of the excluded object
<b>Signature:</b>
```typescript
type: string;
```

View file

@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [SavedObjectsExportResultDetails](./kibana-plugin-core-server.savedobjectsexportresultdetails.md) &gt; [excludedObjects](./kibana-plugin-core-server.savedobjectsexportresultdetails.excludedobjects.md)
## SavedObjectsExportResultDetails.excludedObjects property
excluded objects details
<b>Signature:</b>
```typescript
excludedObjects: SavedObjectsExportExcludedObject[];
```

View file

@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [SavedObjectsExportResultDetails](./kibana-plugin-core-server.savedobjectsexportresultdetails.md) &gt; [excludedObjectsCount](./kibana-plugin-core-server.savedobjectsexportresultdetails.excludedobjectscount.md)
## SavedObjectsExportResultDetails.excludedObjectsCount property
number of objects that were excluded from the export
<b>Signature:</b>
```typescript
excludedObjectsCount: number;
```

View file

@ -16,6 +16,8 @@ export interface SavedObjectsExportResultDetails
| Property | Type | Description |
| --- | --- | --- |
| [excludedObjects](./kibana-plugin-core-server.savedobjectsexportresultdetails.excludedobjects.md) | <code>SavedObjectsExportExcludedObject[]</code> | excluded objects details |
| [excludedObjectsCount](./kibana-plugin-core-server.savedobjectsexportresultdetails.excludedobjectscount.md) | <code>number</code> | number of objects that were excluded from the export |
| [exportedCount](./kibana-plugin-core-server.savedobjectsexportresultdetails.exportedcount.md) | <code>number</code> | number of successfully exported objects |
| [missingRefCount](./kibana-plugin-core-server.savedobjectsexportresultdetails.missingrefcount.md) | <code>number</code> | number of missing references |
| [missingReferences](./kibana-plugin-core-server.savedobjectsexportresultdetails.missingreferences.md) | <code>Array&lt;{</code><br/><code> id: string;</code><br/><code> type: string;</code><br/><code> }&gt;</code> | missing references details |

View file

@ -11,7 +11,7 @@ A type's export transform function will be executed once per user-initiated expo
<b>Signature:</b>
```typescript
export declare type SavedObjectsExportTransform = <T = unknown>(context: SavedObjectsExportTransformContext, objects: Array<SavedObject<T>>) => SavedObject[] | Promise<SavedObject[]>;
export declare type SavedObjectsExportTransform<T = unknown> = (context: SavedObjectsExportTransformContext, objects: Array<SavedObject<T>>) => SavedObject[] | Promise<SavedObject[]>;
```
## Remarks

View file

@ -52,6 +52,6 @@ export class Plugin() {
| Property | Type | Description |
| --- | --- | --- |
| [addClientWrapper](./kibana-plugin-core-server.savedobjectsservicesetup.addclientwrapper.md) | <code>(priority: number, id: string, factory: SavedObjectsClientWrapperFactory) =&gt; void</code> | Add a [client wrapper factory](./kibana-plugin-core-server.savedobjectsclientwrapperfactory.md) with the given priority. |
| [registerType](./kibana-plugin-core-server.savedobjectsservicesetup.registertype.md) | <code>(type: SavedObjectsType) =&gt; void</code> | Register a [savedObjects type](./kibana-plugin-core-server.savedobjectstype.md) definition.<!-- -->See the [mappings format](./kibana-plugin-core-server.savedobjectstypemappingdefinition.md) and [migration format](./kibana-plugin-core-server.savedobjectmigrationmap.md) for more details about these. |
| [registerType](./kibana-plugin-core-server.savedobjectsservicesetup.registertype.md) | <code>&lt;Attributes = any&gt;(type: SavedObjectsType&lt;Attributes&gt;) =&gt; void</code> | Register a [savedObjects type](./kibana-plugin-core-server.savedobjectstype.md) definition.<!-- -->See the [mappings format](./kibana-plugin-core-server.savedobjectstypemappingdefinition.md) and [migration format](./kibana-plugin-core-server.savedobjectmigrationmap.md) for more details about these. |
| [setClientFactoryProvider](./kibana-plugin-core-server.savedobjectsservicesetup.setclientfactoryprovider.md) | <code>(clientFactoryProvider: SavedObjectsClientFactoryProvider) =&gt; void</code> | Set the default [factory provider](./kibana-plugin-core-server.savedobjectsclientfactoryprovider.md) for creating Saved Objects clients. Only one provider can be set, subsequent calls to this method will fail. |

View file

@ -11,7 +11,7 @@ See the [mappings format](./kibana-plugin-core-server.savedobjectstypemappingdef
<b>Signature:</b>
```typescript
registerType: (type: SavedObjectsType) => void;
registerType: <Attributes = any>(type: SavedObjectsType<Attributes>) => void;
```
## Example

View file

@ -9,5 +9,5 @@ An optional [saved objects management section](./kibana-plugin-core-server.saved
<b>Signature:</b>
```typescript
management?: SavedObjectsTypeManagementDefinition;
management?: SavedObjectsTypeManagementDefinition<Attributes>;
```

View file

@ -7,7 +7,7 @@
<b>Signature:</b>
```typescript
export interface SavedObjectsType
export interface SavedObjectsType<Attributes = any>
```
## Remarks
@ -54,7 +54,7 @@ Example after converting to a multi-namespace (shareable) type in 8.1:
Note: migration function(s) can be optionally specified for any of these versions and will not interfere with the conversion process. |
| [hidden](./kibana-plugin-core-server.savedobjectstype.hidden.md) | <code>boolean</code> | Is the type hidden by default. If true, repositories will not have access to this type unless explicitly declared as an <code>extraType</code> when creating the repository.<!-- -->See [createInternalRepository](./kibana-plugin-core-server.savedobjectsservicestart.createinternalrepository.md)<!-- -->. |
| [indexPattern](./kibana-plugin-core-server.savedobjectstype.indexpattern.md) | <code>string</code> | If defined, the type instances will be stored in the given index instead of the default one. |
| [management](./kibana-plugin-core-server.savedobjectstype.management.md) | <code>SavedObjectsTypeManagementDefinition</code> | An optional [saved objects management section](./kibana-plugin-core-server.savedobjectstypemanagementdefinition.md) definition for the type. |
| [management](./kibana-plugin-core-server.savedobjectstype.management.md) | <code>SavedObjectsTypeManagementDefinition&lt;Attributes&gt;</code> | An optional [saved objects management section](./kibana-plugin-core-server.savedobjectstypemanagementdefinition.md) definition for the type. |
| [mappings](./kibana-plugin-core-server.savedobjectstype.mappings.md) | <code>SavedObjectsTypeMappingDefinition</code> | The [mapping definition](./kibana-plugin-core-server.savedobjectstypemappingdefinition.md) for the type. |
| [migrations](./kibana-plugin-core-server.savedobjectstype.migrations.md) | <code>SavedObjectMigrationMap &#124; (() =&gt; SavedObjectMigrationMap)</code> | An optional map of [migrations](./kibana-plugin-core-server.savedobjectmigrationfn.md) or a function returning a map of [migrations](./kibana-plugin-core-server.savedobjectmigrationfn.md) to be used to migrate the type. |
| [name](./kibana-plugin-core-server.savedobjectstype.name.md) | <code>string</code> | The name of the type, which is also used as the internal id. |

View file

@ -9,5 +9,5 @@ Function returning the url to use to redirect to the editing page of this object
<b>Signature:</b>
```typescript
getEditUrl?: (savedObject: SavedObject<any>) => string;
getEditUrl?: (savedObject: SavedObject<Attributes>) => string;
```

View file

@ -9,7 +9,7 @@ Function returning the url to use to redirect to this object from the management
<b>Signature:</b>
```typescript
getInAppUrl?: (savedObject: SavedObject<any>) => {
getInAppUrl?: (savedObject: SavedObject<Attributes>) => {
path: string;
uiCapabilitiesPath: string;
};

View file

@ -9,5 +9,5 @@ Function returning the title to display in the management table. If not defined,
<b>Signature:</b>
```typescript
getTitle?: (savedObject: SavedObject<any>) => string;
getTitle?: (savedObject: SavedObject<Attributes>) => string;
```

View file

@ -0,0 +1,49 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [SavedObjectsTypeManagementDefinition](./kibana-plugin-core-server.savedobjectstypemanagementdefinition.md) &gt; [isExportable](./kibana-plugin-core-server.savedobjectstypemanagementdefinition.isexportable.md)
## SavedObjectsTypeManagementDefinition.isExportable property
Optional hook to specify whether an object should be exportable.
If specified, `isExportable` will be called during export for each of this type's objects in the export, and the ones not matching the predicate will be excluded from the export.
When implementing both `isExportable` and `onExport`<!-- -->, it is mandatory that `isExportable` returns the same value for an object before and after going though the export transform. E.g `isExportable(objectBeforeTransform) === isExportable(objectAfterTransform)`
<b>Signature:</b>
```typescript
isExportable?: SavedObjectsExportablePredicate<Attributes>;
```
## Remarks
`importableAndExportable` must be `true` to specify this property.
## Example
Registering a type with a per-object exportability predicate
```ts
// src/plugins/my_plugin/server/plugin.ts
import { myType } from './saved_objects';
export class Plugin() {
setup: (core: CoreSetup) => {
core.savedObjects.registerType({
...myType,
management: {
...myType.management,
isExportable: (object) => {
if (object.attributes.myCustomAttr === 'foo') {
return false;
}
return true;
}
},
});
}
}
```

View file

@ -9,7 +9,7 @@ Configuration options for the [type](./kibana-plugin-core-server.savedobjectstyp
<b>Signature:</b>
```typescript
export interface SavedObjectsTypeManagementDefinition
export interface SavedObjectsTypeManagementDefinition<Attributes = any>
```
## Properties
@ -17,11 +17,12 @@ export interface SavedObjectsTypeManagementDefinition
| Property | Type | Description |
| --- | --- | --- |
| [defaultSearchField](./kibana-plugin-core-server.savedobjectstypemanagementdefinition.defaultsearchfield.md) | <code>string</code> | The default search field to use for this type. Defaults to <code>id</code>. |
| [getEditUrl](./kibana-plugin-core-server.savedobjectstypemanagementdefinition.getediturl.md) | <code>(savedObject: SavedObject&lt;any&gt;) =&gt; string</code> | Function returning the url to use to redirect to the editing page of this object. If not defined, editing will not be allowed. |
| [getInAppUrl](./kibana-plugin-core-server.savedobjectstypemanagementdefinition.getinappurl.md) | <code>(savedObject: SavedObject&lt;any&gt;) =&gt; {</code><br/><code> path: string;</code><br/><code> uiCapabilitiesPath: string;</code><br/><code> }</code> | Function returning the url to use to redirect to this object from the management section. If not defined, redirecting to the object will not be allowed. |
| [getTitle](./kibana-plugin-core-server.savedobjectstypemanagementdefinition.gettitle.md) | <code>(savedObject: SavedObject&lt;any&gt;) =&gt; string</code> | Function returning the title to display in the management table. If not defined, will use the object's type and id to generate a label. |
| [getEditUrl](./kibana-plugin-core-server.savedobjectstypemanagementdefinition.getediturl.md) | <code>(savedObject: SavedObject&lt;Attributes&gt;) =&gt; string</code> | Function returning the url to use to redirect to the editing page of this object. If not defined, editing will not be allowed. |
| [getInAppUrl](./kibana-plugin-core-server.savedobjectstypemanagementdefinition.getinappurl.md) | <code>(savedObject: SavedObject&lt;Attributes&gt;) =&gt; {</code><br/><code> path: string;</code><br/><code> uiCapabilitiesPath: string;</code><br/><code> }</code> | Function returning the url to use to redirect to this object from the management section. If not defined, redirecting to the object will not be allowed. |
| [getTitle](./kibana-plugin-core-server.savedobjectstypemanagementdefinition.gettitle.md) | <code>(savedObject: SavedObject&lt;Attributes&gt;) =&gt; string</code> | Function returning the title to display in the management table. If not defined, will use the object's type and id to generate a label. |
| [icon](./kibana-plugin-core-server.savedobjectstypemanagementdefinition.icon.md) | <code>string</code> | The eui icon name to display in the management table. If not defined, the default icon will be used. |
| [importableAndExportable](./kibana-plugin-core-server.savedobjectstypemanagementdefinition.importableandexportable.md) | <code>boolean</code> | Is the type importable or exportable. Defaults to <code>false</code>. |
| [onExport](./kibana-plugin-core-server.savedobjectstypemanagementdefinition.onexport.md) | <code>SavedObjectsExportTransform</code> | An optional export transform function that can be used transform the objects of the registered type during the export process.<!-- -->It can be used to either mutate the exported objects, or add additional objects (of any type) to the export list.<!-- -->See [the transform type documentation](./kibana-plugin-core-server.savedobjectsexporttransform.md) for more info and examples. |
| [onImport](./kibana-plugin-core-server.savedobjectstypemanagementdefinition.onimport.md) | <code>SavedObjectsImportHook</code> | An optional [import hook](./kibana-plugin-core-server.savedobjectsimporthook.md) to use when importing given type.<!-- -->Import hooks are executed during the savedObjects import process and allow to interact with the imported objects. See the [hook documentation](./kibana-plugin-core-server.savedobjectsimporthook.md) for more info. |
| [isExportable](./kibana-plugin-core-server.savedobjectstypemanagementdefinition.isexportable.md) | <code>SavedObjectsExportablePredicate&lt;Attributes&gt;</code> | Optional hook to specify whether an object should be exportable.<!-- -->If specified, <code>isExportable</code> will be called during export for each of this type's objects in the export, and the ones not matching the predicate will be excluded from the export.<!-- -->When implementing both <code>isExportable</code> and <code>onExport</code>, it is mandatory that <code>isExportable</code> returns the same value for an object before and after going though the export transform. E.g <code>isExportable(objectBeforeTransform) === isExportable(objectAfterTransform)</code> |
| [onExport](./kibana-plugin-core-server.savedobjectstypemanagementdefinition.onexport.md) | <code>SavedObjectsExportTransform&lt;Attributes&gt;</code> | An optional export transform function that can be used transform the objects of the registered type during the export process.<!-- -->It can be used to either mutate the exported objects, or add additional objects (of any type) to the export list.<!-- -->See [the transform type documentation](./kibana-plugin-core-server.savedobjectsexporttransform.md) for more info and examples.<!-- -->When implementing both <code>isExportable</code> and <code>onExport</code>, it is mandatory that <code>isExportable</code> returns the same value for an object before and after going though the export transform. E.g <code>isExportable(objectBeforeTransform) === isExportable(objectAfterTransform)</code> |
| [onImport](./kibana-plugin-core-server.savedobjectstypemanagementdefinition.onimport.md) | <code>SavedObjectsImportHook&lt;Attributes&gt;</code> | An optional [import hook](./kibana-plugin-core-server.savedobjectsimporthook.md) to use when importing given type.<!-- -->Import hooks are executed during the savedObjects import process and allow to interact with the imported objects. See the [hook documentation](./kibana-plugin-core-server.savedobjectsimporthook.md) for more info. |

View file

@ -10,10 +10,12 @@ It can be used to either mutate the exported objects, or add additional objects
See [the transform type documentation](./kibana-plugin-core-server.savedobjectsexporttransform.md) for more info and examples.
When implementing both `isExportable` and `onExport`<!-- -->, it is mandatory that `isExportable` returns the same value for an object before and after going though the export transform. E.g `isExportable(objectBeforeTransform) === isExportable(objectAfterTransform)`
<b>Signature:</b>
```typescript
onExport?: SavedObjectsExportTransform;
onExport?: SavedObjectsExportTransform<Attributes>;
```
## Remarks

View file

@ -11,7 +11,7 @@ Import hooks are executed during the savedObjects import process and allow to in
<b>Signature:</b>
```typescript
onImport?: SavedObjectsImportHook;
onImport?: SavedObjectsImportHook<Attributes>;
```
## Remarks

View file

@ -11,9 +11,9 @@ To only get the visible types (which is the most common use case), use `getVisib
<b>Signature:</b>
```typescript
getAllTypes(): SavedObjectsType[];
getAllTypes(): SavedObjectsType<any>[];
```
<b>Returns:</b>
`SavedObjectsType[]`
`SavedObjectsType<any>[]`

View file

@ -9,9 +9,9 @@ Return all [types](./kibana-plugin-core-server.savedobjectstype.md) currently re
<b>Signature:</b>
```typescript
getImportableAndExportableTypes(): SavedObjectsType[];
getImportableAndExportableTypes(): SavedObjectsType<any>[];
```
<b>Returns:</b>
`SavedObjectsType[]`
`SavedObjectsType<any>[]`

View file

@ -9,7 +9,7 @@ Return the [type](./kibana-plugin-core-server.savedobjectstype.md) definition fo
<b>Signature:</b>
```typescript
getType(type: string): SavedObjectsType | undefined;
getType(type: string): SavedObjectsType<any> | undefined;
```
## Parameters
@ -20,5 +20,5 @@ getType(type: string): SavedObjectsType | undefined;
<b>Returns:</b>
`SavedObjectsType | undefined`
`SavedObjectsType<any> | undefined`

View file

@ -11,9 +11,9 @@ A visible type is a type that doesn't explicitly define `hidden=true` during reg
<b>Signature:</b>
```typescript
getVisibleTypes(): SavedObjectsType[];
getVisibleTypes(): SavedObjectsType<any>[];
```
<b>Returns:</b>
`SavedObjectsType[]`
`SavedObjectsType<any>[]`

View file

@ -95,6 +95,7 @@ The email connector can send email using many popular SMTP email services.
For more information about configuring the email connector to work with different email systems, refer to:
* <<elasticcloud>>
* <<gmail>>
* <<outlook>>
* <<exchange>>
@ -102,6 +103,29 @@ For more information about configuring the email connector to work with differen
For other email servers, you can check the list of well-known services that Nodemailer supports in the JSON file https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json[well-known/services.json]. The properties of the objects in those files &mdash; `host`, `port`, and `secure` &mdash; correspond to the same email connector configuration properties. A missing `secure` property in the "well-known/services.json" file is considered `false`. Typically, `port: 465` uses `secure: true`, and `port: 25` and `port: 587` use `secure: false`.
[float]
[[elasticcloud]]
==== Sending email from Elastic Cloud
IMPORTANT: These instructions require you to link:{cloud}/ec-watcher.html#ec-watcher-whitelist[whitelist] the email addresses that notifications get sent first.
Use the following connector settings to send email from Elastic Cloud:
Sender::
`noreply@watcheralert.found.io`
Host::
`dockerhost`
Port::
`10025`
Secure::
Toggle off
Authentication::
Toggle off
[float]
[[gmail]]
==== Sending email from Gmail

View file

@ -2,6 +2,7 @@
[[data-rollups]]
== Rollup Jobs
experimental::[]
A rollup job is a periodic task that aggregates data from indices specified
by an index pattern, and then rolls it into a new index. Rollup indices are a good way to

View file

@ -325,6 +325,9 @@ The time interval policy will rotate the log file every given interval of time.
When `includeElasticMapsService` is turned off, only the vector layers configured by <<regionmap-settings, `map.regionmap`>>
and the tile layer configured by <<tilemap-url, `map.tilemap.url`>> are available in <<maps, Maps>>. *Default: `true`*
| `map.emsUrl:`
| Specifies the URL of a self hosted <<elastic-maps-server,{hosted-ems}>>
| `map.proxyElasticMapsServiceInMaps:`
| Set to `true` to proxy all <<maps, Maps application>> Elastic Maps Service
requests through the {kib} server. *Default: `false`*

Binary file not shown.

Before

Width:  |  Height:  |  Size: 111 KiB

View file

@ -9,7 +9,7 @@ best practices recommended by Elastic. However, you can tailor them to meet your
specific needs.
[role="screenshot"]
image::user/monitoring/images/monitoring-kibana-alerts.png["{kib} alerts in {stack-monitor-app}"]
image::user/monitoring/images/monitoring-kibana-alerting-notification.png["{kib} alerting notifications in {stack-monitor-app}"]
When you open *{stack-monitor-app}*, the preconfigured rules are created
automatically. They are initially configured to detect and notify on various
@ -23,9 +23,8 @@ been recreated as rules in {kib} {alert-features}. For this reason, the existing
The default action for all {stack-monitor-app} rules is to write to {kib} logs
and display a notification in the UI.
[role="screenshot"]
image::user/monitoring/images/monitoring-kibana-alerting-notification.png["{kib} alerting notifications in {stack-monitor-app}"]
To review and modify all available rules, use *Enter setup mode* on the
*Cluster overview* page in *{stack-monitor-app}*:
[role="screenshot"]
image::user/monitoring/images/monitoring-kibana-alerting-setup-mode.png["Modify {kib} alerting rules in {stack-monitor-app}"]

View file

@ -141,6 +141,7 @@
"@kbn/rule-data-utils": "link:bazel-bin/packages/kbn-rule-data-utils",
"@kbn/securitysolution-list-constants": "link:bazel-bin/packages/kbn-securitysolution-list-constants",
"@kbn/securitysolution-es-utils": "link:bazel-bin/packages/kbn-securitysolution-es-utils",
"@kbn/securitysolution-hook-utils": "link:bazel-bin/packages/kbn-securitysolution-hook-utils",
"@kbn/securitysolution-io-ts-types": "link:bazel-bin/packages/kbn-securitysolution-io-ts-types",
"@kbn/securitysolution-io-ts-alerting-types": "link:bazel-bin/packages/kbn-securitysolution-io-ts-alerting-types",
"@kbn/securitysolution-io-ts-list-types": "link:bazel-bin/packages/kbn-securitysolution-io-ts-list-types",
@ -154,7 +155,7 @@
"@kbn/std": "link:bazel-bin/packages/kbn-std",
"@kbn/tinymath": "link:bazel-bin/packages/kbn-tinymath",
"@kbn/ui-framework": "link:packages/kbn-ui-framework",
"@kbn/ui-shared-deps": "link:packages/kbn-ui-shared-deps",
"@kbn/ui-shared-deps": "link:bazel-bin/packages/kbn-ui-shared-deps",
"@kbn/utility-types": "link:bazel-bin/packages/kbn-utility-types",
"@kbn/common-utils": "link:bazel-bin/packages/kbn-common-utils",
"@kbn/utils": "link:bazel-bin/packages/kbn-utils",
@ -290,6 +291,7 @@
"mapbox-gl-draw-rectangle-mode": "1.0.4",
"markdown-it": "^10.0.0",
"md5": "^2.1.0",
"mdast-util-to-hast": "10.0.1",
"memoize-one": "^5.0.0",
"mime": "^2.4.4",
"mime-types": "^2.1.27",

View file

@ -40,11 +40,13 @@ filegroup(
"//packages/kbn-securitysolution-list-utils:build",
"//packages/kbn-securitysolution-utils:build",
"//packages/kbn-securitysolution-es-utils:build",
"//packages/kbn-securitysolution-hook-utils:build",
"//packages/kbn-server-http-tools:build",
"//packages/kbn-server-route-repository:build",
"//packages/kbn-std:build",
"//packages/kbn-telemetry-tools:build",
"//packages/kbn-tinymath:build",
"//packages/kbn-ui-shared-deps:build",
"//packages/kbn-utility-types:build",
"//packages/kbn-utils:build",
],

View file

@ -22,9 +22,8 @@ export async function emptyKibanaIndexAction({
kbnClient: KbnClient;
}) {
const stats = createStats('emptyKibanaIndex', log);
const kibanaPluginIds = await kbnClient.plugins.getEnabledIds();
await cleanKibanaIndices({ client, stats, log, kibanaPluginIds });
await cleanKibanaIndices({ client, stats, log });
await migrateKibanaIndex(kbnClient);
stats.createdIndex('.kibana');
return stats.toJSON();

View file

@ -37,7 +37,6 @@ export async function unloadAction({
}) {
const name = relative(REPO_ROOT, inputDir);
const stats = createStats(name, log);
const kibanaPluginIds = await kbnClient.plugins.getEnabledIds();
const files = prioritizeMappings(await readDirectory(inputDir));
for (const filename of files) {
@ -47,7 +46,7 @@ export async function unloadAction({
createReadStream(resolve(inputDir, filename)) as Readable,
...createParseArchiveStreams({ gzip: isGzip(filename) }),
createFilterRecordsStream('index'),
createDeleteIndexStream(client, stats, log, kibanaPluginIds),
createDeleteIndexStream(client, stats, log),
] as [Readable, ...Writable[]]);
}

View file

@ -28,7 +28,7 @@ describe('esArchiver: createDeleteIndexStream()', () => {
await createPromiseFromStreams([
createListStream([createStubIndexRecord('index1')]),
createDeleteIndexStream(client, stats, log, []),
createDeleteIndexStream(client, stats, log),
]);
sinon.assert.notCalled(stats.deletedIndex as sinon.SinonSpy);
@ -43,7 +43,7 @@ describe('esArchiver: createDeleteIndexStream()', () => {
await createPromiseFromStreams([
createListStream([createStubIndexRecord('index1')]),
createDeleteIndexStream(client, stats, log, []),
createDeleteIndexStream(client, stats, log),
]);
sinon.assert.calledOnce(stats.deletedIndex as sinon.SinonSpy);

View file

@ -14,12 +14,7 @@ import { Stats } from '../stats';
import { deleteIndex } from './delete_index';
import { cleanKibanaIndices } from './kibana_index';
export function createDeleteIndexStream(
client: KibanaClient,
stats: Stats,
log: ToolingLog,
kibanaPluginIds: string[]
) {
export function createDeleteIndexStream(client: KibanaClient, stats: Stats, log: ToolingLog) {
return new Transform({
readableObjectMode: true,
writableObjectMode: true,
@ -29,7 +24,7 @@ export function createDeleteIndexStream(
const { index } = record.value;
if (index.startsWith('.kibana')) {
await cleanKibanaIndices({ client, stats, log, kibanaPluginIds });
await cleanKibanaIndices({ client, stats, log });
} else {
await deleteIndex({ client, stats, log, index });
}

View file

@ -96,21 +96,11 @@ export async function cleanKibanaIndices({
client,
stats,
log,
kibanaPluginIds,
}: {
client: KibanaClient;
stats: Stats;
log: ToolingLog;
kibanaPluginIds: string[];
}) {
if (!kibanaPluginIds.includes('spaces')) {
return await deleteKibanaIndices({
client,
stats,
log,
});
}
while (true) {
const resp = await client.deleteByQuery(
{

View file

@ -6,7 +6,8 @@
* Side Public License, v 1.
*/
import { LangModule as LangModuleType } from '../types';
import { ID } from './constants';
import { lexerRules } from './lexer_rules';
export const EsqlLang = { ID, lexerRules };
export const EsqlLang: LangModuleType = { ID, lexerRules };

View file

@ -0,0 +1,21 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { monaco } from './monaco_imports';
import { LangModule as LangModuleType } from './types';
function registerLanguage(language: LangModuleType) {
const { ID, lexerRules, languageConfiguration } = language;
monaco.languages.register({ id: ID });
monaco.languages.setMonarchTokensProvider(ID, lexerRules);
if (languageConfiguration) {
monaco.languages.setLanguageConfiguration(ID, languageConfiguration);
}
}
export { registerLanguage };

View file

@ -12,7 +12,13 @@ import './register_globals';
export { monaco } from './monaco_imports';
export { XJsonLang } from './xjson';
export { PainlessLang, PainlessContext, PainlessAutocompleteField } from './painless';
/* eslint-disable-next-line @kbn/eslint/module_migration */
import * as BarePluginApi from 'monaco-editor/esm/vs/editor/editor.api';
export { BarePluginApi };
import { registerLanguage } from './helpers';
import {
LangModule as LangModuleType,
CompleteLangModule as CompleteLangModuleType,
} from './types';
export { BarePluginApi, registerLanguage, LangModuleType, CompleteLangModuleType };

View file

@ -9,8 +9,9 @@
import { ID } from './constants';
import { lexerRules, languageConfiguration } from './lexer_rules';
import { getSuggestionProvider, getSyntaxErrors } from './language';
import { CompleteLangModule as CompleteLangModuleType } from '../types';
export const PainlessLang = {
export const PainlessLang: CompleteLangModuleType = {
ID,
getSuggestionProvider,
lexerRules,

View file

@ -10,6 +10,8 @@ import { XJsonLang } from './xjson';
import { PainlessLang } from './painless';
import { EsqlLang } from './esql';
import { monaco } from './monaco_imports';
import { registerLanguage } from './helpers';
// @ts-ignore
import xJsonWorkerSrc from '!!raw-loader!../../target_web/xjson.editor.worker.js';
// @ts-ignore
@ -20,14 +22,9 @@ import painlessWorkerSrc from '!!raw-loader!../../target_web/painless.editor.wor
/**
* Register languages and lexer rules
*/
monaco.languages.register({ id: XJsonLang.ID });
monaco.languages.setMonarchTokensProvider(XJsonLang.ID, XJsonLang.lexerRules);
monaco.languages.setLanguageConfiguration(XJsonLang.ID, XJsonLang.languageConfiguration);
monaco.languages.register({ id: PainlessLang.ID });
monaco.languages.setMonarchTokensProvider(PainlessLang.ID, PainlessLang.lexerRules);
monaco.languages.setLanguageConfiguration(PainlessLang.ID, PainlessLang.languageConfiguration);
monaco.languages.register({ id: EsqlLang.ID });
monaco.languages.setMonarchTokensProvider(EsqlLang.ID, EsqlLang.lexerRules);
registerLanguage(XJsonLang);
registerLanguage(PainlessLang);
registerLanguage(EsqlLang);
/**
* Create web workers by language ID

View file

@ -0,0 +1,22 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { monaco } from './monaco_imports';
export interface LangModule {
ID: string;
lexerRules: monaco.languages.IMonarchLanguage;
languageConfiguration?: monaco.languages.LanguageConfiguration;
getSuggestionProvider?: Function;
getSyntaxErrors?: Function;
}
export interface CompleteLangModule extends LangModule {
languageConfiguration: monaco.languages.LanguageConfiguration;
getSuggestionProvider: Function;
getSyntaxErrors: Function;
}

View file

@ -12,5 +12,6 @@
import './language';
import { ID } from './constants';
import { lexerRules, languageConfiguration } from './lexer_rules';
import { LangModule as LangModuleType } from '../types';
export const XJsonLang = { ID, lexerRules, languageConfiguration };
export const XJsonLang: LangModuleType = { ID, lexerRules, languageConfiguration };

View file

@ -108,6 +108,6 @@ pageLoadAssetSize:
banners: 17946
mapsEms: 26072
timelines: 28613
cases: 162385
screenshotMode: 17856
visTypePie: 35583
cases: 144442

View file

@ -9,8 +9,5 @@
"build": "../../node_modules/.bin/tsc",
"kbn:bootstrap": "yarn build",
"kbn:watch": "yarn build --watch"
},
"dependencies": {
"@kbn/ui-shared-deps": "link:../kbn-ui-shared-deps"
}
}

View file

@ -15,7 +15,7 @@ import cpy from 'cpy';
import del from 'del';
import { tap, filter } from 'rxjs/operators';
import { REPO_ROOT } from '@kbn/utils';
import { ToolingLog } from '@kbn/dev-utils';
import { ToolingLog, createReplaceSerializer } from '@kbn/dev-utils';
import { runOptimizer, OptimizerConfig, OptimizerUpdate, logOptimizerState } from '../index';
import { allValuesFrom } from '../common';
@ -29,6 +29,8 @@ expect.addSnapshotSerializer({
test: (value: any) => typeof value === 'string' && value.includes(REPO_ROOT),
});
expect.addSnapshotSerializer(createReplaceSerializer(/\w+-fastbuild/, '<platform>-fastbuild'));
const log = new ToolingLog({
level: 'error',
writeTo: {
@ -130,13 +132,13 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {
expect(foo.cache.getModuleCount()).toBe(6);
expect(foo.cache.getReferencedFiles()).toMatchInlineSnapshot(`
Array [
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/bazel-out/<platform>-fastbuild/bin/packages/kbn-ui-shared-deps/target/public_path_module_creator.js,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/kibana.json,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/async_import.ts,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/ext.ts,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/index.ts,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/lib.ts,
<absolute path>/packages/kbn-optimizer/src/worker/entry_point_creator.ts,
<absolute path>/packages/kbn-ui-shared-deps/public_path_module_creator.js,
]
`);
@ -153,6 +155,7 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {
<absolute path>/node_modules/@kbn/optimizer/postcss.config.js,
<absolute path>/node_modules/css-loader/package.json,
<absolute path>/node_modules/style-loader/package.json,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/bazel-out/<platform>-fastbuild/bin/packages/kbn-ui-shared-deps/target/public_path_module_creator.js,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/bar/kibana.json,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/bar/public/index.scss,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/bar/public/index.ts,
@ -162,7 +165,6 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/src/core/public/core_app/styles/_globals_v8dark.scss,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/src/core/public/core_app/styles/_globals_v8light.scss,
<absolute path>/packages/kbn-optimizer/src/worker/entry_point_creator.ts,
<absolute path>/packages/kbn-ui-shared-deps/public_path_module_creator.js,
]
`);
@ -173,10 +175,10 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {
expect(baz.cache.getReferencedFiles()).toMatchInlineSnapshot(`
Array [
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/bazel-out/<platform>-fastbuild/bin/packages/kbn-ui-shared-deps/target/public_path_module_creator.js,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/x-pack/baz/kibana.json,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/x-pack/baz/public/index.ts,
<absolute path>/packages/kbn-optimizer/src/worker/entry_point_creator.ts,
<absolute path>/packages/kbn-ui-shared-deps/public_path_module_creator.js,
]
`);
});

View file

@ -54,8 +54,19 @@ export class PopulateBundleCachePlugin {
for (const module of compilation.modules) {
if (isNormalModule(module)) {
moduleCount += 1;
const path = getModulePath(module);
const parsedPath = parseFilePath(path);
let path = getModulePath(module);
let parsedPath = parseFilePath(path);
if (parsedPath.dirs.includes('bazel-out')) {
const index = parsedPath.dirs.indexOf('bazel-out');
path = Path.join(
workerConfig.repoRoot,
'bazel-out',
...parsedPath.dirs.slice(index + 1),
parsedPath.filename ?? ''
);
parsedPath = parseFilePath(path);
}
if (!parsedPath.dirs.includes('node_modules')) {
referencedFiles.add(path);

View file

@ -0,0 +1,87 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
PKG_BASE_NAME = "kbn-securitysolution-hook-utils"
PKG_REQUIRE_NAME = "@kbn/securitysolution-hook-utils"
SOURCE_FILES = glob(
[
"src/**/*.ts",
],
exclude = [
"**/*.test.*",
"**/*.mock.*",
],
)
SRCS = SOURCE_FILES
filegroup(
name = "srcs",
srcs = SRCS,
)
NPM_MODULE_EXTRA_FILES = [
"package.json",
"README.md",
]
SRC_DEPS = [
"@npm//react",
"@npm//rxjs",
"@npm//tslib",
]
TYPES_DEPS = [
"@npm//@types/jest",
"@npm//@types/node",
"@npm//@types/react",
]
DEPS = SRC_DEPS + TYPES_DEPS
ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//:tsconfig.base.json",
],
)
ts_project(
name = "tsc",
srcs = SRCS,
args = ["--pretty"],
declaration = True,
declaration_map = True,
incremental = True,
out_dir = "target",
root_dir = "src",
source_map = True,
tsconfig = ":tsconfig",
deps = DEPS,
)
js_library(
name = PKG_BASE_NAME,
package_name = PKG_REQUIRE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
visibility = ["//visibility:public"],
deps = DEPS + [":tsc"],
)
pkg_npm(
name = "npm_module",
deps = [
":%s" % PKG_BASE_NAME,
],
)
filegroup(
name = "build",
srcs = [
":npm_module",
],
visibility = ["//visibility:public"],
)

View file

@ -0,0 +1,3 @@
# kbn-securitysolution-hook-utils
This package contains shared utilities for React hooks.

View file

@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
module.exports = {
preset: '@kbn/test',
rootDir: '../..',
roots: ['<rootDir>/packages/kbn-securitysolution-hook-utils'],
};

View file

@ -0,0 +1,9 @@
{
"name": "@kbn/securitysolution-hook-utils",
"version": "1.0.0",
"description": "Security Solution utilities for React hooks",
"license": "SSPL-1.0 OR Elastic License 2.0",
"main": "./target/index.js",
"types": "./target/index.d.ts",
"private": true
}

View file

@ -0,0 +1,12 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
export * from './use_async';
export * from './use_is_mounted';
export * from './use_observable';
export * from './with_optional_signal';

View file

@ -0,0 +1,18 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
/**
* Represents the state of an asynchronous task, along with an initiator
* function to kick off the work.
*/
export interface Task<Args extends unknown[], Result> {
loading: boolean;
error: unknown | undefined;
result: Result | undefined;
start: (...args: Args) => void;
}

View file

@ -8,26 +8,26 @@
import { useCallback, useState } from 'react';
import { Task } from '../types';
import { useIsMounted } from '../use_is_mounted';
// TODO: This is probably better off in another package such as kbn-securitysolution-hook-utils
export interface Async<Args extends unknown[], Result> {
loading: boolean;
error: unknown | undefined;
result: Result | undefined;
start: (...args: Args) => void;
}
/**
*
* @param fn Async function
* This hook wraps a promise-returning thunk (task) in order to conditionally
* initiate the work, and automatically provide state corresponding to the
* task's status.
*
* @returns An {@link AsyncTask} containing the underlying task's state along with a start callback
* In order to function properly and not rerender unnecessarily, ensure that
* your task is a stable function reference.
*
* @param fn a function returning a promise.
*
* @returns An {@link Task} containing the task's current state along with a
* start callback
*/
export const useAsync = <Args extends unknown[], Result>(
fn: (...args: Args) => Promise<Result>
): Async<Args, Result> => {
): Task<Args, Result> => {
const isMounted = useIsMounted();
const [loading, setLoading] = useState(false);
const [error, setError] = useState<unknown | undefined>();

View file

@ -10,8 +10,6 @@ import { useCallback, useEffect, useRef } from 'react';
type GetIsMounted = () => boolean;
// TODO: This is probably better off in another package such as kbn-securitysolution-hook-utils
/**
*
* @returns A {@link GetIsMounted} getter function returning whether the component is currently mounted

View file

@ -0,0 +1,160 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { act, renderHook } from '@testing-library/react-hooks';
import { Subject, throwError } from 'rxjs';
import { useObservable } from '.';
interface TestArgs {
n: number;
s: string;
}
type TestReturn = Subject<unknown>;
describe('useObservable', () => {
let fn: jest.Mock<TestReturn, TestArgs[]>;
let subject: TestReturn;
let args: TestArgs;
beforeEach(() => {
args = { n: 1, s: 's' };
subject = new Subject();
fn = jest.fn().mockReturnValue(subject);
});
it('does not invoke fn if start was not called', () => {
renderHook(() => useObservable(fn));
expect(fn).not.toHaveBeenCalled();
});
it('invokes the function when start is called', () => {
const { result } = renderHook(() => useObservable(fn));
act(() => {
result.current.start(args);
});
expect(fn).toHaveBeenCalled();
});
it('invokes the function with start args', () => {
const { result } = renderHook(() => useObservable(fn));
const expectedArgs = { ...args };
act(() => {
result.current.start(args);
});
expect(fn).toHaveBeenCalledWith(expectedArgs);
});
it('populates result with the next value of the fn', () => {
const { result } = renderHook(() => useObservable(fn));
act(() => {
result.current.start(args);
});
act(() => subject.next('value'));
expect(result.current.result).toEqual('value');
expect(result.current.error).toBeUndefined();
});
it('populates error if observable throws an error', () => {
const error = new Error('whoops');
const errorFn = () => throwError(error);
const { result } = renderHook(() => useObservable(errorFn));
act(() => {
result.current.start();
});
expect(result.current.result).toBeUndefined();
expect(result.current.error).toEqual(error);
});
it('populates the loading state while no value has resolved', () => {
const { result } = renderHook(() => useObservable(fn));
act(() => {
result.current.start(args);
});
expect(result.current.loading).toBe(true);
act(() => subject.next('a value'));
expect(result.current.loading).toBe(false);
});
it('updates result with each resolved value', () => {
const { result } = renderHook(() => useObservable(fn));
act(() => {
result.current.start(args);
});
act(() => subject.next('a value'));
expect(result.current.result).toEqual('a value');
act(() => subject.next('a subsequent value'));
expect(result.current.result).toEqual('a subsequent value');
});
it('does not update result with values if start has not been called', () => {
const { result } = renderHook(() => useObservable(fn));
act(() => subject.next('a value'));
expect(result.current.result).toBeUndefined();
act(() => subject.next('a subsequent value'));
expect(result.current.result).toBeUndefined();
});
it('unsubscribes on unmount', () => {
const { result, unmount } = renderHook(() => useObservable(fn));
act(() => {
result.current.start(args);
});
expect(subject.observers).toHaveLength(1);
unmount();
expect(subject.observers).toHaveLength(0);
});
it('multiple start calls reset state', () => {
const { result } = renderHook(() => useObservable(fn));
act(() => {
result.current.start(args);
});
expect(result.current.loading).toBe(true);
act(() => subject.next('one value'));
expect(result.current.loading).toBe(false);
expect(result.current.result).toBe('one value');
act(() => {
result.current.start(args);
});
expect(result.current.loading).toBe(true);
expect(result.current.result).toBe(undefined);
act(() => subject.next('another value'));
expect(result.current.loading).toBe(false);
expect(result.current.result).toBe('another value');
});
});

View file

@ -0,0 +1,72 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { useCallback, useEffect, useRef, useState } from 'react';
import { Observable, Subscription } from 'rxjs';
import { useIsMounted } from '../use_is_mounted';
import { Task } from '../types';
/**
*
* @param fn function returning an observable
*
* @returns An {@link Async} containing the underlying task's state along with a start callback
*/
export const useObservable = <Args extends unknown[], Result>(
fn: (...args: Args) => Observable<Result>
): Task<Args, Result> => {
const isMounted = useIsMounted();
const [loading, setLoading] = useState(false);
const [error, setError] = useState<unknown | undefined>();
const [result, setResult] = useState<Result | undefined>();
const subRef = useRef<Subscription | undefined>();
const start = useCallback(
(...args: Args) => {
if (subRef.current) {
subRef.current.unsubscribe();
}
setLoading(true);
setResult(undefined);
setError(undefined);
subRef.current = fn(...args).subscribe(
(r) => {
if (isMounted()) {
setResult(r);
setLoading(false);
}
},
(e) => {
if (isMounted()) {
setError(e);
setLoading(false);
}
}
);
},
[fn, isMounted]
);
useEffect(
() => () => {
if (subRef.current) {
subRef.current.unsubscribe();
}
},
[]
);
return {
error,
loading,
result,
start,
};
};

View file

@ -12,8 +12,6 @@ interface SignalArgs {
export type OptionalSignalArgs<Args> = Omit<Args, 'signal'> & Partial<SignalArgs>;
// TODO: This is probably better off in another package such as kbn-securitysolution-hook-utils
/**
*
* @param fn an async function receiving an AbortSignal argument

View file

@ -0,0 +1,14 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"incremental": true,
"outDir": "target",
"rootDir": "src",
"sourceMap": true,
"sourceRoot": "../../../../packages/kbn-securitysolution-hook-utils/src",
"types": ["jest", "node"]
},
"include": ["src/**/*"]
}

View file

@ -28,6 +28,7 @@ NPM_MODULE_EXTRA_FILES = [
]
SRC_DEPS = [
"//packages/kbn-securitysolution-hook-utils",
"//packages/kbn-securitysolution-io-ts-list-types",
"//packages/kbn-securitysolution-list-api",
"//packages/kbn-securitysolution-list-constants",

View file

@ -7,7 +7,6 @@
*/
export * from './transforms';
export * from './use_api';
export * from './use_async';
export * from './use_create_list_index';
export * from './use_cursor';
export * from './use_delete_list';
@ -16,9 +15,7 @@ export * from './use_exception_lists';
export * from './use_export_list';
export * from './use_find_lists';
export * from './use_import_list';
export * from './use_is_mounted';
export * from './use_persist_exception_item';
export * from './use_persist_exception_list';
export * from './use_read_list_index';
export * from './use_read_list_privileges';
export * from './with_optional_signal';

View file

@ -7,8 +7,7 @@
*/
import { createListIndex } from '@kbn/securitysolution-list-api';
import { withOptionalSignal } from '../with_optional_signal';
import { useAsync } from '../use_async';
import { useAsync, withOptionalSignal } from '@kbn/securitysolution-hook-utils';
const createListIndexWithOptionalSignal = withOptionalSignal(createListIndex);

View file

@ -7,8 +7,7 @@
*/
import { deleteList } from '@kbn/securitysolution-list-api';
import { withOptionalSignal } from '../with_optional_signal';
import { useAsync } from '../use_async';
import { useAsync, withOptionalSignal } from '@kbn/securitysolution-hook-utils';
const deleteListWithOptionalSignal = withOptionalSignal(deleteList);

View file

@ -7,8 +7,7 @@
*/
import { exportList } from '@kbn/securitysolution-list-api';
import { withOptionalSignal } from '../with_optional_signal';
import { useAsync } from '../use_async';
import { useAsync, withOptionalSignal } from '@kbn/securitysolution-hook-utils';
const exportListWithOptionalSignal = withOptionalSignal(exportList);

View file

@ -7,8 +7,7 @@
*/
import { findLists } from '@kbn/securitysolution-list-api';
import { withOptionalSignal } from '../with_optional_signal';
import { useAsync } from '../use_async';
import { useAsync, withOptionalSignal } from '@kbn/securitysolution-hook-utils';
const findListsWithOptionalSignal = withOptionalSignal(findLists);

View file

@ -7,8 +7,7 @@
*/
import { importList } from '@kbn/securitysolution-list-api';
import { withOptionalSignal } from '../with_optional_signal';
import { useAsync } from '../use_async';
import { useAsync, withOptionalSignal } from '@kbn/securitysolution-hook-utils';
const importListWithOptionalSignal = withOptionalSignal(importList);

View file

@ -7,8 +7,7 @@
*/
import { readListIndex } from '@kbn/securitysolution-list-api';
import { withOptionalSignal } from '../with_optional_signal';
import { useAsync } from '../use_async';
import { useAsync, withOptionalSignal } from '@kbn/securitysolution-hook-utils';
const readListIndexWithOptionalSignal = withOptionalSignal(readListIndex);

View file

@ -7,8 +7,7 @@
*/
import { readListPrivileges } from '@kbn/securitysolution-list-api';
import { withOptionalSignal } from '../with_optional_signal';
import { useAsync } from '../use_async';
import { useAsync, withOptionalSignal } from '@kbn/securitysolution-hook-utils';
const readListPrivilegesWithOptionalSignal = withOptionalSignal(readListPrivileges);

View file

@ -11,6 +11,6 @@
"scripts": {
"build": "../../node_modules/.bin/tsc",
"kbn:bootstrap": "yarn build",
"watch": "yarn build --watch"
"kbn:watch": "yarn build --watch"
}
}

View file

@ -71,11 +71,12 @@ export default function ({ config: storybookConfig }: { config: Configuration })
],
},
resolve: {
// Tell Webpack about the scss extension
extensions: ['.scss'],
extensions: ['.js', '.ts', '.tsx', '.json'],
mainFields: ['browser', 'main'],
alias: {
core_app_image_assets: resolve(REPO_ROOT, 'src/core/public/core_app/images'),
},
symlinks: false,
},
stats,
};

View file

@ -0,0 +1,145 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
load("@npm//webpack-cli:index.bzl", webpack = "webpack_cli")
PKG_BASE_NAME = "kbn-ui-shared-deps"
PKG_REQUIRE_NAME = "@kbn/ui-shared-deps"
SOURCE_FILES = glob(
[
"src/**/*",
],
exclude = [
"**/*.md",
],
)
SRCS = SOURCE_FILES
filegroup(
name = "srcs",
srcs = SRCS,
)
NPM_MODULE_EXTRA_FILES = [
"flot_charts/package.json",
"theme/package.json",
"package.json",
"README.md"
]
SRC_DEPS = [
"//packages/elastic-datemath",
"//packages/elastic-safer-lodash-set",
"//packages/kbn-analytics",
"//packages/kbn-babel-preset",
"//packages/kbn-i18n",
"//packages/kbn-monaco",
"//packages/kbn-std",
"//packages/kbn-utils",
"@npm//@elastic/charts",
"@npm//@elastic/eui",
"@npm//@elastic/numeral",
"@npm//abortcontroller-polyfill",
"@npm//angular",
"@npm//babel-loader",
"@npm//compression-webpack-plugin",
"@npm//core-js",
"@npm//css-minimizer-webpack-plugin",
"@npm//css-loader",
"@npm//fflate",
"@npm//jquery",
"@npm//loader-utils",
# TODO: we can remove this once EUI patches the dependencies
"@npm//mdast-util-to-hast",
"@npm//mini-css-extract-plugin",
"@npm//moment",
"@npm//moment-timezone",
"@npm//raw-loader",
"@npm//react",
"@npm//react-dom",
"@npm//react-intl",
"@npm//react-is",
"@npm//react-router",
"@npm//react-router-dom",
"@npm//regenerator-runtime",
"@npm//resize-observer-polyfill",
"@npm//rison-node",
"@npm//rxjs",
"@npm//styled-components",
"@npm//symbol-observable",
"@npm//terser-webpack-plugin",
"@npm//url-loader",
"@npm//val-loader",
"@npm//whatwg-fetch"
]
TYPES_DEPS = [
"@npm//@types/node",
]
DEPS = SRC_DEPS + TYPES_DEPS
ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//:tsconfig.base.json",
],
)
ts_project(
name = "tsc",
args = ['--pretty'],
srcs = SRCS,
deps = DEPS,
allow_js = True,
declaration = True,
declaration_map = True,
incremental = True,
out_dir = "target",
source_map = True,
root_dir = "src",
tsconfig = ":tsconfig",
)
webpack(
name = "shared_built_assets",
data = DEPS + [
"//:package.json",
":srcs",
":tsconfig",
":webpack.config.js",
],
output_dir = True,
args = [
"--config",
"$(location webpack.config.js)",
"--output-path",
"$(@D)",
"--display=minimal"
],
)
js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = DEPS + [":tsc", ":shared_built_assets"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
pkg_npm(
name = "npm_module",
deps = [
":%s" % PKG_BASE_NAME,
]
)
filegroup(
name = "build",
srcs = [
":npm_module",
],
visibility = ["//visibility:public"],
)

View file

@ -0,0 +1,4 @@
{
"main": "../target/flot_charts/index.js",
"types": "../target/flot_charts/index.d.ts"
}

View file

@ -1,59 +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
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
/**
* Absolute path to the distributable directory
*/
export const distDir: string;
/**
* Filename of the main bundle file in the distributable directory
*/
export const jsFilename: string;
/**
* Filename of files that must be loaded before the jsFilename
*/
export const jsDepFilenames: string[];
/**
* Filename of the unthemed css file in the distributable directory
*/
export const baseCssDistFilename: string;
/**
* Filename of the dark-theme css file in the distributable directory
*/
export const darkCssDistFilename: string;
/**
* Filename of the dark-theme css file in the distributable directory
*/
export const darkV8CssDistFilename: string;
/**
* Filename of the light-theme css file in the distributable directory
*/
export const lightCssDistFilename: string;
/**
* Filename of the light-theme css file in the distributable directory
*/
export const lightV8CssDistFilename: string;
/**
* Externals mapping inteded to be used in a webpack config
*/
export const externals: {
[key: string]: string;
};
/**
* Webpack loader for configuring the public path lookup from `window.__kbnPublicPath__`.
*/
export const publicPathLoader: string;

View file

@ -3,9 +3,6 @@
"version": "1.0.0",
"private": true,
"license": "SSPL-1.0 OR Elastic License 2.0",
"scripts": {
"build": "node scripts/build",
"kbn:bootstrap": "node scripts/build --dev",
"kbn:watch": "node scripts/build --dev --watch"
}
"main": "target/index.js",
"types": "target/index.d.ts"
}

View file

@ -1,98 +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
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
const Path = require('path');
const { run, createFailError } = require('@kbn/dev-utils');
const webpack = require('webpack');
const Stats = require('webpack/lib/Stats');
const del = require('del');
const { getWebpackConfig } = require('../webpack.config');
const DIST_DIR = Path.resolve(__dirname, '../target');
run(
async ({ log, flags }) => {
log.info('cleaning previous build output');
await del(DIST_DIR);
const compiler = webpack(
getWebpackConfig({
dev: flags.dev,
})
);
/** @param {webpack.Stats} stats */
const onCompilationComplete = async (stats) => {
const took = Math.round((stats.endTime - stats.startTime) / 1000);
if (!stats.hasErrors() && !stats.hasWarnings()) {
log.success(`webpack completed in about ${took} seconds`);
return;
}
throw createFailError(
`webpack failure in about ${took} seconds\n${stats.toString({
colors: true,
...Stats.presetToOptions('minimal'),
})}`
);
};
if (flags.watch) {
compiler.hooks.done.tap('report on stats', (stats) => {
onCompilationComplete(stats).catch((error) => {
log.error(error.message);
});
});
compiler.hooks.watchRun.tap('report on start', () => {
if (process.stdout.isTTY) {
process.stdout.cursorTo(0, 0);
process.stdout.clearScreenDown();
}
log.info('Running webpack compilation...');
});
compiler.watch({}, (error) => {
if (error) {
log.error('Fatal webpack error');
log.error(error);
process.exit(1);
}
});
return;
}
log.info('running webpack');
await onCompilationComplete(
await new Promise((resolve, reject) => {
compiler.run((error, stats) => {
if (error) {
reject(error);
} else {
resolve(stats);
}
});
})
);
},
{
description: 'build @kbn/ui-shared-deps',
flags: {
boolean: ['watch', 'dev'],
help: `
--watch Run in watch mode
--dev Build development friendly version
`,
},
}
);

Some files were not shown because too many files have changed in this diff Show more