Skip to content

Commit

Permalink
Review nits
Browse files Browse the repository at this point in the history
  • Loading branch information
eliperelman committed Dec 28, 2019
1 parent becf2bb commit 983bc52
Show file tree
Hide file tree
Showing 15 changed files with 173 additions and 181 deletions.
26 changes: 13 additions & 13 deletions docs/development/core/server/kibana-plugin-server.basepath.get.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [BasePath](./kibana-plugin-server.basepath.md) &gt; [get](./kibana-plugin-server.basepath.get.md)

## BasePath.get property

returns `basePath` value, specific for an incoming request.

<b>Signature:</b>

```typescript
(request: KibanaRequest<unknown, unknown, unknown, any> | LegacyRequest) => string;
```
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [BasePath](./kibana-plugin-server.basepath.md) &gt; [get](./kibana-plugin-server.basepath.get.md)

## BasePath.get property

returns `basePath` value, specific for an incoming request.

<b>Signature:</b>

```typescript
get: (request: KibanaRequest<unknown, unknown, unknown, any> | LegacyRequest) => string;
```
26 changes: 13 additions & 13 deletions docs/development/core/server/kibana-plugin-server.basepath.set.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [BasePath](./kibana-plugin-server.basepath.md) &gt; [set](./kibana-plugin-server.basepath.set.md)

## BasePath.set property

sets `basePath` value, specific for an incoming request.

<b>Signature:</b>

```typescript
(request: KibanaRequest<unknown, unknown, unknown, any> | LegacyRequest, requestSpecificBasePath: string) => void;
```
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [BasePath](./kibana-plugin-server.basepath.md) &gt; [set](./kibana-plugin-server.basepath.set.md)

## BasePath.set property

sets `basePath` value, specific for an incoming request.

<b>Signature:</b>

```typescript
set: (request: KibanaRequest<unknown, unknown, unknown, any> | LegacyRequest, requestSpecificBasePath: string) => void;
```
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## IRenderOptions.includeUserSettings property

Set whether to output user settings in the page metadata.
Set whether to output user settings in the page metadata. `true` by default.

<b>Signature:</b>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export interface IRenderOptions

| Property | Type | Description |
| --- | --- | --- |
| [includeUserSettings](./kibana-plugin-server.irenderoptions.includeusersettings.md) | <code>boolean</code> | Set whether to output user settings in the page metadata. |
| [includeUserSettings](./kibana-plugin-server.irenderoptions.includeusersettings.md) | <code>boolean</code> | Set whether to output user settings in the page metadata. <code>true</code> by default. |

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [IRouter](./kibana-plugin-server.irouter.md) &gt; [handleLegacyErrors](./kibana-plugin-server.irouter.handlelegacyerrors.md)

## IRouter.handleLegacyErrors property

Wrap a router handler to catch and converts legacy boom errors to proper custom errors.

<b>Signature:</b>

```typescript
<P, Q, B>(handler: RequestHandler<P, Q, B>) => RequestHandler<P, Q, B>;
```
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [IRouter](./kibana-plugin-server.irouter.md) &gt; [handleLegacyErrors](./kibana-plugin-server.irouter.handlelegacyerrors.md)

## IRouter.handleLegacyErrors property

Wrap a router handler to catch and converts legacy boom errors to proper custom errors.

<b>Signature:</b>

```typescript
handleLegacyErrors: <P, Q, B>(handler: RequestHandler<P, Q, B>) => RequestHandler<P, Q, B>;
```
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [RouteConfig](./kibana-plugin-server.routeconfig.md) &gt; [validate](./kibana-plugin-server.routeconfig.validate.md)

## RouteConfig.validate property

A schema created with `@kbn/config-schema` that every request will be validated against.

<b>Signature:</b>

```typescript
RouteValidatorFullConfig<P, Q, B> | false;
```

## Remarks

