diff --git a/CHANGELOG.md b/CHANGELOG.md index 0567aefb..2be7ce20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Added +- resolveAll to `MineWinsConflictsResolver` to handle an array of conflicts. + ## [6.47.0] - 2024-06-11 ### Added - Add option to save asynchronous cache diff --git a/src/utils/MineWinsConflictsResolver.ts b/src/utils/MineWinsConflictsResolver.ts index 3f994d40..882caec6 100644 --- a/src/utils/MineWinsConflictsResolver.ts +++ b/src/utils/MineWinsConflictsResolver.ts @@ -48,6 +48,20 @@ export class MineWinsConflictsResolver implements ConflictsResolver { }) } + public async resolveAll() { + const conflictsResponse = await this.client.getConflicts>(this.bucket) + const { data: conflicts }: { data: VBaseConflictData[] } = conflictsResponse + + const resolvedConflicts = conflicts.map((conflict) => { + conflict.base.parsedContent = this.parseConflict(conflict.base) + conflict.master.parsedContent = this.parseConflict(conflict.master) + conflict.mine.parsedContent = this.parseConflict(conflict.mine) + return this.resolveConflictMineWins(conflict) + }) + + return resolvedConflicts + } + protected mergeMineWins(base: Configuration, master: Configuration, mine: Configuration) { if (isArray(master)) { return this.mergeMineWinsArray((base || []) as ConfigurationData[], master, (mine || []) as ConfigurationData[])