@stackbit/sdk
Advanced tools
Comparing version 0.2.37 to 0.2.38
@@ -719,2 +719,3 @@ "use strict"; | ||
'contentModels', | ||
'presetSource', | ||
'modelsSource', | ||
@@ -721,0 +722,0 @@ 'models', |
@@ -222,2 +222,13 @@ "use strict"; | ||
}); | ||
const presetSourceFilesSchema = joi_1.default.object({ | ||
type: joi_1.default.string().valid(joi_1.default.override, 'files').required(), | ||
presetDirs: joi_1.default.array().items(joi_1.default.string()).required() | ||
}); | ||
const presetSourceSchema = joi_1.default.object({ | ||
type: joi_1.default.string().valid('files').required() | ||
}).when('.type', { | ||
switch: [ | ||
{ is: 'files', then: presetSourceFilesSchema } | ||
] | ||
}); | ||
const modelsSourceFilesSchema = joi_1.default.object({ | ||
@@ -643,2 +654,3 @@ type: joi_1.default.string().valid(joi_1.default.override, 'files').required(), | ||
contentModels: joi_1.default.any(), | ||
presetSource: presetSourceSchema, | ||
modelsSource: modelsSourceSchema, | ||
@@ -645,0 +657,0 @@ models: modelsSchema |
@@ -31,2 +31,3 @@ import { StricterUnion } from '../utils'; | ||
contentModels?: ContentModelMap; | ||
presetSource?: PresetSource; | ||
modelsSource?: ModelsSource; | ||
@@ -76,2 +77,7 @@ } | ||
} | ||
export declare type PresetSource = PresetSourceFiles; | ||
export interface PresetSourceFiles { | ||
type: 'files'; | ||
presetDirs: string[]; | ||
} | ||
export declare type ModelsSource = ModelsSourceFiles | ModelsSourceContentful | ModelsSourceSanity; | ||
@@ -78,0 +84,0 @@ export interface ModelsSourceFiles { |
@@ -13,4 +13,8 @@ "use strict"; | ||
async function loadPresets(dirPath, config) { | ||
var _a, _b; | ||
const presetFiles = []; | ||
const presetsRelDirs = ['.stackbit/presets', 'node_modules/@stackbit/components/presets']; | ||
let presetsRelDirs = ['.stackbit/presets', 'node_modules/@stackbit/components/presets']; | ||
if (((_a = config.presetSource) === null || _a === void 0 ? void 0 : _a.type) === 'files' && ((_b = config.presetSource) === null || _b === void 0 ? void 0 : _b.presetDirs)) { | ||
presetsRelDirs = [...new Set([...presetsRelDirs, ...config.presetSource.presetDirs])]; | ||
} | ||
for (const presetsRelDir of presetsRelDirs) { | ||
@@ -17,0 +21,0 @@ const presetsDir = path_1.default.join(dirPath, presetsRelDir); |
{ | ||
"name": "@stackbit/sdk", | ||
"version": "0.2.37", | ||
"version": "0.2.38", | ||
"description": "Stackbit SDK", | ||
@@ -68,3 +68,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "2102ed599336f5b42c03e91636176d7e79b3fdde" | ||
"gitHead": "00aed1ebdcb433c5251ff62fb43cf32b887b82ae" | ||
} |
@@ -835,2 +835,3 @@ import path from 'path'; | ||
'contentModels', | ||
'presetSource', | ||
'modelsSource', | ||
@@ -837,0 +838,0 @@ 'models', |
@@ -12,2 +12,4 @@ import Joi from 'joi'; | ||
ModelsSource, | ||
PresetSource, | ||
PresetSourceFiles, | ||
SanityImport, | ||
@@ -257,2 +259,15 @@ YamlBaseModel, | ||
const presetSourceFilesSchema = Joi.object<PresetSourceFiles>({ | ||
type: Joi.string().valid(Joi.override, 'files').required(), | ||
presetDirs: Joi.array().items(Joi.string()).required() | ||
}); | ||
const presetSourceSchema = Joi.object<PresetSource>({ | ||
type: Joi.string().valid('files').required() | ||
}).when('.type', { | ||
switch: [ | ||
{ is: 'files', then: presetSourceFilesSchema } | ||
] | ||
}); | ||
const modelsSourceFilesSchema = Joi.object<ModelsSourceFiles>({ | ||
@@ -731,2 +746,3 @@ type: Joi.string().valid(Joi.override, 'files').required(), | ||
contentModels: Joi.any(), // contentModels should have been already validated by now | ||
presetSource: presetSourceSchema, | ||
modelsSource: modelsSourceSchema, | ||
@@ -733,0 +749,0 @@ models: modelsSchema |
@@ -34,2 +34,3 @@ import { StricterUnion } from '../utils'; | ||
contentModels?: ContentModelMap; | ||
presetSource?: PresetSource; | ||
modelsSource?: ModelsSource; | ||
@@ -89,2 +90,9 @@ } | ||
export type PresetSource = PresetSourceFiles; | ||
export interface PresetSourceFiles { | ||
type: 'files'; | ||
presetDirs: string[]; | ||
} | ||
export type ModelsSource = ModelsSourceFiles | ModelsSourceContentful | ModelsSourceSanity; | ||
@@ -91,0 +99,0 @@ |
@@ -16,4 +16,8 @@ import _ from 'lodash'; | ||
const presetFiles = []; | ||
const presetsRelDirs = ['.stackbit/presets', 'node_modules/@stackbit/components/presets']; | ||
let presetsRelDirs = ['.stackbit/presets', 'node_modules/@stackbit/components/presets']; | ||
if (config.presetSource?.type === 'files' && config.presetSource?.presetDirs) { | ||
presetsRelDirs = [...new Set([...presetsRelDirs, ...config.presetSource.presetDirs])]; | ||
} | ||
for (const presetsRelDir of presetsRelDirs) { | ||
@@ -20,0 +24,0 @@ const presetsDir = path.join(dirPath, presetsRelDir); |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
794586
14266
0