added chatResult handling and updated onboarding flow

This commit is contained in:
John Yeo
2025-05-23 16:14:50 +01:00
109 changed files with 1838 additions and 3015 deletions

View File

@@ -0,0 +1,28 @@
import { z } from "zod";
export const ChatFeatureCreditSchema = z.object({
metered_feature_id: z.string().nonempty(),
credit_cost: z.number().gt(0),
});
export const ChatResultFeatureSchema = z.object({
id: z.string(),
name: z.string(),
type: z.enum(["boolean", "single_use", "continuous_use", "credit_system"]),
display: z.object({
singular: z.string(),
plural: z.string(),
}),
credit_schema: z
.array(
z.object({
metered_feature_id: z.string(),
credit_cost: z.number(),
}),
)
.nullish(),
});
export type ChatResultFeature = z.infer<typeof ChatResultFeatureSchema>;

View File

@@ -0,0 +1,17 @@
import { pgTable, text, numeric, jsonb, boolean } from "drizzle-orm/pg-core";
import { ChatResultFeature, ProductV2 } from "@autumn/shared";
import { collatePgColumn } from "../../db/utils.js";
export const chatResults = pgTable("chat_results", {
id: text("id").primaryKey(),
created_at: numeric("created_at"),
data: jsonb("data")
.$type<{
features: ChatResultFeature[];
products: ProductV2[];
}>()
.notNull(),
}).enableRLS();
collatePgColumn(chatResults.id, "C");