The API contract requires hasPassword in user responses but it was missing from toUserResponse helper and meAuthStatus handler. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
/**
|
|
* Admin procedure helpers - shared transformation functions
|
|
*/
|
|
|
|
import type { OrgSites, Orgs, Users } from "@reviq/db-schema";
|
|
import type { Selectable } from "kysely";
|
|
|
|
/** Transform org record to API response format */
|
|
export const toOrgResponse = (org: Selectable<Orgs>) => ({
|
|
id: org.id,
|
|
slug: org.slug,
|
|
displayName: org.display_name,
|
|
logoUrl: org.logo_url,
|
|
createdAt: org.created_at,
|
|
});
|
|
|
|
/** Transform user record to API response format */
|
|
export const toUserResponse = (user: Selectable<Users>) => ({
|
|
id: user.id,
|
|
email: user.email,
|
|
displayName: user.display_name,
|
|
fullName: user.full_name,
|
|
phoneNumber: user.phone_number,
|
|
avatarUrl: user.avatar_url,
|
|
emailVerified: user.email_verified_at !== null,
|
|
needsSetup: user.display_name === null,
|
|
isSuperuser: user.is_superuser,
|
|
hasPassword: user.password_hash !== null,
|
|
});
|
|
|
|
/** Transform site record to API response format */
|
|
export const toSiteResponse = (site: Selectable<OrgSites>) => ({
|
|
id: site.id,
|
|
domain: site.domain,
|
|
createdAt: site.created_at,
|
|
});
|