fix(api): keep session and birth-row types through next build
Independent Staging Quality Gate / validate (push) Successful in 9m45s
Independent Staging Quality Gate / publish (push) Successful in 10m53s

Transcript limits were collapsing the create schema, and joined profile selects typed as GenericStringError, so Docker next build failed after tests passed.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jesse_Chen
2026-08-19 21:15:33 +08:00
co-authored by Cursor
parent d434aa48ab
commit d7887b03e5
7 changed files with 79 additions and 51 deletions
@@ -34,7 +34,9 @@ const chatSessionWriteObjectSchema = z.object({
updated_at: z.string().datetime(),
}).strict();
function limitTranscriptSize<Schema extends z.ZodType<{ messages: Array<{ text: string }> }>>(schema: Schema) {
function limitTranscriptSize<Output extends { messages: Array<{ text: string }> }>(
schema: z.ZodType<Output>,
): z.ZodType<Output> {
return schema.superRefine((value, context) => {
const totalChars = value.messages.reduce((sum, message) => sum + message.text.length, 0);
if (totalChars > CHAT_SESSION_MAX_TOTAL_MESSAGE_CHARS) {
+22 -13
View File
@@ -2,6 +2,9 @@ import type { GlobalBirthProfile } from "./global-birth-payloads.ts";
const usableActiveStatuses = new Set(["accepted", "confirmed"]);
export const ACCOUNT_BIRTH_SELECT =
"name,birth_date,reported_birth_time,active_birth_time,birth_time,birth_time_status,country_code,province_code,city_code,district_code,latitude,longitude,timezone_offset,timezone_id" as const;
export type AccountBirthRow = Readonly<{
name?: unknown;
birth_date?: unknown;
@@ -19,6 +22,11 @@ export type AccountBirthRow = Readonly<{
timezone_id?: unknown;
}>;
function asAccountBirthRow(row: unknown): AccountBirthRow {
if (!row || typeof row !== "object" || Array.isArray(row)) return {};
return row as AccountBirthRow;
}
function text(value: unknown): string | undefined {
if (typeof value !== "string") return undefined;
const trimmed = value.trim();
@@ -60,22 +68,23 @@ function selectedClock(row: AccountBirthRow): string | undefined {
return reported ?? active;
}
export function globalBirthProfileFromAccountRow(row: AccountBirthRow): GlobalBirthProfile & {
export function globalBirthProfileFromAccountRow(row: unknown): GlobalBirthProfile & {
birthTimeStatus?: string;
} {
const accountRow = asAccountBirthRow(row);
return {
name: text(row.name),
date: calendarDate(row.birth_date),
time: selectedClock(row),
countryCode: text(row.country_code),
provinceCode: text(row.province_code),
cityCode: text(row.city_code),
districtCode: text(row.district_code),
latitude: finiteNumber(row.latitude) ?? null,
longitude: finiteNumber(row.longitude) ?? null,
timezoneOffset: finiteNumber(row.timezone_offset) ?? null,
timezoneId: text(row.timezone_id),
birthTimeStatus: text(row.birth_time_status),
name: text(accountRow.name),
date: calendarDate(accountRow.birth_date),
time: selectedClock(accountRow),
countryCode: text(accountRow.country_code),
provinceCode: text(accountRow.province_code),
cityCode: text(accountRow.city_code),
districtCode: text(accountRow.district_code),
latitude: finiteNumber(accountRow.latitude) ?? null,
longitude: finiteNumber(accountRow.longitude) ?? null,
timezoneOffset: finiteNumber(accountRow.timezone_offset) ?? null,
timezoneId: text(accountRow.timezone_id),
birthTimeStatus: text(accountRow.birth_time_status),
};
}