diff --git a/src/notion/fetch/schemaCheck/checkDbPropertyOptionsMatchesType.ts b/src/notion/fetch/schemaCheck/checkDbPropertyOptionsMatchesType.ts index 2726f0f..28235ee 100644 --- a/src/notion/fetch/schemaCheck/checkDbPropertyOptionsMatchesType.ts +++ b/src/notion/fetch/schemaCheck/checkDbPropertyOptionsMatchesType.ts @@ -7,7 +7,14 @@ import { richTextToPlainText } from "../../utils/text/richTextToPlainText"; export function checkDbPropertyOptionsMatchesType( db: DatabaseObjectResponse, propName: string, - typeOptions: readonly string[] + typeOptions: readonly string[], + options: { + failOnMissingFromDb: boolean; + failOnMissingFromType: boolean; + } = { + failOnMissingFromDb: true, + failOnMissingFromType: false + } ) { const prop = db.properties[propName]; const dbTitle = richTextToPlainText(db.title); @@ -35,6 +42,12 @@ export function checkDbPropertyOptionsMatchesType( notInDb.length } options missing from db: [${notInDb.map((i) => `"${i}"`)}]`; } + if (options.failOnMissingFromDb && notInDb.length > 0) { + throw new Error(message); + } + if (options.failOnMissingFromType && notInType.length > 0) { + throw new Error(message); + } console.warn(message); } }