Skip to content

Commit fe3c271

Browse files
author
Dmitrii
committed
Replaced the incorrect runtime type used for ruleSource
1 parent 51f9eed commit fe3c271

2 files changed

Lines changed: 28 additions & 17 deletions

File tree

x-pack/plugins/alerting/server/integration_tests/__snapshots__/serverless_upgrade_and_rollback_checks.test.ts.snap

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugins/security_solution/server/lib/detection_engine/rule_schema/model/rule_schemas.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import {
4141
IndexPatternArray,
4242
InvestigationFields,
4343
InvestigationGuide,
44+
IsExternalRuleCustomized,
4445
IsRuleImmutable,
4546
ItemsPerSearch,
4647
KqlQueryLanguage,
@@ -63,7 +64,6 @@ import {
6364
RuleQuery,
6465
RuleReferenceArray,
6566
RuleSignatureId,
66-
RuleSource,
6767
RuleVersion,
6868
SavedQueryId,
6969
SetupGuide,
@@ -84,7 +84,6 @@ import {
8484
TimestampOverrideFallbackDisabled,
8585
} from '../../../../../common/api/detection_engine/model/rule_schema';
8686
import type { SERVER_APP_ID } from '../../../../../common/constants';
87-
import { convertObjectKeysToCamelCase } from '../../../../utils/object_case_converters';
8887

8988
// 8.10.x is mapped as an array of strings
9089
export type LegacyInvestigationFields = z.infer<typeof LegacyInvestigationFields>;
@@ -104,8 +103,20 @@ export const InvestigationFieldsCombined = z.union([
104103
LegacyInvestigationFields,
105104
]);
106105

106+
/**
107+
* This is the same type as RuleSource, but with the keys in camelCase. Intended
108+
* for internal use only (not for API responses).
109+
*/
107110
export type RuleSourceCamelCased = z.infer<typeof RuleSourceCamelCased>;
108-
export const RuleSourceCamelCased = RuleSource.transform(convertObjectKeysToCamelCase);
111+
export const RuleSourceCamelCased = z.discriminatedUnion('type', [
112+
z.object({
113+
type: z.literal('external'),
114+
isCustomized: IsExternalRuleCustomized,
115+
}),
116+
z.object({
117+
type: z.literal('internal'),
118+
}),
119+
]);
109120

110121
// Conversion to an interface has to be disabled for the entire file; otherwise,
111122
// the resulting union would not be assignable to Alerting's RuleParams due to a

0 commit comments

Comments
 (0)