Skip to content

Commit 54821b4

Browse files
Adds more version plumbing to the backend for conflicts to bubble up to the UI
1 parent 7885e37 commit 54821b4

File tree

8 files changed

+29
-1
lines changed

8 files changed

+29
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,4 +310,4 @@ export type DeserializerOrUndefined = t.TypeOf<typeof deserializerOrUndefined>;
310310

311311
export const _version = t.string;
312312
export const _versionOrUndefined = t.union([_version, t.undefined]);
313-
export type _versionOrUndefined = t.TypeOf<typeof _versionOrUndefined>;
313+
export type _VersionOrUndefined = t.TypeOf<typeof _versionOrUndefined>;

x-pack/plugins/lists/server/routes/update_endpoint_list_item_route.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const updateEndpointListItemRoute = (router: IRouter): void => {
4141
meta,
4242
type,
4343
_tags,
44+
_version,
4445
comments,
4546
entries,
4647
item_id: itemId,
@@ -49,6 +50,7 @@ export const updateEndpointListItemRoute = (router: IRouter): void => {
4950
const exceptionLists = getExceptionListClient(context);
5051
const exceptionListItem = await exceptionLists.updateEndpointListItem({
5152
_tags,
53+
_version,
5254
comments,
5355
description,
5456
entries,

x-pack/plugins/lists/server/routes/update_exception_list_item_route.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const updateExceptionListItemRoute = (router: IRouter): void => {
4141
meta,
4242
type,
4343
_tags,
44+
_version,
4445
comments,
4546
entries,
4647
item_id: itemId,
@@ -50,6 +51,7 @@ export const updateExceptionListItemRoute = (router: IRouter): void => {
5051
const exceptionLists = getExceptionListClient(context);
5152
const exceptionListItem = await exceptionLists.updateExceptionListItem({
5253
_tags,
54+
_version,
5355
comments,
5456
description,
5557
entries,

x-pack/plugins/lists/server/routes/update_exception_list_route.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export const updateExceptionListRoute = (router: IRouter): void => {
3636
try {
3737
const {
3838
_tags,
39+
_version,
3940
tags,
4041
name,
4142
description,
@@ -54,6 +55,7 @@ export const updateExceptionListRoute = (router: IRouter): void => {
5455
} else {
5556
const list = await exceptionLists.updateExceptionList({
5657
_tags,
58+
_version,
5759
description,
5860
id,
5961
listId,

x-pack/plugins/lists/server/services/exception_lists/exception_list_client.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ export class ExceptionListClient {
131131
*/
132132
public updateEndpointListItem = async ({
133133
_tags,
134+
_version,
134135
comments,
135136
description,
136137
entries,
@@ -145,6 +146,7 @@ export class ExceptionListClient {
145146
await this.createEndpointList();
146147
return updateExceptionListItem({
147148
_tags,
149+
_version,
148150
comments,
149151
description,
150152
entries,
@@ -198,6 +200,7 @@ export class ExceptionListClient {
198200

199201
public updateExceptionList = async ({
200202
_tags,
203+
_version,
201204
id,
202205
description,
203206
listId,
@@ -210,6 +213,7 @@ export class ExceptionListClient {
210213
const { savedObjectsClient, user } = this;
211214
return updateExceptionList({
212215
_tags,
216+
_version,
213217
description,
214218
id,
215219
listId,
@@ -270,6 +274,7 @@ export class ExceptionListClient {
270274

271275
public updateExceptionListItem = async ({
272276
_tags,
277+
_version,
273278
comments,
274279
description,
275280
entries,
@@ -284,6 +289,7 @@ export class ExceptionListClient {
284289
const { savedObjectsClient, user } = this;
285290
return updateExceptionListItem({
286291
_tags,
292+
_version,
287293
comments,
288294
description,
289295
entries,

x-pack/plugins/lists/server/services/exception_lists/exception_list_client_types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
UpdateCommentsArray,
3939
_Tags,
4040
_TagsOrUndefined,
41+
_VersionOrUndefined,
4142
} from '../../../common/schemas';
4243

4344
export interface ConstructorOptions {
@@ -64,6 +65,7 @@ export interface CreateExceptionListOptions {
6465

6566
export interface UpdateExceptionListOptions {
6667
_tags: _TagsOrUndefined;
68+
_version: _VersionOrUndefined;
6769
id: IdOrUndefined;
6870
listId: ListIdOrUndefined;
6971
namespaceType: NamespaceType;
@@ -130,6 +132,7 @@ export interface CreateEndpointListItemOptions {
130132

131133
export interface UpdateExceptionListItemOptions {
132134
_tags: _TagsOrUndefined;
135+
_version: _VersionOrUndefined;
133136
comments: UpdateCommentsArray;
134137
entries: EntriesArrayOrUndefined;
135138
id: IdOrUndefined;
@@ -144,6 +147,7 @@ export interface UpdateExceptionListItemOptions {
144147

145148
export interface UpdateEndpointListItemOptions {
146149
_tags: _TagsOrUndefined;
150+
_version: _VersionOrUndefined;
147151
comments: UpdateCommentsArray;
148152
entries: EntriesArrayOrUndefined;
149153
id: IdOrUndefined;

x-pack/plugins/lists/server/services/exception_lists/update_exception_list.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
NamespaceType,
1919
TagsOrUndefined,
2020
_TagsOrUndefined,
21+
_VersionOrUndefined,
2122
} from '../../../common/schemas';
2223

2324
import { getSavedObjectType, transformSavedObjectUpdateToExceptionList } from './utils';
@@ -26,6 +27,7 @@ import { getExceptionList } from './get_exception_list';
2627
interface UpdateExceptionListOptions {
2728
id: IdOrUndefined;
2829
_tags: _TagsOrUndefined;
30+
_version: _VersionOrUndefined;
2931
name: NameOrUndefined;
3032
description: DescriptionOrUndefined;
3133
savedObjectsClient: SavedObjectsClientContract;
@@ -40,6 +42,7 @@ interface UpdateExceptionListOptions {
4042

4143
export const updateExceptionList = async ({
4244
_tags,
45+
_version,
4346
id,
4447
savedObjectsClient,
4548
namespaceType,
@@ -67,6 +70,9 @@ export const updateExceptionList = async ({
6770
tags,
6871
type,
6972
updated_by: user,
73+
},
74+
{
75+
version: _version,
7076
}
7177
);
7278
return transformSavedObjectUpdateToExceptionList({ exceptionList, savedObject });

x-pack/plugins/lists/server/services/exception_lists/update_exception_list_item.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
TagsOrUndefined,
2121
UpdateCommentsArrayOrUndefined,
2222
_TagsOrUndefined,
23+
_VersionOrUndefined,
2324
} from '../../../common/schemas';
2425

2526
import {
@@ -33,6 +34,7 @@ interface UpdateExceptionListItemOptions {
3334
id: IdOrUndefined;
3435
comments: UpdateCommentsArrayOrUndefined;
3536
_tags: _TagsOrUndefined;
37+
_version: _VersionOrUndefined;
3638
name: NameOrUndefined;
3739
description: DescriptionOrUndefined;
3840
entries: EntriesArrayOrUndefined;
@@ -48,6 +50,7 @@ interface UpdateExceptionListItemOptions {
4850

4951
export const updateExceptionListItem = async ({
5052
_tags,
53+
_version,
5154
comments,
5255
entries,
5356
id,
@@ -89,6 +92,9 @@ export const updateExceptionListItem = async ({
8992
tags,
9093
type,
9194
updated_by: user,
95+
},
96+
{
97+
version: _version,
9298
}
9399
);
94100
return transformSavedObjectUpdateToExceptionListItem({

0 commit comments

Comments
 (0)