-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.x] [embeddable] remove embeddable factory methods from setup and s…
…tart API (#204797) (#204993) # Backport This will backport the following commits from `main` to `8.x`: - [[embeddable] remove embeddable factory methods from setup and start API (#204797)](#204797) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Nathan Reese","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-19T18:19:48Z","message":"[embeddable] remove embeddable factory methods from setup and start API (#204797)\n\nPart of embeddable rebuild cleanup. PR removes legacy embeddable factory\r\nregistration APIs.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"3b61e7bea7408e586faa4be6464e963b50385896","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Embedding","Team:Presentation","release_note:skip","v9.0.0","ci:project-deploy-observability","Team:obs-ux-infra_services","project:embeddableRebuild","backport:version","v8.18.0"],"title":"[embeddable] remove embeddable factory methods from setup and start API","number":204797,"url":"https://github.com/elastic/kibana/pull/204797","mergeCommit":{"message":"[embeddable] remove embeddable factory methods from setup and start API (#204797)\n\nPart of embeddable rebuild cleanup. PR removes legacy embeddable factory\r\nregistration APIs.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"3b61e7bea7408e586faa4be6464e963b50385896"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/204797","number":204797,"mergeCommit":{"message":"[embeddable] remove embeddable factory methods from setup and start API (#204797)\n\nPart of embeddable rebuild cleanup. PR removes legacy embeddable factory\r\nregistration APIs.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"3b61e7bea7408e586faa4be6464e963b50385896"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Nathan Reese <[email protected]>
- Loading branch information
1 parent
c986805
commit 6c05f46
Showing
38 changed files
with
172 additions
and
1,082 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
src/plugins/embeddable/public/__snapshots__/plugin.test.ts.snap
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import { identity } from 'lodash'; | ||
import { SerializableRecord } from '@kbn/utility-types'; | ||
import { EnhancementRegistryDefinition, EnhancementRegistryItem } from './types'; | ||
|
||
export class EnhancementsRegistry { | ||
private registry: Map<string, EnhancementRegistryItem> = new Map(); | ||
|
||
public registerEnhancement = (enhancement: EnhancementRegistryDefinition) => { | ||
if (this.registry.has(enhancement.id)) { | ||
throw new Error(`enhancement with id ${enhancement.id} already exists in the registry`); | ||
} | ||
this.registry.set(enhancement.id, { | ||
id: enhancement.id, | ||
telemetry: enhancement.telemetry || ((state, stats) => stats), | ||
inject: enhancement.inject || identity, | ||
extract: | ||
enhancement.extract || | ||
((state: SerializableRecord) => { | ||
return { state, references: [] }; | ||
}), | ||
migrations: enhancement.migrations || {}, | ||
}); | ||
}; | ||
|
||
public getEnhancements = (): EnhancementRegistryItem[] => { | ||
return Array.from(this.registry.values()); | ||
}; | ||
|
||
public getEnhancement = (id: string): EnhancementRegistryItem => { | ||
return ( | ||
this.registry.get(id) || { | ||
id: 'unknown', | ||
telemetry: (state, stats) => stats, | ||
inject: identity, | ||
extract: (state: SerializableRecord) => { | ||
return { state, references: [] }; | ||
}, | ||
migrations: {}, | ||
} | ||
); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import type { SerializableRecord } from '@kbn/utility-types'; | ||
import { PersistableState, PersistableStateDefinition } from '@kbn/kibana-utils-plugin/common'; | ||
|
||
export interface EnhancementRegistryDefinition<P extends SerializableRecord = SerializableRecord> | ||
extends PersistableStateDefinition<P> { | ||
id: string; | ||
} | ||
|
||
export interface EnhancementRegistryItem<P extends SerializableRecord = SerializableRecord> | ||
extends PersistableState<P> { | ||
id: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 0 additions & 65 deletions
65
src/plugins/embeddable/public/lib/embeddables/default_embeddable_factory_provider.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.