added chatResult handling and updated onboarding flow
This commit is contained in:
28
shared/models/chatResultModels/chatResultFeature.ts
Normal file
28
shared/models/chatResultModels/chatResultFeature.ts
Normal 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>;
|
||||
17
shared/models/chatResultModels/chatResultTable.ts
Normal file
17
shared/models/chatResultModels/chatResultTable.ts
Normal 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");
|
||||
Reference in New Issue
Block a user