/* * 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 { MeterAggregation, MeterAggregation$inboundSchema, } from "./meter-aggregation.js"; import { MeterFilter, MeterFilter$inboundSchema } from "./meter-filter.js"; import { ResetUsage, ResetUsage$inboundSchema } from "./reset-usage.js"; import { SDKValidationError } from "./sdk-validation-error.js"; import { Status, Status$inboundSchema } from "./status.js"; export type MeterMeter = { aggregation?: MeterAggregation | undefined; createdAt?: Date | undefined; createdBy?: string | undefined; /** * EnvironmentID is the environment identifier for the meter */ environmentId?: string | undefined; /** * EventName is the unique identifier for the event that this meter is tracking * * @remarks * It is a mandatory field in the events table and hence being used as the primary matching field * We can have multiple meters tracking the same event but with different filters and aggregation */ eventName?: string | undefined; /** * Filters define the criteria for the meter to be applied on the events before aggregation * * @remarks * It also defines the possible values on which later the charges will be applied */ filters?: Array | undefined; /** * ID is the unique identifier for the meter */ id?: string | undefined; /** * Name is the display name of the meter */ name?: string | undefined; resetUsage?: ResetUsage | undefined; status?: Status | undefined; tenantId?: string | undefined; updatedAt?: Date | undefined; updatedBy?: string | undefined; }; /** @internal */ export const MeterMeter$inboundSchema: z.ZodMiniType = z .pipe( z.object({ aggregation: types.optional(MeterAggregation$inboundSchema), created_at: types.optional(types.date()), created_by: types.optional(types.string()), environment_id: types.optional(types.string()), event_name: types.optional(types.string()), filters: types.optional(z.array(MeterFilter$inboundSchema)), id: types.optional(types.string()), name: types.optional(types.string()), reset_usage: types.optional(ResetUsage$inboundSchema), status: types.optional(Status$inboundSchema), tenant_id: types.optional(types.string()), updated_at: types.optional(types.date()), updated_by: types.optional(types.string()), }), z.transform((v) => { return remap$(v, { "created_at": "createdAt", "created_by": "createdBy", "environment_id": "environmentId", "event_name": "eventName", "reset_usage": "resetUsage", "tenant_id": "tenantId", "updated_at": "updatedAt", "updated_by": "updatedBy", }); }), ); export function meterMeterFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => MeterMeter$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'MeterMeter' from JSON`, ); }