@sanity/data-aspects
Advanced tools
Comparing version 2.34.2-empty-template-cli.0 to 2.34.3-cdr-ga.20
@@ -7,26 +7,17 @@ "use strict"; | ||
exports.default = void 0; | ||
var _startCase2 = _interopRequireDefault(require("lodash/startCase")); | ||
var _dataAspects = _interopRequireDefault(require("config:@sanity/data-aspects")); | ||
var _generateHelpUrl = require("@sanity/generate-help-url"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var bundledTypeNames = ['geopoint', 'richDate', 'date', 'sanity.imageAsset', 'sanity.fileAsset']; | ||
var BUNDLED_DOC_TYPES = ['sanity.imageAsset', 'sanity.fileAsset']; | ||
function isDocumentType(type) { | ||
return type.type && type.type.name === 'document'; | ||
} | ||
function isObjectType(type) { | ||
return type.type !== null && type.jsonType === 'object'; | ||
} | ||
function isBundledDocType(typeName) { | ||
return BUNDLED_DOC_TYPES.includes(typeName); | ||
} | ||
function schemaHasUserDefinedDocumentTypes(schema) { | ||
@@ -37,5 +28,3 @@ return schema.getTypeNames().some(typeName => { | ||
} | ||
var hasWarned = false; | ||
function warnAboutHiddenTypes() { | ||
@@ -45,8 +34,6 @@ if (hasWarned) { | ||
} | ||
hasWarned = true; // eslint-disable-next-line no-console, prefer-template | ||
hasWarned = true; | ||
// eslint-disable-next-line no-console, prefer-template | ||
console.warn("👋 Hi there! Looks like you have hidden types configured in your studio's config/@sanity/data-aspects.json" + " This config is now obsolete and should be removed. Read more at ".concat((0, _generateHelpUrl.generateHelpUrl)('toplevel-objects-to-document-type'))); | ||
} | ||
class DataAspectsResolver { | ||
@@ -60,24 +47,21 @@ constructor(schema) { | ||
} | ||
getConfig() { | ||
return this.config; | ||
} | ||
getField(type, fieldName) { | ||
return type.fields.filter(currField => currField.name === fieldName); | ||
} | ||
getType(typeName) { | ||
return this.schema.get(typeName); | ||
} | ||
inferTypesLegacy() { | ||
return (this.schema.getTypeNames() || []).filter(typeName => { | ||
// Exclude types which come bundled with Sanity | ||
return !bundledTypeNames.includes(typeName) && // Exclude types which are explicitly named in (legacy) hiddenTypes config | ||
!this.config.hiddenTypes.includes(typeName) && // Only include if its an object type | ||
return !bundledTypeNames.includes(typeName) && | ||
// Exclude types which are explicitly named in (legacy) hiddenTypes config | ||
!this.config.hiddenTypes.includes(typeName) && | ||
// Only include if its an object type | ||
isObjectType(this.getType(typeName)); | ||
}); | ||
} | ||
getDocumentTypes() { | ||
@@ -87,10 +71,7 @@ if (this.config.hiddenTypes.length > 0) { | ||
} | ||
return this.schema.getTypeNames().filter(typeName => !isBundledDocType(typeName) && isDocumentType(this.schema.get(typeName))); | ||
} | ||
getInferredTypes() { | ||
return schemaHasUserDefinedDocumentTypes(this.schema) ? this.getDocumentTypes() : this.inferTypesLegacy(); | ||
} | ||
getDisplayName(typeName) { | ||
@@ -101,35 +82,27 @@ var typeOption = this.config.typeOptions[typeName] || {}; | ||
} | ||
getIcon(typeName) { | ||
return this.getType(typeName).icon; | ||
} | ||
getListConstraints(typeName) { | ||
var typeOption = this.config.typeOptions[typeName]; | ||
if (!typeOption) { | ||
return ''; | ||
} | ||
var constraints = []; | ||
if (typeOption.order) {// prefix order items with . because that's what gql requires | ||
if (typeOption.order) { | ||
// prefix order items with . because that's what gql requires | ||
//constraints.push(typeOptions.order) | ||
} | ||
if (typeOption.limit || typeOption.limit == 0) { | ||
constraints.push("limit: ".concat(typeOption.limit)); | ||
} | ||
if (typeOption.offset) { | ||
constraints.push("offset: ".concat(typeOption.offset)); | ||
} | ||
return constraints.filter(Boolean).join(', '); | ||
} | ||
getListQuery(options) { | ||
var typeName = options.typeName, | ||
keyForId = options.keyForId, | ||
keyForDisplayFieldName = options.keyForDisplayFieldName; | ||
keyForId = options.keyForId, | ||
keyForDisplayFieldName = options.keyForDisplayFieldName; | ||
var fieldName = this.getItemDisplayField(typeName); | ||
@@ -140,6 +113,4 @@ var constraints = this.getListConstraints(typeName); | ||
} | ||
} | ||
var _default = DataAspectsResolver; | ||
exports.default = _default; |
{ | ||
"name": "@sanity/data-aspects", | ||
"version": "2.34.2-empty-template-cli.0+184a9350e5", | ||
"version": "2.34.3-cdr-ga.20+ce57aa9877", | ||
"description": "Sanity plugin which controls how your data is presented", | ||
@@ -36,3 +36,3 @@ "main": "lib/DataAspectsResolver.js", | ||
"homepage": "https://www.sanity.io/", | ||
"gitHead": "184a9350e50aa05877a3b10e052ce4e2ca743ef0" | ||
"gitHead": "ce57aa9877de817376861009ccaaa06b259f9f6b" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
126
7291