UNPKG

z-deduper

Version:

This library will allow you to build a Custom Zapier deduper for your advanced polling triggers use cases in your Zapier app.

46 lines (45 loc) 1.16 kB
import { DeduperChanges, PollRecord } from "./interfaces"; import { Storage } from "./storage"; export declare class Deduper { private storage; private changes?; private cache; constructor(storage: Storage); /** * Initialize the deduper * * Note: Should only be called once when the zap is activated */ initialize(currentRecords: PollRecord[]): Promise<boolean>; load(): Promise<boolean>; /** * Find changes * * Compares the current records with the cached record hashes to find * which records are new and which are updated. */ findChanges(currentRecords: PollRecord[]): DeduperChanges; private getTimestamp; /** * Save to the cache * * Note: Should be called after each poll to update the deduper cache. * */ persistChanges(currentRecords: PollRecord[]): Promise<boolean>; /** * Hash a record */ private hash; /** * Convert records into cache records * */ private getRecords; } /** * Get a deduper instance * * @param zapId Zap ID */ export declare function getDeduper(zapId: string): Deduper;