From 0c5b307d9b5c85b9e8c02659d4e045ee4f9e75ec Mon Sep 17 00:00:00 2001 From: Ed R <145260780+era-zx@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:55:00 -0700 Subject: [PATCH 1/2] non-root validation and value whitespace trimming --- .../data_warehouse/etl/type_transformation.ts | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/server/src/domain_objects/data_warehouse/etl/type_transformation.ts b/server/src/domain_objects/data_warehouse/etl/type_transformation.ts index 4eb8b46f6..faef1ad12 100644 --- a/server/src/domain_objects/data_warehouse/etl/type_transformation.ts +++ b/server/src/domain_objects/data_warehouse/etl/type_transformation.ts @@ -413,6 +413,23 @@ export default class TypeTransformation extends BaseDomainClass { let results: Node[] | Edge[] = []; // if no root array, act normally if (!this.root_array) { + let valid = false; + + // no conditions immediately equals true + if (!this.conditions || this.conditions.length === 0) valid = true; + + if (this.conditions) { + for (const condition of this.conditions) { + const isValid = TypeTransformation.validTransformationCondition(condition, data.data as {[key: string]: any}); + if (isValid) { + valid = true; + break; + } + } + } + + // we don't error out on a non-matching condition, simply pass the transformation by + if (!valid) return new Promise((resolve) => resolve(Result.Success([]))); const results = await this.generateResults(data); if (results.isError) { @@ -790,6 +807,7 @@ export default class TypeTransformation extends BaseDomainClass { const value = this.getNestedValue(condition.key!, payload, index); if (!value) return false; + let rootExpressionResult = TypeTransformation.compare(condition.operator!, value, condition.value); // handle subexpressions @@ -823,8 +841,7 @@ export default class TypeTransformation extends BaseDomainClass { } case 'in': { - const expectedValues = expected.split(','); - + const expectedValues = expected.split(',').map((item: string) => item.trim()); //split by comma and trim whitespace return expectedValues.includes(value); } From 8803f7feebc00a3dbe8843b974b4cab4176fe42d Mon Sep 17 00:00:00 2001 From: Ed R <145260780+era-zx@users.noreply.github.com> Date: Thu, 14 Nov 2024 13:11:15 -0700 Subject: [PATCH 2/2] prettier spacing --- .../domain_objects/data_warehouse/etl/type_transformation.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/src/domain_objects/data_warehouse/etl/type_transformation.ts b/server/src/domain_objects/data_warehouse/etl/type_transformation.ts index faef1ad12..ce495fff5 100644 --- a/server/src/domain_objects/data_warehouse/etl/type_transformation.ts +++ b/server/src/domain_objects/data_warehouse/etl/type_transformation.ts @@ -413,6 +413,7 @@ export default class TypeTransformation extends BaseDomainClass { let results: Node[] | Edge[] = []; // if no root array, act normally if (!this.root_array) { + let valid = false; // no conditions immediately equals true @@ -430,6 +431,7 @@ export default class TypeTransformation extends BaseDomainClass { // we don't error out on a non-matching condition, simply pass the transformation by if (!valid) return new Promise((resolve) => resolve(Result.Success([]))); + const results = await this.generateResults(data); if (results.isError) {