Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Saved Objects] Browser-side client deprecation notice #148979

Merged
merged 9 commits into from
Jan 18, 2023

Conversation

jloleysens
Copy link
Contributor

@jloleysens jloleysens commented Jan 16, 2023

Summary

In the near future we will remove Saved Object (SO) HTTP APIs. This PR deprecates all browser-side SO types and interfaces.

General notes on the approach taken:

  • Add a deprecation notice that links to a GitHub issue that can be referenced by all teams
  • Do not break existing imports/exports
  • Mocks are also an indication of SO browser-side use, added deprecation notices
  • Some common types must also be deprecated, some may remain. For those to be removed they are moved to a separate file, with a deprecated type-alias which is re-exported

Notes to reviewers

  • Easiest way to get an overview of the changes is to have the file-tree open in the "Files changed" view
  • Are there any other ways browser-side code can get knowledge of Saved Objects?
  • Please go through some client code and test that the DX is working as expected (the GitHub issue is discoverable)

Related

@jloleysens jloleysens changed the title [Saved Objects] Browser-side client deprecation [Saved Objects] Browser-side client deprecation notice Jan 16, 2023
Copy link
Contributor

@rudolf rudolf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳

@jloleysens jloleysens added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc release_note:skip Skip the PR/issue when compiling release notes auto-backport Deprecated - use backport:version if exact versions are needed v8.7.0 Feature:Saved Objects labels Jan 17, 2023
@jloleysens jloleysens marked this pull request as ready for review January 17, 2023 12:13
@jloleysens jloleysens requested a review from a team as a code owner January 17, 2023 12:13
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

Copy link
Contributor

@TinaHeiligers TinaHeiligers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits about exports and naming, otherwise nice work!

type: string;
id: string;
}
import * as serverTypes from './will_move_to_server';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer named imports/exports, especially in packages.

Copy link
Contributor Author

@jloleysens jloleysens Jan 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are a few reasons why it is OK to break convention in this case:

  1. We are not * exporting: we are still selectively exposing a set of types for public use
  2. A namespace serves the function of asing, but in a more efficient way in this instance (IMO)
  3. I expect this code will change/be removed soon anyway (once we remove the SO client from browsers)

Happy to revisit if you feel strongly!

* @public
* @deprecated See https://github.com/elastic/dev/issues/2194
*/
export type SavedObjectAttributeSingle = serverTypes.SavedObjectAttributeSingle;
Copy link
Contributor

@TinaHeiligers TinaHeiligers Jan 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I'm not a fan of this syntax. Using named imports:

import {
  SavedObjectAttributeSingle as LegacySavedObjectAttributeSingle,
  SavedObjectAttribute as LegacySavedObjectAttribute,
  SavedObjectAttributes as LegacySavedObjectAttributes,
  SavedObjectReference as LegacySavedObjectReference,
  SavedObject as LegacySavedObject,
} from './will_move_to_server';

allows us to use export type SavedObjectAttributeSingle = LegacySavedObjectAttributeSingle;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same response as #148979 (comment) :)

@jloleysens jloleysens enabled auto-merge (squash) January 18, 2023 10:04
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/core-saved-objects-server 92 96 +4
Unknown metric groups

API count

id before after diff
@kbn/core-saved-objects-common 83 67 -16
@kbn/core-saved-objects-server 306 325 +19
core 2824 2792 -32
data 3300 3276 -24
dataViews 1032 1020 -12
total -65

References to deprecated APIs

