Skip to content

Commit

Permalink
refactor: detectedConflict type
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelstroschein committed Oct 30, 2024
1 parent e587e39 commit e0d20a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
6 changes: 2 additions & 4 deletions packages/lix-plugin-csv/src/detectConflicts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import {
getLowestCommonAncestor,
getLeafChange,
type LixPlugin,
type Conflict,
getLeafChangesOnlyInSource,
type DetectedConflict,
} from "@lix-js/sdk";

export const detectConflicts: NonNullable<
LixPlugin["detectConflicts"]
> = async ({ sourceLix, targetLix }) => {
const result: Conflict[] = [];
const result: DetectedConflict[] = [];

const leafChangesOnlyInSource = await getLeafChangesOnlyInSource({
sourceLix,
Expand Down Expand Up @@ -67,8 +67,6 @@ export const detectConflicts: NonNullable<
conflicting_change_id: change.id,
reason:
"The snapshots of the change do not match. More sophisticated reasoning will be added later.",
metadata: null,
resolved_change_id: null,
});
}

Expand Down
15 changes: 8 additions & 7 deletions packages/lix-sdk/src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import type {
Change,
LixFile,
NewConflict,
Snapshot,
} from "./database/schema.js";
import type { Change, LixFile, Snapshot } from "./database/schema.js";
import type { LixReadonly } from "./types.js";

// named lixplugin to avoid conflict with built-in plugin type
Expand Down Expand Up @@ -41,7 +36,7 @@ export type LixPlugin = {
detectConflicts?: (args: {
sourceLix: LixReadonly;
targetLix: LixReadonly;
}) => Promise<NewConflict[]>;
}) => Promise<DetectedConflict[]>;
applyChanges?: (args: {
lix: LixReadonly;
file: LixFile;
Expand Down Expand Up @@ -71,3 +66,9 @@ export type DetectedChange = {
*/
snapshot?: Snapshot["content"];
};

export type DetectedConflict = {
change_id: string;
conflicting_change_id: string;
reason?: string;
};

0 comments on commit e0d20a0

Please sign in to comment.