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..d2e08a81 100644 --- a/src/utils/MineWinsConflictsResolver.ts +++ b/src/utils/MineWinsConflictsResolver.ts @@ -48,6 +48,21 @@ export class MineWinsConflictsResolver implements ConflictsResolver { }) } + public async resolveAll() { + return await this.client.getConflicts>(this.bucket).then((data) => { + const { data: conflicts }: { data: VBaseConflictData[] } = data + + const resolved = 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 resolved as any + }) + } + protected mergeMineWins(base: Configuration, master: Configuration, mine: Configuration) { if (isArray(master)) { return this.mergeMineWinsArray((base || []) as ConfigurationData[], master, (mine || []) as ConfigurationData[])