/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as types from "../../types/primitives.js"; import { SDKValidationError } from "./sdk-validation-error.js"; export type UsageBreakdownItem = { /** * cost is the cost attributed to this group for the line item */ cost?: string | undefined; /** * event_count is the number of events from this group (optional) */ eventCount?: number | undefined; /** * grouped_by contains the grouping field values (e.g., {"source": "api", "org_id": "org123"}) */ groupedBy?: { [k: string]: string } | undefined; /** * percentage is the percentage of total line item cost from this group (optional) */ percentage?: string | undefined; /** * usage is the total usage amount from this group (optional, for additional context) */ usage?: string | undefined; }; /** @internal */ export const UsageBreakdownItem$inboundSchema: z.ZodMiniType< UsageBreakdownItem, unknown > = z.pipe( z.object({ cost: types.optional(types.string()), event_count: types.optional(types.number()), grouped_by: types.optional(z.record(z.string(), types.string())), percentage: types.optional(types.string()), usage: types.optional(types.string()), }), z.transform((v) => { return remap$(v, { "event_count": "eventCount", "grouped_by": "groupedBy", }); }), ); export function usageBreakdownItemFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => UsageBreakdownItem$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UsageBreakdownItem' from JSON`, ); }