New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

es-mapping-to-schema

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es-mapping-to-schema - npm Package Compare versions

Comparing version 1.0.6 to 2.0.0

.idea/libraries/es_mapping_to_schema_node_modules.xml

13

index.js

@@ -22,2 +22,6 @@ const _ = require('lodash');

schema.properties = RecurseMappingToSchema({}, mapping.properties, modifiers);
if (modifiers.allStrict) {
schema.strict = true;
}
}

@@ -87,7 +91,10 @@

const MappingToSchema = (mapping, arrayPaths, optionalPaths) => {
const MappingToSchema = (mapping, options) => {
options = options || {};
const modifiers = {
arrayPaths: arrayPaths,
arrayPaths: options.arrayPaths,
allStrict: options.allStrict && options.allStrict === true,
isArray: false,
optionalPaths: optionalPaths,
optionalPaths: options.optionalPaths,
isOptional: false

@@ -94,0 +101,0 @@ };

{
"name": "es-mapping-to-schema",
"version": "1.0.6",
"version": "2.0.0",
"description": "Convert Elasticsearch mappings to Schema Inspector schemas",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -370,3 +370,3 @@ const chai = require('chai');

selectors: {
type: 'array',
type: 'array',
items: {

@@ -393,3 +393,3 @@ selector: {

const schema = MappingToSchema(mapping, ['selectors']);
const schema = MappingToSchema(mapping, {arrayPaths: ['selectors']});
expect(schema).to.eql(expectedSchema);

@@ -549,3 +549,3 @@ });

type: 'object',
optional: true,
optional: true,
properties: {

@@ -590,5 +590,203 @@ customerId: {

const schema = MappingToSchema(mapping, null, ['customer']);
const schema = MappingToSchema(mapping, {optionalPaths: ['customer']});
expect(schema).to.eql(expectedSchema);
});
it('should convert a mapping into a schema with optional properties', () => {
const mapping = {
_all: {
enabled: false
},
properties: {
booleanThing: {
type: 'boolean'
},
stringThing: {
type: 'string'
},
integerThing: {
type: 'integer'
},
longThing: {
type: 'long'
},
shortThing: {
type: 'short'
},
byteThing: {
type: 'byte'
},
floatThing: {
type: 'float'
},
doubleThing: {
type: 'double'
},
nonanalyzedStringThing: {
type: 'string',
index: 'not_analyzed'
},
variousTerm: {
type: 'string',
fields: {
raw: {
type: 'string',
index: 'not_analyzed',
store: true
},
normalized: {
type: 'string',
analyzer: 'facet_analyzer'
},
lang_en: {
type: 'string',
analyzer: 'english'
},
lang_en_raw: {
type: 'string',
analyzer: 'raw_diacritic_free'
}
}
},
customer: {
type: 'object',
properties: {
customerId: {
type: 'string',
index: 'not_analyzed'
},
projectId: {
type: 'string',
index: 'not_analyzed'
},
localTime: {
type: 'date',
format: 'dateOptionalTime'
}
}
},
selectors: {
type: 'nested',
include_in_parent: true,
properties: {
selector: {
properties: {
name: {
type: 'string',
fields: {
raw: {
type: 'string',
index: 'not_analyzed',
store: true
},
normalized: {
type: 'string',
analyzer: 'facet_analyzer'
}
}
},
value: {
type: 'string',
fields: {
raw: {
type: 'string',
index: 'not_analyzed',
store: true
}
}
}
}
}
}
}
}
};
const expectedSchema = {
type: 'object',
strict: true,
properties: {
booleanThing: {
type: 'boolean'
},
stringThing: {
type: 'string',
maxLength: 32766,
rules: ['trim']
},
integerThing: {
type: 'integer'
},
longThing: {
type: 'integer'
},
shortThing: {
type: 'integer'
},
byteThing: {
type: 'integer'
},
floatThing: {
type: 'number'
},
doubleThing: {
type: 'number'
},
nonanalyzedStringThing: {
type: 'string',
maxLength: 32766,
rules: ['trim']
},
variousTerm: {
type: 'string',
maxLength: 32766,
rules: ['trim']
},
customer: {
strict: true,
type: 'object',
properties: {
customerId: {
type: 'string',
maxLength: 32766,
rules: ['trim']
},
projectId: {
type: 'string',
maxLength: 32766,
rules: ['trim']
},
localTime: {
type: 'date'
}
}
},
selectors: {
type: 'object',
strict: true,
properties: {
selector: {
type: 'object',
strict: true,
properties: {
name: {
type: 'string',
maxLength: 32766,
rules: ['trim']
},
value: {
type: 'string',
maxLength: 32766,
rules: ['trim']
}
}
}
}
}
}
};
const schema = MappingToSchema(mapping, {allStrict: true});
expect(schema).to.eql(expectedSchema);
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc