-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
Partially move server-side savedObjects
domain implementation to packages
#137448
Partially move server-side savedObjects
domain implementation to packages
#137448
Conversation
…-ref HEAD~1..HEAD --fix'
…mentation-stage-1
f4a2c19
to
95837c8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self-review
const createMockedTypeRegistry = ({ | ||
isNamespaceAgnostic, | ||
isSingleNamespace, | ||
isMultiNamespace, | ||
}: { | ||
isNamespaceAgnostic: boolean; | ||
isSingleNamespace: boolean; | ||
isMultiNamespace: boolean; | ||
}): ISavedObjectTypeRegistry => { | ||
const typeRegistry: Partial<ISavedObjectTypeRegistry> = { | ||
isNamespaceAgnostic: jest.fn().mockReturnValue(isNamespaceAgnostic), | ||
isSingleNamespace: jest.fn().mockReturnValue(isSingleNamespace), | ||
isMultiNamespace: jest.fn().mockReturnValue(isMultiNamespace), | ||
}; | ||
return typeRegistry as ISavedObjectTypeRegistry; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only test of the @kbn/core-saved-objects-base-server-internal
that was using a mock from code that was moved to this package. I KISS'ed and created an inline mock helper.
The alternative would have been to create 2 additional packages (impl+mock) just for the SO type registry, and it didn't feel worth it.
const createSerializerMock = () => { | ||
const mock: jest.Mocked<ISavedObjectsSerializer> = { | ||
isRawSavedObject: jest.fn(), | ||
rawToSavedObject: jest.fn(), | ||
savedObjectToRaw: jest.fn(), | ||
generateRawId: jest.fn(), | ||
generateRawLegacyUrlAliasId: jest.fn(), | ||
}; | ||
return mock; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we didn't have one yet, I introduced a mock for ISavedObjectsSerializer
.
ALL_NAMESPACES_STRING, | ||
DEFAULT_NAMESPACE_STRING, | ||
FIND_DEFAULT_PAGE, | ||
FIND_DEFAULT_PER_PAGE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These constants are in practice only used internally by Core, but they are also used by the SavedObjectsUtils
implementation that is publicly exposed. To avoid duplicating them, I exposed them from the public util package, as it didn't felt like it would be causing any harm for them to be publicly accessible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds reasonable to me.
SavedObjectsUtils, | ||
mergeSavedObjectMigrationMaps, | ||
} from './saved_objects'; | ||
export { SavedObjectsClient } from './saved_objects'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to check if we still need to export SavedObjectsClient
and SavedObjectTypeRegistry
from the entrypoint, but this will be done in the next PR or in the follow-up cleanup.
export { | ||
SavedObjectsClient, | ||
SavedObjectsErrorHelpers, | ||
SavedObjectsSerializer, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last external usage of SavedObjectsSerializer
have been removed and replaced by the newly introduced mock. It's no longer publicly exposed.
…mentation-stage-1
Pinging @elastic/kibana-core (Team:Core) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ResponseOps changes LGTM
@elasticmachine merge upstream |
@pgayvallet I tried to help but seemed to have done the opposite 😨 . Sorry 'bout that! |
Attempt to undo an incorrect merge.
@elasticmachine merge upstream |
merge conflict between base and head |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thus far without aby obvious changes needed.
"name": "@kbn/core-saved-objects-utils-server", | ||
"private": true, | ||
"version": "1.0.0", | ||
"main": "./target_node/index.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to add Core as the author here and in the other packages as per recent changes. That being said, I wonde rif there's a way to share package ownership between teams, since the code in here is mostly related to the security wrappers.
@kibana-operations, is there a plan to reflect code-ownership in packages or do we rely on the CODEOWNER's file?
* Side Public License, v 1. | ||
*/ | ||
|
||
export { mergeSavedObjectMigrationMaps } from './merge_migration_maps'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With recent changes to the build tooling, this and all the other src/index.ts
files need to move to the package's root. See #138476 for more info.
ALL_NAMESPACES_STRING, | ||
DEFAULT_NAMESPACE_STRING, | ||
FIND_DEFAULT_PAGE, | ||
FIND_DEFAULT_PER_PAGE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds reasonable to me.
PKG_DIRNAME = "core-saved-objects-utils-server" | ||
PKG_REQUIRE_NAME = "@kbn/core-saved-objects-utils-server" | ||
|
||
SOURCE_FILES = glob( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if there's tooling to make changes required by #138476 after a package is created, so we may need to update the bazel configs manually here. From what I can tell, there's a pretty standard exclude
list that we should be able to copy-paste.
@@ -0,0 +1,4 @@ | |||
# @kbn/core-saved-objects-base-server-internal | |||
|
|||
This package contains the base parts of the server-side savedObjects internal implementation, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to be a bit more specific as to what the package contains. "base parts" isn't very descriptive. The list as per the PR description would be fine.
# @kbn/core-saved-objects-base-server-mocks | ||
|
||
This package contains the mocks for the base server-side savedObjects sub-domain: | ||
- `SavedObjectTypeRegistry` mock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding which mocks the package contains!
FYI, it looks like the failing CI tests are related to recent changes in non-core code. I've tested resolving conflicts with main locally and the tests passed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SecuritySolution changes LGTM
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Any counts in public APIs
Public APIs missing exports
Unknown metric groupsAPI count
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
…ckages (elastic#137448) * create @kbn/core-saved-objects-utils-server package * create empty @kbn/core-saved-objects-base-server-internal package * fix more internal imports * [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' * start moving stuff to base package * Fix SS mocks * adapt some imports * start fixing internal imports * fix remaining core usages * start fixing external usages * lint * move type registry and mocks to packages * adapt usages of serializer in tests * fix test mocking * [CI] Auto-commit changed files from 'node scripts/generate packages_build_manifest' * fix more internal usages of SOTR/mock * fix package * fix external usages * fix more mocked packages * fix more mocked packages * self review * Fix mistake from main merge Attempt to undo an incorrect merge. * add root_input_dir Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Christiane (Tina) Heiligers <christiane.heiligers@elastic.co>
…ckages (elastic#137448) * create @kbn/core-saved-objects-utils-server package * create empty @kbn/core-saved-objects-base-server-internal package * fix more internal imports * [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' * start moving stuff to base package * Fix SS mocks * adapt some imports * start fixing internal imports * fix remaining core usages * start fixing external usages * lint * move type registry and mocks to packages * adapt usages of serializer in tests * fix test mocking * [CI] Auto-commit changed files from 'node scripts/generate packages_build_manifest' * fix more internal usages of SOTR/mock * fix package * fix external usages * fix more mocked packages * fix more mocked packages * self review * Fix mistake from main merge Attempt to undo an incorrect merge. * add root_input_dir Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Christiane (Tina) Heiligers <christiane.heiligers@elastic.co>
Summary
First part of third stage (yea, I know, hopefully the next one with be the last) of #135820
Now that all the server-side
savedObjects
public types have been moved to packages, we can start moving the internal implementation.Unsurprisingly, this is probably the biggest Core domain in term of files, and will be the same in term of number of packages.
From my initial investigation, I'm currently planning on having the following packages (removed the ``@kbn/core-saved-objects` prefix here):
@kbn/core-saved-objects-utils-server
@kbn/core-saved-objects-base-internal
@kbn/core-saved-objects-api-internal
(depends onbase
)@kbn/core-saved-objects-import-export-internal
(depends onbase
andapi
)@kbn/core-saved-objects-migration-internal
(depends onbase
andapi
)@kbn/core-saved-objects-internal
(depends on all the others)This PR is the first step, handling the creation of and code extraction to the following packages:
@kbn/core-saved-objects-utils-server
@kbn/core-saved-objects-base-server-internal
@kbn/core-saved-objects-base-server-mocks
NOTE: I did not look yet at the problem of the cyclic dependency with types of
CoreUsageData
. This only impacts the higher-level internal package,@kbn/core-saved-objects-internal
, and I will take a look when the time comes