Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sanity/schema

Package Overview
Dependencies
Maintainers
7
Versions
1376
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/schema - npm Package Compare versions

Comparing version 0.100.3 to 0.100.4

lib/types/file.js

5

lib/Schema.js

@@ -74,2 +74,7 @@ 'use strict';

}, {
key: 'has',
value: function has(name) {
return name in this._registry;
}
}, {
key: 'getTypeNames',

@@ -76,0 +81,0 @@ value: function getTypeNames() {

7

lib/types/image.js

@@ -30,3 +30,3 @@ 'use strict';

name: 'image',
type: 'object',
type: null,
jsonType: 'object'

@@ -62,4 +62,5 @@ };

});
(0, _utils.lazyGetter)(options, 'preview', function () {
return (subTypeDef.options || {}).preview || (0, _guessPreviewConfig2.default)(parsed.fields);
(0, _utils.lazyGetter)(parsed, 'preview', function () {
return subTypeDef.preview || (subTypeDef.options || {}).preview || (0, _guessPreviewConfig2.default)(parsed.fields);
});

@@ -66,0 +67,0 @@

@@ -97,2 +97,11 @@ 'use strict';

var _file = require('./file');
Object.defineProperty(exports, 'file', {
enumerable: true,
get: function get() {
return _file.FileType;
}
});
var _object = require('./object');

@@ -123,2 +132,11 @@

}
});
var _geopoint = require('./geopoint');
Object.defineProperty(exports, 'geopoint', {
enumerable: true,
get: function get() {
return _geopoint.GeoPointType;
}
});

@@ -8,2 +8,6 @@ 'use strict';

var _startCase2 = require('lodash/startCase');
var _startCase3 = _interopRequireDefault(_startCase2);
var _keyBy2 = require('lodash/keyBy');

@@ -34,3 +38,2 @@

name: 'object',
title: 'Object',
type: null,

@@ -40,9 +43,27 @@ jsonType: 'object'

function warnIfOldPreviewFormat(type, preview) {
if (preview && Array.isArray(preview.fields)) {
console.warn('Heads up! Preview fields must now be an object on the format:\n {property1: \'some.dot.path\', property2: \'some.dot.path2\'}.\nPlease check the type definition for "' + type.name + '" in your schema.\nThe encountered preview fields was: ' + JSON.stringify(preview.fields) + '\n');
function parseFields(fields) {
return fields.reduce(function (acc, field) {
acc[field] = field;
return acc;
}, {});
}
function parsePreview(preview) {
if (!preview) {
return preview;
}
if (Array.isArray(preview.fields)) {
return _extends({}, preview, {
fields: parseFields(preview.fields)
});
}
return preview;
}
function warnIfPreviewOnOptions(type) {
if (type.options && type.options.preview) {
// eslint-disable-next-line no-console
console.warn('Heads up! The preview config is no longer defined on "options", but instead on the type/field itself.\nPlease move {options: {preview: ...}} to {..., preview: ...} on the type/field definition of "' + type.name + '".\n');
}
}
var ObjectType = {

@@ -56,2 +77,3 @@ get: function get() {

type: OBJECT_CORE,
title: subTypeDef.title || (subTypeDef.name ? (0, _startCase3.default)(subTypeDef.name) : ''),
options: options,

@@ -73,4 +95,6 @@ fields: subTypeDef.fields.map(function (fieldDef) {

(0, _utils.lazyGetter)(options, 'preview', function () {
return warnIfOldPreviewFormat(parsed, (subTypeDef.options || {}).preview) || (0, _guessPreviewConfig2.default)(parsed.fields);
(0, _utils.lazyGetter)(parsed, 'preview', function () {
warnIfPreviewOnOptions(subTypeDef);
var preview = parsePreview(subTypeDef.preview || (subTypeDef.options || {}).preview);
return preview || (0, _guessPreviewConfig2.default)(parsed.fields);
});

@@ -90,3 +114,6 @@

}
var current = Object.assign({}, parent, (0, _pick3.default)(extensionDef, OVERRIDABLE_FIELDS), { type: parent });
var current = Object.assign({}, parent, (0, _pick3.default)(extensionDef, OVERRIDABLE_FIELDS), {
title: extensionDef.title || subTypeDef.title,
type: parent
});
return subtype(current);

@@ -93,0 +120,0 @@ }

{
"name": "@sanity/schema",
"version": "0.100.3",
"version": "0.100.4",
"description": "",

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

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