@stackbit/sdk
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -365,6 +365,13 @@ "use strict"; | ||
const models = (_b = config.models) !== null && _b !== void 0 ? _b : {}; | ||
if (!contentModels) { | ||
return config; | ||
if (lodash_1.default.isEmpty(contentModels)) { | ||
return { | ||
valid: true, | ||
value: config, | ||
errors: [] | ||
}; | ||
} | ||
const validationResult = config_validator_1.validateContentModels(contentModels, models); | ||
if (lodash_1.default.isEmpty(models)) { | ||
return validationResult; | ||
} | ||
const extendedModels = lodash_1.default.mapValues(models, (model, modelName) => { | ||
@@ -405,3 +412,3 @@ const contentModel = validationResult.value.contentModels[modelName]; | ||
value: { | ||
...lodash_1.default.omit(config, ['contentModels', 'models']), | ||
...config, | ||
models: extendedModels | ||
@@ -408,0 +415,0 @@ }, |
@@ -365,2 +365,5 @@ "use strict"; | ||
const models = lodash_1.default.get(prefs, 'context.models'); | ||
if (!models) { | ||
return contentModel; | ||
} | ||
const modelName = lodash_1.default.last(state.path); | ||
@@ -567,2 +570,3 @@ const model = models[modelName]; | ||
logicFields: joi_1.default.array().items(logicField), | ||
contentModels: joi_1.default.any(), | ||
modelsSource: modelsSourceSchema, | ||
@@ -569,0 +573,0 @@ models: modelsSchema |
{ | ||
"name": "@stackbit/sdk", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Stackbit SDK", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -435,8 +435,12 @@ import path from 'path'; | ||
function validateAndExtendContentModels(config: any) { | ||
function validateAndExtendContentModels(config: any): ConfigValidationResult { | ||
const contentModels = config.contentModels ?? {}; | ||
const models = config.models ?? {}; | ||
if (!contentModels) { | ||
return config; | ||
if (_.isEmpty(contentModels)) { | ||
return { | ||
valid: true, | ||
value: config, | ||
errors: [] | ||
}; | ||
} | ||
@@ -446,2 +450,6 @@ | ||
if (_.isEmpty(models)) { | ||
return validationResult; | ||
} | ||
const extendedModels = _.mapValues(models, (model, modelName) => { | ||
@@ -481,3 +489,3 @@ const contentModel = validationResult.value.contentModels[modelName]; | ||
value: { | ||
..._.omit(config, ['contentModels', 'models']), | ||
...config, | ||
models: extendedModels | ||
@@ -484,0 +492,0 @@ }, |
@@ -419,2 +419,5 @@ import Joi from 'joi'; | ||
const models = _.get(prefs, 'context.models'); | ||
if (!models) { | ||
return contentModel; | ||
} | ||
const modelName = _.last(state.path)!; | ||
@@ -648,2 +651,3 @@ const model = models[modelName]; | ||
logicFields: Joi.array().items(logicField), | ||
contentModels: Joi.any(), | ||
modelsSource: modelsSourceSchema, | ||
@@ -650,0 +654,0 @@ models: modelsSchema |
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
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
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
641675
11467