Skip to content

Commit

Permalink
[Security Solution] Remove remaining usage of rule_schema_legacy types (
Browse files Browse the repository at this point in the history
elastic#188079)

## Summary

Leftover work from elastic#186615

- Removes remaining usage of `rule_schema_legacy` types. In this PR,
simply inlines the last io-ts types used, to be able to get rid of the
legacy folder.
- The remaining files that need to be migrated to using Zod schema types
are:
-
`x-pack/plugins/security_solution/common/api/detection_engine/rule_exceptions/find_exception_references/find_exception_references_route.ts`
- `x-pack/plugins/security_solution/common/api/timeline/model/api.ts`

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: Georgii Gorbachev <[email protected]>
  • Loading branch information
jpdjere and banderror authored Jul 22, 2024
1 parent 232a166 commit 0c5d7b9
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 77 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@ import {
list_id,
DefaultNamespaceArray,
} from '@kbn/securitysolution-io-ts-list-types';
import { NonEmptyStringArray } from '@kbn/securitysolution-io-ts-types';
import { NonEmptyStringArray, NonEmptyString, UUID } from '@kbn/securitysolution-io-ts-types';

// TODO https://github.com/elastic/security-team/issues/7491
// eslint-disable-next-line no-restricted-imports
import { RuleName, RuleObjectId, RuleSignatureId } from '../../model/rule_schema_legacy';
type RuleObjectId = t.TypeOf<typeof RuleObjectId>;
const RuleObjectId = UUID;

type RuleSignatureId = t.TypeOf<typeof RuleSignatureId>;
const RuleSignatureId = t.string;

type RuleName = t.TypeOf<typeof RuleName>;
const RuleName = NonEmptyString;

// If ids and list_ids are undefined, route will fetch all lists matching the
// specified namespace type
Expand Down
31 changes: 25 additions & 6 deletions x-pack/plugins/security_solution/common/api/timeline/model/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,31 @@ import { Direction } from '../../../search_strategy';
import type { PinnedEvent } from '../pinned_events/pinned_events_route';
import { PinnedEventRuntimeType } from '../pinned_events/pinned_events_route';
// TODO https://github.com/elastic/security-team/issues/7491
// eslint-disable-next-line no-restricted-imports
import {
SavedObjectResolveAliasPurpose,
SavedObjectResolveAliasTargetId,
SavedObjectResolveOutcome,
} from '../../detection_engine/model/rule_schema_legacy';

/**
* Outcome is a property of the saved object resolve api
* will tell us info about the rule after 8.0 migrations
*/
export type SavedObjectResolveOutcome = runtimeTypes.TypeOf<typeof SavedObjectResolveOutcome>;
export const SavedObjectResolveOutcome = runtimeTypes.union([
runtimeTypes.literal('exactMatch'),
runtimeTypes.literal('aliasMatch'),
runtimeTypes.literal('conflict'),
]);

export type SavedObjectResolveAliasTargetId = runtimeTypes.TypeOf<
typeof SavedObjectResolveAliasTargetId
>;
export const SavedObjectResolveAliasTargetId = runtimeTypes.string;

export type SavedObjectResolveAliasPurpose = runtimeTypes.TypeOf<
typeof SavedObjectResolveAliasPurpose
>;
export const SavedObjectResolveAliasPurpose = runtimeTypes.union([
runtimeTypes.literal('savedObjectConversion'),
runtimeTypes.literal('savedObjectImport'),
]);

import { ErrorSchema } from './error_schema';

export const BareNoteSchema = runtimeTypes.intersection([
Expand Down

0 comments on commit 0c5d7b9

Please sign in to comment.