fix(api): keep session and birth-row types through next build
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:
@@ -13,7 +13,7 @@ import {
|
||||
import { dailyProfilePayload } from "@/lib/global-birth-payloads";
|
||||
import { loadLanguageModelCatalog } from "@/lib/model-catalog";
|
||||
import { consumeUserRequestRateLimit } from "@/lib/request-rate-limit";
|
||||
import { globalBirthProfileFromAccountRow } from "@/lib/server-owned-birth-profile";
|
||||
import { ACCOUNT_BIRTH_SELECT, globalBirthProfileFromAccountRow } from "@/lib/server-owned-birth-profile";
|
||||
import { createServerSupabaseClient } from "@/lib/supabase/server";
|
||||
import { getDailyStarlanguageAgent } from "@/mastra";
|
||||
|
||||
@@ -22,22 +22,6 @@ export const maxDuration = 20;
|
||||
|
||||
type Profile = ReturnType<typeof globalBirthProfileFromAccountRow>;
|
||||
type BirthPayload = NonNullable<Awaited<ReturnType<typeof dailyProfilePayload>>>;
|
||||
const accountBirthColumns = [
|
||||
"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",
|
||||
].join(",");
|
||||
type CardSource = "engine_evidence" | "agent";
|
||||
type CacheEntry = { readonly day: string; readonly card: DailyStarlanguageCard; readonly source: CardSource };
|
||||
type Generated =
|
||||
@@ -192,7 +176,7 @@ export async function POST(request: Request) {
|
||||
|
||||
const { data: row, error } = await supabase
|
||||
.from("profiles")
|
||||
.select(accountBirthColumns)
|
||||
.select(ACCOUNT_BIRTH_SELECT)
|
||||
.eq("id", user.id)
|
||||
.maybeSingle();
|
||||
if (error || !row) return unavailable("birth_profile_incomplete");
|
||||
|
||||
@@ -3,6 +3,7 @@ import { z } from "zod";
|
||||
import { isProductEnabled } from "@/lib/product-access";
|
||||
import { consumeUserRequestRateLimit } from "@/lib/request-rate-limit";
|
||||
import {
|
||||
ACCOUNT_BIRTH_SELECT,
|
||||
globalBirthProfileFromAccountRow,
|
||||
globalBirthProfileFromStoredChart,
|
||||
} from "@/lib/server-owned-birth-profile";
|
||||
@@ -10,22 +11,6 @@ import { createServerSupabaseClient } from "@/lib/supabase/server";
|
||||
import { synastryBirthPayload } from "@/lib/global-birth-payloads";
|
||||
|
||||
const apiBase = process.env.JYOTISH_API_BASE ?? "http://127.0.0.1:5200";
|
||||
const accountBirthColumns = [
|
||||
"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",
|
||||
].join(",");
|
||||
const synastryRequestSchema = z.object({
|
||||
partnerChartProfileId: z.string().uuid(),
|
||||
relationshipType: z.enum(["romance", "business", "family", "general"]).optional(),
|
||||
@@ -168,7 +153,7 @@ export async function POST(request: Request) {
|
||||
|
||||
const { data: selfRow, error: selfError } = await supabase
|
||||
.from("profiles")
|
||||
.select(accountBirthColumns)
|
||||
.select(ACCOUNT_BIRTH_SELECT)
|
||||
.eq("id", user.id)
|
||||
.maybeSingle();
|
||||
if (selfError || !selfRow) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user