From 4c2460ac5b677d3e02626facfd77ea4383705ec0 Mon Sep 17 00:00:00 2001 From: Pl217 Date: Wed, 25 Dec 2024 13:18:59 +0100 Subject: [PATCH] Clean up entity prototype codec After cleaning the invalid data in DB, the codec no longer needs to accommodate string IDs and key with typo "cadinality", and therefore `cardinality` can be made required --- src/db/models/entityPrototype.ts | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/src/db/models/entityPrototype.ts b/src/db/models/entityPrototype.ts index 43c56b74..26e0c5e7 100644 --- a/src/db/models/entityPrototype.ts +++ b/src/db/models/entityPrototype.ts @@ -40,30 +40,11 @@ export const ENTITY_PROTOTYPE_TYPE = t.keyof({ }); const ENTITY_REFS = t.array( - t.intersection([ - t.type({ - /** - * Like in many other areas where IDs are stored in JSON in DB, - * there is a mixup of values with strings - * - * TODO: Make sure no more string values are stored instead of numerical IDs - */ - id: t.union([ENTITY_PROTOTYPE_ID, t.string]), - refCode: t.string, - }), - t.partial({ - cardinality: t.union([t.literal('1-1'), t.literal('0-N')]), - /** - * @deprecated - * There are records in database that have - * this typo "cadinality", instead of "cardinality" - * - * TODO: Rename this property to "cardinality" in DB, then, - * drop this definition and make "cardinality" required - */ - cadinality: t.union([t.literal('1-1'), t.literal('0-N')]), - }), - ]) + t.type({ + id: ENTITY_PROTOTYPE_ID, + refCode: t.string, + cardinality: t.union([t.literal('1-1'), t.literal('0-N')]), + }) ); export const ENTITY_PROTOTYPE_VALUE = t.intersection([