mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-10-03 10:13:47 +10:00
fix(web): keep every document in the account export zip
Resume and letter ids are UUIDv7, so their first eight characters are a timestamp. Two documents with the same name created within about a minute got the same path in the "Export everything" zip, and one silently replaced the other. Name each file with the full id instead.
This commit is contained in:
@@ -7,11 +7,12 @@ describe("buildAccountZip", () => {
|
||||
const zip = buildAccountZip({
|
||||
exportedAt: "2026-09-29T00:00:00.000Z",
|
||||
user: { id: "u1", name: "Dana" },
|
||||
// UUIDv7 ids created seconds apart share their leading (timestamp) characters.
|
||||
resumes: [
|
||||
{ id: "resume-aaaaaaaa-1", name: "Product Designer" },
|
||||
{ id: "resume-bbbbbbbb-2", name: "Product Designer" },
|
||||
{ id: "01a0ec71-03e8-77b1-a5e4-ce04be126204", name: "Product Designer" },
|
||||
{ id: "01a0ec71-32c8-728b-b43b-b760a673b825", name: "Product Designer" },
|
||||
],
|
||||
coverLetters: [{ id: "letter-cccccccc", name: "Lumen letter" }],
|
||||
coverLetters: [{ id: "01a0ec71-a410-71da-9156-b347210cf72b", name: "Product Designer" }],
|
||||
applications: [{ id: "app-1", company: "Lumen", role: "Designer" }],
|
||||
} as never);
|
||||
|
||||
@@ -19,9 +20,9 @@ describe("buildAccountZip", () => {
|
||||
expect(Object.keys(files).sort()).toEqual([
|
||||
"account.json",
|
||||
"applications.json",
|
||||
"letters/lumen-letter-letter-c.json",
|
||||
"resumes/product-designer-resume-a.json",
|
||||
"resumes/product-designer-resume-b.json",
|
||||
"letters/product-designer-01a0ec71-a410-71da-9156-b347210cf72b.json",
|
||||
"resumes/product-designer-01a0ec71-03e8-77b1-a5e4-ce04be126204.json",
|
||||
"resumes/product-designer-01a0ec71-32c8-728b-b43b-b760a673b825.json",
|
||||
]);
|
||||
expect(JSON.parse(strFromU8(files["account.json"] as Uint8Array))).toEqual({
|
||||
exportedAt: "2026-09-29T00:00:00.000Z",
|
||||
|
||||
@@ -6,8 +6,8 @@ type AccountExport = RouterOutput["auth"]["exportData"];
|
||||
|
||||
const json = (value: unknown) => strToU8(`${JSON.stringify(value, null, 2)}\n`);
|
||||
|
||||
// The id keeps two documents with the same name apart.
|
||||
const fileName = (name: string, id: string) => `${slugify(name)}-${id.slice(0, 8)}.json`;
|
||||
// The whole id keeps two documents with the same name apart. Ids are UUIDv7, so a prefix is only a timestamp and repeats.
|
||||
const fileName = (name: string, id: string) => `${slugify(name)}-${id}.json`;
|
||||
|
||||
/**
|
||||
* "Export everything": one zip with the account, each resume and letter as its own JSON file, and the applications.
|
||||
|
||||
Reference in New Issue
Block a user