File size: 783 Bytes
e068192
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import fs from "fs/promises";
import path from "path";
import { compareItems } from "../src/core/pipeline.js";
import type { RawProductItem } from "../src/types.js";

const root = process.cwd();
const capturedAt = "2026-04-03T10:00:00.000Z";

const datasetPath = path.join(root, "examples", "sample-dataset.json");
const outPath = path.join(root, "examples", "sample-output.json");

const s = await fs.readFile(datasetPath, "utf-8");
const data = JSON.parse(s) as { items: Omit<RawProductItem, "capturedAt">[] };

const rawItems: RawProductItem[] = data.items.map((x) => ({ ...x, capturedAt }));
const { items } = compareItems(rawItems, { dedupe: "platform" });

await fs.writeFile(outPath, `${JSON.stringify({ items }, null, 2)}\n`, "utf-8");
process.stdout.write(`${outPath}\n`);