
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
@flatfile/implementation-utils-dedupe-worker
Advanced tools
Provides functionality for easily implementing record deduplication logic.
Provides a job worker for deduping records in a sheet as well as utility functions for deduping records.
deduplicateRecords
: A function for deduping records in a sheet based on specified dedupe keys.getDedupeActionInputForm
: A function for getting the input form for the dedupe action.DedupeJobWorker
: An abstract job worker for deduping records in a sheet, compatible with both @flatfile/safe-api
's FlatfileRecord and the legacy Item
class from the embedded "safe" client.To use the DedupeJobWorker
, you need to create a concrete class that extends it and implements the fetchRecords
and writeRecords
methods. This allows you to define how records are retrieved from and written back to your sheet.
Here's a complete example of how to set up a deduplication action on a sheet.
Create your Dedupe Worker
Create a file, for example my-dedupe.worker.ts
, and define your worker by extending DedupeJobWorker
. This implementation uses @flatfile/safe-api
for easier record handling.
import type { Collection } from "collect.js";
import { DedupeJobWorker } from "@flatfile/dedupe-worker";
import api from "@flatfile/safe-api";
export class MyDedupeWorker extends DedupeJobWorker {
/**
* Fetches all records from the sheet using a stream.
*/
async fetchRecords() {
return await api.records.stream({ sheetId: this.sheetId });
}
/**
* Writes the updated, deleted, and new records back to the sheet.
*/
async writeRecords(records: Collection) {
return await api.records.write({ sheetId: this.sheetId }, records);
}
}
Register the Action on a Sheet
When defining your sheet, add an action with the input form from getDedupeActionInputForm
.
import { getDedupeActionInputForm } from "@flatfile/dedupe-worker";
const mySheetFields = [
{ key: "firstName", type: "string", label: "First Name" },
{ key: "lastName", type: "string", label: "Last Name" },
{ key: "email", type: "string", label: "Email" },
];
export const MY_SHEET = {
name: "My Sheet",
slug: "my-sheet",
fields: mySheetFields,
actions: {
dedupe: {
operation: ACTION_DEDUPE,
label: "Dedupe",
description:
"Dedupe records in this sheet based on the selected field.",
mode: "foreground",
primary: false,
inputForm: getDedupeActionInputForm(mySheetFields),
},
},
};
Register the Listener
In your main listener file (e.g., index.ts
), import your worker and use the worker()
utility from @flatfile/implementation-utils-job-worker
to simplify listener setup.
import { FlatfileListener } from "@flatfile/listener";
import { worker } from "@flatfile/implementation-utils-job-worker";
import { getDedupeActionInputForm } from "@flatfile/dedupe-worker";
import { MyDedupeWorker } from "./my-dedupe.worker";
export default function (listener: FlatfileListener) {
listener.use(worker(MyDedupeWorker));
}
FAQs
Provides functionality for easily implementing record deduplication logic.
The npm package @flatfile/implementation-utils-dedupe-worker receives a total of 33 weekly downloads. As such, @flatfile/implementation-utils-dedupe-worker popularity was classified as not popular.
We found that @flatfile/implementation-utils-dedupe-worker demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 15 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.