Skip to content

Commit 3ea33a3

Browse files
[SEIM][Detection Engine] Moves the io-ts schemas to the common folder from the server side (#67913)
## Summary This moves the io-ts schemas from the common folder from the server side up to the common folder. ### Checklist - [x] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios
1 parent bf6fbf5 commit 3ea33a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+333
-535
lines changed
Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,10 @@ import { pipe } from 'fp-ts/lib/pipeable';
99

1010
import { getErrorPayload } from './__mocks__/utils';
1111
import { errorSchema, ErrorSchema } from './error_schema';
12-
import { setFeatureFlagsForTestsOnly, unSetFeatureFlagsForTestsOnly } from '../../../feature_flags';
13-
import { exactCheck } from '../../../../../../common/exact_check';
14-
import { getPaths, foldLeftRight } from '../../../../../../common/test_utils';
12+
import { exactCheck } from '../../../exact_check';
13+
import { foldLeftRight, getPaths } from '../../../test_utils';
1514

1615
describe('error_schema', () => {
17-
beforeAll(() => {
18-
setFeatureFlagsForTestsOnly();
19-
});
20-
21-
afterAll(() => {
22-
unSetFeatureFlagsForTestsOnly();
23-
});
24-
2516
test('it should validate an error with a UUID given for id', () => {
2617
const error = getErrorPayload();
2718
const decoded = errorSchema.decode(getErrorPayload());
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import * as t from 'io-ts';
88

99
/* eslint-disable @typescript-eslint/camelcase */
10-
import { rule_id, status_code, message } from './schemas';
10+
import { rule_id, status_code, message } from '../common/schemas';
1111
/* eslint-enable @typescript-eslint/camelcase */
1212

1313
// We use id: t.string intentionally and _never_ the id from global schemas as
Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,10 @@ import { pipe } from 'fp-ts/lib/pipeable';
99
import { getFindResponseSingle, getBaseResponsePayload } from './__mocks__/utils';
1010
import { left } from 'fp-ts/lib/Either';
1111
import { RulesSchema } from './rules_schema';
12-
import { setFeatureFlagsForTestsOnly, unSetFeatureFlagsForTestsOnly } from '../../../feature_flags';
13-
import { getPaths, foldLeftRight } from '../../../../../../common/test_utils';
14-
import { exactCheck } from '../../../../../../common/exact_check';
12+
import { exactCheck } from '../../../exact_check';
13+
import { foldLeftRight, getPaths } from '../../../test_utils';
1514

1615
describe('find_rules_schema', () => {
17-
beforeAll(() => {
18-
setFeatureFlagsForTestsOnly();
19-
});
20-
21-
afterAll(() => {
22-
unSetFeatureFlagsForTestsOnly();
23-
});
24-
2516
test('it should validate a typical single find rules response', () => {
2617
const payload = getFindResponseSingle();
2718
const decoded = findRulesSchema.decode(payload);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import * as t from 'io-ts';
88

99
import { rulesSchema } from './rules_schema';
10-
import { page, perPage, total } from './schemas';
10+
import { page, perPage, total } from '../common/schemas';
1111

1212
export const findRulesSchema = t.exact(
1313
t.type({
Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,11 @@ import { pipe } from 'fp-ts/lib/pipeable';
88
import { left, Either } from 'fp-ts/lib/Either';
99
import { ImportRulesSchema, importRulesSchema } from './import_rules_schema';
1010
import { ErrorSchema } from './error_schema';
11-
import { setFeatureFlagsForTestsOnly, unSetFeatureFlagsForTestsOnly } from '../../../feature_flags';
1211
import { Errors } from 'io-ts';
13-
import { exactCheck } from '../../../../../../common/exact_check';
14-
import { foldLeftRight, getPaths } from '../../../../../../common/test_utils';
12+
import { exactCheck } from '../../../exact_check';
13+
import { foldLeftRight, getPaths } from '../../../test_utils';
1514

1615
describe('import_rules_schema', () => {
17-
beforeAll(() => {
18-
setFeatureFlagsForTestsOnly();
19-
});
20-
21-
afterAll(() => {
22-
unSetFeatureFlagsForTestsOnly();
23-
});
24-
2516
test('it should validate an empty import response with no errors', () => {
2617
const payload: ImportRulesSchema = { success: true, success_count: 0, errors: [] };
2718
const decoded = importRulesSchema.decode(payload);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import * as t from 'io-ts';
88

99
/* eslint-disable @typescript-eslint/camelcase */
10-
import { success, success_count } from './schemas';
10+
import { success, success_count } from '../common/schemas';
1111
import { errorSchema } from './error_schema';
1212
/* eslint-enable @typescript-eslint/camelcase */
1313

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,10 @@
77
import { pipe } from 'fp-ts/lib/pipeable';
88
import { left } from 'fp-ts/lib/Either';
99
import { PrePackagedRulesSchema, prePackagedRulesSchema } from './prepackaged_rules_schema';
10-
import { setFeatureFlagsForTestsOnly, unSetFeatureFlagsForTestsOnly } from '../../../feature_flags';
11-
import { exactCheck } from '../../../../../../common/exact_check';
12-
import { getPaths, foldLeftRight } from '../../../../../../common/test_utils';
10+
import { exactCheck } from '../../../exact_check';
11+
import { foldLeftRight, getPaths } from '../../../test_utils';
1312

1413
describe('prepackaged_rules_schema', () => {
15-
beforeAll(() => {
16-
setFeatureFlagsForTestsOnly();
17-
});
18-
19-
afterAll(() => {
20-
unSetFeatureFlagsForTestsOnly();
21-
});
22-
2314
test('it should validate an empty prepackaged response with defaults', () => {
2415
const payload: PrePackagedRulesSchema = { rules_installed: 0, rules_updated: 0 };
2516
const decoded = prePackagedRulesSchema.decode(payload);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import * as t from 'io-ts';
88

99
/* eslint-disable @typescript-eslint/camelcase */
10-
import { rules_installed, rules_updated } from './schemas';
10+
import { rules_installed, rules_updated } from '../common/schemas';
1111
/* eslint-enable @typescript-eslint/camelcase */
1212

1313
export const prePackagedRulesSchema = t.exact(

0 commit comments

Comments
 (0)