You \*must\* specify a validation schema to be able to read: - url path segments - request query - request body To opt out of validating the request, specify `validate: false`<!-- -->. In this case request params, query, and body will be \*\*empty\*\* objects and have no access to raw values. In some cases you may want to use another validation library. To do this, you need to instruct the `@kbn/config-schema` library to output \*\*non-validated values\*\* with setting schema as `schema.object({}, { allowUnknowns: true })`<!-- -->;

## Example


```ts
import { schema } from '@kbn/config-schema';
router.get({
path: 'path/{id}',
validate: {
params: schema.object({
id: schema.string(),
}),
query: schema.object({...}),
body: schema.object({...}),
},
},
(context, req, res,) {
req.params; // type Readonly<{id: string}>
console.log(req.params.id); // value
});

router.get({
path: 'path/{id}',
validate: false, // handler has no access to params, query, body values.
},
(context, req, res,) {
req.params; // type Readonly<{}>;
console.log(req.params.id); // undefined
});

router.get({
path: 'path/{id}',
validate: {
// handler has access to raw non-validated params in runtime
params: schema.object({}, { allowUnknowns: true })
},
},
(context, req, res,) {
req.params; // type Readonly<{}>;
console.log(req.params.id); // value
myValidationLibrary.validate({ params: req.params });
});

```

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [RouteConfig](./kibana-plugin-server.routeconfig.md) &gt; [validate](./kibana-plugin-server.routeconfig.validate.md)

## RouteConfig.validate property

A schema created with `@kbn/config-schema` that every request will be validated against.

<b>Signature:</b>

```typescript
validate: RouteValidatorFullConfig<P, Q, B> | false;
```

## Remarks

You \*must\* specify a validation schema to be able to read: - url path segments - request query - request body To opt out of validating the request, specify `validate: false`<!-- -->. In this case request params, query, and body will be \*\*empty\*\* objects and have no access to raw values. In some cases you may want to use another validation library. To do this, you need to instruct the `@kbn/config-schema` library to output \*\*non-validated values\*\* with setting schema as `schema.object({}, { allowUnknowns: true })`<!-- -->;

## Example


```ts
import { schema } from '@kbn/config-schema';
router.get({
path: 'path/{id}',
validate: {
params: schema.object({
id: schema.string(),
}),
query: schema.object({...}),
body: schema.object({...}),
},
},
(context, req, res,) {
req.params; // type Readonly<{id: string}>
console.log(req.params.id); // value
});

router.get({
path: 'path/{id}',
validate: false, // handler has no access to params, query, body values.
},
(context, req, res,) {
req.params; // type Readonly<{}>;
console.log(req.params.id); // undefined
});

router.get({
path: 'path/{id}',
validate: {
// handler has access to raw non-validated params in runtime
params: schema.object({}, { allowUnknowns: true })
},
},
(context, req, res,) {
req.params; // type Readonly<{}>;
console.log(req.params.id); // value
myValidationLibrary.validate({ params: req.params });
});

```

Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [RouteValidationError](./kibana-plugin-server.routevalidationerror.md) &gt; [(constructor)](./kibana-plugin-server.routevalidationerror._constructor_.md)

## RouteValidationError.(constructor)

Constructs a new instance of the `RouteValidationError` class

<b>Signature:</b>

```typescript
constructor(error;: Error | string, path?: string[];)
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| error | <code>Error &#124; string</code> | |
| path | <code>string[]</code> | |

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [RouteValidationError](./kibana-plugin-server.routevalidationerror.md) &gt; [(constructor)](./kibana-plugin-server.routevalidationerror._constructor_.md)

## RouteValidationError.(constructor)

Constructs a new instance of the `RouteValidationError` class

<b>Signature:</b>

```typescript
constructor(error: Error | string, path?: string[]);
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| error | <code>Error &#124; string</code> | |
| path | <code>string[]</code> | |

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [RouteValidationResultFactory](./kibana-plugin-server.routevalidationresultfactory.md) &gt; [badRequest](./kibana-plugin-server.routevalidationresultfactory.badrequest.md)

## RouteValidationResultFactory.badRequest property

<b>Signature:</b>

