diff --git a/.eslintrc.js b/.eslintrc.js
index 8762c1dc02d2d..af68f367aebb7 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -297,7 +297,8 @@ module.exports = {
'src/legacy/**/*',
'x-pack/**/*',
'!x-pack/**/*.test.*',
- 'src/plugins/**/(public|server)/**/*',
+ '!x-pack/test/**/*',
+ '(src|x-pack)/plugins/**/(public|server)/**/*',
'src/core/(public|server)/**/*',
],
from: [
@@ -317,13 +318,32 @@ module.exports = {
'!src/core/server/types',
'!src/core/server/*.test.mocks.ts',
- 'src/plugins/**/public/**/*',
- '!src/plugins/**/public/index.{js,ts,tsx}',
-
- 'src/plugins/**/server/**/*',
- '!src/plugins/**/server/index.{js,ts,tsx}',
+ '(src|x-pack)/plugins/**/(public|server)/**/*',
+ '!(src|x-pack)/plugins/**/(public|server)/(index|mocks).{js,ts,tsx}',
],
allowSameFolder: true,
+ errorMessage: 'Plugins may only import from top-level public and server modules.',
+ },
+ {
+ target: [
+ '(src|x-pack)/plugins/**/*',
+ '!(src|x-pack)/plugins/*/server/**/*',
+
+ 'src/legacy/core_plugins/**/*',
+ '!src/legacy/core_plugins/*/server/**/*',
+ '!src/legacy/core_plugins/*/index.{js,ts,tsx}',
+
+ 'x-pack/legacy/plugins/**/*',
+ '!x-pack/legacy/plugins/*/server/**/*',
+ '!x-pack/legacy/plugins/*/index.{js,ts,tsx}',
+ ],
+ from: [
+ 'src/core/server',
+ 'src/core/server/**/*',
+ '(src|x-pack)/plugins/*/server/**/*',
+ ],
+ errorMessage:
+ 'Server modules cannot be imported into client modules or shared modules.',
},
{
target: ['src/core/**/*'],
@@ -340,6 +360,11 @@ module.exports = {
],
errorMessage: 'The core cannot depend on any plugins.',
},
+ {
+ target: ['(src|x-pack)/plugins/*/public/**/*'],
+ from: ['ui/**/*', 'uiExports/**/*'],
+ errorMessage: 'Plugins cannot import legacy UI code.',
+ },
{
from: ['src/legacy/ui/**/*', 'ui/**/*'],
target: [
diff --git a/docs/development/core/public/kibana-plugin-public.md b/docs/development/core/public/kibana-plugin-public.md
index c599e1eaa14fe..2c43f36ede09e 100644
--- a/docs/development/core/public/kibana-plugin-public.md
+++ b/docs/development/core/public/kibana-plugin-public.md
@@ -89,6 +89,13 @@ The plugin integrates with the core system via lifecycle events: `setup`
| [SavedObjectsCreateOptions](./kibana-plugin-public.savedobjectscreateoptions.md) | |
| [SavedObjectsFindOptions](./kibana-plugin-public.savedobjectsfindoptions.md) | |
| [SavedObjectsFindResponsePublic](./kibana-plugin-public.savedobjectsfindresponsepublic.md) | Return type of the Saved Objects find() method.\*Note\*: this type is different between the Public and Server Saved Objects clients. |
+| [SavedObjectsImportConflictError](./kibana-plugin-public.savedobjectsimportconflicterror.md) | Represents a failure to import due to a conflict. |
+| [SavedObjectsImportError](./kibana-plugin-public.savedobjectsimporterror.md) | Represents a failure to import. |
+| [SavedObjectsImportMissingReferencesError](./kibana-plugin-public.savedobjectsimportmissingreferenceserror.md) | Represents a failure to import due to missing references. |
+| [SavedObjectsImportResponse](./kibana-plugin-public.savedobjectsimportresponse.md) | The response describing the result of an import. |
+| [SavedObjectsImportRetry](./kibana-plugin-public.savedobjectsimportretry.md) | Describes a retry operation for importing a saved object. |
+| [SavedObjectsImportUnknownError](./kibana-plugin-public.savedobjectsimportunknownerror.md) | Represents a failure to import due to an unknown reason. |
+| [SavedObjectsImportUnsupportedTypeError](./kibana-plugin-public.savedobjectsimportunsupportedtypeerror.md) | Represents a failure to import due to having an unsupported saved object type. |
| [SavedObjectsMigrationVersion](./kibana-plugin-public.savedobjectsmigrationversion.md) | Information about the migrations that have been applied to this SavedObject. When Kibana starts up, KibanaMigrator detects outdated documents and migrates them based on this value. For each migration that has been applied, the plugin's name is used as a key and the latest migration version as the value. |
| [SavedObjectsStart](./kibana-plugin-public.savedobjectsstart.md) | |
| [SavedObjectsUpdateOptions](./kibana-plugin-public.savedobjectsupdateoptions.md) | |
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimportconflicterror.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimportconflicterror.md
new file mode 100644
index 0000000000000..6becc3d507461
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimportconflicterror.md
@@ -0,0 +1,20 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportConflictError](./kibana-plugin-public.savedobjectsimportconflicterror.md)
+
+## SavedObjectsImportConflictError interface
+
+Represents a failure to import due to a conflict.
+
+Signature:
+
+```typescript
+export interface SavedObjectsImportConflictError
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [type](./kibana-plugin-public.savedobjectsimportconflicterror.type.md) | 'conflict' | |
+
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimportconflicterror.type.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimportconflicterror.type.md
new file mode 100644
index 0000000000000..af20cc8fa8df2
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimportconflicterror.type.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportConflictError](./kibana-plugin-public.savedobjectsimportconflicterror.md) > [type](./kibana-plugin-public.savedobjectsimportconflicterror.type.md)
+
+## SavedObjectsImportConflictError.type property
+
+Signature:
+
+```typescript
+type: 'conflict';
+```
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimporterror.error.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimporterror.error.md
new file mode 100644
index 0000000000000..ece6016e8bf54
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimporterror.error.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportError](./kibana-plugin-public.savedobjectsimporterror.md) > [error](./kibana-plugin-public.savedobjectsimporterror.error.md)
+
+## SavedObjectsImportError.error property
+
+Signature:
+
+```typescript
+error: SavedObjectsImportConflictError | SavedObjectsImportUnsupportedTypeError | SavedObjectsImportMissingReferencesError | SavedObjectsImportUnknownError;
+```
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimporterror.id.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimporterror.id.md
new file mode 100644
index 0000000000000..995fe61745a00
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimporterror.id.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportError](./kibana-plugin-public.savedobjectsimporterror.md) > [id](./kibana-plugin-public.savedobjectsimporterror.id.md)
+
+## SavedObjectsImportError.id property
+
+Signature:
+
+```typescript
+id: string;
+```
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimporterror.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimporterror.md
new file mode 100644
index 0000000000000..dee8bb1c79a57
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimporterror.md
@@ -0,0 +1,23 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportError](./kibana-plugin-public.savedobjectsimporterror.md)
+
+## SavedObjectsImportError interface
+
+Represents a failure to import.
+
+Signature:
+
+```typescript
+export interface SavedObjectsImportError
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [error](./kibana-plugin-public.savedobjectsimporterror.error.md) | SavedObjectsImportConflictError | SavedObjectsImportUnsupportedTypeError | SavedObjectsImportMissingReferencesError | SavedObjectsImportUnknownError | |
+| [id](./kibana-plugin-public.savedobjectsimporterror.id.md) | string | |
+| [title](./kibana-plugin-public.savedobjectsimporterror.title.md) | string | |
+| [type](./kibana-plugin-public.savedobjectsimporterror.type.md) | string | |
+
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimporterror.title.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimporterror.title.md
new file mode 100644
index 0000000000000..71fa13ad4a5d0
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimporterror.title.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportError](./kibana-plugin-public.savedobjectsimporterror.md) > [title](./kibana-plugin-public.savedobjectsimporterror.title.md)
+
+## SavedObjectsImportError.title property
+
+Signature:
+
+```typescript
+title?: string;
+```
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimporterror.type.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimporterror.type.md
new file mode 100644
index 0000000000000..fe98dc928e5f0
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimporterror.type.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportError](./kibana-plugin-public.savedobjectsimporterror.md) > [type](./kibana-plugin-public.savedobjectsimporterror.type.md)
+
+## SavedObjectsImportError.type property
+
+Signature:
+
+```typescript
+type: string;
+```
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimportmissingreferenceserror.blocking.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimportmissingreferenceserror.blocking.md
new file mode 100644
index 0000000000000..76bd6e0939a96
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimportmissingreferenceserror.blocking.md
@@ -0,0 +1,14 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportMissingReferencesError](./kibana-plugin-public.savedobjectsimportmissingreferenceserror.md) > [blocking](./kibana-plugin-public.savedobjectsimportmissingreferenceserror.blocking.md)
+
+## SavedObjectsImportMissingReferencesError.blocking property
+
+Signature:
+
+```typescript
+blocking: Array<{
+ type: string;
+ id: string;
+ }>;
+```
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimportmissingreferenceserror.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimportmissingreferenceserror.md
new file mode 100644
index 0000000000000..58af9e9be0cc5
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimportmissingreferenceserror.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportMissingReferencesError](./kibana-plugin-public.savedobjectsimportmissingreferenceserror.md)
+
+## SavedObjectsImportMissingReferencesError interface
+
+Represents a failure to import due to missing references.
+
+Signature:
+
+```typescript
+export interface SavedObjectsImportMissingReferencesError
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [blocking](./kibana-plugin-public.savedobjectsimportmissingreferenceserror.blocking.md) | Array<{
type: string;
id: string;
}> | |
+| [references](./kibana-plugin-public.savedobjectsimportmissingreferenceserror.references.md) | Array<{
type: string;
id: string;
}> | |
+| [type](./kibana-plugin-public.savedobjectsimportmissingreferenceserror.type.md) | 'missing_references' | |
+
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimportmissingreferenceserror.references.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimportmissingreferenceserror.references.md
new file mode 100644
index 0000000000000..f1dc3b454f7ed
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimportmissingreferenceserror.references.md
@@ -0,0 +1,14 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportMissingReferencesError](./kibana-plugin-public.savedobjectsimportmissingreferenceserror.md) > [references](./kibana-plugin-public.savedobjectsimportmissingreferenceserror.references.md)
+
+## SavedObjectsImportMissingReferencesError.references property
+
+Signature:
+
+```typescript
+references: Array<{
+ type: string;
+ id: string;
+ }>;
+```
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimportmissingreferenceserror.type.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimportmissingreferenceserror.type.md
new file mode 100644
index 0000000000000..340b36248d83e
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimportmissingreferenceserror.type.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportMissingReferencesError](./kibana-plugin-public.savedobjectsimportmissingreferenceserror.md) > [type](./kibana-plugin-public.savedobjectsimportmissingreferenceserror.type.md)
+
+## SavedObjectsImportMissingReferencesError.type property
+
+Signature:
+
+```typescript
+type: 'missing_references';
+```
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimportresponse.errors.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimportresponse.errors.md
new file mode 100644
index 0000000000000..c085fd0f8c3b4
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimportresponse.errors.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportResponse](./kibana-plugin-public.savedobjectsimportresponse.md) > [errors](./kibana-plugin-public.savedobjectsimportresponse.errors.md)
+
+## SavedObjectsImportResponse.errors property
+
+Signature:
+
+```typescript
+errors?: SavedObjectsImportError[];
+```
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimportresponse.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimportresponse.md
new file mode 100644
index 0000000000000..9733f11fd6b8f
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimportresponse.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportResponse](./kibana-plugin-public.savedobjectsimportresponse.md)
+
+## SavedObjectsImportResponse interface
+
+The response describing the result of an import.
+
+Signature:
+
+```typescript
+export interface SavedObjectsImportResponse
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [errors](./kibana-plugin-public.savedobjectsimportresponse.errors.md) | SavedObjectsImportError[] | |
+| [success](./kibana-plugin-public.savedobjectsimportresponse.success.md) | boolean | |
+| [successCount](./kibana-plugin-public.savedobjectsimportresponse.successcount.md) | number | |
+
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimportresponse.success.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimportresponse.success.md
new file mode 100644
index 0000000000000..062b8ce3f7c72
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimportresponse.success.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportResponse](./kibana-plugin-public.savedobjectsimportresponse.md) > [success](./kibana-plugin-public.savedobjectsimportresponse.success.md)
+
+## SavedObjectsImportResponse.success property
+
+Signature:
+
+```typescript
+success: boolean;
+```
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimportresponse.successcount.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimportresponse.successcount.md
new file mode 100644
index 0000000000000..c2c9385926175
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimportresponse.successcount.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportResponse](./kibana-plugin-public.savedobjectsimportresponse.md) > [successCount](./kibana-plugin-public.savedobjectsimportresponse.successcount.md)
+
+## SavedObjectsImportResponse.successCount property
+
+Signature:
+
+```typescript
+successCount: number;
+```
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimportretry.id.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimportretry.id.md
new file mode 100644
index 0000000000000..2569152f17b15
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimportretry.id.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportRetry](./kibana-plugin-public.savedobjectsimportretry.md) > [id](./kibana-plugin-public.savedobjectsimportretry.id.md)
+
+## SavedObjectsImportRetry.id property
+
+Signature:
+
+```typescript
+id: string;
+```
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimportretry.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimportretry.md
new file mode 100644
index 0000000000000..e2cad52f92f2d
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimportretry.md
@@ -0,0 +1,23 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportRetry](./kibana-plugin-public.savedobjectsimportretry.md)
+
+## SavedObjectsImportRetry interface
+
+Describes a retry operation for importing a saved object.
+
+Signature:
+
+```typescript
+export interface SavedObjectsImportRetry
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [id](./kibana-plugin-public.savedobjectsimportretry.id.md) | string | |
+| [overwrite](./kibana-plugin-public.savedobjectsimportretry.overwrite.md) | boolean | |
+| [replaceReferences](./kibana-plugin-public.savedobjectsimportretry.replacereferences.md) | Array<{
type: string;
from: string;
to: string;
}> | |
+| [type](./kibana-plugin-public.savedobjectsimportretry.type.md) | string | |
+
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimportretry.overwrite.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimportretry.overwrite.md
new file mode 100644
index 0000000000000..9d1f96b2fcfcf
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimportretry.overwrite.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportRetry](./kibana-plugin-public.savedobjectsimportretry.md) > [overwrite](./kibana-plugin-public.savedobjectsimportretry.overwrite.md)
+
+## SavedObjectsImportRetry.overwrite property
+
+Signature:
+
+```typescript
+overwrite: boolean;
+```
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimportretry.replacereferences.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimportretry.replacereferences.md
new file mode 100644
index 0000000000000..fe587ef8134cc
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimportretry.replacereferences.md
@@ -0,0 +1,15 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportRetry](./kibana-plugin-public.savedobjectsimportretry.md) > [replaceReferences](./kibana-plugin-public.savedobjectsimportretry.replacereferences.md)
+
+## SavedObjectsImportRetry.replaceReferences property
+
+Signature:
+
+```typescript
+replaceReferences: Array<{
+ type: string;
+ from: string;
+ to: string;
+ }>;
+```
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimportretry.type.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimportretry.type.md
new file mode 100644
index 0000000000000..b84dac102483a
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimportretry.type.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportRetry](./kibana-plugin-public.savedobjectsimportretry.md) > [type](./kibana-plugin-public.savedobjectsimportretry.type.md)
+
+## SavedObjectsImportRetry.type property
+
+Signature:
+
+```typescript
+type: string;
+```
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimportunknownerror.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimportunknownerror.md
new file mode 100644
index 0000000000000..e683757171787
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimportunknownerror.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportUnknownError](./kibana-plugin-public.savedobjectsimportunknownerror.md)
+
+## SavedObjectsImportUnknownError interface
+
+Represents a failure to import due to an unknown reason.
+
+Signature:
+
+```typescript
+export interface SavedObjectsImportUnknownError
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [message](./kibana-plugin-public.savedobjectsimportunknownerror.message.md) | string | |
+| [statusCode](./kibana-plugin-public.savedobjectsimportunknownerror.statuscode.md) | number | |
+| [type](./kibana-plugin-public.savedobjectsimportunknownerror.type.md) | 'unknown' | |
+
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimportunknownerror.message.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimportunknownerror.message.md
new file mode 100644
index 0000000000000..976c2817bda0a
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimportunknownerror.message.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportUnknownError](./kibana-plugin-public.savedobjectsimportunknownerror.md) > [message](./kibana-plugin-public.savedobjectsimportunknownerror.message.md)
+
+## SavedObjectsImportUnknownError.message property
+
+Signature:
+
+```typescript
+message: string;
+```
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimportunknownerror.statuscode.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimportunknownerror.statuscode.md
new file mode 100644
index 0000000000000..6c7255dd4b631
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimportunknownerror.statuscode.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportUnknownError](./kibana-plugin-public.savedobjectsimportunknownerror.md) > [statusCode](./kibana-plugin-public.savedobjectsimportunknownerror.statuscode.md)
+
+## SavedObjectsImportUnknownError.statusCode property
+
+Signature:
+
+```typescript
+statusCode: number;
+```
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimportunknownerror.type.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimportunknownerror.type.md
new file mode 100644
index 0000000000000..2ef764d68322e
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimportunknownerror.type.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportUnknownError](./kibana-plugin-public.savedobjectsimportunknownerror.md) > [type](./kibana-plugin-public.savedobjectsimportunknownerror.type.md)
+
+## SavedObjectsImportUnknownError.type property
+
+Signature:
+
+```typescript
+type: 'unknown';
+```
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimportunsupportedtypeerror.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimportunsupportedtypeerror.md
new file mode 100644
index 0000000000000..09ae53c031352
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimportunsupportedtypeerror.md
@@ -0,0 +1,20 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportUnsupportedTypeError](./kibana-plugin-public.savedobjectsimportunsupportedtypeerror.md)
+
+## SavedObjectsImportUnsupportedTypeError interface
+
+Represents a failure to import due to having an unsupported saved object type.
+
+Signature:
+
+```typescript
+export interface SavedObjectsImportUnsupportedTypeError
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [type](./kibana-plugin-public.savedobjectsimportunsupportedtypeerror.type.md) | 'unsupported_type' | |
+
diff --git a/docs/development/core/public/kibana-plugin-public.savedobjectsimportunsupportedtypeerror.type.md b/docs/development/core/public/kibana-plugin-public.savedobjectsimportunsupportedtypeerror.type.md
new file mode 100644
index 0000000000000..55ddf15058fab
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.savedobjectsimportunsupportedtypeerror.type.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [SavedObjectsImportUnsupportedTypeError](./kibana-plugin-public.savedobjectsimportunsupportedtypeerror.md) > [type](./kibana-plugin-public.savedobjectsimportunsupportedtypeerror.type.md)
+
+## SavedObjectsImportUnsupportedTypeError.type property
+
+Signature:
+
+```typescript
+type: 'unsupported_type';
+```
diff --git a/src/core/public/index.ts b/src/core/public/index.ts
index f53bf44bcdcfd..f83ca2564de8e 100644
--- a/src/core/public/index.ts
+++ b/src/core/public/index.ts
@@ -111,6 +111,13 @@ export {
SavedObjectsClientContract,
SavedObjectsClient,
SimpleSavedObject,
+ SavedObjectsImportResponse,
+ SavedObjectsImportConflictError,
+ SavedObjectsImportUnsupportedTypeError,
+ SavedObjectsImportMissingReferencesError,
+ SavedObjectsImportUnknownError,
+ SavedObjectsImportError,
+ SavedObjectsImportRetry,
} from './saved_objects';
export {
diff --git a/src/core/public/public.api.md b/src/core/public/public.api.md
index 37c204a519801..83b4e67c1cb15 100644
--- a/src/core/public/public.api.md
+++ b/src/core/public/public.api.md
@@ -939,6 +939,82 @@ export interface SavedObjectsFindResponsePublic;
+ // (undocumented)
+ references: Array<{
+ type: string;
+ id: string;
+ }>;
+ // (undocumented)
+ type: 'missing_references';
+}
+
+// @public
+export interface SavedObjectsImportResponse {
+ // (undocumented)
+ errors?: SavedObjectsImportError[];
+ // (undocumented)
+ success: boolean;
+ // (undocumented)
+ successCount: number;
+}
+
+// @public
+export interface SavedObjectsImportRetry {
+ // (undocumented)
+ id: string;
+ // (undocumented)
+ overwrite: boolean;
+ // (undocumented)
+ replaceReferences: Array<{
+ type: string;
+ from: string;
+ to: string;
+ }>;
+ // (undocumented)
+ type: string;
+}
+
+// @public
+export interface SavedObjectsImportUnknownError {
+ // (undocumented)
+ message: string;
+ // (undocumented)
+ statusCode: number;
+ // (undocumented)
+ type: 'unknown';
+}
+
+// @public
+export interface SavedObjectsImportUnsupportedTypeError {
+ // (undocumented)
+ type: 'unsupported_type';
+}
+
// @public
export interface SavedObjectsMigrationVersion {
// (undocumented)
diff --git a/src/core/public/saved_objects/index.ts b/src/core/public/saved_objects/index.ts
index 453c3e42a1687..5015a9c3db78e 100644
--- a/src/core/public/saved_objects/index.ts
+++ b/src/core/public/saved_objects/index.ts
@@ -40,4 +40,11 @@ export {
SavedObjectsBaseOptions,
SavedObjectsFindOptions,
SavedObjectsMigrationVersion,
+ SavedObjectsImportResponse,
+ SavedObjectsImportConflictError,
+ SavedObjectsImportUnsupportedTypeError,
+ SavedObjectsImportMissingReferencesError,
+ SavedObjectsImportUnknownError,
+ SavedObjectsImportError,
+ SavedObjectsImportRetry,
} from '../../server/types';
diff --git a/src/core/server/saved_objects/types.ts b/src/core/server/saved_objects/types.ts
index 2c6f5e4a520a7..c1fa820ef2019 100644
--- a/src/core/server/saved_objects/types.ts
+++ b/src/core/server/saved_objects/types.ts
@@ -23,6 +23,16 @@ import { MigrationDefinition } from './migrations/core/document_migrator';
import { SavedObjectsSchemaDefinition } from './schema';
import { PropertyValidators } from './validation';
+export {
+ SavedObjectsImportResponse,
+ SavedObjectsImportConflictError,
+ SavedObjectsImportUnsupportedTypeError,
+ SavedObjectsImportMissingReferencesError,
+ SavedObjectsImportUnknownError,
+ SavedObjectsImportError,
+ SavedObjectsImportRetry,
+} from './import/types';
+
/**
* Information about the migrations that have been applied to this SavedObject.
* When Kibana starts up, KibanaMigrator detects outdated documents and
diff --git a/src/legacy/core_plugins/kibana/public/dashboard/migrations/migrations_730.ts b/src/legacy/core_plugins/kibana/public/dashboard/migrations/migrations_730.ts
index 5300811a6dab9..1ab5738cf4752 100644
--- a/src/legacy/core_plugins/kibana/public/dashboard/migrations/migrations_730.ts
+++ b/src/legacy/core_plugins/kibana/public/dashboard/migrations/migrations_730.ts
@@ -16,6 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
+// This file should be moved to dashboard/server/
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { SavedObjectsMigrationLogger } from 'src/core/server';
import { inspect } from 'util';
import { DashboardDoc730ToLatest, DashboardDoc700To720 } from './types';
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/process_import_response.ts b/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/process_import_response.ts
index 029cb620b52c7..2444d18133af4 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/process_import_response.ts
+++ b/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/process_import_response.ts
@@ -24,7 +24,7 @@ import {
SavedObjectsImportMissingReferencesError,
SavedObjectsImportUnknownError,
SavedObjectsImportError,
-} from 'src/core/server';
+} from 'src/core/public';
export interface ProcessedImportResponse {
failedImports: Array<{
diff --git a/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts b/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts
index 4c7ea6676f9ef..acc2da1514483 100644
--- a/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts
+++ b/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts
@@ -17,7 +17,7 @@
* under the License.
*/
-import { SavedObjectAttributes } from 'src/core/server';
+import { SavedObjectAttributes } from 'src/core/public';
import { SavedObjectMetaData } from '../types';
import { EmbeddableInput, EmbeddableOutput, IEmbeddable } from './i_embeddable';
import { ErrorEmbeddable } from './error_embeddable';
diff --git a/src/plugins/kibana_react/public/saved_objects/saved_object_finder.tsx b/src/plugins/kibana_react/public/saved_objects/saved_object_finder.tsx
index 51fbbd2ba3046..bd2beaf77a305 100644
--- a/src/plugins/kibana_react/public/saved_objects/saved_object_finder.tsx
+++ b/src/plugins/kibana_react/public/saved_objects/saved_object_finder.tsx
@@ -44,7 +44,7 @@ import {
import { Direction } from '@elastic/eui/src/services/sort/sort_direction';
import { i18n } from '@kbn/i18n';
-import { SavedObjectAttributes } from '../../../../core/server';
+import { SavedObjectAttributes } from '../../../../core/public';
import { SimpleSavedObject, CoreStart } from '../../../../core/public';
import { useKibana } from '../context';
diff --git a/x-pack/legacy/plugins/actions/server/shim.ts b/x-pack/legacy/plugins/actions/server/shim.ts
index 1af62d276f10b..c40e4ea79d1c3 100644
--- a/x-pack/legacy/plugins/actions/server/shim.ts
+++ b/x-pack/legacy/plugins/actions/server/shim.ts
@@ -9,7 +9,7 @@ import { Legacy } from 'kibana';
import * as Rx from 'rxjs';
import { ActionsConfigType } from './types';
import { TaskManager } from '../../task_manager';
-import { XPackMainPlugin } from '../../xpack_main/xpack_main';
+import { XPackMainPlugin } from '../../xpack_main/server/xpack_main';
import KbnServer from '../../../../../src/legacy/server/kbn_server';
import { LegacySpacesPlugin as SpacesPluginStartContract } from '../../spaces';
import {
diff --git a/x-pack/legacy/plugins/alerting/server/shim.ts b/x-pack/legacy/plugins/alerting/server/shim.ts
index 0ee1ef843d7d0..ef1f1b41049e5 100644
--- a/x-pack/legacy/plugins/alerting/server/shim.ts
+++ b/x-pack/legacy/plugins/alerting/server/shim.ts
@@ -8,7 +8,7 @@ import Hapi from 'hapi';
import { Legacy } from 'kibana';
import { LegacySpacesPlugin as SpacesPluginStartContract } from '../../spaces';
import { TaskManager } from '../../task_manager';
-import { XPackMainPlugin } from '../../xpack_main/xpack_main';
+import { XPackMainPlugin } from '../../xpack_main/server/xpack_main';
import KbnServer from '../../../../../src/legacy/server/kbn_server';
import {
PluginSetupContract as EncryptedSavedObjectsSetupContract,
diff --git a/x-pack/legacy/plugins/apm/index.ts b/x-pack/legacy/plugins/apm/index.ts
index 91745246687d9..cf2cbd2507215 100644
--- a/x-pack/legacy/plugins/apm/index.ts
+++ b/x-pack/legacy/plugins/apm/index.ts
@@ -7,7 +7,7 @@
import { i18n } from '@kbn/i18n';
import { Server } from 'hapi';
import { resolve } from 'path';
-import { APMPluginContract } from '../../../plugins/apm/server/plugin';
+import { APMPluginContract } from '../../../plugins/apm/server';
import { LegacyPluginInitializer } from '../../../../src/legacy/types';
import mappings from './mappings.json';
import { makeApmUsageCollector } from './server/lib/apm_telemetry';
diff --git a/x-pack/legacy/plugins/apm/public/utils/testHelpers.tsx b/x-pack/legacy/plugins/apm/public/utils/testHelpers.tsx
index 4e0a0209926bf..0c8a7cbc17884 100644
--- a/x-pack/legacy/plugins/apm/public/utils/testHelpers.tsx
+++ b/x-pack/legacy/plugins/apm/public/utils/testHelpers.tsx
@@ -15,6 +15,7 @@ import React, { ReactNode } from 'react';
import { render, waitForElement } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
import { MemoryRouter } from 'react-router-dom';
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { APMConfig } from '../../../../../plugins/apm/server';
import { LocationProvider } from '../context/LocationContext';
import { PromiseReturnType } from '../../typings/common';
diff --git a/x-pack/legacy/plugins/canvas/shareable_runtime/types.ts b/x-pack/legacy/plugins/canvas/shareable_runtime/types.ts
index 08004f8ff8b45..191c0405d2e2d 100644
--- a/x-pack/legacy/plugins/canvas/shareable_runtime/types.ts
+++ b/x-pack/legacy/plugins/canvas/shareable_runtime/types.ts
@@ -7,7 +7,7 @@
import { RefObject } from 'react';
// @ts-ignore Unlinked Webpack Type
import ContainerStyle from 'types/interpreter';
-import { SavedObject, SavedObjectAttributes } from 'src/core/server';
+import { SavedObject, SavedObjectAttributes } from 'src/core/public';
import { ElementPosition, CanvasPage, CanvasWorkpad, RendererSpec } from '../types';
diff --git a/x-pack/legacy/plugins/infra/index.ts b/x-pack/legacy/plugins/infra/index.ts
index dbf1f4ad61de3..5466f2572a48e 100644
--- a/x-pack/legacy/plugins/infra/index.ts
+++ b/x-pack/legacy/plugins/infra/index.ts
@@ -14,7 +14,7 @@ import { getConfigSchema } from './server/kibana.index';
import { savedObjectMappings } from './server/saved_objects';
import { plugin, InfraServerPluginDeps } from './server/new_platform_index';
import { InfraSetup } from '../../../plugins/infra/server';
-import { APMPluginContract } from '../../../plugins/apm/server/plugin';
+import { APMPluginContract } from '../../../plugins/apm/server';
const APP_ID = 'infra';
const logsSampleDataLinkLabel = i18n.translate('xpack.infra.sampleDataLinkLabel', {
diff --git a/x-pack/legacy/plugins/infra/public/hooks/use_bulk_get_saved_object.tsx b/x-pack/legacy/plugins/infra/public/hooks/use_bulk_get_saved_object.tsx
index 3a40c4fa6bf0c..934022d6e6bd0 100644
--- a/x-pack/legacy/plugins/infra/public/hooks/use_bulk_get_saved_object.tsx
+++ b/x-pack/legacy/plugins/infra/public/hooks/use_bulk_get_saved_object.tsx
@@ -7,8 +7,7 @@
import { useState, useCallback } from 'react';
import { npStart } from 'ui/new_platform';
-import { SavedObjectsBatchResponse } from 'src/core/public';
-import { SavedObjectAttributes } from 'src/core/server';
+import { SavedObjectAttributes, SavedObjectsBatchResponse } from 'src/core/public';
export const useBulkGetSavedObject = (type: string) => {
const [data, setData] = useState | null>(null);
diff --git a/x-pack/legacy/plugins/infra/public/hooks/use_create_saved_object.tsx b/x-pack/legacy/plugins/infra/public/hooks/use_create_saved_object.tsx
index 80811a6d6c7bf..f03a198355bb8 100644
--- a/x-pack/legacy/plugins/infra/public/hooks/use_create_saved_object.tsx
+++ b/x-pack/legacy/plugins/infra/public/hooks/use_create_saved_object.tsx
@@ -7,8 +7,11 @@
import { useState, useCallback } from 'react';
import { npStart } from 'ui/new_platform';
-import { SavedObjectsCreateOptions, SimpleSavedObject } from 'src/core/public';
-import { SavedObjectAttributes } from 'src/core/server';
+import {
+ SavedObjectAttributes,
+ SavedObjectsCreateOptions,
+ SimpleSavedObject,
+} from 'src/core/public';
export const useCreateSavedObject = (type: string) => {
const [data, setData] = useState | null>(null);
diff --git a/x-pack/legacy/plugins/infra/public/hooks/use_find_saved_object.tsx b/x-pack/legacy/plugins/infra/public/hooks/use_find_saved_object.tsx
index 949a2344418e9..2487d830266b1 100644
--- a/x-pack/legacy/plugins/infra/public/hooks/use_find_saved_object.tsx
+++ b/x-pack/legacy/plugins/infra/public/hooks/use_find_saved_object.tsx
@@ -7,8 +7,7 @@
import { useState, useCallback } from 'react';
import { npStart } from 'ui/new_platform';
-import { SavedObjectsBatchResponse } from 'src/core/public';
-import { SavedObjectAttributes } from 'src/core/server';
+import { SavedObjectAttributes, SavedObjectsBatchResponse } from 'src/core/public';
export const useFindSavedObject = (type: string) => {
const [data, setData] = useState | null>(null);
diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/framework/adapter_types.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/framework/adapter_types.ts
index e88736b08b95b..a0fd6d3e951bf 100644
--- a/x-pack/legacy/plugins/infra/server/lib/adapters/framework/adapter_types.ts
+++ b/x-pack/legacy/plugins/infra/server/lib/adapters/framework/adapter_types.ts
@@ -9,7 +9,7 @@ import { Lifecycle } from 'hapi';
import { ObjectType } from '@kbn/config-schema';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
import { RouteMethod, RouteConfig } from '../../../../../../../../src/core/server';
-import { APMPluginContract } from '../../../../../../../plugins/apm/server/plugin';
+import { APMPluginContract } from '../../../../../../../plugins/apm/server';
// NP_TODO: Compose real types from plugins we depend on, no "any"
export interface InfraServerPluginDeps {
diff --git a/x-pack/legacy/plugins/lens/server/usage/task.ts b/x-pack/legacy/plugins/lens/server/usage/task.ts
index feb73538f44f0..64bc37ce909a2 100644
--- a/x-pack/legacy/plugins/lens/server/usage/task.ts
+++ b/x-pack/legacy/plugins/lens/server/usage/task.ts
@@ -15,7 +15,7 @@ import {
DeleteDocumentByQueryResponse,
} from 'elasticsearch';
import { ESSearchResponse } from '../../../apm/typings/elasticsearch';
-import { XPackMainPlugin } from '../../../xpack_main/xpack_main';
+import { XPackMainPlugin } from '../../../xpack_main/server/xpack_main';
import { RunContext } from '../../../task_manager';
import { getVisualizationCounts } from './visualization_counts';
diff --git a/x-pack/legacy/plugins/license_management/public/np_ready/plugin.ts b/x-pack/legacy/plugins/license_management/public/np_ready/plugin.ts
index abd658ff91db0..1da3c942830ca 100644
--- a/x-pack/legacy/plugins/license_management/public/np_ready/plugin.ts
+++ b/x-pack/legacy/plugins/license_management/public/np_ready/plugin.ts
@@ -5,7 +5,7 @@
*/
import { CoreSetup, CoreStart, Plugin } from 'src/core/public';
-import { XPackMainPlugin } from '../../../xpack_main/xpack_main';
+import { XPackMainPlugin } from '../../../xpack_main/server/xpack_main';
import { PLUGIN } from '../../common/constants';
import { Breadcrumb } from './application/breadcrumbs';
diff --git a/x-pack/legacy/plugins/license_management/server/np_ready/types.ts b/x-pack/legacy/plugins/license_management/server/np_ready/types.ts
index a636481323e29..0e66946ec1cc6 100644
--- a/x-pack/legacy/plugins/license_management/server/np_ready/types.ts
+++ b/x-pack/legacy/plugins/license_management/server/np_ready/types.ts
@@ -5,7 +5,7 @@
*/
import { IRouter } from 'src/core/server';
-import { XPackMainPlugin } from '../../../xpack_main/xpack_main';
+import { XPackMainPlugin } from '../../../xpack_main/server/xpack_main';
import { ElasticsearchPlugin } from '../../../../../../src/legacy/core_plugins/elasticsearch';
export interface Dependencies {
diff --git a/x-pack/legacy/plugins/ml/common/types/modules.ts b/x-pack/legacy/plugins/ml/common/types/modules.ts
index 52259d8748a95..cd6395500a804 100644
--- a/x-pack/legacy/plugins/ml/common/types/modules.ts
+++ b/x-pack/legacy/plugins/ml/common/types/modules.ts
@@ -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 { SavedObjectAttributes } from 'src/core/server/types';
+import { SavedObjectAttributes } from 'src/core/public';
import { Datafeed, Job } from '../../public/application/jobs/new_job/common/job_creator/configs';
export interface ModuleJob {
diff --git a/x-pack/legacy/plugins/ml/server/lib/check_privileges/check_privileges.ts b/x-pack/legacy/plugins/ml/server/lib/check_privileges/check_privileges.ts
index e7c896bb36ed8..6b426169799a7 100644
--- a/x-pack/legacy/plugins/ml/server/lib/check_privileges/check_privileges.ts
+++ b/x-pack/legacy/plugins/ml/server/lib/check_privileges/check_privileges.ts
@@ -5,7 +5,7 @@
*/
import { Privileges, getDefaultPrivileges } from '../../../common/types/privileges';
-import { XPackMainPlugin } from '../../../../../../legacy/plugins/xpack_main/xpack_main';
+import { XPackMainPlugin } from '../../../../xpack_main/server/xpack_main';
import { callWithRequestType } from '../../../common/types/kibana';
import { isSecurityDisabled } from '../../lib/security_utils';
import { upgradeCheckProvider } from './upgrade';
diff --git a/x-pack/legacy/plugins/ml/server/lib/security_utils.d.ts b/x-pack/legacy/plugins/ml/server/lib/security_utils.d.ts
index 84d9961b0c6f0..26fdff73b3460 100644
--- a/x-pack/legacy/plugins/ml/server/lib/security_utils.d.ts
+++ b/x-pack/legacy/plugins/ml/server/lib/security_utils.d.ts
@@ -4,6 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { XPackMainPlugin } from '../../../../../legacy/plugins/xpack_main/xpack_main';
+import { XPackMainPlugin } from '../../../xpack_main/server/xpack_main';
export function isSecurityDisabled(xpackMainPlugin: XPackMainPlugin): boolean;
diff --git a/x-pack/legacy/plugins/ml/server/new_platform/plugin.ts b/x-pack/legacy/plugins/ml/server/new_platform/plugin.ts
index 727d05605614f..c468c87d7abc8 100644
--- a/x-pack/legacy/plugins/ml/server/new_platform/plugin.ts
+++ b/x-pack/legacy/plugins/ml/server/new_platform/plugin.ts
@@ -12,7 +12,7 @@ import { Logger, PluginInitializerContext, CoreSetup } from 'src/core/server';
import { ElasticsearchPlugin } from 'src/legacy/core_plugins/elasticsearch';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
import { CloudSetup } from '../../../../../plugins/cloud/server';
-import { XPackMainPlugin } from '../../../xpack_main/xpack_main';
+import { XPackMainPlugin } from '../../../xpack_main/server/xpack_main';
import { addLinksToSampleDatasets } from '../lib/sample_data_sets';
import { checkLicense } from '../lib/check_license';
// @ts-ignore: could not find declaration file for module
diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/__tests__/execute_job.js b/x-pack/legacy/plugins/reporting/export_types/csv/server/__tests__/execute_job.js
index 16408b09d5953..3e35fd970e2c7 100644
--- a/x-pack/legacy/plugins/reporting/export_types/csv/server/__tests__/execute_job.js
+++ b/x-pack/legacy/plugins/reporting/export_types/csv/server/__tests__/execute_job.js
@@ -11,6 +11,8 @@ import nodeCrypto from '@elastic/node-crypto';
import { CancellationToken } from '../../../../common/cancellation_token';
import { FieldFormatsService } from '../../../../../../../../src/legacy/ui/field_formats/mixin/field_formats_service';
+// Reporting uses an unconventional directory structure so the linter marks this as a violation
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { StringFormat } from '../../../../../../../../src/plugins/data/server';
import { executeJobFactory } from '../execute_job';
diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/__tests__/field_format_map.js b/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/__tests__/field_format_map.js
index e9da43aa1dd32..ac130e4721601 100644
--- a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/__tests__/field_format_map.js
+++ b/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/__tests__/field_format_map.js
@@ -7,6 +7,8 @@
import expect from '@kbn/expect';
import { FieldFormatsService } from '../../../../../../../../../src/legacy/ui/field_formats/mixin/field_formats_service';
+// Reporting uses an unconventional directory structure so the linter marks this as a violation
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { BytesFormat, NumberFormat } from '../../../../../../../../../src/plugins/data/server';
import { fieldFormatMapFactory } from '../field_format_map';
diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts b/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts
index 081800d1d7b2d..ba29c3ef1ec3f 100644
--- a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts
+++ b/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts
@@ -18,11 +18,15 @@ import {
import { getDataSource } from './get_data_source';
import { getFilters } from './get_filters';
import { JobParamsDiscoverCsv } from '../../../csv/types';
+
import {
esQuery,
esFilters,
IIndexPattern,
Query,
+ // Reporting uses an unconventional directory structure so the linter marks this as a violation, server files should
+ // be moved under reporting/server/
+ // eslint-disable-next-line @kbn/eslint/no-restricted-paths
} from '../../../../../../../../src/plugins/data/server';
const getEsQueryConfig = async (config: any) => {
diff --git a/x-pack/legacy/plugins/reporting/server/usage/get_export_type_handler.ts b/x-pack/legacy/plugins/reporting/server/usage/get_export_type_handler.ts
index f8913a0dcea6b..7874f67ef4c0c 100644
--- a/x-pack/legacy/plugins/reporting/server/usage/get_export_type_handler.ts
+++ b/x-pack/legacy/plugins/reporting/server/usage/get_export_type_handler.ts
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { XPackMainPlugin } from '../../../xpack_main/xpack_main';
+import { XPackMainPlugin } from '../../../xpack_main/server/xpack_main';
import { ExportTypesRegistry } from '../lib/export_types_registry';
/*
diff --git a/x-pack/legacy/plugins/reporting/types.d.ts b/x-pack/legacy/plugins/reporting/types.d.ts
index 597e9cafdc2a2..c17b969d5d7fa 100644
--- a/x-pack/legacy/plugins/reporting/types.d.ts
+++ b/x-pack/legacy/plugins/reporting/types.d.ts
@@ -7,7 +7,7 @@
import { ResponseObject } from 'hapi';
import { EventEmitter } from 'events';
import { Legacy } from 'kibana';
-import { XPackMainPlugin } from '../xpack_main/xpack_main';
+import { XPackMainPlugin } from '../xpack_main/server/xpack_main';
import {
ElasticsearchPlugin,
CallCluster,
diff --git a/x-pack/legacy/plugins/searchprofiler/server/np_ready/types.ts b/x-pack/legacy/plugins/searchprofiler/server/np_ready/types.ts
index 7862aa386785b..9b25f8bb36b0c 100644
--- a/x-pack/legacy/plugins/searchprofiler/server/np_ready/types.ts
+++ b/x-pack/legacy/plugins/searchprofiler/server/np_ready/types.ts
@@ -6,7 +6,7 @@
import { ServerRoute } from 'hapi';
import { ElasticsearchPlugin, Request } from 'src/legacy/core_plugins/elasticsearch';
-import { XPackMainPlugin } from '../../../xpack_main/xpack_main';
+import { XPackMainPlugin } from '../../../xpack_main/server/xpack_main';
export type RegisterRoute = (args: ServerRoute & { config: any }) => void;
diff --git a/x-pack/legacy/plugins/security/public/views/management/edit_role/components/edit_role_page.test.tsx b/x-pack/legacy/plugins/security/public/views/management/edit_role/components/edit_role_page.test.tsx
index cb60b773f92e0..67c32c8393171 100644
--- a/x-pack/legacy/plugins/security/public/views/management/edit_role/components/edit_role_page.test.tsx
+++ b/x-pack/legacy/plugins/security/public/views/management/edit_role/components/edit_role_page.test.tsx
@@ -9,8 +9,11 @@ import React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { UICapabilities } from 'ui/capabilities';
import { Space } from '../../../../../../spaces/common/model/space';
-import { Feature } from '../../../../../../../../plugins/features/server';
+import { Feature } from '../../../../../../../../plugins/features/public';
+// These modules should be moved into a common directory
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { Actions } from '../../../../../../../../plugins/security/server/authorization/actions';
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { privilegesFactory } from '../../../../../../../../plugins/security/server/authorization/privileges';
import { RawKibanaPrivileges, Role } from '../../../../../common/model';
import { EditRolePage } from './edit_role_page';
diff --git a/x-pack/legacy/plugins/security/public/views/management/edit_role/components/edit_role_page.tsx b/x-pack/legacy/plugins/security/public/views/management/edit_role/components/edit_role_page.tsx
index c5bf910b007d0..7637d28dd4229 100644
--- a/x-pack/legacy/plugins/security/public/views/management/edit_role/components/edit_role_page.tsx
+++ b/x-pack/legacy/plugins/security/public/views/management/edit_role/components/edit_role_page.tsx
@@ -23,7 +23,7 @@ import React, { ChangeEvent, Component, Fragment, HTMLProps } from 'react';
import { UICapabilities } from 'ui/capabilities';
import { toastNotifications } from 'ui/notify';
import { Space } from '../../../../../../spaces/common/model/space';
-import { Feature } from '../../../../../../../../plugins/features/server';
+import { Feature } from '../../../../../../../../plugins/features/public';
import {
KibanaPrivileges,
RawKibanaPrivileges,
diff --git a/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/feature_table/feature_table.tsx b/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/feature_table/feature_table.tsx
index 8425826235f0b..a05dc687fce4a 100644
--- a/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/feature_table/feature_table.tsx
+++ b/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/feature_table/feature_table.tsx
@@ -17,7 +17,7 @@ import {
import { FormattedMessage, InjectedIntl } from '@kbn/i18n/react';
import _ from 'lodash';
import React, { Component } from 'react';
-import { Feature } from '../../../../../../../../../../../plugins/features/server';
+import { Feature } from '../../../../../../../../../../../plugins/features/public';
import { FeaturesPrivileges, KibanaPrivileges, Role } from '../../../../../../../../common/model';
import {
AllowedPrivilege,
diff --git a/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/kibana_privileges_region.tsx b/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/kibana_privileges_region.tsx
index 199067b2e7469..97d61916926b6 100644
--- a/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/kibana_privileges_region.tsx
+++ b/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/kibana_privileges_region.tsx
@@ -8,7 +8,7 @@ import { InjectedIntl } from '@kbn/i18n/react';
import React, { Component } from 'react';
import { UICapabilities } from 'ui/capabilities';
import { Space } from '../../../../../../../../spaces/common/model/space';
-import { Feature } from '../../../../../../../../../../plugins/features/server';
+import { Feature } from '../../../../../../../../../../plugins/features/public';
import { KibanaPrivileges, Role } from '../../../../../../../common/model';
import { KibanaPrivilegeCalculatorFactory } from '../../../../../../lib/kibana_privilege_calculator';
import { RoleValidator } from '../../../lib/validate_role';
diff --git a/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/simple_privilege_section/simple_privilege_section.test.tsx b/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/simple_privilege_section/simple_privilege_section.test.tsx
index 74d62b0c86758..1f29f774fd6cc 100644
--- a/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/simple_privilege_section/simple_privilege_section.test.tsx
+++ b/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/simple_privilege_section/simple_privilege_section.test.tsx
@@ -7,7 +7,7 @@
import { EuiButtonGroup, EuiButtonGroupProps, EuiComboBox, EuiSuperSelect } from '@elastic/eui';
import React from 'react';
import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers';
-import { Feature } from '../../../../../../../../../../../plugins/features/server';
+import { Feature } from '../../../../../../../../../../../plugins/features/public';
import { KibanaPrivileges, Role } from '../../../../../../../../common/model';
import { KibanaPrivilegeCalculatorFactory } from '../../../../../../../lib/kibana_privilege_calculator';
import { SimplePrivilegeSection } from './simple_privilege_section';
diff --git a/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/simple_privilege_section/simple_privilege_section.tsx b/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/simple_privilege_section/simple_privilege_section.tsx
index d564179798ad8..7768dc769a32f 100644
--- a/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/simple_privilege_section/simple_privilege_section.tsx
+++ b/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/simple_privilege_section/simple_privilege_section.tsx
@@ -15,7 +15,7 @@ import {
import { FormattedMessage, InjectedIntl } from '@kbn/i18n/react';
import React, { Component, Fragment } from 'react';
-import { Feature } from '../../../../../../../../../../../plugins/features/server';
+import { Feature } from '../../../../../../../../../../../plugins/features/public';
import { KibanaPrivileges, Role, RoleKibanaPrivilege } from '../../../../../../../../common/model';
import { KibanaPrivilegeCalculatorFactory } from '../../../../../../../lib/kibana_privilege_calculator';
import { isGlobalPrivilegeDefinition } from '../../../../../../../lib/privilege_utils';
diff --git a/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_section/privilege_matrix.test.tsx b/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_section/privilege_matrix.test.tsx
index 3d4a0d89ed7a1..ee121caa13a2a 100644
--- a/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_section/privilege_matrix.test.tsx
+++ b/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_section/privilege_matrix.test.tsx
@@ -8,7 +8,7 @@ import { EuiButtonEmpty, EuiInMemoryTable } from '@elastic/eui';
import React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { Space } from '../../../../../../../../../spaces/common/model/space';
-import { Feature } from '../../../../../../../../../../../plugins/features/server';
+import { Feature } from '../../../../../../../../../../../plugins/features/public';
import { KibanaPrivileges, Role } from '../../../../../../../../common/model';
import { KibanaPrivilegeCalculatorFactory } from '../../../../../../..//lib/kibana_privilege_calculator';
import { PrivilegeMatrix } from './privilege_matrix';
diff --git a/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_section/privilege_matrix.tsx b/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_section/privilege_matrix.tsx
index be49494efbe9a..92dace65d466c 100644
--- a/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_section/privilege_matrix.tsx
+++ b/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_section/privilege_matrix.tsx
@@ -24,7 +24,7 @@ import { FormattedMessage, InjectedIntl } from '@kbn/i18n/react';
import React, { Component, Fragment } from 'react';
import { Space } from '../../../../../../../../../spaces/common/model/space';
import { SpaceAvatar } from '../../../../../../../../../spaces/public/components';
-import { Feature } from '../../../../../../../../../../../plugins/features/server';
+import { Feature } from '../../../../../../../../../../../plugins/features/public';
import { FeaturesPrivileges, Role } from '../../../../../../../../common/model';
import { CalculatedPrivilege } from '../../../../../../../lib/kibana_privilege_calculator';
import { isGlobalPrivilegeDefinition } from '../../../../../../../lib/privilege_utils';
diff --git a/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_section/privilege_space_form.tsx b/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_section/privilege_space_form.tsx
index a616d3537cee3..5abb87d23bb6e 100644
--- a/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_section/privilege_space_form.tsx
+++ b/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_section/privilege_space_form.tsx
@@ -25,7 +25,7 @@ import {
import { FormattedMessage, InjectedIntl } from '@kbn/i18n/react';
import React, { Component, Fragment } from 'react';
import { Space } from '../../../../../../../../../spaces/common/model/space';
-import { Feature } from '../../../../../../../../../../../plugins/features/server';
+import { Feature } from '../../../../../../../../../../../plugins/features/public';
import { KibanaPrivileges, Role } from '../../../../../../../../common/model';
import {
AllowedPrivilege,
diff --git a/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_section/space_aware_privilege_section.tsx b/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_section/space_aware_privilege_section.tsx
index cdb5521bd0c86..d324cf99c8418 100644
--- a/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_section/space_aware_privilege_section.tsx
+++ b/x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_section/space_aware_privilege_section.tsx
@@ -16,7 +16,7 @@ import _ from 'lodash';
import React, { Component, Fragment } from 'react';
import { UICapabilities } from 'ui/capabilities';
import { Space } from '../../../../../../../../../spaces/common/model/space';
-import { Feature } from '../../../../../../../../../../../plugins/features/server';
+import { Feature } from '../../../../../../../../../../../plugins/features/public';
import { KibanaPrivileges, Role } from '../../../../../../../../common/model';
import { KibanaPrivilegeCalculatorFactory } from '../../../../../../../lib/kibana_privilege_calculator';
import { isReservedRole } from '../../../../../../../lib/role_utils';
diff --git a/x-pack/legacy/plugins/snapshot_restore/index.ts b/x-pack/legacy/plugins/snapshot_restore/index.ts
index 0cc1043e25557..19b67b41be2a6 100644
--- a/x-pack/legacy/plugins/snapshot_restore/index.ts
+++ b/x-pack/legacy/plugins/snapshot_restore/index.ts
@@ -7,8 +7,8 @@
import { Legacy } from 'kibana';
import { resolve } from 'path';
import { PLUGIN } from './common/constants';
-import { Plugin as SnapshotRestorePlugin } from './plugin';
-import { createShim } from './shim';
+import { Plugin as SnapshotRestorePlugin } from './server/plugin';
+import { createShim } from './server/shim';
export function snapshotRestore(kibana: any) {
return new kibana.Plugin({
diff --git a/x-pack/legacy/plugins/snapshot_restore/plugin.ts b/x-pack/legacy/plugins/snapshot_restore/server/plugin.ts
similarity index 79%
rename from x-pack/legacy/plugins/snapshot_restore/plugin.ts
rename to x-pack/legacy/plugins/snapshot_restore/server/plugin.ts
index 35ef05f91be8e..f9264ee1f2507 100644
--- a/x-pack/legacy/plugins/snapshot_restore/plugin.ts
+++ b/x-pack/legacy/plugins/snapshot_restore/server/plugin.ts
@@ -3,8 +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 { API_BASE_PATH } from './common/constants';
-import { registerRoutes } from './server/routes/api/register_routes';
+import { API_BASE_PATH } from '../common/constants';
+import { registerRoutes } from './routes/api/register_routes';
import { Core, Plugins } from './shim';
export class Plugin {
diff --git a/x-pack/legacy/plugins/snapshot_restore/server/routes/api/app.ts b/x-pack/legacy/plugins/snapshot_restore/server/routes/api/app.ts
index 6c7ad0ae30387..9961801ecc6c7 100644
--- a/x-pack/legacy/plugins/snapshot_restore/server/routes/api/app.ts
+++ b/x-pack/legacy/plugins/snapshot_restore/server/routes/api/app.ts
@@ -13,7 +13,7 @@ import {
// NOTE: now we import it from our "public" folder, but when the Authorisation lib
// will move to the "es_ui_shared" plugin, it will be imported from its "static" folder
import { Privileges } from '../../../public/app/lib/authorization';
-import { Plugins } from '../../../shim';
+import { Plugins } from '../../shim';
let xpackMainPlugin: any;
diff --git a/x-pack/legacy/plugins/snapshot_restore/server/routes/api/policy.ts b/x-pack/legacy/plugins/snapshot_restore/server/routes/api/policy.ts
index 38f9a2301af5a..bbfc82b8a6de9 100644
--- a/x-pack/legacy/plugins/snapshot_restore/server/routes/api/policy.ts
+++ b/x-pack/legacy/plugins/snapshot_restore/server/routes/api/policy.ts
@@ -10,7 +10,7 @@ import {
} from '../../../../../server/lib/create_router/error_wrappers';
import { SlmPolicyEs, SlmPolicy, SlmPolicyPayload } from '../../../common/types';
import { deserializePolicy, serializePolicy } from '../../../common/lib';
-import { Plugins } from '../../../shim';
+import { Plugins } from '../../shim';
import { getManagedPolicyNames } from '../../lib';
let callWithInternalUser: any;
diff --git a/x-pack/legacy/plugins/snapshot_restore/server/routes/api/register_routes.ts b/x-pack/legacy/plugins/snapshot_restore/server/routes/api/register_routes.ts
index 11a6cad86640e..713df194044d3 100644
--- a/x-pack/legacy/plugins/snapshot_restore/server/routes/api/register_routes.ts
+++ b/x-pack/legacy/plugins/snapshot_restore/server/routes/api/register_routes.ts
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { Router } from '../../../../../server/lib/create_router';
-import { Plugins } from '../../../shim';
+import { Plugins } from '../../shim';
import { registerAppRoutes } from './app';
import { registerRepositoriesRoutes } from './repositories';
import { registerSnapshotsRoutes } from './snapshots';
diff --git a/x-pack/legacy/plugins/snapshot_restore/server/routes/api/repositories.ts b/x-pack/legacy/plugins/snapshot_restore/server/routes/api/repositories.ts
index 13f44d2a1aeeb..f6ac946ab07d5 100644
--- a/x-pack/legacy/plugins/snapshot_restore/server/routes/api/repositories.ts
+++ b/x-pack/legacy/plugins/snapshot_restore/server/routes/api/repositories.ts
@@ -17,7 +17,7 @@ import {
SlmPolicyEs,
} from '../../../common/types';
-import { Plugins } from '../../../shim';
+import { Plugins } from '../../shim';
import {
deserializeRepositorySettings,
serializeRepositorySettings,
diff --git a/x-pack/legacy/plugins/snapshot_restore/server/routes/api/snapshots.ts b/x-pack/legacy/plugins/snapshot_restore/server/routes/api/snapshots.ts
index eed47b7343ec5..042a2dfeaf6b5 100644
--- a/x-pack/legacy/plugins/snapshot_restore/server/routes/api/snapshots.ts
+++ b/x-pack/legacy/plugins/snapshot_restore/server/routes/api/snapshots.ts
@@ -10,7 +10,7 @@ import {
} from '../../../../../server/lib/create_router/error_wrappers';
import { SnapshotDetails, SnapshotDetailsEs } from '../../../common/types';
import { deserializeSnapshotDetails } from '../../../common/lib';
-import { Plugins } from '../../../shim';
+import { Plugins } from '../../shim';
import { getManagedRepositoryName } from '../../lib';
let callWithInternalUser: any;
diff --git a/x-pack/legacy/plugins/snapshot_restore/shim.ts b/x-pack/legacy/plugins/snapshot_restore/server/shim.ts
similarity index 83%
rename from x-pack/legacy/plugins/snapshot_restore/shim.ts
rename to x-pack/legacy/plugins/snapshot_restore/server/shim.ts
index ef8d65fca77d4..84c9ddf8e0bea 100644
--- a/x-pack/legacy/plugins/snapshot_restore/shim.ts
+++ b/x-pack/legacy/plugins/snapshot_restore/server/shim.ts
@@ -6,10 +6,10 @@
import { i18n } from '@kbn/i18n';
import { Legacy } from 'kibana';
-import { createRouter, Router } from '../../server/lib/create_router';
-import { registerLicenseChecker } from '../../server/lib/register_license_checker';
-import { elasticsearchJsPlugin } from './server/client/elasticsearch_slm';
-import { CloudSetup } from '../../../plugins/cloud/server';
+import { createRouter, Router } from '../../../server/lib/create_router';
+import { registerLicenseChecker } from '../../../server/lib/register_license_checker';
+import { elasticsearchJsPlugin } from './client/elasticsearch_slm';
+import { CloudSetup } from '../../../../plugins/cloud/server';
export interface Core {
http: {
createRouter(basePath: string): Router;
diff --git a/x-pack/legacy/plugins/spaces/index.ts b/x-pack/legacy/plugins/spaces/index.ts
index 6ea06f47b9012..b20ddacc7e527 100644
--- a/x-pack/legacy/plugins/spaces/index.ts
+++ b/x-pack/legacy/plugins/spaces/index.ts
@@ -8,7 +8,7 @@ import { resolve } from 'path';
import KbnServer, { Server } from 'src/legacy/server/kbn_server';
import { Legacy } from 'kibana';
import { KibanaRequest } from '../../../../src/core/server';
-import { SpacesServiceSetup } from '../../../plugins/spaces/server/spaces_service/spaces_service';
+import { SpacesServiceSetup } from '../../../plugins/spaces/server';
import { SpacesPluginSetup } from '../../../plugins/spaces/server';
// @ts-ignore
import { AuditLogger } from '../../server/lib/audit_logger';
diff --git a/x-pack/legacy/plugins/spaces/public/lib/copy_saved_objects_to_space/types.ts b/x-pack/legacy/plugins/spaces/public/lib/copy_saved_objects_to_space/types.ts
index d2576ca5c6c16..9fcc5a89736cc 100644
--- a/x-pack/legacy/plugins/spaces/public/lib/copy_saved_objects_to_space/types.ts
+++ b/x-pack/legacy/plugins/spaces/public/lib/copy_saved_objects_to_space/types.ts
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { SavedObjectsImportRetry, SavedObjectsImportResponse } from 'src/core/server';
+import { SavedObjectsImportRetry, SavedObjectsImportResponse } from 'src/core/public';
export interface CopyOptions {
includeRelated: boolean;
diff --git a/x-pack/legacy/plugins/spaces/public/views/management/edit_space/enabled_features/enabled_features.test.tsx b/x-pack/legacy/plugins/spaces/public/views/management/edit_space/enabled_features/enabled_features.test.tsx
index 4485491f5cd89..a69a8f47263e6 100644
--- a/x-pack/legacy/plugins/spaces/public/views/management/edit_space/enabled_features/enabled_features.test.tsx
+++ b/x-pack/legacy/plugins/spaces/public/views/management/edit_space/enabled_features/enabled_features.test.tsx
@@ -7,7 +7,7 @@
import { EuiLink } from '@elastic/eui';
import React from 'react';
import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers';
-import { Feature } from '../../../../../../../../plugins/features/server';
+import { Feature } from '../../../../../../../../plugins/features/public';
import { Space } from '../../../../../common/model/space';
import { SectionPanel } from '../section_panel';
import { EnabledFeatures } from './enabled_features';
diff --git a/x-pack/legacy/plugins/spaces/public/views/management/edit_space/enabled_features/enabled_features.tsx b/x-pack/legacy/plugins/spaces/public/views/management/edit_space/enabled_features/enabled_features.tsx
index 1c1925a6a4ee0..b1f3e8c43de9c 100644
--- a/x-pack/legacy/plugins/spaces/public/views/management/edit_space/enabled_features/enabled_features.tsx
+++ b/x-pack/legacy/plugins/spaces/public/views/management/edit_space/enabled_features/enabled_features.tsx
@@ -8,7 +8,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiLink, EuiSpacer, EuiText, EuiTitle } from
import { FormattedMessage, InjectedIntl } from '@kbn/i18n/react';
import React, { Component, Fragment, ReactNode } from 'react';
import { UICapabilities } from 'ui/capabilities';
-import { Feature } from '../../../../../../../../plugins/features/server';
+import { Feature } from '../../../../../../../../plugins/features/public';
import { Space } from '../../../../../common/model/space';
import { getEnabledFeatures } from '../../lib/feature_utils';
import { SectionPanel } from '../section_panel';
diff --git a/x-pack/legacy/plugins/spaces/public/views/management/edit_space/enabled_features/feature_table.tsx b/x-pack/legacy/plugins/spaces/public/views/management/edit_space/enabled_features/feature_table.tsx
index 91f14cf228c55..d408ea6582742 100644
--- a/x-pack/legacy/plugins/spaces/public/views/management/edit_space/enabled_features/feature_table.tsx
+++ b/x-pack/legacy/plugins/spaces/public/views/management/edit_space/enabled_features/feature_table.tsx
@@ -8,7 +8,7 @@ import { EuiCheckbox, EuiIcon, EuiInMemoryTable, EuiSwitch, EuiText, IconType }
import { FormattedMessage, InjectedIntl } from '@kbn/i18n/react';
import _ from 'lodash';
import React, { ChangeEvent, Component } from 'react';
-import { Feature } from '../../../../../../../../plugins/features/server';
+import { Feature } from '../../../../../../../../plugins/features/public';
import { Space } from '../../../../../common/model/space';
import { ToggleAllFeatures } from './toggle_all_features';
diff --git a/x-pack/legacy/plugins/spaces/public/views/management/edit_space/manage_space_page.tsx b/x-pack/legacy/plugins/spaces/public/views/management/edit_space/manage_space_page.tsx
index 7a3fea0d76a3b..dfd60f7c193c1 100644
--- a/x-pack/legacy/plugins/spaces/public/views/management/edit_space/manage_space_page.tsx
+++ b/x-pack/legacy/plugins/spaces/public/views/management/edit_space/manage_space_page.tsx
@@ -22,7 +22,7 @@ import { capabilities } from 'ui/capabilities';
import { Breadcrumb } from 'ui/chrome';
import { kfetch } from 'ui/kfetch';
import { toastNotifications } from 'ui/notify';
-import { Feature } from '../../../../../../../plugins/features/server';
+import { Feature } from '../../../../../../../plugins/features/public';
import { isReservedSpace } from '../../../../common';
import { Space } from '../../../../common/model/space';
import { SpacesManager } from '../../../lib';
diff --git a/x-pack/legacy/plugins/spaces/public/views/management/lib/feature_utils.test.ts b/x-pack/legacy/plugins/spaces/public/views/management/lib/feature_utils.test.ts
index 3420a4ccd7278..8621ec5614368 100644
--- a/x-pack/legacy/plugins/spaces/public/views/management/lib/feature_utils.test.ts
+++ b/x-pack/legacy/plugins/spaces/public/views/management/lib/feature_utils.test.ts
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { Feature } from '../../../../../../../plugins/features/server';
+import { Feature } from '../../../../../../../plugins/features/public';
import { getEnabledFeatures } from './feature_utils';
const buildFeatures = () =>
diff --git a/x-pack/legacy/plugins/spaces/public/views/management/lib/feature_utils.ts b/x-pack/legacy/plugins/spaces/public/views/management/lib/feature_utils.ts
index 0ff428c711784..ef46a53967744 100644
--- a/x-pack/legacy/plugins/spaces/public/views/management/lib/feature_utils.ts
+++ b/x-pack/legacy/plugins/spaces/public/views/management/lib/feature_utils.ts
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { Feature } from '../../../../../../../plugins/features/server';
+import { Feature } from '../../../../../../../plugins/features/public';
import { Space } from '../../../../common/model/space';
diff --git a/x-pack/legacy/plugins/spaces/public/views/management/spaces_grid/spaces_grid_page.tsx b/x-pack/legacy/plugins/spaces/public/views/management/spaces_grid/spaces_grid_page.tsx
index bd7c61a018c9f..c6ad2e36740d9 100644
--- a/x-pack/legacy/plugins/spaces/public/views/management/spaces_grid/spaces_grid_page.tsx
+++ b/x-pack/legacy/plugins/spaces/public/views/management/spaces_grid/spaces_grid_page.tsx
@@ -23,7 +23,7 @@ import { capabilities } from 'ui/capabilities';
import { kfetch } from 'ui/kfetch';
// @ts-ignore
import { toastNotifications } from 'ui/notify';
-import { Feature } from '../../../../../../../plugins/features/server';
+import { Feature } from '../../../../../../../plugins/features/public';
import { isReservedSpace } from '../../../../common';
import { DEFAULT_SPACE_ID } from '../../../../common/constants';
import { Space } from '../../../../common/model/space';
diff --git a/x-pack/legacy/plugins/task_manager/migrations.ts b/x-pack/legacy/plugins/task_manager/migrations.ts
index dd6651fddb90a..65ca38d0b447d 100644
--- a/x-pack/legacy/plugins/task_manager/migrations.ts
+++ b/x-pack/legacy/plugins/task_manager/migrations.ts
@@ -4,6 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/
+// Task manager uses an unconventional directory structure so the linter marks this as a violation, server files should
+// be moved under task_manager/server/
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { SavedObject } from 'src/core/server';
export const migrations = {
diff --git a/x-pack/legacy/plugins/task_manager/task_manager.test.ts b/x-pack/legacy/plugins/task_manager/task_manager.test.ts
index 0b4a22910e611..b95a8a47f4095 100644
--- a/x-pack/legacy/plugins/task_manager/task_manager.test.ts
+++ b/x-pack/legacy/plugins/task_manager/task_manager.test.ts
@@ -7,7 +7,11 @@
import _ from 'lodash';
import sinon from 'sinon';
import { TaskManager, claimAvailableTasks } from './task_manager';
+// Task manager uses an unconventional directory structure so the linter marks this as a violation, server files should
+// be moved under task_manager/server/
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { savedObjectsClientMock } from 'src/core/server/mocks';
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { SavedObjectsSerializer, SavedObjectsSchema } from 'src/core/server';
import { mockLogger } from './test_utils';
diff --git a/x-pack/legacy/plugins/task_manager/task_manager.ts b/x-pack/legacy/plugins/task_manager/task_manager.ts
index 269d7ff67384b..6622a84b31fbb 100644
--- a/x-pack/legacy/plugins/task_manager/task_manager.ts
+++ b/x-pack/legacy/plugins/task_manager/task_manager.ts
@@ -4,6 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { performance } from 'perf_hooks';
+// Task manager uses an unconventional directory structure so the linter marks this as a violation, server files should
+// be moved under task_manager/server/
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { SavedObjectsClientContract, SavedObjectsSerializer } from 'src/core/server';
import { Logger } from './types';
import { fillPool, FillPoolResult } from './lib/fill_pool';
diff --git a/x-pack/legacy/plugins/task_manager/task_runner.test.ts b/x-pack/legacy/plugins/task_manager/task_runner.test.ts
index 578b86ba0b3f6..72d4be736955b 100644
--- a/x-pack/legacy/plugins/task_manager/task_runner.test.ts
+++ b/x-pack/legacy/plugins/task_manager/task_runner.test.ts
@@ -10,7 +10,10 @@ import { minutesFromNow } from './lib/intervals';
import { ConcreteTaskInstance } from './task';
import { TaskManagerRunner } from './task_runner';
import { mockLogger } from './test_utils';
-import { SavedObjectsErrorHelpers } from '../../../../src/core/server/saved_objects/service/lib/errors';
+// Task manager uses an unconventional directory structure so the linter marks this as a violation, server files should
+// be moved under task_manager/server/
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
+import { SavedObjectsErrorHelpers } from '../../../../src/core/server';
let fakeTimer: sinon.SinonFakeTimers;
diff --git a/x-pack/legacy/plugins/task_manager/task_store.test.ts b/x-pack/legacy/plugins/task_manager/task_store.test.ts
index 46efc4bb57ba7..eb58a9f797943 100644
--- a/x-pack/legacy/plugins/task_manager/task_store.test.ts
+++ b/x-pack/legacy/plugins/task_manager/task_store.test.ts
@@ -9,7 +9,11 @@ import sinon from 'sinon';
import uuid from 'uuid';
import { TaskDictionary, TaskDefinition, TaskInstance, TaskStatus } from './task';
import { FetchOpts, StoreOpts, OwnershipClaimingOpts, TaskStore } from './task_store';
+// Task manager uses an unconventional directory structure so the linter marks this as a violation, server files should
+// be moved under task_manager/server/
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { savedObjectsClientMock } from 'src/core/server/mocks';
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { SavedObjectsSerializer, SavedObjectsSchema, SavedObjectAttributes } from 'src/core/server';
const taskDefinitions: TaskDictionary = {
diff --git a/x-pack/legacy/plugins/task_manager/task_store.ts b/x-pack/legacy/plugins/task_manager/task_store.ts
index 58bffd2269eb6..919ef43abd6e2 100644
--- a/x-pack/legacy/plugins/task_manager/task_store.ts
+++ b/x-pack/legacy/plugins/task_manager/task_store.ts
@@ -15,6 +15,9 @@ import {
SavedObjectAttributes,
SavedObjectsSerializer,
SavedObjectsRawDoc,
+ // Task manager uses an unconventional directory structure so the linter marks this as a violation, server files should
+ // be moved under task_manager/server/
+ // eslint-disable-next-line @kbn/eslint/no-restricted-paths
} from 'src/core/server';
import {
ConcreteTaskInstance,
diff --git a/x-pack/legacy/plugins/upgrade_assistant/common/types.ts b/x-pack/legacy/plugins/upgrade_assistant/common/types.ts
index ce653e461e13b..0e65506bb584d 100644
--- a/x-pack/legacy/plugins/upgrade_assistant/common/types.ts
+++ b/x-pack/legacy/plugins/upgrade_assistant/common/types.ts
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { SavedObject, SavedObjectAttributes } from 'src/core/server';
+import { SavedObject, SavedObjectAttributes } from 'src/core/public';
export enum ReindexStep {
// Enum values are spaced out by 10 to give us room to insert steps in between.
diff --git a/x-pack/legacy/plugins/upgrade_assistant/server/np_ready/types.ts b/x-pack/legacy/plugins/upgrade_assistant/server/np_ready/types.ts
index edee1d09cdeeb..77ba97529c32f 100644
--- a/x-pack/legacy/plugins/upgrade_assistant/server/np_ready/types.ts
+++ b/x-pack/legacy/plugins/upgrade_assistant/server/np_ready/types.ts
@@ -6,7 +6,7 @@
import { Legacy } from 'kibana';
import { IRouter } from 'src/core/server';
import { ElasticsearchPlugin } from 'src/legacy/core_plugins/elasticsearch';
-import { XPackMainPlugin } from '../../../xpack_main/xpack_main';
+import { XPackMainPlugin } from '../../../xpack_main/server/xpack_main';
export interface ServerShim {
plugins: {
diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/types.ts b/x-pack/legacy/plugins/watcher/server/np_ready/types.ts
index 1b566332befdf..3d4454aa2a8b7 100644
--- a/x-pack/legacy/plugins/watcher/server/np_ready/types.ts
+++ b/x-pack/legacy/plugins/watcher/server/np_ready/types.ts
@@ -5,7 +5,7 @@
*/
import { IRouter, ElasticsearchServiceSetup, IClusterClient } from 'src/core/server';
-import { XPackMainPlugin } from '../../../xpack_main/xpack_main';
+import { XPackMainPlugin } from '../../../xpack_main/server/xpack_main';
export interface ServerShim {
route: any;
diff --git a/x-pack/legacy/plugins/xpack_main/xpack_main.d.ts b/x-pack/legacy/plugins/xpack_main/server/xpack_main.d.ts
similarity index 78%
rename from x-pack/legacy/plugins/xpack_main/xpack_main.d.ts
rename to x-pack/legacy/plugins/xpack_main/server/xpack_main.d.ts
index 2a197811cc032..05cb97663e1af 100644
--- a/x-pack/legacy/plugins/xpack_main/xpack_main.d.ts
+++ b/x-pack/legacy/plugins/xpack_main/server/xpack_main.d.ts
@@ -5,9 +5,9 @@
*/
import KbnServer from 'src/legacy/server/kbn_server';
-import { Feature, FeatureWithAllOrReadPrivileges } from '../../../plugins/features/server';
-import { XPackInfo, XPackInfoOptions } from './server/lib/xpack_info';
-export { XPackFeature } from './server/lib/xpack_info';
+import { Feature, FeatureWithAllOrReadPrivileges } from '../../../../plugins/features/server';
+import { XPackInfo, XPackInfoOptions } from './lib/xpack_info';
+export { XPackFeature } from './lib/xpack_info';
export interface XPackMainPlugin {
info: XPackInfo;
diff --git a/x-pack/plugins/apm/server/index.ts b/x-pack/plugins/apm/server/index.ts
index 53eb4a909cebe..b0e10d245e0b9 100644
--- a/x-pack/plugins/apm/server/index.ts
+++ b/x-pack/plugins/apm/server/index.ts
@@ -48,4 +48,4 @@ export type APMConfig = ReturnType;
export const plugin = (initContext: PluginInitializerContext) => new APMPlugin(initContext);
-export { APMPlugin } from './plugin';
+export { APMPlugin, APMPluginContract } from './plugin';
diff --git a/x-pack/plugins/features/server/feature.ts b/x-pack/plugins/features/common/feature.ts
similarity index 100%
rename from x-pack/plugins/features/server/feature.ts
rename to x-pack/plugins/features/common/feature.ts
diff --git a/x-pack/plugins/features/server/feature_kibana_privileges.ts b/x-pack/plugins/features/common/feature_kibana_privileges.ts
similarity index 100%
rename from x-pack/plugins/features/server/feature_kibana_privileges.ts
rename to x-pack/plugins/features/common/feature_kibana_privileges.ts
diff --git a/x-pack/plugins/features/common/index.ts b/x-pack/plugins/features/common/index.ts
new file mode 100644
index 0000000000000..6111d7d25a61b
--- /dev/null
+++ b/x-pack/plugins/features/common/index.ts
@@ -0,0 +1,8 @@
+/*
+ * 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 { FeatureKibanaPrivileges } from './feature_kibana_privileges';
+export * from './feature';
diff --git a/x-pack/plugins/features/public/index.ts b/x-pack/plugins/features/public/index.ts
new file mode 100644
index 0000000000000..6a2c99aad4bd8
--- /dev/null
+++ b/x-pack/plugins/features/public/index.ts
@@ -0,0 +1,7 @@
+/*
+ * 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 { Feature, FeatureWithAllOrReadPrivileges, FeatureKibanaPrivileges } from '../common';
diff --git a/x-pack/plugins/features/server/feature_registry.test.ts b/x-pack/plugins/features/server/feature_registry.test.ts
index 66460a811009e..7b25035892668 100644
--- a/x-pack/plugins/features/server/feature_registry.test.ts
+++ b/x-pack/plugins/features/server/feature_registry.test.ts
@@ -5,7 +5,7 @@
*/
import { FeatureRegistry } from './feature_registry';
-import { Feature } from './feature';
+import { Feature } from '../common/feature';
describe('FeatureRegistry', () => {
it('allows a minimal feature to be registered', () => {
diff --git a/x-pack/plugins/features/server/feature_registry.ts b/x-pack/plugins/features/server/feature_registry.ts
index bec0ab1ed0bf7..60a229fc58612 100644
--- a/x-pack/plugins/features/server/feature_registry.ts
+++ b/x-pack/plugins/features/server/feature_registry.ts
@@ -5,8 +5,7 @@
*/
import { cloneDeep, uniq } from 'lodash';
-import { FeatureKibanaPrivileges } from './feature_kibana_privileges';
-import { Feature, FeatureWithAllOrReadPrivileges } from './feature';
+import { Feature, FeatureWithAllOrReadPrivileges, FeatureKibanaPrivileges } from '../common';
import { validateFeature } from './feature_schema';
export class FeatureRegistry {
diff --git a/x-pack/plugins/features/server/feature_schema.ts b/x-pack/plugins/features/server/feature_schema.ts
index b5ba10f8d0300..8926bd766be32 100644
--- a/x-pack/plugins/features/server/feature_schema.ts
+++ b/x-pack/plugins/features/server/feature_schema.ts
@@ -8,7 +8,7 @@ import Joi from 'joi';
import { difference } from 'lodash';
import { Capabilities as UICapabilities } from '../../../../src/core/server';
-import { FeatureWithAllOrReadPrivileges } from './feature';
+import { FeatureWithAllOrReadPrivileges } from '../common/feature';
// Each feature gets its own property on the UICapabilities object,
// but that object has a few built-in properties which should not be overwritten.
diff --git a/x-pack/plugins/features/server/index.ts b/x-pack/plugins/features/server/index.ts
index 6a08c25fb7780..2b4f85aa04f04 100644
--- a/x-pack/plugins/features/server/index.ts
+++ b/x-pack/plugins/features/server/index.ts
@@ -13,8 +13,7 @@ import { Plugin } from './plugin';
// run-time contracts.
export { uiCapabilitiesRegex } from './feature_schema';
-export { Feature, FeatureWithAllOrReadPrivileges } from './feature';
-export { FeatureKibanaPrivileges } from './feature_kibana_privileges';
+export { Feature, FeatureWithAllOrReadPrivileges, FeatureKibanaPrivileges } from '../common';
export { PluginSetupContract } from './plugin';
export const plugin = (initializerContext: PluginInitializerContext) =>
diff --git a/x-pack/plugins/features/server/oss_features.ts b/x-pack/plugins/features/server/oss_features.ts
index d70f72a7ff085..b48963ebb8139 100644
--- a/x-pack/plugins/features/server/oss_features.ts
+++ b/x-pack/plugins/features/server/oss_features.ts
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { i18n } from '@kbn/i18n';
-import { Feature } from './feature';
+import { Feature } from '../common/feature';
export interface BuildOSSFeaturesParams {
savedObjectTypes: string[];
diff --git a/x-pack/plugins/features/server/plugin.ts b/x-pack/plugins/features/server/plugin.ts
index f3a3375d1936b..96a8e68f8326d 100644
--- a/x-pack/plugins/features/server/plugin.ts
+++ b/x-pack/plugins/features/server/plugin.ts
@@ -15,7 +15,7 @@ import { deepFreeze } from '../../../../src/core/utils';
import { XPackInfo } from '../../../legacy/plugins/xpack_main/server/lib/xpack_info';
import { PluginSetupContract as TimelionSetupContract } from '../../../../src/plugins/timelion/server';
import { FeatureRegistry } from './feature_registry';
-import { Feature, FeatureWithAllOrReadPrivileges } from './feature';
+import { Feature, FeatureWithAllOrReadPrivileges } from '../common/feature';
import { uiCapabilitiesForFeatures } from './ui_capabilities_for_features';
import { buildOSSFeatures } from './oss_features';
import { defineRoutes } from './routes';
diff --git a/x-pack/plugins/features/server/ui_capabilities_for_features.ts b/x-pack/plugins/features/server/ui_capabilities_for_features.ts
index 368b38ce7df91..a13afa854de52 100644
--- a/x-pack/plugins/features/server/ui_capabilities_for_features.ts
+++ b/x-pack/plugins/features/server/ui_capabilities_for_features.ts
@@ -6,7 +6,7 @@
import _ from 'lodash';
import { Capabilities as UICapabilities } from '../../../../src/core/server';
-import { Feature } from './feature';
+import { Feature } from '../common/feature';
const ELIGIBLE_FLAT_MERGE_KEYS = ['catalogue'];
diff --git a/x-pack/plugins/security/public/index.ts b/x-pack/plugins/security/public/index.ts
index 12a3092039d0d..dc34fcbbe7d1e 100644
--- a/x-pack/plugins/security/public/index.ts
+++ b/x-pack/plugins/security/public/index.ts
@@ -6,6 +6,7 @@
import { PluginInitializer } from 'src/core/public';
import { SecurityPlugin, SecurityPluginSetup, SecurityPluginStart } from './plugin';
+export { SessionInfo } from './types';
export const plugin: PluginInitializer = () =>
new SecurityPlugin();
diff --git a/x-pack/plugins/security/server/authentication/authenticator.ts b/x-pack/plugins/security/server/authentication/authenticator.ts
index 8f947349cb2e8..842cb37504832 100644
--- a/x-pack/plugins/security/server/authentication/authenticator.ts
+++ b/x-pack/plugins/security/server/authentication/authenticator.ts
@@ -31,7 +31,7 @@ import {
import { AuthenticationResult } from './authentication_result';
import { DeauthenticationResult } from './deauthentication_result';
import { Tokens } from './tokens';
-import { SessionInfo } from '../../public/types';
+import { SessionInfo } from '../../public';
/**
* The shape of the session that is actually stored in the cookie.
diff --git a/x-pack/plugins/spaces/server/index.ts b/x-pack/plugins/spaces/server/index.ts
index 21d6c840fb017..18f7575ff75d6 100644
--- a/x-pack/plugins/spaces/server/index.ts
+++ b/x-pack/plugins/spaces/server/index.ts
@@ -16,6 +16,7 @@ import { Plugin } from './plugin';
// end public contract exports
export { SpacesPluginSetup } from './plugin';
+export { SpacesServiceSetup } from './spaces_service';
export const config = { schema: ConfigSchema };
export const plugin = (initializerContext: PluginInitializerContext) =>
diff --git a/x-pack/plugins/spaces/server/plugin.ts b/x-pack/plugins/spaces/server/plugin.ts
index 732731ac35ecd..0c901dc950d86 100644
--- a/x-pack/plugins/spaces/server/plugin.ts
+++ b/x-pack/plugins/spaces/server/plugin.ts
@@ -17,7 +17,7 @@ import {
import { PluginSetupContract as FeaturesPluginSetup } from '../../features/server';
import { PluginSetupContract as SecurityPluginSetup } from '../../security/server';
import { LicensingPluginSetup } from '../../licensing/server';
-import { XPackMainPlugin } from '../../../legacy/plugins/xpack_main/xpack_main';
+import { XPackMainPlugin } from '../../../legacy/plugins/xpack_main/server/xpack_main';
import { createDefaultSpace } from './lib/create_default_space';
// @ts-ignore
import { AuditLogger } from '../../../../server/lib/audit_logger';
@@ -26,7 +26,7 @@ import { SpacesAuditLogger } from './lib/audit_logger';
import { createSpacesTutorialContextFactory } from './lib/spaces_tutorial_context_factory';
import { registerSpacesUsageCollector } from './lib/spaces_usage_collector';
import { SpacesService } from './spaces_service';
-import { SpacesServiceSetup } from './spaces_service/spaces_service';
+import { SpacesServiceSetup } from './spaces_service';
import { ConfigType } from './config';
import { toggleUICapabilities } from './lib/toggle_ui_capabilities';
import { initSpacesRequestInterceptors } from './lib/request_interceptors';
diff --git a/x-pack/plugins/spaces/server/spaces_service/index.ts b/x-pack/plugins/spaces/server/spaces_service/index.ts
index e37d1db3f85bb..69a7e171a5186 100644
--- a/x-pack/plugins/spaces/server/spaces_service/index.ts
+++ b/x-pack/plugins/spaces/server/spaces_service/index.ts
@@ -4,4 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/
-export { SpacesService } from './spaces_service';
+export { SpacesService, SpacesServiceSetup } from './spaces_service';
diff --git a/x-pack/test/typings/hapi.d.ts b/x-pack/test/typings/hapi.d.ts
index 6a67c5ccee337..fa2712e69a5b0 100644
--- a/x-pack/test/typings/hapi.d.ts
+++ b/x-pack/test/typings/hapi.d.ts
@@ -6,7 +6,7 @@
import 'hapi';
-import { XPackMainPlugin } from '../../legacy/plugins/xpack_main/xpack_main';
+import { XPackMainPlugin } from '../../legacy/plugins/xpack_main/server/xpack_main';
import { SecurityPlugin } from '../../legacy/plugins/security';
import { ActionsPlugin, ActionsClient } from '../../legacy/plugins/actions';
import { TaskManager } from '../../legacy/plugins/task_manager';
diff --git a/x-pack/typings/hapi.d.ts b/x-pack/typings/hapi.d.ts
index d97e47f3ce0f8..569508caf3f20 100644
--- a/x-pack/typings/hapi.d.ts
+++ b/x-pack/typings/hapi.d.ts
@@ -6,7 +6,7 @@
import 'hapi';
-import { XPackMainPlugin } from '../legacy/plugins/xpack_main/xpack_main';
+import { XPackMainPlugin } from '../legacy/plugins/xpack_main/server/xpack_main';
import { SecurityPlugin } from '../legacy/plugins/security';
import { ActionsPlugin, ActionsClient } from '../legacy/plugins/actions';
import { TaskManager } from '../legacy/plugins/task_manager';