@stackbit/sdk
Advanced tools
Comparing version 0.2.25 to 0.2.26
import { ConfigError, ConfigLoadError, ConfigValidationError } from './config-errors'; | ||
import { Config, Model, ModelsSource } from './config-types'; | ||
export interface ConfigLoaderOptions { | ||
[option: string]: any; | ||
dirPath: string; | ||
@@ -22,3 +21,3 @@ modelsSource?: ModelsSource; | ||
} | ||
export declare function loadConfig({ dirPath, ...options }: ConfigLoaderOptions): Promise<ConfigLoaderResult>; | ||
export declare function loadConfig({ dirPath, modelsSource }: ConfigLoaderOptions): Promise<ConfigLoaderResult>; | ||
export declare function validateAndNormalizeConfig(config: any, externalModels?: Model[]): NormalizedValidationResult; |
@@ -36,3 +36,3 @@ "use strict"; | ||
const presets_loader_1 = require("./presets-loader"); | ||
async function loadConfig({ dirPath, ...options }) { | ||
async function loadConfig({ dirPath, modelsSource }) { | ||
const { config, errors: configLoadErrors } = await loadConfigFromDir(dirPath); | ||
@@ -46,3 +46,3 @@ if (!config) { | ||
} | ||
const { models: externalModels, errors: externalModelsLoadErrors } = await loadModelsFromExternalSource(config, dirPath, options); | ||
const { models: externalModels, errors: externalModelsLoadErrors } = await loadModelsFromExternalSource(config, dirPath, modelsSource); | ||
const normalizedResult = validateAndNormalizeConfig(config, externalModels); | ||
@@ -175,4 +175,4 @@ const presetsResult = await presets_loader_1.loadPresets(dirPath, normalizedResult.config); | ||
} | ||
async function loadModelsFromExternalSource(config, dirPath, options = {}) { | ||
const modelsSource = lodash_1.default.get(config, 'modelsSource', options.modelsSource); | ||
async function loadModelsFromExternalSource(config, dirPath, modelsSource) { | ||
modelsSource = lodash_1.default.get(config, 'modelsSource', modelsSource); | ||
const sourceType = lodash_1.default.get(modelsSource, 'type', 'files'); | ||
@@ -187,3 +187,3 @@ if (sourceType === 'files') { | ||
try { | ||
const { models } = await module.fetchAndConvertSchema(lodash_1.default.omit(options, 'modelsSource')); | ||
const { models } = await module.fetchAndConvertSchema(lodash_1.default.omit(modelsSource, ['type', 'module'])); | ||
return { | ||
@@ -190,0 +190,0 @@ models: models, |
@@ -83,2 +83,3 @@ import { StricterUnion } from '../utils'; | ||
module?: string; | ||
[key: string]: any; | ||
} | ||
@@ -89,2 +90,3 @@ export interface ModelsSourceSanity { | ||
module?: string; | ||
[key: string]: any; | ||
} | ||
@@ -91,0 +93,0 @@ /******************* |
{ | ||
"name": "@stackbit/sdk", | ||
"version": "0.2.25", | ||
"version": "0.2.26", | ||
"description": "Stackbit SDK", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -33,3 +33,2 @@ import path from 'path'; | ||
export interface ConfigLoaderOptions { | ||
[option: string]: any; | ||
dirPath: string; | ||
@@ -56,3 +55,3 @@ modelsSource?: ModelsSource; | ||
export async function loadConfig({ dirPath, ...options }: ConfigLoaderOptions): Promise<ConfigLoaderResult> { | ||
export async function loadConfig({ dirPath, modelsSource }: ConfigLoaderOptions): Promise<ConfigLoaderResult> { | ||
const { config, errors: configLoadErrors } = await loadConfigFromDir(dirPath); | ||
@@ -68,3 +67,3 @@ | ||
const { models: externalModels, errors: externalModelsLoadErrors } = await loadModelsFromExternalSource(config, dirPath, options); | ||
const { models: externalModels, errors: externalModelsLoadErrors } = await loadModelsFromExternalSource(config, dirPath, modelsSource); | ||
@@ -226,5 +225,5 @@ const normalizedResult = validateAndNormalizeConfig(config, externalModels); | ||
dirPath: string, | ||
options: Omit<ConfigLoaderOptions, 'dirPath'> = {} | ||
modelsSource?: ModelsSource | ||
): Promise<{ models: Model[]; errors: ConfigLoadError[] }> { | ||
const modelsSource = _.get(config, 'modelsSource', options.modelsSource); | ||
modelsSource = _.get(config, 'modelsSource', modelsSource); | ||
const sourceType = _.get(modelsSource, 'type', 'files'); | ||
@@ -238,3 +237,3 @@ if (sourceType === 'files') { | ||
try { | ||
const { models } = await module.fetchAndConvertSchema(_.omit(options, 'modelsSource')); | ||
const { models } = await module.fetchAndConvertSchema(_.omit(modelsSource, ['type', 'module'])); | ||
return { | ||
@@ -241,0 +240,0 @@ models: models, |
@@ -98,2 +98,3 @@ import { StricterUnion } from '../utils'; | ||
module?: string; | ||
[key: string]: any; | ||
} | ||
@@ -105,2 +106,3 @@ | ||
module?: string; | ||
[key: string]: any; | ||
} | ||
@@ -107,0 +109,0 @@ |
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
771338
13728