-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Reporting] Define shims of legacy dependencies #54082
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
Changes from 11 commits
7315513
d954ef0
bb65245
79a9288
c931081
62dc408
78a2ea1
3e71f57
956ae17
e4761ff
48ec88c
44b714c
4192c34
4e7e448
71bd4a5
c64b4f7
ae8d134
81afb28
a6e830a
79524ef
ec3f12b
bdc87c9
80e0fcc
17b3b10
f7609d1
cb40fa3
15ab24b
37f6c3e
ddf8fac
b4dcefb
9d446a1
25e30da
5378584
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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), | ||
| }; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,10 +27,6 @@ export function oncePerServer(fn: ServerFn) { | |
| throw new TypeError('This function expects to be called with a single argument'); | ||
| } | ||
|
|
||
| if (!server || typeof server.expose !== 'function') { | ||
|
Contributor
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. Yesssss |
||
| throw new TypeError('This function expects to be passed the server'); | ||
| } | ||
|
|
||
| // @ts-ignore | ||
| return fn.call(this, server); | ||
| }); | ||
|
|
||
| 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); | ||
|
||
| let jobParamsRison: string | null; | ||
|
|
||
| if (request.payload) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /* | ||
| * 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 { | ||
| // This condition is for unit tests | ||
| const getSavedObjectsClient = request.getSavedObjectsClient | ||
| ? request.getSavedObjectsClient.bind(request) | ||
| : request.getSavedObjectsClient; | ||
| return { | ||
| getSavedObjectsClient, | ||
| headers: request.headers, | ||
| auth: request.auth, // for getUser | ||
| params: request.params, | ||
| payload: request.payload, | ||
| query: request.query, | ||
| pre: request.pre, | ||
| getBasePath: request.getBasePath, | ||
| route: request.route, | ||
| }; | ||
| } |
| 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; | ||
|
||
| route: Legacy.Request['route']; | ||
| pre: { | ||
| management: { | ||
| jobTypes: any; | ||
| }; | ||
| user: any; | ||
| }; | ||
| } | ||
|
|
||
| export type ResponseFacade = ResponseObject & { | ||
| isBoom: boolean; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.