/* * 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 { PointBucket, PointBucket$inboundSchema } from "./point-bucket.js"; import { SDKValidationError } from "./sdk-validation-error.js"; export type UsageAnalyticPoint = { /** * Buckets lists every commitment bucket this (possibly rolled-up) window * * @remarks * overlaps — only populated when BreakdownBucket=true and the line item has * CommitmentTimeBuckets. A coarse window can overlap more than one bucket, and * only partially, so this is a list. Empty when the window touches no bucket. * It is an informational HINT only: the point's single cost/computed_* totals * mix all overlapped buckets and out-of-bucket time and CANNOT be split per * bucket — read bucket_summaries for exact per-bucket cost. */ buckets?: Array | undefined; /** * Commitment breakdown (only populated for windowed commitments) */ computedCommitmentUtilizedAmount?: string | undefined; computedOverageAmount?: string | undefined; computedTrueUpAmount?: string | undefined; /** * Cost is the final cost after discount (Subtotal - Discount) */ cost?: string | undefined; discount?: string | undefined; /** * Number of events in this time window */ eventCount?: number | undefined; subtotal?: string | undefined; timestamp?: string | undefined; usage?: string | undefined; }; /** @internal */ export const UsageAnalyticPoint$inboundSchema: z.ZodMiniType< UsageAnalyticPoint, unknown > = z.pipe( z.object({ buckets: types.optional(z.array(PointBucket$inboundSchema)), computed_commitment_utilized_amount: types.optional(types.string()), computed_overage_amount: types.optional(types.string()), computed_true_up_amount: types.optional(types.string()), cost: types.optional(types.string()), discount: types.optional(types.string()), event_count: types.optional(types.number()), subtotal: types.optional(types.string()), timestamp: types.optional(types.string()), usage: types.optional(types.string()), }), z.transform((v) => { return remap$(v, { "computed_commitment_utilized_amount": "computedCommitmentUtilizedAmount", "computed_overage_amount": "computedOverageAmount", "computed_true_up_amount": "computedTrueUpAmount", "event_count": "eventCount", }); }), ); export function usageAnalyticPointFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => UsageAnalyticPoint$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UsageAnalyticPoint' from JSON`, ); }