Skip to content

Commit

Permalink
Migrate more types
Browse files Browse the repository at this point in the history
  • Loading branch information
janmonschke committed Sep 26, 2024
1 parent c9851b3 commit e4e4e7c
Show file tree
Hide file tree
Showing 12 changed files with 189 additions and 162 deletions.
31 changes: 19 additions & 12 deletions oas_docs/output/kibana.serverless.staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16962,11 +16962,6 @@ paths:
required:
- timeline
- totalCount
- defaultTimelineCount
- templateTimelineCount
- favoriteCount
- elasticTemplateTimelineCount
- customTemplateTimelineCount
description: Indicates that the (template) Timelines were found and returned.
'400':
content:
Expand Down Expand Up @@ -31598,6 +31593,18 @@ components:
updatedBy:
nullable: true
type: string
Security_Timeline_API_SavedTimelineWithSavedObjectId:
allOf:
- $ref: '#/components/schemas/Security_Timeline_API_SavedTimeline'
- type: object
properties:
savedObjectId:
type: string
version:
type: string
required:
- savedObjectId
- version
Security_Timeline_API_SerializedFilterQueryResult:
type: object
properties:
Expand Down Expand Up @@ -31647,6 +31654,8 @@ components:
Security_Timeline_API_TimelineResponse:
allOf:
- $ref: '#/components/schemas/Security_Timeline_API_SavedTimeline'
- $ref: >-
#/components/schemas/Security_Timeline_API_SavedTimelineWithSavedObjectId
- type: object
properties:
eventIdToNoteIds:
Expand Down Expand Up @@ -31674,13 +31683,6 @@ components:
$ref: '#/components/schemas/Security_Timeline_API_PinnedEvent'
nullable: true
type: array
savedObjectId:
type: string
version:
type: string
required:
- savedObjectId
- version
Security_Timeline_API_TimelineSavedToReturnObject:
allOf:
- $ref: '#/components/schemas/Security_Timeline_API_SavedTimeline'
Expand All @@ -31689,22 +31691,27 @@ components:
eventIdToNoteIds:
items:
$ref: '#/components/schemas/Security_Timeline_API_Note'
nullable: true
type: array
noteIds:
items:
type: string
nullable: true
type: array
notes:
items:
$ref: '#/components/schemas/Security_Timeline_API_Note'
nullable: true
type: array
pinnedEventIds:
items:
type: string
nullable: true
type: array
pinnedEventsSaveObject:
items:
$ref: '#/components/schemas/Security_Timeline_API_PinnedEvent'
nullable: true
type: array
savedObjectId:
type: string
Expand Down
31 changes: 19 additions & 12 deletions oas_docs/output/kibana.staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21051,11 +21051,6 @@ paths:
required:
- timeline
- totalCount
- defaultTimelineCount
- templateTimelineCount
- favoriteCount
- elasticTemplateTimelineCount
- customTemplateTimelineCount
description: Indicates that the (template) Timelines were found and returned.
'400':
content:
Expand Down Expand Up @@ -39607,6 +39602,18 @@ components:
updatedBy:
nullable: true
type: string
Security_Timeline_API_SavedTimelineWithSavedObjectId:
allOf:
- $ref: '#/components/schemas/Security_Timeline_API_SavedTimeline'
- type: object
properties:
savedObjectId:
type: string
version:
type: string
required:
- savedObjectId
- version
Security_Timeline_API_SerializedFilterQueryResult:
type: object
properties:
Expand Down Expand Up @@ -39656,6 +39663,8 @@ components:
Security_Timeline_API_TimelineResponse:
allOf:
- $ref: '#/components/schemas/Security_Timeline_API_SavedTimeline'
- $ref: >-
#/components/schemas/Security_Timeline_API_SavedTimelineWithSavedObjectId
- type: object
properties:
eventIdToNoteIds:
Expand Down Expand Up @@ -39683,13 +39692,6 @@ components:
$ref: '#/components/schemas/Security_Timeline_API_PinnedEvent'
nullable: true
type: array
savedObjectId:
type: string
version:
type: string
required:
- savedObjectId
- version
Security_Timeline_API_TimelineSavedToReturnObject:
allOf:
- $ref: '#/components/schemas/Security_Timeline_API_SavedTimeline'
Expand All @@ -39698,22 +39700,27 @@ components:
eventIdToNoteIds:
items:
$ref: '#/components/schemas/Security_Timeline_API_Note'
nullable: true
type: array
noteIds:
items:
type: string
nullable: true
type: array
notes:
items:
$ref: '#/components/schemas/Security_Timeline_API_Note'
nullable: true
type: array
pinnedEventIds:
items:
type: string
nullable: true
type: array
pinnedEventsSaveObject:
items:
$ref: '#/components/schemas/Security_Timeline_API_PinnedEvent'
nullable: true
type: array
savedObjectId:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ export type GetTimelinesResponse = z.infer<typeof GetTimelinesResponse>;
export const GetTimelinesResponse = z.object({
timeline: z.array(TimelineResponse),
totalCount: z.number(),
defaultTimelineCount: z.number(),
templateTimelineCount: z.number(),
favoriteCount: z.number(),
elasticTemplateTimelineCount: z.number(),
customTemplateTimelineCount: z.number(),
defaultTimelineCount: z.number().optional(),
templateTimelineCount: z.number().optional(),
favoriteCount: z.number().optional(),
elasticTemplateTimelineCount: z.number().optional(),
customTemplateTimelineCount: z.number().optional(),
});
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ paths:
required: [
timeline,
totalCount,
defaultTimelineCount,
templateTimelineCount,
favoriteCount,
elasticTemplateTimelineCount,
customTemplateTimelineCount,
]
properties:
timeline:
Expand Down
45 changes: 6 additions & 39 deletions x-pack/plugins/security_solution/common/api/timeline/model/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ import {
RowRendererId,
RowRendererIdEnum,
SavedTimeline,
SavedTimelineWithSavedObjectId,
SortDirection,
SortFieldTimeline,
SortFieldTimelineEnum,
TemplateTimelineType,
TemplateTimelineTypeEnum,
TimelineErrorResponse,
TimelineResponse,
TimelineSavedToReturnObject,
TimelineStatus,
TimelineStatusEnum,
Expand All @@ -54,10 +57,13 @@ export {
RowRendererId,
RowRendererIdEnum,
SavedTimeline,
SavedTimelineWithSavedObjectId,
SortDirection,
SortFieldTimeline,
SortFieldTimelineEnum,
TemplateTimelineType,
TimelineErrorResponse,
TimelineResponse,
TemplateTimelineTypeEnum,
TimelineSavedToReturnObject,
TimelineStatus,
Expand Down Expand Up @@ -325,16 +331,6 @@ export const SavedTimelineRuntimeType = runtimeTypes.partial({
savedSearchId: unionWithNullType(runtimeTypes.string),
});

export type SavedTimelineWithSavedObjectId = SavedTimeline & {
savedObjectId?: string | null;
};

/**
* This type represents a timeline type stored in a saved object that does not include any fields that reference
* other saved objects.
*/
export type TimelineWithoutExternalRefs = Omit<SavedTimeline, 'dataViewId' | 'savedQueryId'>;

export const TimelineSavedToReturnObjectRuntimeType = runtimeTypes.intersection([
SavedTimelineRuntimeType,
runtimeTypes.type({
Expand All @@ -354,26 +350,6 @@ export type TimelineSavedObject = runtimeTypes.TypeOf<
typeof TimelineSavedToReturnObjectRuntimeType
>;

const responseTimelines = runtimeTypes.type({
timeline: runtimeTypes.array(TimelineSavedToReturnObjectRuntimeType),
totalCount: runtimeTypes.number,
});

export type ResponseTimelines = runtimeTypes.TypeOf<typeof responseTimelines>;

export const TimelineErrorResponseType = runtimeTypes.union([
runtimeTypes.type({
status_code: runtimeTypes.number,
message: runtimeTypes.string,
}),
runtimeTypes.type({
statusCode: runtimeTypes.number,
message: runtimeTypes.string,
}),
]);

export type TimelineErrorResponse = runtimeTypes.TypeOf<typeof TimelineErrorResponseType>;

/**
* Import/export timelines
*/
Expand Down Expand Up @@ -533,12 +509,3 @@ export interface SortTimeline {
sortField: SortFieldTimeline;
sortOrder: SortDirection;
}

export interface GetAllTimelineVariables {
pageInfo: PageInfoTimeline;
search?: Maybe<string>;
sort?: Maybe<SortTimeline>;
onlyUserFavorite?: Maybe<boolean>;
timelineType?: Maybe<TimelineType>;
status?: Maybe<TimelineStatus>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,14 @@ export const SavedTimeline = z.object({
updatedBy: z.string().nullable().optional(),
});

export type SavedTimelineWithSavedObjectId = z.infer<typeof SavedTimelineWithSavedObjectId>;
export const SavedTimelineWithSavedObjectId = SavedTimeline.merge(
z.object({
savedObjectId: z.string(),
version: z.string(),
})
);

export type BareNote = z.infer<typeof BareNote>;
export const BareNote = z.object({
eventId: z.string().nullable().optional(),
Expand Down Expand Up @@ -253,15 +261,13 @@ export const PinnedEvent = BarePinnedEvent.merge(
);

export type TimelineResponse = z.infer<typeof TimelineResponse>;
export const TimelineResponse = SavedTimeline.merge(
export const TimelineResponse = SavedTimeline.merge(SavedTimelineWithSavedObjectId).merge(
z.object({
eventIdToNoteIds: z.array(Note).nullable().optional(),
notes: z.array(Note).nullable().optional(),
noteIds: z.array(z.string()).nullable().optional(),
pinnedEventIds: z.array(z.string()).nullable().optional(),
pinnedEventsSaveObject: z.array(PinnedEvent).nullable().optional(),
savedObjectId: z.string(),
version: z.string(),
})
);

Expand All @@ -270,11 +276,11 @@ export const TimelineSavedToReturnObject = SavedTimeline.merge(
z.object({
savedObjectId: z.string(),
version: z.string(),
eventIdToNoteIds: z.array(Note).optional(),
notes: z.array(Note).optional(),
noteIds: z.array(z.string()).optional(),
pinnedEventIds: z.array(z.string()).optional(),
pinnedEventsSaveObject: z.array(PinnedEvent).optional(),
eventIdToNoteIds: z.array(Note).nullable().optional(),
notes: z.array(Note).nullable().optional(),
noteIds: z.array(z.string()).nullable().optional(),
pinnedEventIds: z.array(z.string()).nullable().optional(),
pinnedEventsSaveObject: z.array(PinnedEvent).nullable().optional(),
})
);

Expand Down Expand Up @@ -396,6 +402,18 @@ export const ImportTimelineResult = z.object({
.optional(),
});

export type TimelineErrorResponse = z.infer<typeof TimelineErrorResponse>;
export const TimelineErrorResponse = z.union([
z.object({
message: z.string(),
status_code: z.number(),
}),
z.object({
message: z.string(),
statusCode: z.number(),
}),
]);

export type ExportedTimelines = z.infer<typeof ExportedTimelines>;
export const ExportedTimelines = SavedTimeline.merge(
z.object({
Expand Down
Loading

0 comments on commit e4e4e7c

Please sign in to comment.