-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into kbn-72572-client-…
…side-feature-usage
- Loading branch information
Showing
697 changed files
with
13,368 additions
and
8,980 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
18 changes: 18 additions & 0 deletions
18
docs/development/core/server/kibana-plugin-core-server.kibanarequest.id.md
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,18 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [KibanaRequest](./kibana-plugin-core-server.kibanarequest.md) > [id](./kibana-plugin-core-server.kibanarequest.id.md) | ||
|
||
## KibanaRequest.id property | ||
|
||
A identifier to identify this request. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
readonly id: string; | ||
``` | ||
|
||
## Remarks | ||
|
||
Depending on the user's configuration, this value may be sourced from the incoming request's `X-Opaque-Id` header which is not guaranteed to be unique per request. | ||
|
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
11 changes: 11 additions & 0 deletions
11
...t/core/server/kibana-plugin-core-server.savedobjectsbulkcreateobject.version.md
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,11 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [SavedObjectsBulkCreateObject](./kibana-plugin-core-server.savedobjectsbulkcreateobject.md) > [version](./kibana-plugin-core-server.savedobjectsbulkcreateobject.version.md) | ||
|
||
## SavedObjectsBulkCreateObject.version property | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
version?: string; | ||
``` |
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
13 changes: 13 additions & 0 deletions
13
...ment/core/server/kibana-plugin-core-server.savedobjectscreateoptions.version.md
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,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [SavedObjectsCreateOptions](./kibana-plugin-core-server.savedobjectscreateoptions.md) > [version](./kibana-plugin-core-server.savedobjectscreateoptions.version.md) | ||
|
||
## SavedObjectsCreateOptions.version property | ||
|
||
An opaque version number which changes on each successful write operation. Can be used in conjunction with `overwrite` for implementing optimistic concurrency control. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
version?: string; | ||
``` |
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
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,71 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { schema } from '..'; | ||
|
||
const { ip } = schema; | ||
|
||
describe('ip validation', () => { | ||
test('accepts ipv4', () => { | ||
expect(ip().validate('1.1.1.1')).toEqual('1.1.1.1'); | ||
}); | ||
test('accepts ipv6', () => { | ||
expect(ip().validate('1200:0000:AB00:1234:0000:2552:7777:1313')).toEqual( | ||
'1200:0000:AB00:1234:0000:2552:7777:1313' | ||
); | ||
}); | ||
test('rejects ipv6 when not specified', () => { | ||
expect(() => | ||
ip({ versions: ['ipv4'] }).validate('1200:0000:AB00:1234:0000:2552:7777:1313') | ||
).toThrowErrorMatchingInlineSnapshot(`"value must be a valid ipv4 address"`); | ||
}); | ||
test('rejects ipv4 when not specified', () => { | ||
expect(() => ip({ versions: ['ipv6'] }).validate('1.1.1.1')).toThrowErrorMatchingInlineSnapshot( | ||
`"value must be a valid ipv6 address"` | ||
); | ||
}); | ||
test('rejects invalid ip addresses', () => { | ||
expect(() => ip().validate('1.1.1.1/24')).toThrowErrorMatchingInlineSnapshot( | ||
`"value must be a valid ipv4 or ipv6 address"` | ||
); | ||
expect(() => ip().validate('99999.1.1.1')).toThrowErrorMatchingInlineSnapshot( | ||
`"value must be a valid ipv4 or ipv6 address"` | ||
); | ||
expect(() => | ||
ip().validate('ZZZZ:0000:AB00:1234:0000:2552:7777:1313') | ||
).toThrowErrorMatchingInlineSnapshot(`"value must be a valid ipv4 or ipv6 address"`); | ||
expect(() => ip().validate('blah 1234')).toThrowErrorMatchingInlineSnapshot( | ||
`"value must be a valid ipv4 or ipv6 address"` | ||
); | ||
}); | ||
}); | ||
|
||
test('returns error when not string', () => { | ||
expect(() => ip().validate(123)).toThrowErrorMatchingInlineSnapshot( | ||
`"expected value of type [string] but got [number]"` | ||
); | ||
|
||
expect(() => ip().validate([1, 2, 3])).toThrowErrorMatchingInlineSnapshot( | ||
`"expected value of type [string] but got [Array]"` | ||
); | ||
|
||
expect(() => ip().validate(/abc/)).toThrowErrorMatchingInlineSnapshot( | ||
`"expected value of type [string] but got [RegExp]"` | ||
); | ||
}); |
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,46 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import typeDetect from 'type-detect'; | ||
import { internals } from '../internals'; | ||
import { Type, TypeOptions } from './type'; | ||
|
||
export type IpVersion = 'ipv4' | 'ipv6'; | ||
export type IpOptions = TypeOptions<string> & { | ||
/** | ||
* IP versions to accept, defaults to ['ipv4', 'ipv6']. | ||
*/ | ||
versions: IpVersion[]; | ||
}; | ||
|
||
export class IpType extends Type<string> { | ||
constructor(options: IpOptions = { versions: ['ipv4', 'ipv6'] }) { | ||
const schema = internals.string().ip({ version: options.versions, cidr: 'forbidden' }); | ||
super(schema, options); | ||
} | ||
|
||
protected handleError(type: string, { value, version }: Record<string, any>) { | ||
switch (type) { | ||
case 'string.base': | ||
return `expected value of type [string] but got [${typeDetect(value)}]`; | ||
case 'string.ipVersion': | ||
return `value must be a valid ${version.join(' or ')} address`; | ||
} | ||
} | ||
} |
Oops, something went wrong.