feat(#10706): port lineage manipulation helpers for hierarchy operations#11187
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First bit of the move work, the next operation in #10706 after delete. This one's just groundwork, no endpoint yet. It ports the lineage helpers from cht-conf that the move (and later merge) service will need, so it's only plain functions with tests for now.
These don't exist server-side, so I put them in a new
api/src/services/hierarchy/folder:replace-lineage.jsrewrites a doc'sparent/contactlineage in place. It's got amergeflag for the merge variant too, so this'll cover the merge case later as well.lineage-manipulation.jshascreateLineageFromDocandpluckIdsFromLineage, and re-exports the replace-lineage functions.Couple of things I changed from cht-conf, shout if you'd rather I didn't:
minifyLineagesInDoc. It's basically a copy ofminifyfrom@medic/lineage, which we already have here and does a bit more (recursion guard, data_record cleanup), so the move service will just use that instead of carrying another copy.functiondeclarations to arrow functions to keep eslint happy. cht-conf doesn't have thefunc-stylerule but we do.Changes
api/src/services/hierarchy/replace-lineage.jsapi/src/services/hierarchy/lineage-manipulation.jsapi/tests/mocha/services/hierarchy/replace-lineage.spec.jsapi/tests/mocha/services/hierarchy/lineage-manipulation.spec.jsnpm run unit-api: lint clean, 13 passing.