/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; import { safeParse } from "../lib/schemas.js"; import * as openEnums from "../types/enums.js"; import { OpenEnum } from "../types/enums.js"; import { Result as SafeParseResult } from "../types/fp.js"; import * as types from "../types/primitives.js"; import { SDKValidationError } from "./errors/sdk-validation-error.js"; import { QualityBreakdown, QualityBreakdown$inboundSchema, } from "./quality-breakdown.js"; export const Period = { Week: "week", Month: "month", Year: "year", } as const; export type Period = OpenEnum; export type Range = { start: Date; end: Date; }; export type Play = { /** * Bucket start time */ date: string; count: number; }; export type Concurrent = { /** * Bucket start time */ date: string; total: number; /** * Direct play streams */ direct: number; /** * Direct stream (remux) */ directStream: number; transcode: number; }; export type ByDayOfWeek = { /** * 0 = Sunday, 6 = Saturday */ day: number; name: string; count: number; }; export type ByHourOfDay = { /** * 0-23 */ hour: number; count: number; }; export type Platform = { platform: string | null; count: number; }; export type ActivityResponse = { period: Period; range: Range; /** * Play counts bucketed over time. Engagement-based: only sessions >= 2 min. Bucket size is 6 hours for week, 1 day for month/year. */ plays: Array; /** * Peak concurrent streams per time bucket, broken down by playback type. */ concurrent: Array; /** * Play distribution across days of the week. Always 7 entries. */ byDayOfWeek: Array; /** * Play distribution across hours of the day. Always 24 entries. */ byHourOfDay: Array; /** * Session counts by client platform, sorted by count descending. */ platforms: Array; quality: QualityBreakdown; }; /** @internal */ export const Period$inboundSchema: z.ZodMiniType = openEnums .inboundSchema(Period); /** @internal */ export const Range$inboundSchema: z.ZodMiniType = z.object({ start: types.date(), end: types.date(), }); export function rangeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Range$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Range' from JSON`, ); } /** @internal */ export const Play$inboundSchema: z.ZodMiniType = z.object({ date: types.string(), count: types.number(), }); export function playFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Play$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Play' from JSON`, ); } /** @internal */ export const Concurrent$inboundSchema: z.ZodMiniType = z .object({ date: types.string(), total: types.number(), direct: types.number(), directStream: types.number(), transcode: types.number(), }); export function concurrentFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Concurrent$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Concurrent' from JSON`, ); } /** @internal */ export const ByDayOfWeek$inboundSchema: z.ZodMiniType = z .object({ day: types.number(), name: types.string(), count: types.number(), }); export function byDayOfWeekFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ByDayOfWeek$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ByDayOfWeek' from JSON`, ); } /** @internal */ export const ByHourOfDay$inboundSchema: z.ZodMiniType = z .object({ hour: types.number(), count: types.number(), }); export function byHourOfDayFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ByHourOfDay$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ByHourOfDay' from JSON`, ); } /** @internal */ export const Platform$inboundSchema: z.ZodMiniType = z .object({ platform: types.nullable(types.string()), count: types.number(), }); export function platformFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Platform$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Platform' from JSON`, ); } /** @internal */ export const ActivityResponse$inboundSchema: z.ZodMiniType< ActivityResponse, unknown > = z.object({ period: Period$inboundSchema, range: z.lazy(() => Range$inboundSchema), plays: z.array(z.lazy(() => Play$inboundSchema)), concurrent: z.array(z.lazy(() => Concurrent$inboundSchema)), byDayOfWeek: z.array(z.lazy(() => ByDayOfWeek$inboundSchema)), byHourOfDay: z.array(z.lazy(() => ByHourOfDay$inboundSchema)), platforms: z.array(z.lazy(() => Platform$inboundSchema)), quality: QualityBreakdown$inboundSchema, }); export function activityResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ActivityResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ActivityResponse' from JSON`, ); }