/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Current status of the export job */ export const GetExportStatusResponseStatus = { NotFound: "NOT_FOUND", Running: "RUNNING", Completed: "COMPLETED", Failed: "FAILED", Cancelled: "CANCELLED", Terminated: "TERMINATED", ContinuedAsNew: "CONTINUED_AS_NEW", TimedOut: "TIMED_OUT", } as const; /** * Current status of the export job */ export type GetExportStatusResponseStatus = ClosedEnum< typeof GetExportStatusResponseStatus >; /** * Current stage of the export process */ export const GetExportStatusResponseStage = { Starting: "starting", Fetching: "fetching", Converting: "converting", Uploading: "uploading", Completed: "completed", Failed: "failed", } as const; /** * Current stage of the export process */ export type GetExportStatusResponseStage = ClosedEnum< typeof GetExportStatusResponseStage >; /** * Progress information (available when running) */ export type GetExportStatusResponseProgress = { /** * Current stage of the export process */ stage: GetExportStatusResponseStage; /** * Number of records fetched (available after fetching stage) */ recordCount?: number | undefined; /** * Number of completion feedback records */ completionCount?: number | undefined; /** * Number of response feedback records */ responseCount?: number | undefined; /** * Size of parquet file in bytes (available after converting stage) */ parquetBytes?: number | undefined; /** * Human-readable progress message */ message: string; }; /** * Export result (only present when status is COMPLETED) */ export type Result = { /** * Directory containing exported parquet files (S3 prefix or local path) */ outputPath: string; /** * Path to completions parquet file */ completionsFile: string; /** * Path to responses parquet file */ responsesFile: string; /** * Total number of feedback records exported */ recordCount: number; /** * Number of chat completion feedback records exported */ completionFeedbackCount: number; /** * Number of response feedback records exported */ responseFeedbackCount: number; /** * Unix timestamp (ms) when the export was created */ exportedAt: number; /** * Duration of the export in milliseconds */ durationMs: number; }; /** * Response containing the status and progress of the feedback export job. */ export type GetExportStatusResponse = { /** * Current status of the export job */ status: GetExportStatusResponseStatus; /** * When the export job started */ startTime?: Date | undefined; /** * When the export job completed (if finished) */ closeTime?: Date | undefined; /** * Progress information (available when running) */ progress?: GetExportStatusResponseProgress | undefined; /** * Export result (only present when status is COMPLETED) */ result?: Result | undefined; /** * Error message (only present when status is FAILED) */ error?: string | undefined; }; /** @internal */ export const GetExportStatusResponseStatus$inboundSchema: z.ZodNativeEnum< typeof GetExportStatusResponseStatus > = z.nativeEnum(GetExportStatusResponseStatus); /** @internal */ export const GetExportStatusResponseStatus$outboundSchema: z.ZodNativeEnum< typeof GetExportStatusResponseStatus > = GetExportStatusResponseStatus$inboundSchema; /** @internal */ export const GetExportStatusResponseStage$inboundSchema: z.ZodNativeEnum< typeof GetExportStatusResponseStage > = z.nativeEnum(GetExportStatusResponseStage); /** @internal */ export const GetExportStatusResponseStage$outboundSchema: z.ZodNativeEnum< typeof GetExportStatusResponseStage > = GetExportStatusResponseStage$inboundSchema; /** @internal */ export const GetExportStatusResponseProgress$inboundSchema: z.ZodType< GetExportStatusResponseProgress, z.ZodTypeDef, unknown > = z.object({ stage: GetExportStatusResponseStage$inboundSchema, recordCount: z.number().int().optional(), completionCount: z.number().int().optional(), responseCount: z.number().int().optional(), parquetBytes: z.number().int().optional(), message: z.string(), }); /** @internal */ export type GetExportStatusResponseProgress$Outbound = { stage: string; recordCount?: number | undefined; completionCount?: number | undefined; responseCount?: number | undefined; parquetBytes?: number | undefined; message: string; }; /** @internal */ export const GetExportStatusResponseProgress$outboundSchema: z.ZodType< GetExportStatusResponseProgress$Outbound, z.ZodTypeDef, GetExportStatusResponseProgress > = z.object({ stage: GetExportStatusResponseStage$outboundSchema, recordCount: z.number().int().optional(), completionCount: z.number().int().optional(), responseCount: z.number().int().optional(), parquetBytes: z.number().int().optional(), message: z.string(), }); export function getExportStatusResponseProgressToJSON( getExportStatusResponseProgress: GetExportStatusResponseProgress, ): string { return JSON.stringify( GetExportStatusResponseProgress$outboundSchema.parse( getExportStatusResponseProgress, ), ); } export function getExportStatusResponseProgressFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetExportStatusResponseProgress$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetExportStatusResponseProgress' from JSON`, ); } /** @internal */ export const Result$inboundSchema: z.ZodType = z .object({ outputPath: z.string(), completionsFile: z.string(), responsesFile: z.string(), recordCount: z.number().int(), completionFeedbackCount: z.number().int(), responseFeedbackCount: z.number().int(), exportedAt: z.number().int(), durationMs: z.number().int(), }); /** @internal */ export type Result$Outbound = { outputPath: string; completionsFile: string; responsesFile: string; recordCount: number; completionFeedbackCount: number; responseFeedbackCount: number; exportedAt: number; durationMs: number; }; /** @internal */ export const Result$outboundSchema: z.ZodType< Result$Outbound, z.ZodTypeDef, Result > = z.object({ outputPath: z.string(), completionsFile: z.string(), responsesFile: z.string(), recordCount: z.number().int(), completionFeedbackCount: z.number().int(), responseFeedbackCount: z.number().int(), exportedAt: z.number().int(), durationMs: z.number().int(), }); export function resultToJSON(result: Result): string { return JSON.stringify(Result$outboundSchema.parse(result)); } export function resultFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Result$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Result' from JSON`, ); } /** @internal */ export const GetExportStatusResponse$inboundSchema: z.ZodType< GetExportStatusResponse, z.ZodTypeDef, unknown > = z.object({ status: GetExportStatusResponseStatus$inboundSchema, startTime: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), closeTime: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), progress: z.lazy(() => GetExportStatusResponseProgress$inboundSchema) .optional(), result: z.lazy(() => Result$inboundSchema).optional(), error: z.string().optional(), }); /** @internal */ export type GetExportStatusResponse$Outbound = { status: string; startTime?: string | undefined; closeTime?: string | undefined; progress?: GetExportStatusResponseProgress$Outbound | undefined; result?: Result$Outbound | undefined; error?: string | undefined; }; /** @internal */ export const GetExportStatusResponse$outboundSchema: z.ZodType< GetExportStatusResponse$Outbound, z.ZodTypeDef, GetExportStatusResponse > = z.object({ status: GetExportStatusResponseStatus$outboundSchema, startTime: z.date().transform(v => v.toISOString()).optional(), closeTime: z.date().transform(v => v.toISOString()).optional(), progress: z.lazy(() => GetExportStatusResponseProgress$outboundSchema) .optional(), result: z.lazy(() => Result$outboundSchema).optional(), error: z.string().optional(), }); export function getExportStatusResponseToJSON( getExportStatusResponse: GetExportStatusResponse, ): string { return JSON.stringify( GetExportStatusResponse$outboundSchema.parse(getExportStatusResponse), ); } export function getExportStatusResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetExportStatusResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetExportStatusResponse' from JSON`, ); }