feat: Rollback fix with suggestion updates #1288
Open
+574
−0
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.
Add atomic rollback operation for failed fixes with suggestion updates
Summary
Adds a new
rollbackFixWithSuggestionUpdates()method toFixEntityCollectionthat atomically rolls back a failed fix and updates all associated suggestions in a single DynamoDB transaction.What Changed
rollbackFixWithSuggestionUpdates()method toFixEntityCollection(lines 283-400)fix-entity/index.d.tsWhy This Change?
This method enables safe, atomic rollback of failed fixes by:
FixEntitystatus fromFAILED→ROLLED_BACKSuggestionentities fromERROR→SKIPPEDThe atomic transaction ensures either all updates succeed or none are applied, preventing partial rollback states that could leave the system in an inconsistent state.
How It Works
The method uses ElectroDB's
transaction.write()to perform the following atomically:FAILEDstatus)ERRORstatus)API Signature
async rollbackFixWithSuggestionUpdates(
fixEntityId: string,
opportunityId: string,
suggestionUpdates: Array<{suggestionId: string}>,
options?: {token?: string}
): Promise<{canceled: boolean, data: any[]}>### Parameters
fixEntityId- The ID of the FixEntity to roll backopportunityId- The ID of the opportunity (required for partition key)suggestionUpdates- Array of objects containingsuggestionIdfor each suggestion to updateoptions.token- Optional client request token for idempotent operations (valid for 10 minutes)Returns
canceled- Boolean indicating if the transaction was canceleddata- Array of transaction item resultsValidation & Error Handling
ValidationErrorfor input validation failuresDataAccessErrorfor transaction failuresVersion Impact
This is a minor version feature addition (backward compatible).
Please ensure your pull request adheres to the following guidelines:
Related Issues
Thanks for contributing!