@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.
533 lines (519 loc) • 18.6 kB
text/typescript
/*
* 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 {
AiConfigsAccess,
AiConfigsAccess$inboundSchema,
AiConfigsAccess$Outbound,
AiConfigsAccess$outboundSchema,
} from "./aiconfigsaccess.js";
import {
AiConfigsFilter,
AiConfigsFilter$inboundSchema,
AiConfigsFilter$Outbound,
AiConfigsFilter$outboundSchema,
} from "./aiconfigsfilter.js";
import {
AiConfigsLink,
AiConfigsLink$inboundSchema,
AiConfigsLink$Outbound,
AiConfigsLink$outboundSchema,
} from "./aiconfigslink.js";
import {
AiConfigsMemberSummary,
AiConfigsMemberSummary$inboundSchema,
AiConfigsMemberSummary$Outbound,
AiConfigsMemberSummary$outboundSchema,
} from "./aiconfigsmembersummary.js";
import {
AiConfigsMetricDataSourceRefRep,
AiConfigsMetricDataSourceRefRep$inboundSchema,
AiConfigsMetricDataSourceRefRep$Outbound,
AiConfigsMetricDataSourceRefRep$outboundSchema,
} from "./aiconfigsmetricdatasourcerefrep.js";
import {
AiConfigsMetricDenominatorRep,
AiConfigsMetricDenominatorRep$inboundSchema,
AiConfigsMetricDenominatorRep$Outbound,
AiConfigsMetricDenominatorRep$outboundSchema,
} from "./aiconfigsmetricdenominatorrep.js";
import {
AiConfigsMetricEventDefaultRep,
AiConfigsMetricEventDefaultRep$inboundSchema,
AiConfigsMetricEventDefaultRep$Outbound,
AiConfigsMetricEventDefaultRep$outboundSchema,
} from "./aiconfigsmetriceventdefaultrep.js";
import {
AiConfigsModification,
AiConfigsModification$inboundSchema,
AiConfigsModification$Outbound,
AiConfigsModification$outboundSchema,
} from "./aiconfigsmodification.js";
/**
* The kind of event the metric tracks
*/
export const AiConfigsMetricListingRepKind = {
Pageview: "pageview",
Click: "click",
Custom: "custom",
Trace: "trace",
} as const;
/**
* The kind of event the metric tracks
*/
export type AiConfigsMetricListingRepKind = ClosedEnum<
typeof AiConfigsMetricListingRepKind
>;
/**
* For custom and trace metrics, the success criteria
*/
export const AiConfigsMetricListingRepSuccessCriteria = {
HigherThanBaseline: "HigherThanBaseline",
LowerThanBaseline: "LowerThanBaseline",
} as const;
/**
* For custom and trace metrics, the success criteria
*/
export type AiConfigsMetricListingRepSuccessCriteria = ClosedEnum<
typeof AiConfigsMetricListingRepSuccessCriteria
>;
/**
* The method by which multiple unit event values are aggregated
*/
export const AiConfigsMetricListingRepUnitAggregationType = {
Average: "average",
Sum: "sum",
CountDistinct: "count_distinct",
} as const;
/**
* The method by which multiple unit event values are aggregated
*/
export type AiConfigsMetricListingRepUnitAggregationType = ClosedEnum<
typeof AiConfigsMetricListingRepUnitAggregationType
>;
/**
* The method for analyzing metric events
*/
export const AiConfigsMetricListingRepAnalysisType = {
Mean: "mean",
Percentile: "percentile",
} as const;
/**
* The method for analyzing metric events
*/
export type AiConfigsMetricListingRepAnalysisType = ClosedEnum<
typeof AiConfigsMetricListingRepAnalysisType
>;
export type AiConfigsMetricListingRep = {
/**
* The number of experiments using this metric
*/
experimentCount?: number | undefined;
/**
* The number of metric groups using this metric
*/
metricGroupCount?: number | undefined;
/**
* The number of guarded rollouts using this metric
*/
guardedRolloutCount?: number | undefined;
/**
* The number of release policies using this metric
*/
releasePolicyCount?: 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: AiConfigsMetricListingRepKind;
/**
* The number of feature flags currently attached to this metric
*/
attachedFlagCount?: number | undefined;
/**
* The location and content type of related resources
*/
links: { [k: string]: AiConfigsLink };
site?: AiConfigsLink | undefined;
access?: AiConfigsAccess | undefined;
/**
* Tags for the metric
*/
tags: Array<string>;
creationDate: number;
lastModified?: AiConfigsModification | undefined;
/**
* The ID of the member who maintains this metric
*/
maintainerId?: string | undefined;
maintainer?: AiConfigsMemberSummary | 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?: AiConfigsMetricListingRepSuccessCriteria | 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?: AiConfigsFilter | undefined;
/**
* The method by which multiple unit event values are aggregated
*/
unitAggregationType?:
| AiConfigsMetricListingRepUnitAggregationType
| undefined;
/**
* The method for analyzing metric events
*/
analysisType?: AiConfigsMetricListingRepAnalysisType | 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?: AiConfigsMetricEventDefaultRep | undefined;
dataSource: AiConfigsMetricDataSourceRefRep;
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?: AiConfigsMetricDenominatorRep | undefined;
};
/** @internal */
export const AiConfigsMetricListingRepKind$inboundSchema: z.ZodNativeEnum<
typeof AiConfigsMetricListingRepKind
> = z.nativeEnum(AiConfigsMetricListingRepKind);
/** @internal */
export const AiConfigsMetricListingRepKind$outboundSchema: z.ZodNativeEnum<
typeof AiConfigsMetricListingRepKind
> = AiConfigsMetricListingRepKind$inboundSchema;
/** @internal */
export const AiConfigsMetricListingRepSuccessCriteria$inboundSchema:
z.ZodNativeEnum<typeof AiConfigsMetricListingRepSuccessCriteria> = z
.nativeEnum(AiConfigsMetricListingRepSuccessCriteria);
/** @internal */
export const AiConfigsMetricListingRepSuccessCriteria$outboundSchema:
z.ZodNativeEnum<typeof AiConfigsMetricListingRepSuccessCriteria> =
AiConfigsMetricListingRepSuccessCriteria$inboundSchema;
/** @internal */
export const AiConfigsMetricListingRepUnitAggregationType$inboundSchema:
z.ZodNativeEnum<typeof AiConfigsMetricListingRepUnitAggregationType> = z
.nativeEnum(AiConfigsMetricListingRepUnitAggregationType);
/** @internal */
export const AiConfigsMetricListingRepUnitAggregationType$outboundSchema:
z.ZodNativeEnum<typeof AiConfigsMetricListingRepUnitAggregationType> =
AiConfigsMetricListingRepUnitAggregationType$inboundSchema;
/** @internal */
export const AiConfigsMetricListingRepAnalysisType$inboundSchema:
z.ZodNativeEnum<typeof AiConfigsMetricListingRepAnalysisType> = z.nativeEnum(
AiConfigsMetricListingRepAnalysisType,
);
/** @internal */
export const AiConfigsMetricListingRepAnalysisType$outboundSchema:
z.ZodNativeEnum<typeof AiConfigsMetricListingRepAnalysisType> =
AiConfigsMetricListingRepAnalysisType$inboundSchema;
/** @internal */
export const AiConfigsMetricListingRep$inboundSchema: z.ZodType<
AiConfigsMetricListingRep,
z.ZodTypeDef,
unknown
> = z.object({
experimentCount: z.number().int().optional(),
metricGroupCount: z.number().int().optional(),
guardedRolloutCount: z.number().int().optional(),
releasePolicyCount: 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: AiConfigsMetricListingRepKind$inboundSchema,
_attachedFlagCount: z.number().int().optional(),
_links: z.record(AiConfigsLink$inboundSchema),
_site: AiConfigsLink$inboundSchema.optional(),
_access: AiConfigsAccess$inboundSchema.optional(),
tags: z.array(z.string()),
_creationDate: z.number().int(),
lastModified: AiConfigsModification$inboundSchema.optional(),
maintainerId: z.string().optional(),
_maintainer: AiConfigsMemberSummary$inboundSchema.optional(),
description: z.string().optional(),
category: z.string().optional(),
isNumeric: z.boolean().optional(),
successCriteria: AiConfigsMetricListingRepSuccessCriteria$inboundSchema
.optional(),
unit: z.string().optional(),
eventKey: z.string().optional(),
randomizationUnits: z.array(z.string()).optional(),
analysisUnits: z.array(z.string()).optional(),
filters: AiConfigsFilter$inboundSchema.optional(),
unitAggregationType:
AiConfigsMetricListingRepUnitAggregationType$inboundSchema.optional(),
analysisType: AiConfigsMetricListingRepAnalysisType$inboundSchema.optional(),
percentileValue: z.number().int().optional(),
eventDefault: AiConfigsMetricEventDefaultRep$inboundSchema.optional(),
dataSource: AiConfigsMetricDataSourceRefRep$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: AiConfigsMetricDenominatorRep$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",
});
});
/** @internal */
export type AiConfigsMetricListingRep$Outbound = {
experimentCount?: number | undefined;
metricGroupCount?: number | undefined;
guardedRolloutCount?: number | undefined;
releasePolicyCount?: 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]: AiConfigsLink$Outbound };
_site?: AiConfigsLink$Outbound | undefined;
_access?: AiConfigsAccess$Outbound | undefined;
tags: Array<string>;
_creationDate: number;
lastModified?: AiConfigsModification$Outbound | undefined;
maintainerId?: string | undefined;
_maintainer?: AiConfigsMemberSummary$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?: AiConfigsFilter$Outbound | undefined;
unitAggregationType?: string | undefined;
analysisType?: string | undefined;
percentileValue?: number | undefined;
eventDefault?: AiConfigsMetricEventDefaultRep$Outbound | undefined;
dataSource: AiConfigsMetricDataSourceRefRep$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?: AiConfigsMetricDenominatorRep$Outbound | undefined;
};
/** @internal */
export const AiConfigsMetricListingRep$outboundSchema: z.ZodType<
AiConfigsMetricListingRep$Outbound,
z.ZodTypeDef,
AiConfigsMetricListingRep
> = z.object({
experimentCount: z.number().int().optional(),
metricGroupCount: z.number().int().optional(),
guardedRolloutCount: z.number().int().optional(),
releasePolicyCount: 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: AiConfigsMetricListingRepKind$outboundSchema,
attachedFlagCount: z.number().int().optional(),
links: z.record(AiConfigsLink$outboundSchema),
site: AiConfigsLink$outboundSchema.optional(),
access: AiConfigsAccess$outboundSchema.optional(),
tags: z.array(z.string()),
creationDate: z.number().int(),
lastModified: AiConfigsModification$outboundSchema.optional(),
maintainerId: z.string().optional(),
maintainer: AiConfigsMemberSummary$outboundSchema.optional(),
description: z.string().optional(),
category: z.string().optional(),
isNumeric: z.boolean().optional(),
successCriteria: AiConfigsMetricListingRepSuccessCriteria$outboundSchema
.optional(),
unit: z.string().optional(),
eventKey: z.string().optional(),
randomizationUnits: z.array(z.string()).optional(),
analysisUnits: z.array(z.string()).optional(),
filters: AiConfigsFilter$outboundSchema.optional(),
unitAggregationType:
AiConfigsMetricListingRepUnitAggregationType$outboundSchema.optional(),
analysisType: AiConfigsMetricListingRepAnalysisType$outboundSchema.optional(),
percentileValue: z.number().int().optional(),
eventDefault: AiConfigsMetricEventDefaultRep$outboundSchema.optional(),
dataSource: AiConfigsMetricDataSourceRefRep$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: AiConfigsMetricDenominatorRep$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",
});
});
export function aiConfigsMetricListingRepToJSON(
aiConfigsMetricListingRep: AiConfigsMetricListingRep,
): string {
return JSON.stringify(
AiConfigsMetricListingRep$outboundSchema.parse(aiConfigsMetricListingRep),
);
}
export function aiConfigsMetricListingRepFromJSON(
jsonString: string,
): SafeParseResult<AiConfigsMetricListingRep, SDKValidationError> {
return safeParse(
jsonString,
(x) => AiConfigsMetricListingRep$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'AiConfigsMetricListingRep' from JSON`,
);
}