Huge News!Announcing our $40M Series B led by Abstract Ventures.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 3.3.0 to 3.3.1

14

index.js

@@ -29,8 +29,4 @@ const _ = require('lodash');

// if (nextOptions.isArray) {
// console.log('name: ' + name);
// } else {
schema[name] = determineType(mapping[name], {}, schemaType, nextOptions);
result[name] = recurseMappingObjects(mapping[name], schema[name], schemaType, nextOptions, nextLocalOptions);
// }
schema[name] = determineType(mapping[name], {}, schemaType, nextOptions);
result[name] = recurseMappingObjects(mapping[name], schema[name], schemaType, nextOptions, nextLocalOptions);

@@ -48,3 +44,3 @@ return result;

schema.items = {};
schema.items.type = determineType(mapping, {}, schemaType, Object.assign({}, options, {isArray: false})).type;
schema.items.type = determineType(mapping, {}, schemaType, Object.assign({}, options, {isArray: false})).type;

@@ -93,3 +89,5 @@ if (mapping.properties) {

if (options[schemaType].all.rules && schema.type === 'string') {
// Important to check that the mapping.type is a string, and not schema.type
// because schema.type may not be populated if we don't want type coercion
if (options[schemaType].all.rules && mapping.type === 'string') {
schema.rules = options[schemaType].all.rules;

@@ -96,0 +94,0 @@ }

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

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

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

const expectedSchema = {
type: 'object',
type: 'object',
properties: {

@@ -1247,3 +1247,3 @@ arrayOfStrings: {

all: {
types: [
types: [
'object',

@@ -1263,2 +1263,75 @@ 'string',

});
it('should apply rules to all string mappings', () => {
const mapping = {
properties: {
someValue: {
type: 'integer'
},
someString: {
type: 'string'
},
deeper: {
properties: {
anotherString: {
type: 'string'
},
aNumber: {
type: 'double'
}
}
}
}
};
const expectedSchema = {
type: 'object',
properties: {
someValue: {
type: 'integer'
},
someString: {
rules: [
'trim',
'lower'
]
},
deeper: {
type: 'object',
properties: {
anotherString: {
rules: [
'trim',
'lower'
]
},
aNumber: {
type: 'number'
}
}
}
}
};
const schemas = MappingToSchema(mapping, {
sanitization: {
all: {
types: [
'object',
'integer',
'number',
'array',
'boolean',
'date'
],
rules: [
'trim',
'lower'
]
}
}
});
expect(schemas.sanitization).to.eql(expectedSchema);
});
});
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