A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!
TypeScript agent-skillsaidsh-pluginhacktoberfestjavascriptmcp-serverreactresume-builderself-hostedtypescript
fix: retain submission receipts in account backups
Amruth Pillai88b6efe7c099
diff --git a/apps/mobile/scripts/application-profile.test.mjs b/apps/mobile/scripts/application-profile.test.mjsindex 948cfae2b..714b008c7 100644--- a/apps/mobile/scripts/application-profile.test.mjs+++ b/apps/mobile/scripts/application-profile.test.mjs@@ -273,6 +273,16 @@ test("mobile export cleanup removes account/profile and workspace exports, prese});test("native account export stays bound to its account through fetch and file writing", async () => {+ const utilsRequire = createRequire(new URL("../../../packages/utils/package.json", import.meta.url));+ const fflate = utilsRequire("fflate");+ const slug = load(new URL("../../../packages/utils/src/slug.ts", import.meta.url), {+ "@sindresorhus/slugify": utilsRequire("@sindresorhus/slugify"),+ "unique-names-generator": utilsRequire("unique-names-generator"),+ });+ const accountZip = load(new URL("../../../packages/utils/src/account-zip.ts", import.meta.url), {+ fflate,+ "./slug": slug,+ });for (const switchDuring of ["fetch", "write", "write-cleanup", "unmount", null]) {let scope = "account-A";let mutation;@@ -280,6 +290,7 @@ test("native account export stays bound to its account through fetch and file wrlet deletes = 0;let shares = 0;let unmount;+ let archive;const react = {createElement: () => null,useRef: () => ({ current: null }),@@ -302,8 +313,9 @@ test("native account export stays bound to its account through fetch and file wrPaths: { cache: {} },File: class {exists = true;- async write() {+ async write(bytes) {writes++;+ archive = bytes;if (switchDuring === "write") scope = "account-B";if (switchDuring === "write-cleanup") {scope = "account-B";@@ -324,10 +336,7 @@ test("native account export stays bound to its account through fetch and file wrassert.equal(kind, "data");},},- "@reactive-resume/utils/account-zip": {- buildAccountZip: () => new Uint8Array([80, 75]),- AccountExportLimitError: class extends Error {},- },+ "@reactive-resume/utils/account-zip": accountZip,"@/auth/session": { getAccountScope: () => scope },"@/api/client": {client: {@@ -341,7 +350,20 @@ test("native account export stays bound to its account through fetch and file wrunmount?.();assert.ok(options.signal.aborted);}- return { applicationProfile: { email: "[email protected]" } };+ return {+ exportedAt: "2030-01-02T00:00:00.000Z",+ user: { id: "account-A" },+ resumes: [],+ coverLetters: [],+ career: {},+ aiContentReports: [],+ applicationProfile: { email: "[email protected]" },+ applications: [+ { id: "never-sent", status: "saved", submittedAt: null },+ { id: "sent-then-saved", status: "saved", submittedAt: new Date("2030-01-01T12:00:00.000Z") },+ { id: "older-server", status: "closed" },+ ],+ };},},},@@ -355,5 +377,13 @@ test("native account export stays bound to its account through fetch and file wrassert.equal(writes, switchDuring === "fetch" || switchDuring === "unmount" ? 0 : 1);assert.equal(deletes, switchDuring === "write" ? 1 : 0);assert.equal(shares, switchDuring === null ? 1 : 0);+ if (archive) {+ const files = fflate.unzipSync(archive);+ assert.deepEqual(JSON.parse(fflate.strFromU8(files["applications.json"])), [+ { id: "never-sent", status: "saved", submittedAt: null },+ { id: "sent-then-saved", status: "saved", submittedAt: "2030-01-01T12:00:00.000Z" },+ { id: "older-server", status: "closed" },+ ]);+ }}});diff --git a/apps/web/src/features/settings/account/data.test.tsx b/apps/web/src/features/settings/account/data.test.tsxindex 92c8c3756..b91c50fdc 100644--- a/apps/web/src/features/settings/account/data.test.tsx+++ b/apps/web/src/features/settings/account/data.test.tsx@@ -5,6 +5,7 @@ import { beforeEach, expect, it, vi } from "vite-plus/test";import { i18n } from "@lingui/core";import { I18nProvider } from "@lingui/react";import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import { strFromU8, unzipSync } from "fflate";import { AccountExportLimitError } from "@reactive-resume/utils/account-zip";const remove = vi.hoisted(() => vi.fn());@@ -33,7 +34,11 @@ const backup = {user: { id: "owner" },resumes: [],coverLetters: [],- applications: [],+ applications: [+ { id: "never-sent", status: "saved", submittedAt: null },+ { id: "sent-then-saved", status: "saved", submittedAt: new Date("2030-01-01T12:00:00.000Z") },+ { id: "older-server", status: "closed" },+ ],career: {},aiContentReports: [],uploads: { files: [], skipped: [] },@@ -60,6 +65,13 @@ it("requests owned upload bytes and downloads the shared archive", async () => {await waitFor(() => expect(exported.download).toHaveBeenCalledOnce());expect(exported.request.mock.calls[0]?.[0]).toEqual({ includeUploads: true });expect(exported.request.mock.calls[0]?.[1].context).toEqual({ accountId: "owner" });+ const archive = exported.download.mock.calls[0]?.[0] as Blob;+ const files = unzipSync(new Uint8Array(await archive.arrayBuffer()));+ expect(JSON.parse(strFromU8(files["applications.json"] ?? new Uint8Array()))).toEqual([+ { id: "never-sent", status: "saved", submittedAt: null },+ { id: "sent-then-saved", status: "saved", submittedAt: "2030-01-01T12:00:00.000Z" },+ { id: "older-server", status: "closed" },+ ]);expect(exported.toast).not.toHaveBeenCalled();});diff --git a/docs/guides/exporting-your-data.mdx b/docs/guides/exporting-your-data.mdxindex 5cb31e709..ec29b05f3 100644--- a/docs/guides/exporting-your-data.mdx+++ b/docs/guides/exporting-your-data.mdx@@ -44,7 +44,7 @@ You can download a copy of everything you have stored in Reactive Resume in one| `uploads/` | Stored photo and attachment bytes referenced by exported records, including document history and live conversation attachments, within the limits below. || `upload-manifest.json` | Included storage paths and byte counts, export limits, and the path and reason for each skipped file. |-In `applications.json`, `appliedAt` is filled in even for a job you only saved: it starts as the date you saved it. To tell whether you applied, read `status` and `submittedAt`, which is set the first time a job reaches a sent stage.+In `applications.json`, `appliedAt` is filled in even for a job you only saved: it starts as the date you saved it. `status` is the current stage. `submittedAt` is the first recorded submission time, or `null` when no submission is recorded. It stays set if you later return the job to Saved or close it. This records what you tracked in Reactive Resume; it does not confirm delivery to an employer. Older server exports may omit `submittedAt`; a missing field does not prove that you never applied.`career.json` contains your preferences, facts and their source/correction history, stories, reviewed reusable answers with scope, source and evidence revision references, workspace answers and checklist state, saved results, schedules, notifications, discovered roles, voice transcripts, and career conversations with attachment metadata. Referenced live attachment files are saved separately under `uploads/`. Raw voice recordings are not retained or exported.diff --git a/docs/spec.json b/docs/spec.jsonindex 54dc26c1d..16371ea12 100644--- a/docs/spec.json+++ b/docs/spec.json@@ -44236,6 +44236,19 @@"type": "string","format": "date-time","x-native-type": "date"+ },+ "submittedAt": {+ "anyOf": [+ {+ "type": "string",+ "format": "date-time",+ "x-native-type": "date"+ },+ {+ "type": "null"+ }+ ],+ "description": "First recorded submission time, retained after later stage changes; null when no submission is recorded."}},"required": [@@ -44270,7 +44283,8 @@"activity","appliedAt","createdAt",- "updatedAt"+ "updatedAt",+ "submittedAt"]}},diff --git a/packages/api/src/features/auth/router.ts b/packages/api/src/features/auth/router.tsindex 24cdee436..f4a86bbce 100644--- a/packages/api/src/features/auth/router.ts+++ b/packages/api/src/features/auth/router.ts@@ -351,7 +351,16 @@ export const authRouter = {),}).optional(),- applications: z.array(applicationDto.getById.output),+ applications: z.array(+ applicationDto.getById.output.extend({+ submittedAt: z+ .date()+ .nullable()+ .describe(+ "First recorded submission time, retained after later stage changes; null when no submission is recorded.",+ ),+ }),+ ),applicationPipeline: applicationPipelineSchema,aiContentReports: z.array(createSelectSchema(schema.aiContentReport)),career: z.object({diff --git a/tests/e2e/specs/account-backup.spec.ts b/tests/e2e/specs/account-backup.spec.tsindex 171c3fca5..0735983ce 100644--- a/tests/e2e/specs/account-backup.spec.ts+++ b/tests/e2e/specs/account-backup.spec.ts@@ -1,11 +1,62 @@import type { Route } from "@playwright/test";import { readFile } from "node:fs/promises";import { strFromU8, unzipSync } from "fflate";+import { Pool } from "pg";import { expect, test } from "../fixtures/test";-test("account ZIP carries uploaded photo bytes and history after the source account is deleted", async ({+test("account ZIP carries submission receipts, uploaded bytes and history after account deletion", async ({authPage: page,}, info) => {+ const applicationIds: string[] = [];+ for (const status of ["never-sent", "saved", "closed", "applied"] as const) {+ const response = await page.request.post("/api/openapi/applications", {+ data: { company: `Fictional backup ${status}`, role: "Analyst", status: "saved" },+ });+ await expect(response).toBeOK();+ const applicationId = (await response.json()) as string;+ applicationIds.push(applicationId);+ if (status !== "never-sent") {+ await expect(+ await page.request.put(`/api/openapi/applications/${applicationId}`, { data: { status: "applied" } }),+ ).toBeOK();+ if (status !== "applied")+ await expect(+ await page.request.put(`/api/openapi/applications/${applicationId}`, { data: { status } }),+ ).toBeOK();+ }+ const ordinary = await page.request.get(`/api/openapi/applications/${applicationId}`);+ await expect(ordinary).toBeOK();+ expect(await ordinary.json()).not.toHaveProperty("submittedAt");+ }+ const pool = new Pool({ connectionString: process.env.DATABASE_URL });+ const applications = await (async () => {+ try {+ return (+ await pool.query<{ id: string; status: string; applied_at: Date; submitted_at: Date | null }>(+ "select id, status, applied_at, submitted_at from application where id = any($1::text[])",+ [applicationIds],+ )+ ).rows.map((row) => ({+ id: row.id,+ status: row.status,+ appliedAt: row.applied_at.toISOString(),+ submittedAt: row.submitted_at?.toISOString() ?? null,+ }));+ } finally {+ await pool.end();+ }+ })();+ expect(applications).toHaveLength(4);+ expect(applications.find((row) => row.id === applicationIds[0])?.submittedAt).toBeNull();+ for (const row of applications.filter((row) => row.id !== applicationIds[0])) expect(row.submittedAt).not.toBeNull();+ const jsonExport = await page.request.get("/api/openapi/auth/account/export");+ await expect(jsonExport).toBeOK();+ const exported = await jsonExport.json();+ await info.attach("SQL submission receipts and protected export", {+ body: JSON.stringify({ applications, exported }, null, 2),+ contentType: "application/json",+ });+ for (const row of applications) expect(exported.applications).toContainEqual(expect.objectContaining(row));const created = await page.request.post("/api/openapi/resumes", {data: { name: "Fictional backup resume", tags: [], withSampleData: false },});@@ -54,6 +105,7 @@ test("account ZIP carries uploaded photo bytes and history after the source accoawait saved.saveAs(path);const archive = await readFile(path);const files = unzipSync(archive);+ expect(JSON.parse(strFromU8(files["applications.json"] ?? new Uint8Array()))).toEqual(exported.applications);expect(files[file.path]).toEqual(originalBytes);expect(Object.keys(files).filter((key) => key.startsWith(`versions/resumes/${id}/`)).length).toBeGreaterThanOrEqual(2,