```typescript
(error: Error | string, path?: string[]) => {
RouteValidationError;
};
```
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [RouteValidationResultFactory](./kibana-plugin-server.routevalidationresultfactory.md) &gt; [badRequest](./kibana-plugin-server.routevalidationresultfactory.badrequest.md)

## RouteValidationResultFactory.badRequest property

<b>Signature:</b>

```typescript
badRequest: (error: Error | string, path?: string[]) => {
error: RouteValidationError;
};
```
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [RouteValidationResultFactory](./kibana-plugin-server.routevalidationresultfactory.md) &gt; [ok](./kibana-plugin-server.routevalidationresultfactory.ok.md)

## RouteValidationResultFactory.ok property

<b>Signature:</b>

```typescript
<T>(value: T) => {
T;
};
```
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [RouteValidationResultFactory](./kibana-plugin-server.routevalidationresultfactory.md) &gt; [ok](./kibana-plugin-server.routevalidationresultfactory.ok.md)

## RouteValidationResultFactory.ok property

<b>Signature:</b>

```typescript
ok: <T>(value: T) => {
value: T;
};
```
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [RouteValidatorOptions](./kibana-plugin-server.routevalidatoroptions.md) &gt; [unsafe](./kibana-plugin-server.routevalidatoroptions.unsafe.md)

## RouteValidatorOptions.unsafe property

Set the `unsafe` config to avoid running some additional internal \*safe\* validations on top of your custom validation

<b>Signature:</b>

```typescript
unsafe?: {
params?: boolean;
query?: boolean;
body?: boolean;
}

```
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [RouteValidatorOptions](./kibana-plugin-server.routevalidatoroptions.md) &gt; [unsafe](./kibana-plugin-server.routevalidatoroptions.unsafe.md)

## RouteValidatorOptions.unsafe property

Set the `unsafe` config to avoid running some additional internal \*safe\* validations on top of your custom validation

<b>Signature:</b>

```typescript
unsafe?: {
params?: boolean;
query?: boolean;
body?: boolean;
};
```
7 changes: 2 additions & 5 deletions src/core/server/legacy/legacy_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export type ILegacyService = PublicMethodsOf<LegacyService>;
export class LegacyService implements CoreService {
/** Symbol to represent the legacy platform as a fake "plugin". Used by the ContextService */
public readonly legacyId = Symbol();
private hasDiscovered = false;
private readonly log: Logger;
private readonly devConfig$: Observable<DevConfig>;
private readonly httpConfig$: Observable<HttpConfig>;
Expand Down Expand Up @@ -158,8 +157,6 @@ export class LegacyService implements CoreService {
);
}

this.hasDiscovered = true;

return {
pluginSpecs,
disabledPluginSpecs,
Expand All @@ -173,7 +170,7 @@ export class LegacyService implements CoreService {
public async setup(setupDeps: LegacyServiceSetupDeps) {
this.log.debug('setting up legacy service');

if (!this.hasDiscovered) {
if (!this.legacyPlugins) {
throw new Error(
'Legacy service has not discovered legacy plugins yet. Ensure LegacyService.discoverPlugins() is called before LegacyService.setup()'
);
Expand All @@ -187,7 +184,7 @@ export class LegacyService implements CoreService {
public async start(startDeps: LegacyServiceStartDeps) {
const { setupDeps } = this;

if (!setupDeps || !this.hasDiscovered) {
if (!setupDeps || !this.legacyPlugins) {
throw new Error('Legacy service is not setup yet.');
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/server/legacy/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export type LegacyUiExports = SavedObjectsLegacyUiExports & {
injectedVarsReplacers?: VarsReplacer[];
navLinkSpecs?: LegacyNavLinkSpec[] | null;
uiAppSpecs?: Array<LegacyAppSpec | undefined>;
unknown?: [{ pluginSpec: { getId: () => unknown }; type: unknown }];
unknown?: [{ pluginSpec: LegacyPluginSpec; type: unknown }];
};

/**
Expand Down
Loading

0 comments on commit 983bc52

Please sign in to comment.