Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into spacetime
Browse files Browse the repository at this point in the history
  • Loading branch information
wylieconlon committed Jun 5, 2020
2 parents 9fe364b + c7353b0 commit 6a6790e
Show file tree
Hide file tree
Showing 549 changed files with 13,096 additions and 3,720 deletions.
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.19.0
10.21.0
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.19.0
10.21.0
2 changes: 1 addition & 1 deletion .sass-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ files:
- 'src/legacy/core_plugins/timelion/**/*.s+(a|c)ss'
- 'src/plugins/vis_type_vislib/**/*.s+(a|c)ss'
- 'src/plugins/vis_type_xy/**/*.s+(a|c)ss'
- 'x-pack/legacy/plugins/security/**/*.s+(a|c)ss'
- 'x-pack/plugins/canvas/**/*.s+(a|c)ss'
- 'x-pack/plugins/triggers_actions_ui/**/*.s+(a|c)ss'
- 'x-pack/plugins/lens/**/*.s+(a|c)ss'
- 'x-pack/plugins/cross_cluster_replication/**/*.s+(a|c)ss'
- 'x-pack/legacy/plugins/maps/**/*.s+(a|c)ss'
- 'x-pack/plugins/maps/**/*.s+(a|c)ss'
- 'x-pack/plugins/spaces/**/*.s+(a|c)ss'
- 'x-pack/plugins/security/**/*.s+(a|c)ss'
ignore:
- 'x-pack/plugins/canvas/shareable_runtime/**/*.s+(a|c)ss'
rules:
Expand Down
1 change: 1 addition & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ kibanaPipeline(timeoutMinutes: 155, checkPrChanges: true) {
'xpack-ciGroup9': kibanaPipeline.xpackCiGroupProcess(9),
'xpack-ciGroup10': kibanaPipeline.xpackCiGroupProcess(10),
'xpack-accessibility': kibanaPipeline.functionalTestProcess('xpack-accessibility', './test/scripts/jenkins_xpack_accessibility.sh'),
'xpack-pageLoadMetrics': kibanaPipeline.functionalTestProcess('xpack-pageLoadMetrics', './test/scripts/jenkins_xpack_page_load_metrics.sh'),
'xpack-securitySolutionCypress': { processNumber ->
whenChanged(['x-pack/plugins/security_solution/', 'x-pack/test/security_solution_cypress/']) {
kibanaPipeline.functionalTestProcess('xpack-securitySolutionCypress', './test/scripts/jenkins_security_solution_cypress.sh')(processNumber)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
| [SearchBar](./kibana-plugin-plugins-data-public.searchbar.md) | |
| [SYNC\_SEARCH\_STRATEGY](./kibana-plugin-plugins-data-public.sync_search_strategy.md) | |
| [syncQueryStateWithUrl](./kibana-plugin-plugins-data-public.syncquerystatewithurl.md) | Helper to setup syncing of global data with the URL |
| [UI\_SETTINGS](./kibana-plugin-plugins-data-public.ui_settings.md) | |

## Type Aliases

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

[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [UI\_SETTINGS](./kibana-plugin-plugins-data-public.ui_settings.md)

## UI\_SETTINGS variable

<b>Signature:</b>

```typescript
UI_SETTINGS: {
META_FIELDS: string;
DOC_HIGHLIGHT: string;
QUERY_STRING_OPTIONS: string;
QUERY_ALLOW_LEADING_WILDCARDS: string;
SEARCH_QUERY_LANGUAGE: string;
SORT_OPTIONS: string;
COURIER_IGNORE_FILTER_IF_FIELD_NOT_IN_INDEX: string;
COURIER_SET_REQUEST_PREFERENCE: string;
COURIER_CUSTOM_REQUEST_PREFERENCE: string;
COURIER_MAX_CONCURRENT_SHARD_REQUESTS: string;
COURIER_BATCH_SEARCHES: string;
SEARCH_INCLUDE_FROZEN: string;
HISTOGRAM_BAR_TARGET: string;
HISTOGRAM_MAX_BARS: string;
HISTORY_LIMIT: string;
SHORT_DOTS_ENABLE: string;
FORMAT_DEFAULT_TYPE_MAP: string;
FORMAT_NUMBER_DEFAULT_PATTERN: string;
FORMAT_PERCENT_DEFAULT_PATTERN: string;
FORMAT_BYTES_DEFAULT_PATTERN: string;
FORMAT_CURRENCY_DEFAULT_PATTERN: string;
FORMAT_NUMBER_DEFAULT_LOCALE: string;
TIMEPICKER_REFRESH_INTERVAL_DEFAULTS: string;
TIMEPICKER_QUICK_RANGES: string;
INDEXPATTERN_PLACEHOLDER: string;
FILTERS_PINNED_BY_DEFAULT: string;
FILTERS_EDITOR_SUGGEST_VALUES: string;
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
| [fieldFormats](./kibana-plugin-plugins-data-server.fieldformats.md) | |
| [indexPatterns](./kibana-plugin-plugins-data-server.indexpatterns.md) | |
| [search](./kibana-plugin-plugins-data-server.search.md) | |
| [UI\_SETTINGS](./kibana-plugin-plugins-data-server.ui_settings.md) | |

## Type Aliases

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

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [UI\_SETTINGS](./kibana-plugin-plugins-data-server.ui_settings.md)

## UI\_SETTINGS variable

<b>Signature:</b>

```typescript
UI_SETTINGS: {
META_FIELDS: string;
DOC_HIGHLIGHT: string;
QUERY_STRING_OPTIONS: string;
QUERY_ALLOW_LEADING_WILDCARDS: string;
SEARCH_QUERY_LANGUAGE: string;
SORT_OPTIONS: string;
COURIER_IGNORE_FILTER_IF_FIELD_NOT_IN_INDEX: string;
COURIER_SET_REQUEST_PREFERENCE: string;
COURIER_CUSTOM_REQUEST_PREFERENCE: string;
COURIER_MAX_CONCURRENT_SHARD_REQUESTS: string;
COURIER_BATCH_SEARCHES: string;
SEARCH_INCLUDE_FROZEN: string;
HISTOGRAM_BAR_TARGET: string;
HISTOGRAM_MAX_BARS: string;
HISTORY_LIMIT: string;
SHORT_DOTS_ENABLE: string;
FORMAT_DEFAULT_TYPE_MAP: string;
FORMAT_NUMBER_DEFAULT_PATTERN: string;
FORMAT_PERCENT_DEFAULT_PATTERN: string;
FORMAT_BYTES_DEFAULT_PATTERN: string;
FORMAT_CURRENCY_DEFAULT_PATTERN: string;
FORMAT_NUMBER_DEFAULT_LOCALE: string;
TIMEPICKER_REFRESH_INTERVAL_DEFAULTS: string;
TIMEPICKER_QUICK_RANGES: string;
INDEXPATTERN_PLACEHOLDER: string;
FILTERS_PINNED_BY_DEFAULT: string;
FILTERS_EDITOR_SUGGEST_VALUES: string;
}
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@
"zlib": "^1.0.5"
},
"engines": {
"node": "10.19.0",
"node": "10.21.0",
"yarn": "^1.21.1"
}
}
3 changes: 2 additions & 1 deletion packages/kbn-config-schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"kbn:bootstrap": "yarn build"
},
"devDependencies": {
"typescript": "3.7.2"
"typescript": "3.7.2",
"tsd": "^0.7.4"
},
"peerDependencies": {
"joi": "^13.5.2",
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-config-schema/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
ObjectType,
ObjectTypeOptions,
Props,
NullableProps,
RecordOfOptions,
RecordOfType,
StringOptions,
Expand All @@ -57,7 +58,7 @@ import {
StreamType,
} from './types';

export { ObjectType, TypeOf, Type };
export { ObjectType, TypeOf, Type, Props, NullableProps };
export { ByteSizeValue } from './byte_size_value';
export { SchemaTypeError, ValidationError } from './errors';
export { isConfigSchema } from './typeguards';
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-config-schema/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export { LiteralType } from './literal_type';
export { MaybeType } from './maybe_type';
export { MapOfOptions, MapOfType } from './map_type';
export { NumberOptions, NumberType } from './number_type';
export { ObjectType, ObjectTypeOptions, Props, TypeOf } from './object_type';
export { ObjectType, ObjectTypeOptions, Props, NullableProps, TypeOf } from './object_type';
export { RecordOfOptions, RecordOfType } from './record_type';
export { StreamType } from './stream_type';
export { StringOptions, StringType } from './string_type';
Expand Down
140 changes: 133 additions & 7 deletions packages/kbn-config-schema/src/types/object_type.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/

import { expectType } from 'tsd';
import { schema } from '..';
import { TypeOf } from './object_type';

Expand Down Expand Up @@ -360,17 +361,142 @@ test('handles optional properties', () => {

type SchemaType = TypeOf<typeof type>;

let foo: SchemaType = {
expectType<SchemaType>({
required: 'foo',
};
foo = {
});
expectType<SchemaType>({
required: 'hello',
optional: undefined,
};
foo = {
});
expectType<SchemaType>({
required: 'hello',
optional: 'bar',
};
});
});

describe('#extends', () => {
it('allows to extend an existing schema by adding new properties', () => {
const origin = schema.object({
initial: schema.string(),
});

const extended = origin.extends({
added: schema.number(),
});

expect(() => {
extended.validate({ initial: 'foo' });
}).toThrowErrorMatchingInlineSnapshot(
`"[added]: expected value of type [number] but got [undefined]"`
);

expect(() => {
extended.validate({ initial: 'foo', added: 42 });
}).not.toThrowError();

expect(foo).toBeDefined();
expectType<TypeOf<typeof extended>>({
added: 12,
initial: 'foo',
});
});

it('allows to extend an existing schema by removing properties', () => {
const origin = schema.object({
string: schema.string(),
number: schema.number(),
});

const extended = origin.extends({ number: undefined });

expect(() => {
extended.validate({ string: 'foo', number: 12 });
}).toThrowErrorMatchingInlineSnapshot(`"[number]: definition for this key is missing"`);

expect(() => {
extended.validate({ string: 'foo' });
}).not.toThrowError();

expectType<TypeOf<typeof extended>>({
string: 'foo',
});
});

it('allows to extend an existing schema by overriding an existing properties', () => {
const origin = schema.object({
string: schema.string(),
mutated: schema.number(),
});

const extended = origin.extends({
mutated: schema.string(),
});

expect(() => {
extended.validate({ string: 'foo', mutated: 12 });
}).toThrowErrorMatchingInlineSnapshot(
`"[mutated]: expected value of type [string] but got [number]"`
);

expect(() => {
extended.validate({ string: 'foo', mutated: 'bar' });
}).not.toThrowError();

expectType<TypeOf<typeof extended>>({
string: 'foo',
mutated: 'bar',
});
});

it('properly infer the type from optional properties', () => {
const origin = schema.object({
original: schema.maybe(schema.string()),
mutated: schema.maybe(schema.number()),
removed: schema.maybe(schema.string()),
});

const extended = origin.extends({
removed: undefined,
mutated: schema.string(),
});

expect(() => {
extended.validate({ original: 'foo' });
}).toThrowErrorMatchingInlineSnapshot(
`"[mutated]: expected value of type [string] but got [undefined]"`
);
expect(() => {
extended.validate({ original: 'foo' });
}).toThrowErrorMatchingInlineSnapshot(
`"[mutated]: expected value of type [string] but got [undefined]"`
);
expect(() => {
extended.validate({ original: 'foo', mutated: 'bar' });
}).not.toThrowError();

expectType<TypeOf<typeof extended>>({
original: 'foo',
mutated: 'bar',
});
expectType<TypeOf<typeof extended>>({
mutated: 'bar',
});
});

it(`allows to override the original schema's options`, () => {
const origin = schema.object(
{
initial: schema.string(),
},
{ defaultValue: { initial: 'foo' } }
);

const extended = origin.extends(
{
added: schema.number(),
},
{ defaultValue: { initial: 'bar', added: 42 } }
);

expect(extended.validate(undefined)).toEqual({ initial: 'bar', added: 42 });
});
});
Loading

0 comments on commit 6a6790e

Please sign in to comment.