Prevents importing of public code into server#67149
Prevents importing of public code into server#67149tylersmalley merged 13 commits intoelastic:masterfrom
Conversation
We should not be allowing importing of public into server. Any shared code should reside in a common directory. After elastic#66506, this will not even be possible as we will no longer be transpiling public code into commonjs. Blocks elastic#66506 Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
|
Pinging @elastic/apm-ui (Team:apm) |
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
.eslintrc.js
Outdated
| errorMessage: `Plugins may only import from src/core/server and src/core/public.`, | ||
| }, | ||
| { | ||
| target: ['(src|x-pack)/plugins/*/server/**/*', '!x-pack/plugins/apm/**/*'], |
There was a problem hiding this comment.
APM is a less than straightforward update and I would rather not make assumptions for their desired organization. I will follow-up with an issue for the team to resolve.
There was a problem hiding this comment.
I think what you are hitting is caused by the server side types consumed by the client.
Types are inferred from server-side routes and can therefore not be moved to common.
I expect we can resolve this when typescript is updated to 3.8 and we can use type only imports.
Introduced in elastic#66432 and I have a more thorough PR to prevent imports in server from public in elastic#67149 Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
|
Pinging @elastic/kibana-operations (Team:Operations) |
rylnd
left a comment
There was a problem hiding this comment.
SIEM and endpoint changes LGTM 👍
cjcenizal
left a comment
There was a problem hiding this comment.
@tylersmalley 👍 I'm onboard with the intention behind this change. However, one of ES UI's organizing principles is to organize code inside of __packages_do_not_import__ and then re-export from public, server, and common directories. Can we make a couple adjustments that will both follow this principle and fulfill the goal of preventing public code from being imported into server code?
Here's what I think will work:
- Moving all the authorization code back into its original state inside of
__packages_do_not_import__. - Changing the exports from
public/authorizationto be explicit. None of these modules are usable on the server, socommonisn't the best place for them.
export {
WithPrivileges,
NotAuthorizedSection,
AuthorizationProvider,
AuthorizationContext,
SectionError,
Error,
useAuthorizationContext,
} from '../../__packages_do_not_import__/authorization';- Changing the exports from
common/index.tsto consist of the types only, since they're the only things that are usable on both client and server:
export {
Privileges,
MissingPrivileges,
} from '../../__packages_do_not_import__/authorization';Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
cjcenizal
left a comment
There was a problem hiding this comment.
Code LGTM! Didn't test locally. Thanks for making the change I suggested!
nreese
left a comment
There was a problem hiding this comment.
maps changes LGTM
code review
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
|
@elasticmachine merge upstream |
|
@elasticmachine merge upstream |
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
afharo
left a comment
There was a problem hiding this comment.
Usage collection changes (src/plugins/usage_collection/server/report/store_report.test.ts) LGTM!
|
@elastic/kibana-app and @elastic/siem - can I get a codeowners review here? |
|
pinging @elastic/endpoint-app-team as they own the conflicting files. |
lizozom
left a comment
There was a problem hiding this comment.
@elastic/kibana-app-arch LGTM
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
We should not be allowing importing of public into server. Any shared code should reside in a common directory. After elastic#66506, this will not even be possible as we will no longer be transpiling public code into commonjs. Blocks elastic#66506 Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
We should not be allowing importing of public into server. Any shared code should reside in a common directory. After #66506, this will not even be possible as we will no longer be transpiling public code into commonjs. Blocks #66506 Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
We should not be allowing importing of public into server. Any shared code should reside in a common directory. After #66506, this will not even be possible as we will no longer be transpiling public code into commonjs.
Relates to #66506