From 1c301b1068fdfd491e930bb2c3d5dfe205423ea7 Mon Sep 17 00:00:00 2001 From: Pl217 Date: Mon, 4 Apr 2022 16:18:11 +0200 Subject: [PATCH 1/3] Remove `DISAGGREGATION_MODEL_CREATOR` This should have been done in eefff8562ada71e52d6245ccf89c5d125c5718e9, when `creator` column was removed --- src/db/models/disaggregationModel.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/db/models/disaggregationModel.ts b/src/db/models/disaggregationModel.ts index 891b6e48..14e3a6c2 100644 --- a/src/db/models/disaggregationModel.ts +++ b/src/db/models/disaggregationModel.ts @@ -18,11 +18,6 @@ export const DISAGGREGATION_MODEL_ID = brandedType< DisaggregationModelId >(t.number); -export const DISAGGREGATION_MODEL_CREATOR = t.type({ - participantHidId: t.string, - roles: t.array(t.string), -}); - const LOCATION_INFO = t.intersection([ t.type({ name: t.string }), t.partial({ From 883186c69182a36c2e466fc7b3f046c1b15f1804 Mon Sep 17 00:00:00 2001 From: Pl217 Date: Thu, 31 Mar 2022 14:09:43 +0200 Subject: [PATCH 2/3] HPC-8479: Add strict codec for disaggregation model value --- src/db/models/disaggregationModel.ts | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/db/models/disaggregationModel.ts b/src/db/models/disaggregationModel.ts index 14e3a6c2..3a181d65 100644 --- a/src/db/models/disaggregationModel.ts +++ b/src/db/models/disaggregationModel.ts @@ -31,6 +31,16 @@ const LOCATION_INFO = t.intersection([ }), ]); +/** + * Strict version of `LOCATION_INFO` codec defined above. + * Intended to be used when creating new records, in order + * to enforce stricter type of location ID. + */ +const LOCATION_INFO_STRICT = t.intersection([ + LOCATION_INFO.types[0], + t.partial({ id: LOCATION_ID }), +]); + export const DISAGGREGATION_MODEL_VALUE = t.type({ categories: t.array( t.type({ @@ -45,6 +55,26 @@ export const DISAGGREGATION_MODEL_VALUE = t.type({ status: t.boolean, }); +/** + * Strict version of `DISAGGREGATION_MODEL_VALUE` codec defined above. + * Intended to be used when creating new records, in order to enforce + * stricter type of location ID. + * + * Location ID used to allow for string type, which is why there are + * many records using location's pcode instead of ID. This stricter + * type should be used for validating new records upon creation. + */ +export const DISAGGREGATION_MODEL_VALUE_STRICT = t.type({ + categories: DISAGGREGATION_MODEL_VALUE.props.categories, + status: DISAGGREGATION_MODEL_VALUE.props.status, + locations: t.array( + t.intersection([ + LOCATION_INFO_STRICT, + t.partial({ parent: LOCATION_INFO_STRICT }), + ]) + ), +}); + export default defineIDModel({ tableName: 'disaggregationModel', fields: { From 1f6274222485105a13e04e8edc18a9d0b20cc70b Mon Sep 17 00:00:00 2001 From: Pl217 Date: Thu, 7 Apr 2022 16:36:44 +0200 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=94=96=20Bump=20version=20to=20`v4.2.?= =?UTF-8?q?1`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 66355744..a6eac101 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@unocha/hpc-api-core", - "version": "4.2.0", + "version": "4.2.1", "description": "Core libraries supporting HPC.Tools API Backend", "license": "Apache-2.0", "private": false,