//#region src/utils/entityDiff.ts
const DEFAULT_IGNORED_FIELDS = new Set([
	"tenantId",
	"id",
	"projectId",
	"agentId",
	"createdAt",
	"updatedAt"
]);
function isEntityChanged(incoming, existing, ignoredFields = DEFAULT_IGNORED_FIELDS) {
	for (const key of Object.keys(existing)) {
		if (ignoredFields.has(key)) continue;
		if (!(key in incoming)) continue;
		const incomingVal = incoming[key] ?? null;
		const existingVal = existing[key] ?? null;
		if (typeof incomingVal === "object" || typeof existingVal === "object") {
			if (JSON.stringify(incomingVal) !== JSON.stringify(existingVal)) return true;
		} else if (incomingVal !== existingVal) return true;
	}
	return false;
}

//#endregion
export { isEntityChanged };