From e6cbd790aa1e87d814a53f723576574bb1dedff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Arod?= Date: Mon, 26 May 2025 21:08:32 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20arr=C3=AAte=20erreur=20quand=20un=20typ?= =?UTF-8?q?e=20=20n'existe=20plus=20dans=20Notion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../checkDbPropertyOptionsMatchesType.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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); } }