Skip to content

Commit 0e4c9e3

Browse files
Added list and list _item _version and updated tests to pass now
1 parent adb5ba5 commit 0e4c9e3

34 files changed

+158
-46
lines changed

x-pack/plugins/lists/common/schemas/request/patch_list_item_schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import * as t from 'io-ts';
1010

11-
import { id, meta, value } from '../common/schemas';
11+
import { _version, id, meta, value } from '../common/schemas';
1212
import { RequiredKeepUndefined } from '../../types';
1313

1414
export const patchListItemSchema = t.intersection([
@@ -17,7 +17,7 @@ export const patchListItemSchema = t.intersection([
1717
id,
1818
})
1919
),
20-
t.exact(t.partial({ meta, value })),
20+
t.exact(t.partial({ _version, meta, value })),
2121
]);
2222

2323
export type PatchListItemSchema = t.OutputOf<typeof patchListItemSchema>;

x-pack/plugins/lists/common/schemas/request/patch_list_schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import * as t from 'io-ts';
1010

11-
import { description, id, meta, name } from '../common/schemas';
11+
import { _version, description, id, meta, name } from '../common/schemas';
1212
import { RequiredKeepUndefined } from '../../types';
1313

1414
export const patchListSchema = t.intersection([
@@ -17,7 +17,7 @@ export const patchListSchema = t.intersection([
1717
id,
1818
})
1919
),
20-
t.exact(t.partial({ description, meta, name })),
20+
t.exact(t.partial({ _version, description, meta, name })),
2121
]);
2222

2323
export type PatchListSchema = t.OutputOf<typeof patchListSchema>;

x-pack/plugins/lists/common/schemas/request/update_endpoint_list_item_schema.mock.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ import {
1515
NAME,
1616
TAGS,
1717
_TAGS,
18-
_VERSION,
1918
} from '../../constants.mock';
2019

2120
import { UpdateEndpointListItemSchema } from './update_endpoint_list_item_schema';
2221

2322
export const getUpdateEndpointListItemSchemaMock = (): UpdateEndpointListItemSchema => ({
2423
_tags: _TAGS,
25-
_version: _VERSION,
24+
_version: undefined,
2625
comments: COMMENTS,
2726
description: DESCRIPTION,
2827
entries: ENTRIES,

x-pack/plugins/lists/common/schemas/request/update_exception_list_item_schema.mock.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ import {
1616
NAMESPACE_TYPE,
1717
TAGS,
1818
_TAGS,
19-
_VERSION,
2019
} from '../../constants.mock';
2120

2221
import { UpdateExceptionListItemSchema } from './update_exception_list_item_schema';
2322

2423
export const getUpdateExceptionListItemSchemaMock = (): UpdateExceptionListItemSchema => ({
2524
_tags: _TAGS,
26-
_version: _VERSION,
25+
_version: undefined,
2726
comments: COMMENTS,
2827
description: DESCRIPTION,
2928
entries: ENTRIES,

x-pack/plugins/lists/common/schemas/request/update_exception_list_schema.mock.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,13 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import {
8-
DESCRIPTION,
9-
ID,
10-
LIST_ID,
11-
META,
12-
NAME,
13-
NAMESPACE_TYPE,
14-
_TAGS,
15-
_VERSION,
16-
} from '../../constants.mock';
7+
import { DESCRIPTION, ID, LIST_ID, META, NAME, NAMESPACE_TYPE, _TAGS } from '../../constants.mock';
178

189
import { UpdateExceptionListSchema } from './update_exception_list_schema';
1910

2011
export const getUpdateExceptionListSchemaMock = (): UpdateExceptionListSchema => ({
2112
_tags: _TAGS,
22-
_version: _VERSION,
13+
_version: undefined,
2314
description: DESCRIPTION,
2415
id: ID,
2516
list_id: LIST_ID,

x-pack/plugins/lists/common/schemas/request/update_list_item_schema.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import * as t from 'io-ts';
1010

11-
import { id, meta, value } from '../common/schemas';
11+
import { _version, id, meta, value } from '../common/schemas';
1212
import { RequiredKeepUndefined } from '../../types';
1313

1414
export const updateListItemSchema = t.intersection([
@@ -20,6 +20,7 @@ export const updateListItemSchema = t.intersection([
2020
),
2121
t.exact(
2222
t.partial({
23+
_version, // defaults to undefined if not set during decode
2324
meta, // defaults to undefined if not set during decode
2425
})
2526
),

x-pack/plugins/lists/common/schemas/request/update_list_schema.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import * as t from 'io-ts';
1010

11-
import { description, id, meta, name } from '../common/schemas';
11+
import { _version, description, id, meta, name } from '../common/schemas';
1212
import { RequiredKeepUndefined } from '../../types';
1313

1414
export const updateListSchema = t.intersection([
@@ -21,6 +21,7 @@ export const updateListSchema = t.intersection([
2121
),
2222
t.exact(
2323
t.partial({
24+
_version, // defaults to undefined if not set during decode
2425
meta, // defaults to undefined if not set during decode
2526
})
2627
),

x-pack/plugins/lists/common/schemas/response/exception_list_item_schema.mock.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@ import {
1414
NAMESPACE_TYPE,
1515
TIE_BREAKER,
1616
USER,
17-
_VERSION,
1817
} from '../../constants.mock';
1918

2019
import { ExceptionListItemSchema } from './exception_list_item_schema';
2120

2221
export const getExceptionListItemSchemaMock = (): ExceptionListItemSchema => ({
2322
_tags: ['endpoint', 'process', 'malware', 'os:linux'],
24-
_version: _VERSION,
23+
_version: undefined,
2524
comments: COMMENTS,
2625
created_at: DATE_NOW,
2726
created_by: USER,

x-pack/plugins/lists/common/schemas/response/list_item_schema.mock.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
} from '../../../common/constants.mock';
1818

1919
export const getListItemResponseMock = (): ListItemSchema => ({
20+
_version: undefined,
2021
created_at: DATE_NOW,
2122
created_by: USER,
2223
deserializer: undefined,

x-pack/plugins/lists/common/schemas/response/list_item_schema.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import * as t from 'io-ts';
99
/* eslint-disable @typescript-eslint/camelcase */
1010

1111
import {
12+
_versionOrUndefined,
1213
created_at,
1314
created_by,
1415
deserializerOrUndefined,
@@ -25,6 +26,7 @@ import {
2526

2627
export const listItemSchema = t.exact(
2728
t.type({
29+
_version: _versionOrUndefined,
2830
created_at,
2931
created_by,
3032
deserializer: deserializerOrUndefined,

0 commit comments

Comments
 (0)