Open History to see the last commit
1import type { EnvironmentId, ProjectId, ServerSettings } from "@t3tools/contracts";
2
3export type AutoSettleSettings = Pick<
4 ServerSettings,
5 "sidebarAutoSettleAfterDays" | "sidebarAutoSettleOnMerge"
6>;
7
8interface AutoSettleSyncTarget {
9 readonly environmentId: EnvironmentId;
10 readonly projectId?: ProjectId | null;
11 readonly label: string;
12 readonly settings: AutoSettleSettings | null;
13}
14
15export function planAutoSettleSettingsSync(
16 reference: {
17 readonly environmentId: EnvironmentId;
18 readonly projectId?: ProjectId | null;
19 readonly settings: AutoSettleSettings;
20 },
21 targets: readonly AutoSettleSyncTarget[],
22) {
23 const patch: AutoSettleSettings = {
24 sidebarAutoSettleAfterDays: reference.settings.sidebarAutoSettleAfterDays,
25 sidebarAutoSettleOnMerge: reference.settings.sidebarAutoSettleOnMerge,
26 };
27 const mismatches = targets.filter(
28 (target) =>
29 (target.environmentId !== reference.environmentId ||
30 target.projectId !== reference.projectId) &&
31 target.settings !== null &&
32 (target.settings.sidebarAutoSettleAfterDays !== patch.sidebarAutoSettleAfterDays ||
33 target.settings.sidebarAutoSettleOnMerge !== patch.sidebarAutoSettleOnMerge),
34 );
35 return { patch, mismatches };
36}