Add Support for Partial Exports and Imports #505
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.
This PR enables the library to return partial exports when errors occur during exports and imports. This allows for the CLI to still use the partial exports for exports that were successful. In other words, this PR addresses this issue.
Note that I only updated a few of the export and import functions. There are other export and import functions where we could potentially do this as well, although it's something that would take a lot of time to do (and in some cases it doesn't make sense to do it since all the config gets exported in one REST call, so we wouldn't be able to return partial results in those cases), so I focused on the main ones where it would be important to support this. These include scripts, journeys, idm config, and the full config functions.
Generally, the way it works is to keep an array of errors that occur during exports/imports, and at the end throw a FrodoError with those errors in addition to the partial export object(s). The CLI can then decide when an error occurs if they want to utilize the partial exports when the error is thrown.
To follow the rule for the library, which is that it should always throw when encountering errors, anywhere in the functions I modified where it was printing errors were changed to throw errors instead. There are many other places which are still printing errors throughout the library however, so this is another refactoring change that will need to be made across the whole library in the future.
See my PR in the CLI to see the changes I made there to make it work with the changes in the lib.