UNPKG

@launchdarkly/mcp-server

Version:

The local [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server for [LaunchDarkly](https://launchdarkly.com/) federal and European Union (EU) environments.

231 lines (219 loc) • 6.89 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 "../errors/sdkvalidationerror.js"; import { Link, Link$inboundSchema, Link$Outbound, Link$outboundSchema, } from "./link.js"; /** * The kind of event the metric tracks */ export const MetricInGroupRepKind = { Pageview: "pageview", Click: "click", Custom: "custom", Trace: "trace", } as const; /** * The kind of event the metric tracks */ export type MetricInGroupRepKind = ClosedEnum<typeof MetricInGroupRepKind>; /** * The type of unit aggregation to use for the metric */ export const MetricInGroupRepUnitAggregationType = { Sum: "sum", Average: "average", CountDistinct: "count_distinct", } as const; /** * The type of unit aggregation to use for the metric */ export type MetricInGroupRepUnitAggregationType = ClosedEnum< typeof MetricInGroupRepUnitAggregationType >; /** * The method for analyzing metric events */ export const MetricInGroupRepAnalysisType = { Mean: "mean", Percentile: "percentile", } as const; /** * The method for analyzing metric events */ export type MetricInGroupRepAnalysisType = ClosedEnum< typeof MetricInGroupRepAnalysisType >; export type MetricInGroupRep = { /** * The metric key */ key: string; /** * The version ID of the metric */ versionId?: string | undefined; /** * The metric name */ name: string; /** * The kind of event the metric tracks */ kind: MetricInGroupRepKind; /** * For custom metrics, whether to track numeric changes in value against a baseline (<code>true</code>) or to track a conversion when an end user takes an action (<code>false</code>). */ isNumeric?: boolean | undefined; /** * The type of unit aggregation to use for the metric */ unitAggregationType?: MetricInGroupRepUnitAggregationType | undefined; /** * The method for analyzing metric events */ analysisType?: MetricInGroupRepAnalysisType | undefined; /** * The event key sent with the metric. Only relevant for custom metrics. */ eventKey?: string | undefined; /** * The context kind used as the analysis unit for this metric in the experiment iteration */ analysisUnit?: string | undefined; /** * The location and content type of related resources */ links: { [k: string]: Link }; /** * Name of the metric when used within the associated metric group. Can be different from the original name of the metric. Required if and only if the metric group is a <code>funnel</code>. */ nameInGroup?: string | undefined; /** * Deprecated, use <code>analysisUnits</code> instead. * * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. */ randomizationUnits?: Array<string> | undefined; /** * An array of analysis units allowed for this metric. */ analysisUnits?: Array<string> | undefined; }; /** @internal */ export const MetricInGroupRepKind$inboundSchema: z.ZodNativeEnum< typeof MetricInGroupRepKind > = z.nativeEnum(MetricInGroupRepKind); /** @internal */ export const MetricInGroupRepKind$outboundSchema: z.ZodNativeEnum< typeof MetricInGroupRepKind > = MetricInGroupRepKind$inboundSchema; /** @internal */ export const MetricInGroupRepUnitAggregationType$inboundSchema: z.ZodNativeEnum< typeof MetricInGroupRepUnitAggregationType > = z.nativeEnum(MetricInGroupRepUnitAggregationType); /** @internal */ export const MetricInGroupRepUnitAggregationType$outboundSchema: z.ZodNativeEnum<typeof MetricInGroupRepUnitAggregationType> = MetricInGroupRepUnitAggregationType$inboundSchema; /** @internal */ export const MetricInGroupRepAnalysisType$inboundSchema: z.ZodNativeEnum< typeof MetricInGroupRepAnalysisType > = z.nativeEnum(MetricInGroupRepAnalysisType); /** @internal */ export const MetricInGroupRepAnalysisType$outboundSchema: z.ZodNativeEnum< typeof MetricInGroupRepAnalysisType > = MetricInGroupRepAnalysisType$inboundSchema; /** @internal */ export const MetricInGroupRep$inboundSchema: z.ZodType< MetricInGroupRep, z.ZodTypeDef, unknown > = z.object({ key: z.string(), _versionId: z.string().optional(), name: z.string(), kind: MetricInGroupRepKind$inboundSchema, isNumeric: z.boolean().optional(), unitAggregationType: MetricInGroupRepUnitAggregationType$inboundSchema .optional(), analysisType: MetricInGroupRepAnalysisType$inboundSchema.optional(), eventKey: z.string().optional(), analysisUnit: z.string().optional(), _links: z.record(Link$inboundSchema), nameInGroup: z.string().optional(), randomizationUnits: z.array(z.string()).optional(), analysisUnits: z.array(z.string()).optional(), }).transform((v) => { return remap$(v, { "_versionId": "versionId", "_links": "links", }); }); /** @internal */ export type MetricInGroupRep$Outbound = { key: string; _versionId?: string | undefined; name: string; kind: string; isNumeric?: boolean | undefined; unitAggregationType?: string | undefined; analysisType?: string | undefined; eventKey?: string | undefined; analysisUnit?: string | undefined; _links: { [k: string]: Link$Outbound }; nameInGroup?: string | undefined; randomizationUnits?: Array<string> | undefined; analysisUnits?: Array<string> | undefined; }; /** @internal */ export const MetricInGroupRep$outboundSchema: z.ZodType< MetricInGroupRep$Outbound, z.ZodTypeDef, MetricInGroupRep > = z.object({ key: z.string(), versionId: z.string().optional(), name: z.string(), kind: MetricInGroupRepKind$outboundSchema, isNumeric: z.boolean().optional(), unitAggregationType: MetricInGroupRepUnitAggregationType$outboundSchema .optional(), analysisType: MetricInGroupRepAnalysisType$outboundSchema.optional(), eventKey: z.string().optional(), analysisUnit: z.string().optional(), links: z.record(Link$outboundSchema), nameInGroup: z.string().optional(), randomizationUnits: z.array(z.string()).optional(), analysisUnits: z.array(z.string()).optional(), }).transform((v) => { return remap$(v, { versionId: "_versionId", links: "_links", }); }); export function metricInGroupRepToJSON( metricInGroupRep: MetricInGroupRep, ): string { return JSON.stringify( MetricInGroupRep$outboundSchema.parse(metricInGroupRep), ); } export function metricInGroupRepFromJSON( jsonString: string, ): SafeParseResult<MetricInGroupRep, SDKValidationError> { return safeParse( jsonString, (x) => MetricInGroupRep$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'MetricInGroupRep' from JSON`, ); }