Skip to content

Commit

Permalink
export CoreKibanaRequest for now...
Browse files Browse the repository at this point in the history
  • Loading branch information
pgayvallet committed Jun 29, 2022
1 parent 53672cd commit 9398abc
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/core/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export type {
SafeRouteMethod,
} from './http';

export { kibanaResponseFactory, validBodyOutput } from './http';
export { kibanaResponseFactory, validBodyOutput, CoreKibanaRequest } from './http';
export type { KibanaRequest } from './http';

export type {
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/actions/server/lib/task_runner_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
Logger,
SavedObjectsClientContract,
KibanaRequest,
CoreKibanaRequest,
SavedObjectReference,
IBasePath,
SavedObject,
Expand Down Expand Up @@ -226,7 +227,7 @@ function getFakeRequest(apiKey?: string) {

// Since we're using API keys and accessing elasticsearch can only be done
// via a request, we're faking one with the proper authorization headers.
const fakeRequest = KibanaRequest.from({
const fakeRequest = CoreKibanaRequest.from({
headers: requestHeaders,
path: '/',
route: { settings: {} },
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/alerting/server/task_runner/rule_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { PublicMethodsOf } from '@kbn/utility-types';
import type { Request } from '@hapi/hapi';
import { addSpaceIdToPath } from '@kbn/spaces-plugin/server';
import { KibanaRequest } from '@kbn/core/server';
import { CoreKibanaRequest } from '@kbn/core/server';
import { TaskRunnerContext } from './task_runner_factory';
import { ErrorWithReason, validateRuleTypeParams } from '../lib';
import {
Expand Down Expand Up @@ -127,7 +127,7 @@ export function getFakeKibanaRequest(

const path = addSpaceIdToPath('/', spaceId);

const fakeRequest = KibanaRequest.from({
const fakeRequest = CoreKibanaRequest.from({
headers: requestHeaders,
path: '/',
route: { settings: {} },
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/reporting/server/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type {
StatusServiceSetup,
UiSettingsServiceStart,
} from '@kbn/core/server';
import { KibanaRequest, ServiceStatusLevels } from '@kbn/core/server';
import { KibanaRequest, CoreKibanaRequest, ServiceStatusLevels } from '@kbn/core/server';
import type { PluginStart as DataPluginStart } from '@kbn/data-plugin/server';
import type { PluginSetupContract as FeaturesPluginSetup } from '@kbn/features-plugin/server';
import type { FieldFormatsStart } from '@kbn/field-formats-plugin/server';
Expand Down Expand Up @@ -322,7 +322,7 @@ export class ReportingCore {
}

public getFakeRequest(baseRequest: object, spaceId: string | undefined, logger = this.logger) {
const fakeRequest = KibanaRequest.from({
const fakeRequest = CoreKibanaRequest.from({
path: '/',
route: { settings: {} },
url: { href: '/' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {
IClusterClient,
Logger,
} from '@kbn/core/server';
import { KibanaRequest } from '@kbn/core/server';
import { KibanaRequest, CoreKibanaRequest } from '@kbn/core/server';
import { addSpaceIdToPath } from '@kbn/spaces-plugin/common';
import type { SpacesServiceStart } from '@kbn/spaces-plugin/server';

Expand Down Expand Up @@ -165,7 +165,7 @@ export class AnonymousAccessService {
* anonymous service account credentials.
*/
private createFakeAnonymousRequest({ authenticateRequest }: { authenticateRequest: boolean }) {
return KibanaRequest.from({
return CoreKibanaRequest.from({
headers:
authenticateRequest && this.httpAuthorizationHeader
? { authorization: this.httpAuthorizationHeader.toString() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import type { IBasePath, IClusterClient, LoggerFactory } from '@kbn/core/server';
import { KibanaRequest } from '@kbn/core/server';
import { KibanaRequest, CoreKibanaRequest } from '@kbn/core/server';
import type { Logger } from '@kbn/logging';
import type { PublicMethodsOf } from '@kbn/utility-types';

Expand Down Expand Up @@ -131,7 +131,7 @@ const ACCESS_AGREEMENT_ROUTE = '/security/access_agreement';
const OVERWRITTEN_SESSION_ROUTE = '/security/overwritten_session';

function assertRequest(request: KibanaRequest) {
if (!(request instanceof KibanaRequest)) {
if (!(request instanceof CoreKibanaRequest)) {
throw new Error(`Request should be a valid "KibanaRequest" instance, was [${typeof request}].`);
}
}
Expand Down

0 comments on commit 9398abc

Please sign in to comment.