/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; 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"; import { ChunkingStrategy, ChunkingStrategy$inboundSchema, ChunkingStrategy$Outbound, ChunkingStrategy$outboundSchema, } from "./chunkingstrategy.js"; import { VectorStoreFileError, VectorStoreFileError$inboundSchema, VectorStoreFileError$Outbound, VectorStoreFileError$outboundSchema, } from "./vectorstorefileerror.js"; /** * The status of the vector store file. 'in_progress' means currently processing, 'completed' indicates the file is ready for use, 'cancelled' means processing was cancelled, 'failed' means an error occurred. */ export const VectorStoreFileStatus = { InProgress: "in_progress", Completed: "completed", Cancelled: "cancelled", Failed: "failed", } as const; /** * The status of the vector store file. 'in_progress' means currently processing, 'completed' indicates the file is ready for use, 'cancelled' means processing was cancelled, 'failed' means an error occurred. */ export type VectorStoreFileStatus = ClosedEnum; export type VectorStoreFileAttributes = string | boolean | number; /** * A list of files attached to a vector store. */ export type VectorStoreFile = { /** * The identifier, which can be referenced in API endpoints. */ id: string; /** * The object type, which is always 'vector_store.file'. */ object: "vector_store.file"; /** * The total vector store usage in bytes. Note that this may be different from the original file size. */ usageBytes: number; /** * The Unix timestamp (in seconds) for when the vector store file was created. */ createdAt: number; /** * The ID of the vector store that the File is attached to. */ vectorStoreId: string; /** * The name of the underlying file. Extension field not present in the OpenAI API; omitted on create responses. */ filename?: string | undefined; /** * The status of the vector store file. 'in_progress' means currently processing, 'completed' indicates the file is ready for use, 'cancelled' means processing was cancelled, 'failed' means an error occurred. */ status: VectorStoreFileStatus; /** * The last error associated with this vector store file. Will be null if there are no errors. */ lastError: VectorStoreFileError | null; chunkingStrategy?: ChunkingStrategy | undefined; /** * Set of 16 key-value pairs that can be attached to an object. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers. */ attributes?: { [k: string]: string | boolean | number } | undefined; }; /** @internal */ export const VectorStoreFileStatus$inboundSchema: z.ZodNativeEnum< typeof VectorStoreFileStatus > = z.nativeEnum(VectorStoreFileStatus); /** @internal */ export const VectorStoreFileStatus$outboundSchema: z.ZodNativeEnum< typeof VectorStoreFileStatus > = VectorStoreFileStatus$inboundSchema; /** @internal */ export const VectorStoreFileAttributes$inboundSchema: z.ZodType< VectorStoreFileAttributes, z.ZodTypeDef, unknown > = z.union([z.string(), z.boolean(), z.number()]); /** @internal */ export type VectorStoreFileAttributes$Outbound = string | boolean | number; /** @internal */ export const VectorStoreFileAttributes$outboundSchema: z.ZodType< VectorStoreFileAttributes$Outbound, z.ZodTypeDef, VectorStoreFileAttributes > = z.union([z.string(), z.boolean(), z.number()]); export function vectorStoreFileAttributesToJSON( vectorStoreFileAttributes: VectorStoreFileAttributes, ): string { return JSON.stringify( VectorStoreFileAttributes$outboundSchema.parse(vectorStoreFileAttributes), ); } export function vectorStoreFileAttributesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => VectorStoreFileAttributes$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'VectorStoreFileAttributes' from JSON`, ); } /** @internal */ export const VectorStoreFile$inboundSchema: z.ZodType< VectorStoreFile, z.ZodTypeDef, unknown > = z.object({ id: z.string(), object: z.literal("vector_store.file"), usage_bytes: z.number().int(), created_at: z.number().int(), vector_store_id: z.string(), filename: z.string().optional(), status: VectorStoreFileStatus$inboundSchema, last_error: z.nullable(VectorStoreFileError$inboundSchema), chunking_strategy: ChunkingStrategy$inboundSchema.optional(), attributes: z.record(z.union([z.string(), z.boolean(), z.number()])) .optional(), }).transform((v) => { return remap$(v, { "usage_bytes": "usageBytes", "created_at": "createdAt", "vector_store_id": "vectorStoreId", "last_error": "lastError", "chunking_strategy": "chunkingStrategy", }); }); /** @internal */ export type VectorStoreFile$Outbound = { id: string; object: "vector_store.file"; usage_bytes: number; created_at: number; vector_store_id: string; filename?: string | undefined; status: string; last_error: VectorStoreFileError$Outbound | null; chunking_strategy?: ChunkingStrategy$Outbound | undefined; attributes?: { [k: string]: string | boolean | number } | undefined; }; /** @internal */ export const VectorStoreFile$outboundSchema: z.ZodType< VectorStoreFile$Outbound, z.ZodTypeDef, VectorStoreFile > = z.object({ id: z.string(), object: z.literal("vector_store.file"), usageBytes: z.number().int(), createdAt: z.number().int(), vectorStoreId: z.string(), filename: z.string().optional(), status: VectorStoreFileStatus$outboundSchema, lastError: z.nullable(VectorStoreFileError$outboundSchema), chunkingStrategy: ChunkingStrategy$outboundSchema.optional(), attributes: z.record(z.union([z.string(), z.boolean(), z.number()])) .optional(), }).transform((v) => { return remap$(v, { usageBytes: "usage_bytes", createdAt: "created_at", vectorStoreId: "vector_store_id", lastError: "last_error", chunkingStrategy: "chunking_strategy", }); }); export function vectorStoreFileToJSON( vectorStoreFile: VectorStoreFile, ): string { return JSON.stringify(VectorStoreFile$outboundSchema.parse(vectorStoreFile)); } export function vectorStoreFileFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => VectorStoreFile$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'VectorStoreFile' from JSON`, ); }