UNPKG

@vercel/sdk

Version:

<p align="center"> <a href="https://vercel.com"> <img src="https://assets.vercel.com/image/upload/v1588805858/repositories/vercel/logo.png" height="96"> <h3 align="center">Vercel</h3> </a> <p align="center">Develop. Preview. Ship.</p> </p>

199 lines (180 loc) 6.38 kB
/* * 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 { ClosedEnum } from "../types/enums.js"; import { Result as SafeParseResult } from "../types/fp.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; /** * Owner or project scope for the query */ export type CreateObservabilityQueryScope = {}; /** * Direction to order grouped results by. Defaults to desc. */ export const OrderDirection = { Asc: "asc", Desc: "desc", } as const; /** * Direction to order grouped results by. Defaults to desc. */ export type OrderDirection = ClosedEnum<typeof OrderDirection>; /** * Time bucket size */ export type Granularity = {}; export type CreateObservabilityQueryRequestBody = { /** * Metric id */ metric: string; /** * Owner or project scope for the query */ scope: CreateObservabilityQueryScope; /** * Aggregation function to apply. Some aggregations require a dimension: use <agg>/<dimension>, for example unique/visitor_id. */ aggregation?: string | undefined; /** * Dimensions to group results by. JSON dimensions support nested refs, for example event_data/checkout_step. Nested keys containing characters that OData cannot parse as an identifier, such as '-', spaces, quotes, or '/', must be wrapped in single quotes (escape embedded single quotes by doubling them), for example flags/'enable-comments-view' or event_data/'some property''s/value'. */ groupBy?: Array<string> | undefined; /** * Filter to apply to the query. JSON dimensions support nested refs, for example event_data/checkout_step eq 'payment'. Nested keys containing characters that OData cannot parse as an identifier, such as '-', spaces, quotes, or '/', must be wrapped in single quotes (escape embedded single quotes by doubling them), for example flags/'enable-comments-view' eq true or event_data/'some property''s/value' eq true. */ filter?: string | undefined; /** * Maximum number of results */ limit?: number | undefined; /** * Rollup column to order grouped results by. Use the generated rollup key for the requested metric and aggregation. Defaults to the query engine count rollup. */ orderBy?: string | undefined; /** * Direction to order grouped results by. Defaults to desc. */ orderDirection?: OrderDirection | undefined; /** * Time bucket size */ granularity?: Granularity | undefined; /** * Start timestamp */ startTime?: string | undefined; /** * End timestamp */ endTime?: string | undefined; /** * IANA timezone (e.g. Europe/Paris) used only to align calendar buckets (1d/1mo) to that zone's day/month boundaries. startTime/endTime and all output timestamps are always UTC. No effect on sub-day granularities. */ bucketTimezone?: string | undefined; additionalProperties?: { [k: string]: any } | undefined; }; export type CreateObservabilityQueryResponseBody = {}; /** @internal */ export type CreateObservabilityQueryScope$Outbound = {}; /** @internal */ export const CreateObservabilityQueryScope$outboundSchema: z.ZodType< CreateObservabilityQueryScope$Outbound, z.ZodTypeDef, CreateObservabilityQueryScope > = z.object({}); export function createObservabilityQueryScopeToJSON( createObservabilityQueryScope: CreateObservabilityQueryScope, ): string { return JSON.stringify( CreateObservabilityQueryScope$outboundSchema.parse( createObservabilityQueryScope, ), ); } /** @internal */ export const OrderDirection$outboundSchema: z.ZodNativeEnum< typeof OrderDirection > = z.nativeEnum(OrderDirection); /** @internal */ export type Granularity$Outbound = {}; /** @internal */ export const Granularity$outboundSchema: z.ZodType< Granularity$Outbound, z.ZodTypeDef, Granularity > = z.object({}); export function granularityToJSON(granularity: Granularity): string { return JSON.stringify(Granularity$outboundSchema.parse(granularity)); } /** @internal */ export type CreateObservabilityQueryRequestBody$Outbound = { metric: string; scope: CreateObservabilityQueryScope$Outbound; aggregation?: string | undefined; groupBy?: Array<string> | undefined; filter?: string | undefined; limit?: number | undefined; orderBy?: string | undefined; orderDirection?: string | undefined; granularity?: Granularity$Outbound | undefined; startTime?: string | undefined; endTime?: string | undefined; bucketTimezone?: string | undefined; [additionalProperties: string]: unknown; }; /** @internal */ export const CreateObservabilityQueryRequestBody$outboundSchema: z.ZodType< CreateObservabilityQueryRequestBody$Outbound, z.ZodTypeDef, CreateObservabilityQueryRequestBody > = z.object({ metric: z.string(), scope: z.lazy(() => CreateObservabilityQueryScope$outboundSchema), aggregation: z.string().optional(), groupBy: z.array(z.string()).optional(), filter: z.string().optional(), limit: z.number().optional(), orderBy: z.string().optional(), orderDirection: OrderDirection$outboundSchema.optional(), granularity: z.lazy(() => Granularity$outboundSchema).optional(), startTime: z.string().optional(), endTime: z.string().optional(), bucketTimezone: z.string().optional(), additionalProperties: z.record(z.any()).optional(), }).transform((v) => { return { ...v.additionalProperties, ...remap$(v, { additionalProperties: null, }), }; }); export function createObservabilityQueryRequestBodyToJSON( createObservabilityQueryRequestBody: CreateObservabilityQueryRequestBody, ): string { return JSON.stringify( CreateObservabilityQueryRequestBody$outboundSchema.parse( createObservabilityQueryRequestBody, ), ); } /** @internal */ export const CreateObservabilityQueryResponseBody$inboundSchema: z.ZodType< CreateObservabilityQueryResponseBody, z.ZodTypeDef, unknown > = z.object({}); export function createObservabilityQueryResponseBodyFromJSON( jsonString: string, ): SafeParseResult<CreateObservabilityQueryResponseBody, SDKValidationError> { return safeParse( jsonString, (x) => CreateObservabilityQueryResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateObservabilityQueryResponseBody' from JSON`, ); }