-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add utils for mapping field conversion
- Loading branch information
1 parent
eaebc40
commit 58485f1
Showing
5 changed files
with
50 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
28 changes: 28 additions & 0 deletions
28
x-pack/plugins/cloud_security_posture/server/lib/mapping_field_util.ts
This file contains 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,28 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export const DELIMITER = ';'; | ||
export const MAPPING_VERSION_DELIMITER = '_'; | ||
export const DOC_FIELD_VERSION_DELIMITER = '.'; | ||
|
||
export const toBenchmarkDocFieldKey = (benchmarkId: string, benchmarkVersion: string) => { | ||
if (benchmarkVersion.includes(MAPPING_VERSION_DELIMITER)) | ||
return `${benchmarkId}${DELIMITER}${benchmarkVersion.replaceAll( | ||
`${MAPPING_VERSION_DELIMITER}`, | ||
DOC_FIELD_VERSION_DELIMITER | ||
)}`; | ||
return `${benchmarkId}${DELIMITER}${benchmarkVersion}`; | ||
}; | ||
|
||
export const toBenchmarkMappingFieldKey = (benchmarkId: string, benchmarkVersion: string) => { | ||
if (benchmarkVersion.includes(DOC_FIELD_VERSION_DELIMITER)) | ||
return `${benchmarkId}${DELIMITER}${benchmarkVersion.replaceAll( | ||
`${DOC_FIELD_VERSION_DELIMITER}`, | ||
MAPPING_VERSION_DELIMITER | ||
)}`; | ||
return `${benchmarkId}${DELIMITER}${benchmarkVersion}`; | ||
}; |
This file contains 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 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 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