Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@profullstack/profile",
"version": "0.1.2",
"version": "0.1.3",
"type": "module",
"description": "One user profile for every property: email, first_name, last_name, company_domain, job_title, linkedin_url. Validation, signup form fields, storage on Postgres/Turso/Supabase, HTTP handlers, CSV export, CLI and MCP.",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
csvRow,
} from "./index.js";

const VERSION = "0.1.2";
const VERSION = "0.1.3";

const USAGE = `profile - signup profile fields (${COLUMNS.join(", ")})

Expand Down
8 changes: 7 additions & 1 deletion src/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ export function createProfileHandlers({ store, getUser, required = DEFAULT_REQUI
const input = partial ? body : withEmail(body, user.email);
const result = validateProfile(input, { required, partial });
if (!result.ok) return json({ error: "Some fields need fixing.", errors: result.errors }, 400);
const profile = await store.save(user.id, result.profile);
let profile = await store.save(user.id, result.profile);
// A PATCH that does not mention email still leaves a contact address:
// the account's, and only where the profile has none.
if (!profile.email && user.email) {
const email = validateProfile({ email: user.email }, { required: [], partial: true }).profile.email;
if (email) profile = await store.fillBlanks(user.id, { email });
}
await onSaved?.(profile, user);
return json({ profile, missing: missingFields(profile, required) });
});
Expand Down
1 change: 1 addition & 0 deletions test/store.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ for (const [name, open] of backends) {
assert.ok((await res.json()).errors.linkedin_url);
res = await (await h.PATCH(req("PATCH", { job_title: "CEO" }))).json();
assert.equal(res.profile.job_title, "CEO");
assert.equal(res.profile.email, "eve@acme.com", "PATCH fills a missing email from the account");
res = await h.PUT(req("PUT", { first_name: "Eve" }));
assert.equal(res.status, 400, "PUT needs the required fields");
res = await (await h.PUT(req("PUT", { first_name: "Eve", last_name: "Ng" }))).json();
Expand Down
Loading