File size: 1,300 Bytes
9853396 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | import { z } from 'zod';
import { pageInfoSchema } from '@/gql/pagination';
import { traceConnectionSchema, usageMetadataSchema } from '@/features/traces/data/schema';
const projectSchema = z
.object({
id: z.string(),
name: z.string().nullable().optional(),
})
.nullable()
.optional();
const threadTracesSummarySchema = z
.object({
totalCount: z.number().nullable().optional(),
})
.nullable()
.optional();
export const threadSchema = z.object({
id: z.string(),
threadID: z.string(),
createdAt: z.coerce.date(),
updatedAt: z.coerce.date(),
project: projectSchema,
tracesSummary: threadTracesSummarySchema,
firstUserQuery: z.string().nullable().optional(),
usageMetadata: usageMetadataSchema,
});
export type Thread = z.infer<typeof threadSchema>;
export const threadConnectionSchema = z.object({
edges: z.array(
z.object({
node: threadSchema,
cursor: z.string(),
})
),
pageInfo: pageInfoSchema,
totalCount: z.number(),
});
export type ThreadConnection = z.infer<typeof threadConnectionSchema>;
export const threadDetailSchema = threadSchema.extend({
tracesConnection: traceConnectionSchema.optional(),
});
export type ThreadDetail = z.infer<typeof threadDetailSchema>;
|