mirror of
https://framagit.org/enfance-libre/statistiques
synced 2025-12-07 07:23:44 +00:00
feat: arrête erreur quand un type n'existe plus dans Notion
This commit is contained in:
parent
4fb83b8217
commit
e6cbd790aa
1 changed files with 14 additions and 1 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue