Skip to content

Commit

Permalink
Merge branch 'main' into feature-enable-sufeature-privileges
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Apr 9, 2024
2 parents 31c573f + 0d22468 commit f48adb8
Show file tree
Hide file tree
Showing 144 changed files with 2,922 additions and 808 deletions.
12 changes: 6 additions & 6 deletions .buildkite/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ image::management/connectors/images/cases-webhook-connector-comments.png[Add cas

Add HTTP header::
A set of key-value pairs sent as headers with the request URLs for the create case, update case, get case, and create comment methods.
For example, set `Content-Type` to the appropriate media type for your requests.

Create case method::
The REST API HTTP request method to create a case in the third-party system: `post`(default), `put`, or `patch`.
Expand Down
4 changes: 3 additions & 1 deletion docs/management/connectors/action-types/webhook.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ Authentication::
The authentication type: none, basic, or SSL.
If you choose basic authentication, you must provide a user name and password.
If you choose SSL authentication, you must provide SSL server certificate authentication data in a CRT and key file format or a PFX file format. You can also optionally provide a passphrase if the files are password-protected.
HTTP headers:: A set of key-value pairs sent as headers with the request.
HTTP headers::
A set of key-value pairs sent as headers with the request.
For example, set `Content-Type` to the appropriate media type for your requests.
Certificate authority::
A certificate authority (CA) that the connector can trust, for example to sign and validate server certificates.
This option is available for all authentication types.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1519,6 +1519,7 @@
"@types/vinyl-fs": "^3.0.2",
"@types/watchpack": "^1.1.5",
"@types/webpack": "^4.41.3",
"@types/webpack-bundle-analyzer": "^4.7.0",
"@types/webpack-env": "^1.15.3",
"@types/webpack-merge": "^4.1.5",
"@types/webpack-sources": "^0.1.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export const HASH_TO_VERSION_MAP = {
'infrastructure-monitoring-log-view|c50526fc6040c5355ed027d34d05b35c': '10.0.0',
'infrastructure-ui-source|3d1b76c39bfb2cc8296b024d73854724': '10.0.0',
'ingest_manager_settings|b91ffb075799c78ffd7dbd51a279c8c9': '10.1.0',
'ingest-agent-policies|20768dc7ce5eced3eb309e50d8a6cf76': '10.0.0',
'ingest-agent-policies|0fd93cd11c019b118e93a9157c22057b': '10.1.0',
'ingest-download-sources|0b0f6828e59805bd07a650d80817c342': '10.0.0',
'ingest-outputs|b1237f7fdc0967709e75d65d208ace05': '10.6.0',
'ingest-package-policies|a1a074bad36e68d54f98d2158d60f879': '10.0.0',
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-check-mappings-update-cli/current_fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@
],
"infrastructure-ui-source": [],
"ingest-agent-policies": [
"advanced_settings",
"agent_features",
"agent_features.enabled",
"agent_features.name",
Expand Down
4 changes: 4 additions & 0 deletions packages/kbn-check-mappings-update-cli/current_mappings.json
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,10 @@
},
"ingest-agent-policies": {
"properties": {
"advanced_settings": {
"index": false,
"type": "flattened"
},
"agent_features": {
"properties": {
"enabled": {
Expand Down
14 changes: 14 additions & 0 deletions packages/kbn-config-schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,17 @@ export const schema = {
};

export type Schema = typeof schema;

import {
META_FIELD_X_OAS_OPTIONAL,
META_FIELD_X_OAS_MAX_LENGTH,
META_FIELD_X_OAS_MIN_LENGTH,
META_FIELD_X_OAS_GET_ADDITIONAL_PROPERTIES,
} from './src/oas_meta_fields';

export const metaFields = Object.freeze({
META_FIELD_X_OAS_OPTIONAL,
META_FIELD_X_OAS_MAX_LENGTH,
META_FIELD_X_OAS_MIN_LENGTH,
META_FIELD_X_OAS_GET_ADDITIONAL_PROPERTIES,
});
17 changes: 17 additions & 0 deletions packages/kbn-config-schema/src/oas_meta_fields.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

/**
* These fields are used in Joi meta to capture additional information used
* by OpenAPI spec generator.
*/
export const META_FIELD_X_OAS_OPTIONAL = 'x-oas-optional' as const;
export const META_FIELD_X_OAS_MIN_LENGTH = 'x-oas-min-length' as const;
export const META_FIELD_X_OAS_MAX_LENGTH = 'x-oas-max-length' as const;
export const META_FIELD_X_OAS_GET_ADDITIONAL_PROPERTIES =
'x-oas-get-additional-properties' as const;
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import { schema } from '../..';
import { META_FIELD_X_OAS_GET_ADDITIONAL_PROPERTIES } from '../oas_meta_fields';

test('handles object as input', () => {
const type = schema.mapOf(schema.string(), schema.string());
Expand Down Expand Up @@ -186,6 +187,17 @@ test('error preserves full path', () => {
);
});

test('meta', () => {
const stringSchema = schema.string();
const type = schema.mapOf(schema.string(), stringSchema);
const result = type
.getSchema()
.describe()
.metas![0][META_FIELD_X_OAS_GET_ADDITIONAL_PROPERTIES]();

expect(result).toBe(stringSchema.getSchema());
});

describe('#extendsDeep', () => {
describe('#keyType', () => {
const type = schema.mapOf(schema.string(), schema.object({ foo: schema.string() }));
Expand Down
8 changes: 7 additions & 1 deletion packages/kbn-config-schema/src/types/map_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import typeDetect from 'type-detect';
import { SchemaTypeError, SchemaTypesError } from '../errors';
import { internals } from '../internals';
import { META_FIELD_X_OAS_GET_ADDITIONAL_PROPERTIES } from '../oas_meta_fields';
import { Type, TypeOptions, ExtendsDeepOptions } from './type';

export type MapOfOptions<K, V> = TypeOptions<Map<K, V>>;
Expand All @@ -20,7 +21,12 @@ export class MapOfType<K, V> extends Type<Map<K, V>> {

constructor(keyType: Type<K>, valueType: Type<V>, options: MapOfOptions<K, V> = {}) {
const defaultValue = options.defaultValue;
const schema = internals.map().entries(keyType.getSchema(), valueType.getSchema());
const schema = internals
.map()
.entries(keyType.getSchema(), valueType.getSchema())
.meta({
[META_FIELD_X_OAS_GET_ADDITIONAL_PROPERTIES]: () => valueType.getSchema(),
});

super(schema, {
...options,
Expand Down
7 changes: 7 additions & 0 deletions packages/kbn-config-schema/src/types/maybe_type.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import { schema } from '../..';
import { META_FIELD_X_OAS_OPTIONAL } from '../oas_meta_fields';

test('returns value if specified', () => {
const type = schema.maybe(schema.string());
Expand Down Expand Up @@ -96,6 +97,12 @@ describe('maybe + object', () => {
});
});

test('meta', () => {
const maybeString = schema.maybe(schema.string());
const result = maybeString.getSchema().describe().metas[0];
expect(result).toEqual({ [META_FIELD_X_OAS_OPTIONAL]: true });
});

describe('#extendsDeep', () => {
const type = schema.maybe(schema.object({ foo: schema.string() }));

Expand Down
2 changes: 2 additions & 0 deletions packages/kbn-config-schema/src/types/maybe_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import { Type, ExtendsDeepOptions } from './type';

import { META_FIELD_X_OAS_OPTIONAL } from '../oas_meta_fields';
export class MaybeType<V> extends Type<V | undefined> {
private readonly maybeType: Type<V>;

Expand All @@ -16,6 +17,7 @@ export class MaybeType<V> extends Type<V | undefined> {
type
.getSchema()
.optional()
.meta({ [META_FIELD_X_OAS_OPTIONAL]: true })
.default(() => undefined)
);
this.maybeType = type;
Expand Down
12 changes: 12 additions & 0 deletions packages/kbn-config-schema/src/types/record_type.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import { schema } from '../..';
import { META_FIELD_X_OAS_GET_ADDITIONAL_PROPERTIES } from '../oas_meta_fields';

test('handles object as input', () => {
const type = schema.recordOf(schema.string(), schema.string());
Expand Down Expand Up @@ -208,3 +209,14 @@ describe('#extendsDeep', () => {
).toThrowErrorMatchingInlineSnapshot(`"[key.bar]: definition for this key is missing"`);
});
});

test('meta', () => {
const stringSchema = schema.string();
const type = schema.mapOf(schema.string(), stringSchema);
const result = type
.getSchema()
.describe()
.metas![0][META_FIELD_X_OAS_GET_ADDITIONAL_PROPERTIES]();

expect(result).toBe(stringSchema.getSchema());
});
8 changes: 7 additions & 1 deletion packages/kbn-config-schema/src/types/record_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import typeDetect from 'type-detect';
import { SchemaTypeError, SchemaTypesError } from '../errors';
import { internals } from '../internals';
import { Type, TypeOptions, ExtendsDeepOptions } from './type';
import { META_FIELD_X_OAS_GET_ADDITIONAL_PROPERTIES } from '../oas_meta_fields';

export type RecordOfOptions<K extends string, V> = TypeOptions<Record<K, V>>;

Expand All @@ -19,7 +20,12 @@ export class RecordOfType<K extends string, V> extends Type<Record<K, V>> {
private readonly options: RecordOfOptions<K, V>;

constructor(keyType: Type<K>, valueType: Type<V>, options: RecordOfOptions<K, V> = {}) {
const schema = internals.record().entries(keyType.getSchema(), valueType.getSchema());
const schema = internals
.record()
.entries(keyType.getSchema(), valueType.getSchema())
.meta({
[META_FIELD_X_OAS_GET_ADDITIONAL_PROPERTIES]: () => valueType.getSchema(),
});

super(schema, options);
this.keyType = keyType;
Expand Down
12 changes: 12 additions & 0 deletions packages/kbn-config-schema/src/types/string_type.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import { schema } from '../..';
import { META_FIELD_X_OAS_MAX_LENGTH, META_FIELD_X_OAS_MIN_LENGTH } from '../oas_meta_fields';

test('returns value is string and defined', () => {
expect(schema.string().validate('test')).toBe('test');
Expand Down Expand Up @@ -166,6 +167,17 @@ describe('#defaultValue', () => {
});
});

test('meta', () => {
const string = schema.string({ minLength: 1, maxLength: 3 });
const [meta1, meta2] = string.getSchema().describe().metas;
expect(meta1).toEqual({
[META_FIELD_X_OAS_MIN_LENGTH]: 1,
});
expect(meta2).toEqual({
[META_FIELD_X_OAS_MAX_LENGTH]: 3,
});
});

describe('#validate', () => {
test('is called with input value', () => {
let calledWith;
Expand Down
35 changes: 21 additions & 14 deletions packages/kbn-config-schema/src/types/string_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import typeDetect from 'type-detect';
import { internals } from '../internals';
import { Type, TypeOptions, convertValidationFunction } from './type';

import { META_FIELD_X_OAS_MIN_LENGTH, META_FIELD_X_OAS_MAX_LENGTH } from '../oas_meta_fields';

export type StringOptions = TypeOptions<string> & {
minLength?: number;
maxLength?: number;
Expand Down Expand Up @@ -37,24 +39,29 @@ export class StringType extends Type<string> {
}
return value;
});

if (options.minLength !== undefined) {
schema = schema.custom(
convertValidationFunction((value) => {
if (value.length < options.minLength!) {
return `value has length [${value.length}] but it must have a minimum length of [${options.minLength}].`;
}
})
);
schema = schema
.custom(
convertValidationFunction((value) => {
if (value.length < options.minLength!) {
return `value has length [${value.length}] but it must have a minimum length of [${options.minLength}].`;
}
})
)
.meta({ [META_FIELD_X_OAS_MIN_LENGTH]: options.minLength });
}

if (options.maxLength !== undefined) {
schema = schema.custom(
convertValidationFunction((value) => {
if (value.length > options.maxLength!) {
return `value has length [${value.length}] but it must have a maximum length of [${options.maxLength}].`;
}
})
);
schema = schema
.custom(
convertValidationFunction((value) => {
if (value.length > options.maxLength!) {
return `value has length [${value.length}] but it must have a maximum length of [${options.maxLength}].`;
}
})
)
.meta({ [META_FIELD_X_OAS_MAX_LENGTH]: options.maxLength });
}

schema.type = 'string';
Expand Down
23 changes: 23 additions & 0 deletions packages/kbn-config-schema/src/types/type.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { get } from 'lodash';
import { internals } from '../internals';
import { Type, TypeOptions } from './type';

class MyType extends Type<any> {
constructor(opts: TypeOptions<any> = {}) {
super(internals.any(), opts);
}
}

test('describe', () => {
const type = new MyType({ description: 'my description' });
const meta = type.getSchema().describe();
expect(get(meta, 'flags.description')).toBe('my description');
});
6 changes: 6 additions & 0 deletions packages/kbn-config-schema/src/types/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { Reference } from '../references';
export interface TypeOptions<T> {
defaultValue?: T | Reference<T> | (() => T);
validate?: (value: T) => string | void;
/** A human-friendly description of this type to be used in documentation */
description?: string;
}

export interface SchemaStructureEntry {
Expand Down Expand Up @@ -86,6 +88,10 @@ export abstract class Type<V> {
schema = schema.custom(convertValidationFunction(options.validate));
}

if (options.description) {
schema = schema.description(options.description);
}

// Attach generic error handler only if it hasn't been attached yet since
// only the last error handler is counted.
if (schema.$_getFlag('error') === undefined) {
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-es-types/src/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ export interface ESQLSearchParams {
// https://github.com/elastic/elasticsearch/pull/102767
// time_zone?: string;
query: string;
version: string;
filter?: unknown;
locale?: string;
dropNullColumns?: boolean;
Expand Down
11 changes: 11 additions & 0 deletions packages/kbn-esql-utils/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

// we are expecting to retrieve this from an API instead
// https://github.com/elastic/elasticsearch/issues/107069
export const ESQL_LATEST_VERSION = '2024.04.01';
2 changes: 2 additions & 0 deletions packages/kbn-esql-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ export {
getESQLWithSafeLimit,
TextBasedLanguages,
} from './src';

export { ESQL_LATEST_VERSION } from './constants';
Loading

0 comments on commit f48adb8

Please sign in to comment.