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.

781 lines (759 loc) • 23.7 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 { Access, Access$inboundSchema, Access$Outbound, Access$outboundSchema, } from "./access.js"; import { DependentExperimentRep, DependentExperimentRep$inboundSchema, DependentExperimentRep$Outbound, DependentExperimentRep$outboundSchema, } from "./dependentexperimentrep.js"; import { DependentMetricGroupRep, DependentMetricGroupRep$inboundSchema, DependentMetricGroupRep$Outbound, DependentMetricGroupRep$outboundSchema, } from "./dependentmetricgrouprep.js"; import { Filter, Filter$inboundSchema, Filter$Outbound, Filter$outboundSchema, } from "./filter.js"; import { FlagListingRep, FlagListingRep$inboundSchema, FlagListingRep$Outbound, FlagListingRep$outboundSchema, } from "./flaglistingrep.js"; import { Link, Link$inboundSchema, Link$Outbound, Link$outboundSchema, } from "./link.js"; import { MemberSummary, MemberSummary$inboundSchema, MemberSummary$Outbound, MemberSummary$outboundSchema, } from "./membersummary.js"; import { MetricDataSourceRefRep, MetricDataSourceRefRep$inboundSchema, MetricDataSourceRefRep$Outbound, MetricDataSourceRefRep$outboundSchema, } from "./metricdatasourcerefrep.js"; import { MetricDenominatorRep, MetricDenominatorRep$inboundSchema, MetricDenominatorRep$Outbound, MetricDenominatorRep$outboundSchema, } from "./metricdenominatorrep.js"; import { MetricEventDefaultRep, MetricEventDefaultRep$inboundSchema, MetricEventDefaultRep$Outbound, MetricEventDefaultRep$outboundSchema, } from "./metriceventdefaultrep.js"; import { Modification, Modification$inboundSchema, Modification$Outbound, Modification$outboundSchema, } from "./modification.js"; /** * The kind of event the metric tracks */ export const MetricRepKind = { Pageview: "pageview", Click: "click", Custom: "custom", Trace: "trace", } as const; /** * The kind of event the metric tracks */ export type MetricRepKind = ClosedEnum<typeof MetricRepKind>; /** * For custom and trace metrics, the success criteria */ export const MetricRepSuccessCriteria = { HigherThanBaseline: "HigherThanBaseline", LowerThanBaseline: "LowerThanBaseline", } as const; /** * For custom and trace metrics, the success criteria */ export type MetricRepSuccessCriteria = ClosedEnum< typeof MetricRepSuccessCriteria >; /** * The method by which multiple unit event values are aggregated */ export const MetricRepUnitAggregationType = { Average: "average", Sum: "sum", CountDistinct: "count_distinct", } as const; /** * The method by which multiple unit event values are aggregated */ export type MetricRepUnitAggregationType = ClosedEnum< typeof MetricRepUnitAggregationType >; /** * The method for analyzing metric events */ export const MetricRepAnalysisType = { Mean: "mean", Percentile: "percentile", } as const; /** * The method for analyzing metric events */ export type MetricRepAnalysisType = ClosedEnum<typeof MetricRepAnalysisType>; /** * The most recent experiment that used this metric */ export type LastUsedInExperiment = { /** * The experiment key */ key: string; /** * The experiment name */ name: string; /** * The environment ID */ environmentId: string; /** * The environment key */ environmentKey: string; creationDate: number; archivedDate?: number | undefined; /** * The location and content type of related resources */ links: { [k: string]: Link }; }; /** * The most recent guarded rollout that used this metric */ export type LastUsedInGuardedRollout = { /** * The guarded rollout release phase ID */ id: string; /** * The guarded rollout flag key */ flagKey: string; /** * The guarded rollout flag name */ flagName: string; /** * The guarded rollout flag purpose */ flagPurpose?: string | undefined; /** * The guarded rollout environment key */ environmentKey: string; /** * The guarded rollout environment name */ environmentName: string; /** * The guarded rollout status */ status: string; creationDate: number; /** * The location and content type of related resources */ links: { [k: string]: Link }; }; export type MetricRep = { /** * The number of experiments using this metric */ experimentCount?: number | undefined; /** * The number of metric groups using this metric */ metricGroupCount?: number | undefined; /** * The number of active experiments using this metric */ activeExperimentCount?: number | undefined; /** * The number of active guarded rollouts using this metric */ activeGuardedRolloutCount?: number | undefined; /** * The ID of this metric */ id: string; /** * The version ID of the metric */ versionId: string; /** * Version of the metric */ version?: number | undefined; /** * A unique key to reference the metric */ key: string; /** * A human-friendly name for the metric */ name: string; /** * The kind of event the metric tracks */ kind: MetricRepKind; /** * The number of feature flags currently attached to this metric */ attachedFlagCount?: number | undefined; /** * The location and content type of related resources */ links: { [k: string]: Link }; site?: Link | undefined; access?: Access | undefined; /** * Tags for the metric */ tags: Array<string>; creationDate: number; lastModified?: Modification | undefined; /** * The ID of the member who maintains this metric */ maintainerId?: string | undefined; maintainer?: MemberSummary | undefined; /** * Description of the metric */ description?: string | undefined; /** * The category of the metric */ category?: string | undefined; /** * For custom and trace 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; /** * For custom and trace metrics, the success criteria */ successCriteria?: MetricRepSuccessCriteria | undefined; /** * For numeric custom and trace metrics, the unit of measure */ unit?: string | undefined; /** * For custom metrics, the event key to use in your code */ eventKey?: 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; filters?: Filter | undefined; /** * The method by which multiple unit event values are aggregated */ unitAggregationType?: MetricRepUnitAggregationType | undefined; /** * The method for analyzing metric events */ analysisType?: MetricRepAnalysisType | undefined; /** * The percentile for the analysis method. An integer denoting the target percentile between 0 and 100. Required when <code>analysisType</code> is <code>percentile</code>. */ percentileValue?: number | undefined; eventDefault?: MetricEventDefaultRep | undefined; dataSource: MetricDataSourceRefRep; lastSeen?: number | undefined; /** * Whether the metric version is archived */ archived?: boolean | undefined; archivedAt?: number | undefined; /** * For click metrics, the CSS selectors */ selector?: string | undefined; urls?: Array<{ [k: string]: any }> | undefined; /** * Not yet implemented - The start of the measurement window, in milliseconds relative to the unit's first exposure to a flag variation */ windowStartOffset?: number | undefined; /** * Not yet implemented - The end of the measurement window, in milliseconds relative to the unit's first exposure to a flag variation */ windowEndOffset?: number | undefined; /** * Lower winsorization percentile, expressed as a percent in the open interval (0, 100). When both bounds are set, defines a two-sided clamp range. Otherwise lower-only winsorization. */ winsorLowerPercentile?: number | undefined; /** * Upper winsorization percentile, expressed as a percent in the open interval (0, 100). When both bounds are set, must be greater than winsorLowerPercentile. */ winsorUpperPercentile?: number | undefined; /** * When true, the percentile bound calculation includes imputed zeros. Only meaningful when at least one bound is set and the metric includes units that didn't send events. */ winsorIncludeImputed?: boolean | undefined; /** * For trace metrics, the trace query to use for the metric. */ traceQuery?: string | undefined; /** * For trace metrics, the location in the trace to use for numeric values. */ traceValueLocation?: string | undefined; /** * For count_distinct metrics, the column to count distinct values of */ unitAggregationField?: string | undefined; denominator?: MetricDenominatorRep | undefined; experiments?: Array<DependentExperimentRep> | undefined; /** * Metric groups that use this metric */ metricGroups?: Array<DependentMetricGroupRep> | undefined; /** * Whether the metric is active */ isActive?: boolean | undefined; /** * Details on the flags attached to this metric */ attachedFeatures?: Array<FlagListingRep> | null | undefined; /** * The most recent experiment that used this metric */ lastUsedInExperiment?: LastUsedInExperiment | null | undefined; /** * The most recent guarded rollout that used this metric */ lastUsedInGuardedRollout?: LastUsedInGuardedRollout | null | undefined; }; /** @internal */ export const MetricRepKind$inboundSchema: z.ZodNativeEnum< typeof MetricRepKind > = z.nativeEnum(MetricRepKind); /** @internal */ export const MetricRepKind$outboundSchema: z.ZodNativeEnum< typeof MetricRepKind > = MetricRepKind$inboundSchema; /** @internal */ export const MetricRepSuccessCriteria$inboundSchema: z.ZodNativeEnum< typeof MetricRepSuccessCriteria > = z.nativeEnum(MetricRepSuccessCriteria); /** @internal */ export const MetricRepSuccessCriteria$outboundSchema: z.ZodNativeEnum< typeof MetricRepSuccessCriteria > = MetricRepSuccessCriteria$inboundSchema; /** @internal */ export const MetricRepUnitAggregationType$inboundSchema: z.ZodNativeEnum< typeof MetricRepUnitAggregationType > = z.nativeEnum(MetricRepUnitAggregationType); /** @internal */ export const MetricRepUnitAggregationType$outboundSchema: z.ZodNativeEnum< typeof MetricRepUnitAggregationType > = MetricRepUnitAggregationType$inboundSchema; /** @internal */ export const MetricRepAnalysisType$inboundSchema: z.ZodNativeEnum< typeof MetricRepAnalysisType > = z.nativeEnum(MetricRepAnalysisType); /** @internal */ export const MetricRepAnalysisType$outboundSchema: z.ZodNativeEnum< typeof MetricRepAnalysisType > = MetricRepAnalysisType$inboundSchema; /** @internal */ export const LastUsedInExperiment$inboundSchema: z.ZodType< LastUsedInExperiment, z.ZodTypeDef, unknown > = z.object({ key: z.string(), name: z.string(), environmentId: z.string(), environmentKey: z.string(), creationDate: z.number().int(), archivedDate: z.number().int().optional(), _links: z.record(Link$inboundSchema), }).transform((v) => { return remap$(v, { "_links": "links", }); }); /** @internal */ export type LastUsedInExperiment$Outbound = { key: string; name: string; environmentId: string; environmentKey: string; creationDate: number; archivedDate?: number | undefined; _links: { [k: string]: Link$Outbound }; }; /** @internal */ export const LastUsedInExperiment$outboundSchema: z.ZodType< LastUsedInExperiment$Outbound, z.ZodTypeDef, LastUsedInExperiment > = z.object({ key: z.string(), name: z.string(), environmentId: z.string(), environmentKey: z.string(), creationDate: z.number().int(), archivedDate: z.number().int().optional(), links: z.record(Link$outboundSchema), }).transform((v) => { return remap$(v, { links: "_links", }); }); export function lastUsedInExperimentToJSON( lastUsedInExperiment: LastUsedInExperiment, ): string { return JSON.stringify( LastUsedInExperiment$outboundSchema.parse(lastUsedInExperiment), ); } export function lastUsedInExperimentFromJSON( jsonString: string, ): SafeParseResult<LastUsedInExperiment, SDKValidationError> { return safeParse( jsonString, (x) => LastUsedInExperiment$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'LastUsedInExperiment' from JSON`, ); } /** @internal */ export const LastUsedInGuardedRollout$inboundSchema: z.ZodType< LastUsedInGuardedRollout, z.ZodTypeDef, unknown > = z.object({ _id: z.string(), flagKey: z.string(), flagName: z.string(), flagPurpose: z.string().optional(), environmentKey: z.string(), environmentName: z.string(), status: z.string(), creationDate: z.number().int(), _links: z.record(Link$inboundSchema), }).transform((v) => { return remap$(v, { "_id": "id", "_links": "links", }); }); /** @internal */ export type LastUsedInGuardedRollout$Outbound = { _id: string; flagKey: string; flagName: string; flagPurpose?: string | undefined; environmentKey: string; environmentName: string; status: string; creationDate: number; _links: { [k: string]: Link$Outbound }; }; /** @internal */ export const LastUsedInGuardedRollout$outboundSchema: z.ZodType< LastUsedInGuardedRollout$Outbound, z.ZodTypeDef, LastUsedInGuardedRollout > = z.object({ id: z.string(), flagKey: z.string(), flagName: z.string(), flagPurpose: z.string().optional(), environmentKey: z.string(), environmentName: z.string(), status: z.string(), creationDate: z.number().int(), links: z.record(Link$outboundSchema), }).transform((v) => { return remap$(v, { id: "_id", links: "_links", }); }); export function lastUsedInGuardedRolloutToJSON( lastUsedInGuardedRollout: LastUsedInGuardedRollout, ): string { return JSON.stringify( LastUsedInGuardedRollout$outboundSchema.parse(lastUsedInGuardedRollout), ); } export function lastUsedInGuardedRolloutFromJSON( jsonString: string, ): SafeParseResult<LastUsedInGuardedRollout, SDKValidationError> { return safeParse( jsonString, (x) => LastUsedInGuardedRollout$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'LastUsedInGuardedRollout' from JSON`, ); } /** @internal */ export const MetricRep$inboundSchema: z.ZodType< MetricRep, z.ZodTypeDef, unknown > = z.object({ experimentCount: z.number().int().optional(), metricGroupCount: z.number().int().optional(), activeExperimentCount: z.number().int().optional(), activeGuardedRolloutCount: z.number().int().optional(), _id: z.string(), _versionId: z.string(), _version: z.number().int().optional(), key: z.string(), name: z.string(), kind: MetricRepKind$inboundSchema, _attachedFlagCount: z.number().int().optional(), _links: z.record(Link$inboundSchema), _site: Link$inboundSchema.optional(), _access: Access$inboundSchema.optional(), tags: z.array(z.string()), _creationDate: z.number().int(), lastModified: Modification$inboundSchema.optional(), maintainerId: z.string().optional(), _maintainer: MemberSummary$inboundSchema.optional(), description: z.string().optional(), category: z.string().optional(), isNumeric: z.boolean().optional(), successCriteria: MetricRepSuccessCriteria$inboundSchema.optional(), unit: z.string().optional(), eventKey: z.string().optional(), randomizationUnits: z.array(z.string()).optional(), analysisUnits: z.array(z.string()).optional(), filters: Filter$inboundSchema.optional(), unitAggregationType: MetricRepUnitAggregationType$inboundSchema.optional(), analysisType: MetricRepAnalysisType$inboundSchema.optional(), percentileValue: z.number().int().optional(), eventDefault: MetricEventDefaultRep$inboundSchema.optional(), dataSource: MetricDataSourceRefRep$inboundSchema, lastSeen: z.number().int().optional(), archived: z.boolean().optional(), archivedAt: z.number().int().optional(), selector: z.string().optional(), urls: z.array(z.record(z.any())).optional(), windowStartOffset: z.number().int().optional(), windowEndOffset: z.number().int().optional(), winsorLowerPercentile: z.number().optional(), winsorUpperPercentile: z.number().optional(), winsorIncludeImputed: z.boolean().optional(), traceQuery: z.string().optional(), traceValueLocation: z.string().optional(), unitAggregationField: z.string().optional(), denominator: MetricDenominatorRep$inboundSchema.optional(), experiments: z.array(DependentExperimentRep$inboundSchema).optional(), metricGroups: z.array(DependentMetricGroupRep$inboundSchema).optional(), isActive: z.boolean().optional(), _attachedFeatures: z.nullable(z.array(FlagListingRep$inboundSchema)) .optional(), lastUsedInExperiment: z.nullable( z.lazy(() => LastUsedInExperiment$inboundSchema), ).optional(), lastUsedInGuardedRollout: z.nullable( z.lazy(() => LastUsedInGuardedRollout$inboundSchema), ).optional(), }).transform((v) => { return remap$(v, { "_id": "id", "_versionId": "versionId", "_version": "version", "_attachedFlagCount": "attachedFlagCount", "_links": "links", "_site": "site", "_access": "access", "_creationDate": "creationDate", "_maintainer": "maintainer", "_attachedFeatures": "attachedFeatures", }); }); /** @internal */ export type MetricRep$Outbound = { experimentCount?: number | undefined; metricGroupCount?: number | undefined; activeExperimentCount?: number | undefined; activeGuardedRolloutCount?: number | undefined; _id: string; _versionId: string; _version?: number | undefined; key: string; name: string; kind: string; _attachedFlagCount?: number | undefined; _links: { [k: string]: Link$Outbound }; _site?: Link$Outbound | undefined; _access?: Access$Outbound | undefined; tags: Array<string>; _creationDate: number; lastModified?: Modification$Outbound | undefined; maintainerId?: string | undefined; _maintainer?: MemberSummary$Outbound | undefined; description?: string | undefined; category?: string | undefined; isNumeric?: boolean | undefined; successCriteria?: string | undefined; unit?: string | undefined; eventKey?: string | undefined; randomizationUnits?: Array<string> | undefined; analysisUnits?: Array<string> | undefined; filters?: Filter$Outbound | undefined; unitAggregationType?: string | undefined; analysisType?: string | undefined; percentileValue?: number | undefined; eventDefault?: MetricEventDefaultRep$Outbound | undefined; dataSource: MetricDataSourceRefRep$Outbound; lastSeen?: number | undefined; archived?: boolean | undefined; archivedAt?: number | undefined; selector?: string | undefined; urls?: Array<{ [k: string]: any }> | undefined; windowStartOffset?: number | undefined; windowEndOffset?: number | undefined; winsorLowerPercentile?: number | undefined; winsorUpperPercentile?: number | undefined; winsorIncludeImputed?: boolean | undefined; traceQuery?: string | undefined; traceValueLocation?: string | undefined; unitAggregationField?: string | undefined; denominator?: MetricDenominatorRep$Outbound | undefined; experiments?: Array<DependentExperimentRep$Outbound> | undefined; metricGroups?: Array<DependentMetricGroupRep$Outbound> | undefined; isActive?: boolean | undefined; _attachedFeatures?: Array<FlagListingRep$Outbound> | null | undefined; lastUsedInExperiment?: LastUsedInExperiment$Outbound | null | undefined; lastUsedInGuardedRollout?: | LastUsedInGuardedRollout$Outbound | null | undefined; }; /** @internal */ export const MetricRep$outboundSchema: z.ZodType< MetricRep$Outbound, z.ZodTypeDef, MetricRep > = z.object({ experimentCount: z.number().int().optional(), metricGroupCount: z.number().int().optional(), activeExperimentCount: z.number().int().optional(), activeGuardedRolloutCount: z.number().int().optional(), id: z.string(), versionId: z.string(), version: z.number().int().optional(), key: z.string(), name: z.string(), kind: MetricRepKind$outboundSchema, attachedFlagCount: z.number().int().optional(), links: z.record(Link$outboundSchema), site: Link$outboundSchema.optional(), access: Access$outboundSchema.optional(), tags: z.array(z.string()), creationDate: z.number().int(), lastModified: Modification$outboundSchema.optional(), maintainerId: z.string().optional(), maintainer: MemberSummary$outboundSchema.optional(), description: z.string().optional(), category: z.string().optional(), isNumeric: z.boolean().optional(), successCriteria: MetricRepSuccessCriteria$outboundSchema.optional(), unit: z.string().optional(), eventKey: z.string().optional(), randomizationUnits: z.array(z.string()).optional(), analysisUnits: z.array(z.string()).optional(), filters: Filter$outboundSchema.optional(), unitAggregationType: MetricRepUnitAggregationType$outboundSchema.optional(), analysisType: MetricRepAnalysisType$outboundSchema.optional(), percentileValue: z.number().int().optional(), eventDefault: MetricEventDefaultRep$outboundSchema.optional(), dataSource: MetricDataSourceRefRep$outboundSchema, lastSeen: z.number().int().optional(), archived: z.boolean().optional(), archivedAt: z.number().int().optional(), selector: z.string().optional(), urls: z.array(z.record(z.any())).optional(), windowStartOffset: z.number().int().optional(), windowEndOffset: z.number().int().optional(), winsorLowerPercentile: z.number().optional(), winsorUpperPercentile: z.number().optional(), winsorIncludeImputed: z.boolean().optional(), traceQuery: z.string().optional(), traceValueLocation: z.string().optional(), unitAggregationField: z.string().optional(), denominator: MetricDenominatorRep$outboundSchema.optional(), experiments: z.array(DependentExperimentRep$outboundSchema).optional(), metricGroups: z.array(DependentMetricGroupRep$outboundSchema).optional(), isActive: z.boolean().optional(), attachedFeatures: z.nullable(z.array(FlagListingRep$outboundSchema)) .optional(), lastUsedInExperiment: z.nullable( z.lazy(() => LastUsedInExperiment$outboundSchema), ).optional(), lastUsedInGuardedRollout: z.nullable( z.lazy(() => LastUsedInGuardedRollout$outboundSchema), ).optional(), }).transform((v) => { return remap$(v, { id: "_id", versionId: "_versionId", version: "_version", attachedFlagCount: "_attachedFlagCount", links: "_links", site: "_site", access: "_access", creationDate: "_creationDate", maintainer: "_maintainer", attachedFeatures: "_attachedFeatures", }); }); export function metricRepToJSON(metricRep: MetricRep): string { return JSON.stringify(MetricRep$outboundSchema.parse(metricRep)); } export function metricRepFromJSON( jsonString: string, ): SafeParseResult<MetricRep, SDKValidationError> { return safeParse( jsonString, (x) => MetricRep$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'MetricRep' from JSON`, ); }