Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions x-pack/plugins/cases/common/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ export const MAX_CUSTOM_FIELDS_PER_CASE = 10 as const;
export const MAX_CUSTOM_FIELD_KEY_LENGTH = 36 as const; // uuidv4 length
export const MAX_CUSTOM_FIELD_LABEL_LENGTH = 50 as const;
export const MAX_CUSTOM_FIELD_TEXT_VALUE_LENGTH = 160 as const;
export const MAX_TEMPLATE_KEY_LENGTH = 36 as const; // uuidv4 length
export const MAX_TEMPLATE_NAME_LENGTH = 50 as const;
export const MAX_TEMPLATE_DESCRIPTION_LENGTH = 1000 as const;
export const MAX_TEMPLATES_LENGTH = 10 as const;

/**
* Cases features
Expand Down
141 changes: 76 additions & 65 deletions x-pack/plugins/cases/common/types/api/case/v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,81 @@ export const CaseRequestCustomFieldsRt = limitedArraySchema({
max: MAX_CUSTOM_FIELDS_PER_CASE,
});

export const CaseBaseOptionalFieldsRequestRt = rt.exact(
rt.partial({
/**
* The description of the case
*/
description: limitedStringSchema({
fieldName: 'description',
min: 1,
max: MAX_DESCRIPTION_LENGTH,
}),
/**
* The identifying strings for filter a case
*/
tags: limitedArraySchema({
codec: limitedStringSchema({ fieldName: 'tag', min: 1, max: MAX_LENGTH_PER_TAG }),
min: 0,
max: MAX_TAGS_PER_CASE,
fieldName: 'tags',
}),
/**
* The title of a case
*/
title: limitedStringSchema({ fieldName: 'title', min: 1, max: MAX_TITLE_LENGTH }),
/**
* The external system that the case can be synced with
*/
connector: CaseConnectorRt,
/**
* The severity of the case
*/
severity: CaseSeverityRt,
/**
* The users assigned to this case
*/
assignees: limitedArraySchema({
codec: CaseUserProfileRt,
fieldName: 'assignees',
min: 0,
max: MAX_ASSIGNEES_PER_CASE,
}),
/**
* The category of the case.
*/
category: rt.union([
limitedStringSchema({ fieldName: 'category', min: 1, max: MAX_CATEGORY_LENGTH }),
rt.null,
]),
/**
* Custom fields of the case
*/
customFields: CaseRequestCustomFieldsRt,
/**
* The alert sync settings
*/
settings: CaseSettingsRt,
})
);

export const CaseRequestFieldsRt = rt.intersection([
CaseBaseOptionalFieldsRequestRt,
rt.exact(
rt.partial({
/**
* The current status of the case (open, closed, in-progress)
*/
status: CaseStatusRt,

/**
* The plugin owner of the case
*/
owner: rt.string,
})
),
]);

/**
* Create case
*/
Expand Down Expand Up @@ -356,71 +431,7 @@ export const CasesBulkGetResponseRt = rt.strict({
* Update cases
*/
export const CasePatchRequestRt = rt.intersection([
rt.exact(
rt.partial({
/**
* The description of the case
*/
description: limitedStringSchema({
fieldName: 'description',
min: 1,
max: MAX_DESCRIPTION_LENGTH,
}),
/**
* The current status of the case (open, closed, in-progress)
*/
status: CaseStatusRt,
/**
* The identifying strings for filter a case
*/
tags: limitedArraySchema({
codec: limitedStringSchema({ fieldName: 'tag', min: 1, max: MAX_LENGTH_PER_TAG }),
min: 0,
max: MAX_TAGS_PER_CASE,
fieldName: 'tags',
}),
/**
* The title of a case
*/
title: limitedStringSchema({ fieldName: 'title', min: 1, max: MAX_TITLE_LENGTH }),
/**
* The external system that the case can be synced with
*/
connector: CaseConnectorRt,
/**
* The alert sync settings
*/
settings: CaseSettingsRt,
/**
* The plugin owner of the case
*/
owner: rt.string,
/**
* The severity of the case
*/
severity: CaseSeverityRt,
/**
* The users assigned to this case
*/
assignees: limitedArraySchema({
codec: CaseUserProfileRt,
fieldName: 'assignees',
min: 0,
max: MAX_ASSIGNEES_PER_CASE,
}),
/**
* The category of the case.
*/
category: rt.union([
limitedStringSchema({ fieldName: 'category', min: 1, max: MAX_CATEGORY_LENGTH }),
rt.null,
]),
/**
* Custom fields of the case
*/
customFields: CaseRequestCustomFieldsRt,
})
),
CaseRequestFieldsRt,
/**
* The saved object ID and version
*/
Expand Down
Loading