id before after diff
@kbn/core-lifecycle-browser 0 6 +6
@kbn/core-lifecycle-browser-mocks 0 2 +2
@kbn/core-plugins-browser-internal 0 2 +2
@kbn/core-root-browser-internal 0 3 +3
@kbn/core-saved-objects-api-browser 0 155 +155
@kbn/core-saved-objects-api-server 0 111 +111
@kbn/core-saved-objects-api-server-internal 0 291 +291
@kbn/core-saved-objects-browser 0 6 +6
@kbn/core-saved-objects-browser-internal 0 269 +269
@kbn/core-saved-objects-browser-mocks 0 36 +36
@kbn/core-saved-objects-common 6 13 +7
@kbn/core-saved-objects-import-export-server-internal 0 834 +834
@kbn/core-saved-objects-server 0 114 +114
@kbn/core-saved-objects-server-internal 6 84 +78
@kbn/core-ui-settings-server-internal 0 18 +18
actions 50 218 +168
advancedSettings 3 9 +6
aiops 5 9 +4
alerting 95 473 +378
apm 34 40 +6
canvas 117 261 +144
cases 10 1123 +1113
cloudSecurityPosture 1 11 +10
controls 15 51 +36
core 7 46 +39
dashboard 80 173 +93
dashboardEnhanced 0 13 +13
data 59 260 +201
dataViews 40 227 +187
dataVisualizer 15 23 +8
discover 30 42 +12
embeddable 28 49 +21
encryptedSavedObjects 6 114 +108
expressions 0 39 +39
files 0 30 +30
fleet 48 338 +290
globalSearchProviders 0 6 +6
graph 58 115 +57
home 18 100 +82
infra 82 278 +196
kibanaUsageCollection 2 26 +24
kibanaUtils 0 15 +15
lens 18 240 +222
lists 74 122 +48
maps 25 94 +69
ml 174 192 +18
observability 64 94 +30
osquery 5 85 +80
presentationUtil 7 13 +6
savedObjects 77 205 +128
savedObjectsFinder 0 42 +42
savedObjectsManagement 19 157 +138
savedObjectsTagging 3 180 +177
savedObjectsTaggingOss 5 59 +54
savedSearch 8 46 +38
security 67 79 +12
securitySolution 349 738 +389
share 0 75 +75
spaces 13 83 +70
stackAlerts 57 69 +12
synthetics 21 375 +354
taskManager 6 24 +18
transform 26 32 +6
triggersActionsUi 5 14 +9
uiActionsEnhanced 0 30 +30
upgradeAssistant 12 24 +12
usageCollection 0 12 +12
visTypeTimeseries 70 74 +4
visualizations 73 238 +165
watcher 2 12 +10
total +7446

Unreferenced deprecated APIs

id before after diff
@kbn/core-saved-objects-api-browser 0 2 +2

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@jloleysens jloleysens merged commit bbf19ca into elastic:main Jan 18, 2023
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jan 18, 2023
@jloleysens jloleysens deleted the so-browser-side-deprecation branch January 18, 2023 11:07
wayneseymour pushed a commit to wayneseymour/kibana that referenced this pull request Jan 19, 2023
## Summary

In the near future we will remove Saved Object (SO) HTTP APIs. This PR
deprecates all browser-side SO types and interfaces.

General comments on the approach taken here:

* Add a deprecation notice that links to a GitHub issue that can be
referenced by all teams
* Do not break existing imports/exports
* Mocks are also an indication of SO browser-side use, added deprecation
notices
* Some common types must also be deprecated, some may remain. For those
to be removed they are moved to a separate file, with a deprecated
type-alias re-exported

## Notes to reviewers

* Easiest way to get an overview of the changes is to have the file-tree
open in the "Files changed" view
* Are there any other ways browser-side code can get knowledge of Saved
Objects?
* Please go through some client code and test that the DX is working as
expected (the GitHub issue is discoverable)

## Related
* elastic#147150
* elastic/dev#2194

Co-authored-by: kibanamachine <[email protected]>
@jloleysens
Copy link
Contributor Author

Ref #149288

jloleysens added a commit that referenced this pull request Jan 25, 2023
… avoid deprecation (#149289)

## Summary

After merging #148979 there are a
number of imports that can be fixed immediately to address our new
deprecation notice.

## To Core reviewers

The package `core-saved-objects-server` is using types from
`core-saved-objects-api-server` which creates a circular dependency when
using `SavedObject` type from it's new home in
`core-saved-object-server`:

`core-saved-objects-server` -> `core-saved-objects-api-server` ->
`core-saved-objects-server`

One solution is that we can create a new package
`packages/core/saved-objects/core-saved-objects-server-shared` that will
only hold the `SavedObject` type and a select few others. I'm not sure
what the best approach here is. I have left
`core-saved-objects-api-server` unchanged for now (i.e., it is still
importing `SavedObject` from `common` which is deprecated).

Any input would be greatly appreciated!

Co-authored-by: kibanamachine <[email protected]>
@TinaHeiligers
Copy link
Contributor

@jloleysens We forgot to update the docs when deprecating the APIs: https://www.elastic.co/guide/en/kibana/8.6/saved-objects-service.html#_client_side_usage_2

jloleysens added a commit that referenced this pull request Feb 15, 2023
)

## Summary

After merging #148979 there are a
few interfaces in the server-side code that export a reference to a
deprecated SO type.

In this PR we fix them by updating a few imports to use the
non-deprecated SO type. Additionally, we resolve a potential circular
reference issue between `core-saved-objects-server` and
`core-saved-objects-api-server` by "moving" saved objects and related
types exports to `core-saved-objects-api-server`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed backport:skip This commit does not require backporting Feature:Saved Objects release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v8.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants