Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lixdk-206-plugindetectconflicts-should-return-detectedconflict #3197

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
};
Loading