/* * 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 { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type GetVectorStoresUsageRequest = { startTime: number; endTime?: number | undefined; bucketWidth?: components.BucketWidth | undefined; limit?: number | undefined; page?: string | undefined; userIds?: Array | undefined; externalUserIds?: Array | undefined; allOrgs?: string | undefined; orgIds?: Array | undefined; groupBy?: Array | undefined; /** * Optional external end-user identifier forwarded by the API gateway. */ xOnBehalfOf?: string | undefined; }; export type GetVectorStoresUsageData = { object: "bucket"; /** * Unix timestamp of bucket start (inclusive) */ startTime: number; /** * Unix timestamp of bucket end (exclusive) */ endTime: number; /** * Array of usage results for this time bucket */ results: Array; }; /** * OK */ export type GetVectorStoresUsageResponseBody = { object: "page"; data: Array; /** * Whether there are more pages */ hasMore: boolean; /** * Cursor for next page, null if no more pages */ nextPage: string | null; }; /** @internal */ export const GetVectorStoresUsageRequest$inboundSchema: z.ZodType< GetVectorStoresUsageRequest, z.ZodTypeDef, unknown > = z.object({ start_time: z.number().int(), end_time: z.number().int().optional(), bucket_width: components.BucketWidth$inboundSchema.default("1d"), limit: z.number().int().optional(), page: z.string().optional(), user_ids: z.array(z.string()).optional(), external_user_ids: z.array(z.string()).optional(), all_orgs: z.string().optional(), org_ids: z.array(z.string()).optional(), group_by: z.array(components.VectorStoresGroupBy$inboundSchema).optional(), "X-On-Behalf-Of": z.string().optional(), }).transform((v) => { return remap$(v, { "start_time": "startTime", "end_time": "endTime", "bucket_width": "bucketWidth", "user_ids": "userIds", "external_user_ids": "externalUserIds", "all_orgs": "allOrgs", "org_ids": "orgIds", "group_by": "groupBy", "X-On-Behalf-Of": "xOnBehalfOf", }); }); /** @internal */ export type GetVectorStoresUsageRequest$Outbound = { start_time: number; end_time?: number | undefined; bucket_width: string; limit?: number | undefined; page?: string | undefined; user_ids?: Array | undefined; external_user_ids?: Array | undefined; all_orgs?: string | undefined; org_ids?: Array | undefined; group_by?: Array | undefined; "X-On-Behalf-Of"?: string | undefined; }; /** @internal */ export const GetVectorStoresUsageRequest$outboundSchema: z.ZodType< GetVectorStoresUsageRequest$Outbound, z.ZodTypeDef, GetVectorStoresUsageRequest > = z.object({ startTime: z.number().int(), endTime: z.number().int().optional(), bucketWidth: components.BucketWidth$outboundSchema.default("1d"), limit: z.number().int().optional(), page: z.string().optional(), userIds: z.array(z.string()).optional(), externalUserIds: z.array(z.string()).optional(), allOrgs: z.string().optional(), orgIds: z.array(z.string()).optional(), groupBy: z.array(components.VectorStoresGroupBy$outboundSchema).optional(), xOnBehalfOf: z.string().optional(), }).transform((v) => { return remap$(v, { startTime: "start_time", endTime: "end_time", bucketWidth: "bucket_width", userIds: "user_ids", externalUserIds: "external_user_ids", allOrgs: "all_orgs", orgIds: "org_ids", groupBy: "group_by", xOnBehalfOf: "X-On-Behalf-Of", }); }); export function getVectorStoresUsageRequestToJSON( getVectorStoresUsageRequest: GetVectorStoresUsageRequest, ): string { return JSON.stringify( GetVectorStoresUsageRequest$outboundSchema.parse( getVectorStoresUsageRequest, ), ); } export function getVectorStoresUsageRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetVectorStoresUsageRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetVectorStoresUsageRequest' from JSON`, ); } /** @internal */ export const GetVectorStoresUsageData$inboundSchema: z.ZodType< GetVectorStoresUsageData, z.ZodTypeDef, unknown > = z.object({ object: z.literal("bucket"), start_time: z.number().int(), end_time: z.number().int(), results: z.array(z.nullable(z.any())), }).transform((v) => { return remap$(v, { "start_time": "startTime", "end_time": "endTime", }); }); /** @internal */ export type GetVectorStoresUsageData$Outbound = { object: "bucket"; start_time: number; end_time: number; results: Array; }; /** @internal */ export const GetVectorStoresUsageData$outboundSchema: z.ZodType< GetVectorStoresUsageData$Outbound, z.ZodTypeDef, GetVectorStoresUsageData > = z.object({ object: z.literal("bucket"), startTime: z.number().int(), endTime: z.number().int(), results: z.array(z.nullable(z.any())), }).transform((v) => { return remap$(v, { startTime: "start_time", endTime: "end_time", }); }); export function getVectorStoresUsageDataToJSON( getVectorStoresUsageData: GetVectorStoresUsageData, ): string { return JSON.stringify( GetVectorStoresUsageData$outboundSchema.parse(getVectorStoresUsageData), ); } export function getVectorStoresUsageDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetVectorStoresUsageData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetVectorStoresUsageData' from JSON`, ); } /** @internal */ export const GetVectorStoresUsageResponseBody$inboundSchema: z.ZodType< GetVectorStoresUsageResponseBody, z.ZodTypeDef, unknown > = z.object({ object: z.literal("page"), data: z.array(z.lazy(() => GetVectorStoresUsageData$inboundSchema)), has_more: z.boolean(), next_page: z.nullable(z.string()), }).transform((v) => { return remap$(v, { "has_more": "hasMore", "next_page": "nextPage", }); }); /** @internal */ export type GetVectorStoresUsageResponseBody$Outbound = { object: "page"; data: Array; has_more: boolean; next_page: string | null; }; /** @internal */ export const GetVectorStoresUsageResponseBody$outboundSchema: z.ZodType< GetVectorStoresUsageResponseBody$Outbound, z.ZodTypeDef, GetVectorStoresUsageResponseBody > = z.object({ object: z.literal("page"), data: z.array(z.lazy(() => GetVectorStoresUsageData$outboundSchema)), hasMore: z.boolean(), nextPage: z.nullable(z.string()), }).transform((v) => { return remap$(v, { hasMore: "has_more", nextPage: "next_page", }); }); export function getVectorStoresUsageResponseBodyToJSON( getVectorStoresUsageResponseBody: GetVectorStoresUsageResponseBody, ): string { return JSON.stringify( GetVectorStoresUsageResponseBody$outboundSchema.parse( getVectorStoresUsageResponseBody, ), ); } export function getVectorStoresUsageResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetVectorStoresUsageResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetVectorStoresUsageResponseBody' from JSON`, ); }