-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Cases] Migrate attachment client/service layer to unified-only requests #290961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
christineweng
merged 9 commits into
elastic:main
from
christineweng:cases-client-service-cleanup
Sep 15, 2026
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ac8cad0
[Cases] Migrate attachment client/service layer to unified-only requests
christineweng efb663c
[Cases] Split attachmentApiV2 into unified-only and union modules
christineweng e61346b
fix test abd cleanup
christineweng 752e1fb
address comments
christineweng 1c8eb5b
more comments
christineweng ab68be8
fix test
christineweng 510ef97
Merge branch 'main' of github.com:elastic/kibana into cases-client-se…
christineweng 811c4cb
fix: resolve merge fallout from event-closed-case bugfix merge
christineweng 01f790d
Changes from node scripts/deduplicate_dependencies
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,3 +7,4 @@ | |
|
|
||
| export * from './v1'; | ||
| export * from './v2'; | ||
| export * from './v2_union'; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
x-pack/platform/plugins/shared/cases/common/types/api/attachment/v2_union.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import * as rt from 'io-ts'; | ||
| import { MAX_BULK_CREATE_ATTACHMENTS } from '../../../constants'; | ||
| import { | ||
| AttachmentPatchRequestRt, | ||
| AttachmentRequestRt, | ||
| AttachmentRequestWithoutRefsRt, | ||
| } from './v1'; | ||
| import { | ||
| AttachmentRtV2, | ||
| AttachmentsRtV2, | ||
| UnifiedAttachmentPayloadRt, | ||
| } from '../../domain/attachment/v2'; | ||
| import { UnifiedAttachmentPatchRequestRt } from './v2'; | ||
| import { limitedArraySchema } from '../../../schema'; | ||
|
|
||
| export const AttachmentRequestRtV2 = rt.union([AttachmentRequestRt, UnifiedAttachmentPayloadRt]); | ||
| export const AttachmentRequestWithoutRefsRtV2 = rt.union([ | ||
| AttachmentRequestWithoutRefsRt, | ||
| UnifiedAttachmentPayloadRt, | ||
| ]); | ||
| export const AttachmentPatchRequestRtV2 = rt.union([ | ||
| AttachmentPatchRequestRt, | ||
| UnifiedAttachmentPatchRequestRt, | ||
| ]); | ||
|
|
||
| export const AttachmentsFindResponseRtV2 = rt.strict({ | ||
| comments: rt.array(AttachmentRtV2), | ||
| page: rt.number, | ||
| per_page: rt.number, | ||
| total: rt.number, | ||
| }); | ||
|
|
||
| // Version-spanning bulk-create payload: the internal route still accepts both v1 | ||
| // legacy and unified wire shapes and converts to unified before the client call. | ||
| export const BulkCreateAttachmentsRequestRtV2 = limitedArraySchema({ | ||
| codec: AttachmentRequestRtV2, | ||
| min: 0, | ||
| max: MAX_BULK_CREATE_ATTACHMENTS, | ||
| fieldName: 'attachments', | ||
| }); | ||
|
|
||
| // Bulk-get response tolerates legacy shapes: the getter (`AttachmentGetter.bulkGet`) | ||
| // is mixed until every attachment type is migrated (see `toUnifiedAttributes`), so an | ||
| // unmigrated type would fail a unified-only decode here and 500 the route. Narrow this | ||
| // to unified-only once the getter is unified-only too. | ||
| export const BulkGetAttachmentsResponseRtV2 = rt.strict({ | ||
| attachments: AttachmentsRtV2, | ||
| errors: rt.array( | ||
| rt.strict({ | ||
| error: rt.string, | ||
| message: rt.string, | ||
| status: rt.union([rt.undefined, rt.number]), | ||
| savedObjectId: rt.string, | ||
| }) | ||
| ), | ||
| }); | ||
|
|
||
| export type AttachmentRequestV2 = rt.TypeOf<typeof AttachmentRequestRtV2>; | ||
| export type AttachmentPatchRequestV2 = rt.TypeOf<typeof AttachmentPatchRequestRtV2>; | ||
| export type AttachmentsFindResponseV2 = rt.TypeOf<typeof AttachmentsFindResponseRtV2>; | ||
| export type BulkCreateAttachmentsRequestV2 = rt.TypeOf<typeof BulkCreateAttachmentsRequestRtV2>; | ||
| export type BulkGetAttachmentsResponseV2 = rt.TypeOf<typeof BulkGetAttachmentsResponseRtV2>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still using union because actual routes accept both right now, #290934 updates the route to be unified only