-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Reporting] Define shims of legacy dependencies #54082
Merged
Merged
Changes from 8 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
7315513
simplify serverfacade definition
tsullivan d954ef0
simplify requestfacade definition
tsullivan bb65245
makeRequestFacade
tsullivan 79a9288
requestFacade
tsullivan c931081
use the shim
tsullivan 62dc408
import sorting
tsullivan 78a2ea1
originalServer
tsullivan 3e71f57
reduce loc change
tsullivan 956ae17
remove consolelog
tsullivan e4761ff
hacks to fix tests
tsullivan 48ec88c
Merge branch 'master' into reporting/shim-plugin
elasticmachine 44b714c
ServerFacade in index
tsullivan 4192c34
Merge branch 'master' into reporting/shim-plugin
elasticmachine 4e7e448
Cosmetic
tsullivan 71bd4a5
remove field from serverfacade
tsullivan c64b4f7
Merge branch 'master' into reporting/shim-plugin
tsullivan ae8d134
add raw to the request
tsullivan 81afb28
fix types
tsullivan a6e830a
add fieldFormatServiceFactory to legacy
tsullivan 79524ef
Merge branch 'master' into reporting/shim-plugin
elasticmachine ec3f12b
Merge branch 'master' into reporting/shim-plugin
elasticmachine bdc87c9
Merge branch 'master' into reporting/shim-plugin
elasticmachine 80e0fcc
Pass the complete request object to sec plugin
tsullivan 17b3b10
Fix test
tsullivan f7609d1
fix test 2
tsullivan cb40fa3
getUser takes a legacy request
tsullivan 15ab24b
add unit test for new lib
tsullivan 37f6c3e
Merge branch 'master' into reporting/shim-plugin
elasticmachine ddf8fac
add getRawRequest to pass to saved objects method
tsullivan b4dcefb
update test snapshot
tsullivan 9d446a1
Merge branch 'master' into reporting/shim-plugin
elasticmachine 25e30da
leave a TODO comment for type import
tsullivan 5378584
variable rename for legacy id
tsullivan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
import { ServerFacade } from './types'; | ||
|
||
export function makeServerFacade(server: ServerFacade): ServerFacade { | ||
return { | ||
config: server.config, | ||
info: server.info, | ||
route: server.route.bind(server), | ||
newPlatform: server.newPlatform, | ||
plugins: { | ||
elasticsearch: server.plugins.elasticsearch, | ||
xpack_main: server.plugins.xpack_main, | ||
security: server.plugins.security, | ||
}, | ||
savedObjects: server.savedObjects, | ||
uiSettingsServiceFactory: server.uiSettingsServiceFactory, | ||
log: server.log.bind(server), | ||
}; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ import { | |
GetRouteConfigFactoryFn, | ||
RouteConfigFactory, | ||
} from './lib/route_config_factories'; | ||
import { makeRequestFacade } from './lib/make_request_facade'; | ||
import { HandlerErrorFunction, HandlerFunction } from './types'; | ||
|
||
const BASE_GENERATE = `${API_BASE_URL}/generate`; | ||
|
@@ -54,7 +55,8 @@ export function registerGenerateFromJobParams( | |
path: `${BASE_GENERATE}/{exportType}`, | ||
method: 'POST', | ||
options: getRouteConfig(), | ||
handler: async (request: RequestFacade, h: ReportingResponseToolkit) => { | ||
handler: async (originalRequest: RequestFacade, h: ReportingResponseToolkit) => { | ||
const request = makeRequestFacade(originalRequest); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to keep with the |
||
let jobParamsRison: string | null; | ||
|
||
if (request.payload) { | ||
|
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
21 changes: 21 additions & 0 deletions
21
x-pack/legacy/plugins/reporting/server/routes/lib/make_request_facade.ts
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; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { RequestFacade } from '../../../types'; | ||
|
||
export function makeRequestFacade(request: RequestFacade): RequestFacade { | ||
return { | ||
headers: request.headers, | ||
auth: request.auth, // for getUser | ||
params: request.params, | ||
payload: request.payload, | ||
query: request.query, | ||
pre: request.pre, | ||
getBasePath: request.getBasePath, | ||
getSavedObjectsClient: request.getSavedObjectsClient.bind(request), | ||
route: request.route, | ||
}; | ||
} |
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 |
---|---|---|
|
@@ -64,34 +64,30 @@ interface GenerateQuery { | |
interface GenerateExportTypePayload { | ||
jobParams: string; | ||
} | ||
interface DownloadParams { | ||
docId: string; | ||
} | ||
|
||
/* | ||
* Legacy System | ||
*/ | ||
|
||
export type ReportingPluginSpecOptions = Legacy.PluginSpecOptions; | ||
|
||
export type ServerFacade = Legacy.Server & { | ||
type LegacyPlugins = Legacy.Server['plugins']; | ||
|
||
export interface ServerFacade { | ||
config: Legacy.Server['config']; | ||
info: Legacy.Server['info']; | ||
log: Legacy.Server['log']; | ||
newPlatform: Legacy.Server['newPlatform']; | ||
plugins: { | ||
xpack_main?: XPackMainPlugin & { | ||
elasticsearch: LegacyPlugins['elasticsearch']; | ||
security: LegacyPlugins['security']; | ||
xpack_main: XPackMainPlugin & { | ||
status?: any; | ||
}; | ||
}; | ||
}; | ||
|
||
interface ReportingRequest { | ||
query: ListQuery & GenerateQuery; | ||
params: DownloadParams; | ||
payload: GenerateExportTypePayload; | ||
pre: { | ||
management: { | ||
jobTypes: any; | ||
}; | ||
user: any; | ||
}; | ||
route: Legacy.Server['route']; | ||
savedObjects: Legacy.Server['savedObjects']; | ||
uiSettingsServiceFactory: Legacy.Server['uiSettingsServiceFactory']; | ||
} | ||
|
||
export type EnqueueJobFn = <JobParamsType>( | ||
|
@@ -103,7 +99,22 @@ export type EnqueueJobFn = <JobParamsType>( | |
request: RequestFacade | ||
) => Promise<Job>; | ||
|
||
export type RequestFacade = ReportingRequest & Legacy.Request; | ||
export interface RequestFacade { | ||
getBasePath: Legacy.Request['getBasePath']; | ||
getSavedObjectsClient: Legacy.Request['getSavedObjectsClient']; | ||
auth: Legacy.Request['auth']; | ||
headers: Legacy.Request['headers']; | ||
params: Legacy.Request['params']; | ||
payload: JobParamPostPayload | GenerateExportTypePayload; | ||
query: ListQuery & GenerateQuery; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure why this isn't |
||
route: Legacy.Request['route']; | ||
pre: { | ||
management: { | ||
jobTypes: any; | ||
}; | ||
user: any; | ||
}; | ||
} | ||
|
||
export type ResponseFacade = ResponseObject & { | ||
isBoom: boolean; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Yesssss