import { IntegrationInstance } from './../jupiter-types/integration'; import IntegrationLogger from '../integration/types/IntegrationLogger'; export interface DuplicateDifferences { [property: string]: any[]; } export interface ChangeHandlers { handleCreate: (createdItem: T) => void; handleUpdate: (updatedItem: T, original: T, changedProperties: any) => void; handleDelete: (deletedItem: T) => void; handleSkippedDuplicate: (keptItem: T, duplicateItem: T, differences: DuplicateDifferences) => void; uploadRawData?: (item: T) => string[]; } /** * Identifies differences between two sets of items, delegating processing to * change handler functions. * * When the old dataset includes multiple items having the same _key, the item * having the latest _beginOn will be selected and other items are handled as * deletes. * * When the new dataset includes multiple items having the same _key, * `handleSkippedDuplicate` will be called. */ export default function determineChanges({ integrationInstance, oldDataset, newDataset, patch, eventProperties, handlers: { handleCreate, handleUpdate, handleDelete, handleSkippedDuplicate, uploadRawData, }, logger, }: { integrationInstance: IntegrationInstance; oldDataset: DatasetType[]; newDataset: DatasetType[]; patch?: boolean; eventProperties?: string[]; handlers: ChangeHandlers; logger: IntegrationLogger; }): void;