Skip to content

Commit

Permalink
Merge pull request #776 from techmatters/v1.19-rc-merge
Browse files Browse the repository at this point in the history
V1.19 rc merge
  • Loading branch information
stephenhand authored Nov 11, 2024
2 parents 1a566a3 + 04db2d4 commit afeaec9
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions resources-domain/lambdas/import-producer/src/khpMappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,10 @@ const KHP_MAPPING_NODE_SITES: { children: MappingNode } = {
},
};

const MAX_TAXONOMY_DEPTH = 5;

// TODO: this is an array of arrays, is this shape correct?
const KHP_MAPPING_NODE_TAXONOMIES: { children: MappingNode } = {
const KHP_MAPPING_NODE_TAXONOMIES = (depth: number = 0): { children: MappingNode } => ({
children: {
'{taxonomyIndex}': {
children: {
Expand All @@ -272,6 +274,10 @@ const KHP_MAPPING_NODE_TAXONOMIES: { children: MappingNode } = {
info: ctx => ctx.parentValue,
},
),
...(depth + 1 <= MAX_TAXONOMY_DEPTH
? { ancestors: KHP_MAPPING_NODE_TAXONOMIES(depth + 1) }
: {}),
// Deprecated
ancestorTaxonomies: {
children: {
'{ancestorIndex}': {
Expand Down Expand Up @@ -299,15 +305,20 @@ const KHP_MAPPING_NODE_TAXONOMIES: { children: MappingNode } = {
},
},
},
};
});

export const KHP_MAPPING_NODE: MappingNode = {
_id: resourceFieldMapping('id'),
// TODO: Remove this and all other 'objectId' mappings once the updated Arctic API is deployed to production
objectId: resourceFieldMapping('id'),
timeSequence: resourceFieldMapping('importSequenceId'),
sites: KHP_MAPPING_NODE_SITES,
taxonomies: KHP_MAPPING_NODE_TAXONOMIES,
taxonomies: {
...KHP_MAPPING_NODE_TAXONOMIES(),
children: {
'{topIndex}': KHP_MAPPING_NODE_TAXONOMIES(),
},
},
name: resourceFieldMapping('name', ctx => ctx.currentValue.en || ctx.currentValue.fr),
updatedAt: resourceFieldMapping('lastUpdated'),
createdAt: attributeMapping('dateTimeAttributes', 'sourceCreatedAt'),
Expand Down

0 comments on commit afeaec9

Please sign in to comment.