/
githubmirror
/
strapi
Обзор
Документация
Войти
/
githubmirror
/
strapi
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/core/data-transfer/src/utils/schema.ts
31 строка
841 B
Jean-Sébastien Herbaux
fix: allow '.default' to be ignored during schema validation (#20421)
04 июн 2024, 15:05
Не верифицирован
04 июн 2024, 15:05
714ea0a
Код
Авторство
О чём код?
import type { Struct, Utils } from '@strapi/types'; import { mapValues, pick } from 'lodash/fp'; /** * List of schema properties that should be kept when sanitizing schemas */ const VALID_SCHEMA_PROPERTIES = [ 'collectionName', 'info', 'options', 'pluginOptions', 'attributes', 'kind', 'modelType', 'modelName', 'uid', 'plugin', 'globalId', ]; /** * Sanitize a schemas dictionary by omitting unwanted properties * The list of allowed properties can be found here: {@link VALID_SCHEMA_PROPERTIES} */ export const mapSchemasValues = (schemas: Utils.String.Dict<Struct.Schema>) => { return mapValues(pick(VALID_SCHEMA_PROPERTIES), schemas) as Utils.String.Dict<Struct.Schema>; }; export const schemasToValidJSON = (schemas: Utils.String.Dict<Struct.Schema>) => { return JSON.parse(JSON.stringify(schemas)); };