Skip to content

Commit

Permalink
chore: some missing parts of the ECS schema version update
Browse files Browse the repository at this point in the history
- update the ecs-helpers deps for morgan and winston
- update the ECS JSON schema (and the generation script) from ecs.git v8.10.0 tag

Refs: #163
  • Loading branch information
trentm committed Oct 27, 2023
1 parent 7c82a8d commit 2a6cf85
Show file tree
Hide file tree
Showing 4 changed files with 1,444 additions and 208 deletions.
2 changes: 1 addition & 1 deletion packages/ecs-morgan-format/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"node": ">=10"
},
"dependencies": {
"@elastic/ecs-helpers": "^2.0.0",
"@elastic/ecs-helpers": "^2.1.0",
"safe-stable-stringify": "^2.4.3"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/ecs-winston-format/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"node": ">=10"
},
"dependencies": {
"@elastic/ecs-helpers": "^2.0.0",
"@elastic/ecs-helpers": "^2.1.0",
"safe-stable-stringify": "^2.4.3",
"triple-beam": ">=1.1.0"
},
Expand Down
10 changes: 9 additions & 1 deletion utils/create-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ if (!ecsRepo) {
const ecsSchemasDir = path.join(ecsRepo, 'schemas')

// Build the JSON schema properties from the ECS schema YAML files.
const properties = getAllFiles(ecsSchemasDir)
var properties = getAllFiles(ecsSchemasDir)
.filter(file => !file.includes('README.md'))
.map(file => fs.readFileSync(file, 'utf8'))
.map(yaml.safeLoad)
.filter(entry => Array.isArray(entry)) // filter out weird `{name: 'main', ...}` entry
.reduce((acc, [val]) => {
let properties = {}
for (const prop of val.fields) {
Expand Down Expand Up @@ -121,6 +122,7 @@ function set (object, objPath, value, customizer) {
function jsonSchemaTypeFromEcsType (type) {
switch (type) {
case 'keyword':
case 'constant_keyword':
return { type: 'string' }
case 'boolean':
return { type: 'boolean' }
Expand All @@ -134,11 +136,14 @@ function jsonSchemaTypeFromEcsType (type) {
]
}
case 'text':
case 'match_only_text':
case 'wildcard':
return { type: 'string' }
case 'integer':
return { type: 'integer' }
case 'long':
case 'float':
case 'scaled_float':
return { type: 'number' }
case 'geo_point':
return {
Expand All @@ -149,6 +154,9 @@ function jsonSchemaTypeFromEcsType (type) {
}
}
case 'object':
case 'flattened':
case 'nested':
case 'source':
return {
type: 'object',
additionalProperties: true
Expand Down
Loading

0 comments on commit 2a6cf85

Please sign in to comment.