aiconfigsmetriclistingrep.ts•15.6 kB
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod";
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 {
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",
} as const;
/**
* The kind of event the metric tracks
*/
export type AiConfigsMetricListingRepKind = ClosedEnum<
typeof AiConfigsMetricListingRepKind
>;
/**
* For custom metrics, the success criteria
*/
export const AiConfigsMetricListingRepSuccessCriteria = {
HigherThanBaseline: "HigherThanBaseline",
LowerThanBaseline: "LowerThanBaseline",
} as const;
/**
* For custom 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",
} 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 ID of this metric
*/
id: string;
/**
* The version ID of the metric
*/
versionId: string;
/**
* 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 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 metrics, the success criteria
*/
successCriteria?: AiConfigsMetricListingRepSuccessCriteria | undefined;
/**
* For numeric custom metrics, the unit of measure
*/
unit?: string | undefined;
/**
* For custom metrics, the event key to use in your code
*/
eventKey?: string | undefined;
/**
* An array of randomization units allowed for this metric
*/
randomizationUnits?: 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;
};
/** @internal */
export const AiConfigsMetricListingRepKind$inboundSchema: z.ZodNativeEnum<
typeof AiConfigsMetricListingRepKind
> = z.nativeEnum(AiConfigsMetricListingRepKind);
/** @internal */
export const AiConfigsMetricListingRepKind$outboundSchema: z.ZodNativeEnum<
typeof AiConfigsMetricListingRepKind
> = AiConfigsMetricListingRepKind$inboundSchema;
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace AiConfigsMetricListingRepKind$ {
/** @deprecated use `AiConfigsMetricListingRepKind$inboundSchema` instead. */
export const inboundSchema = AiConfigsMetricListingRepKind$inboundSchema;
/** @deprecated use `AiConfigsMetricListingRepKind$outboundSchema` instead. */
export const outboundSchema = AiConfigsMetricListingRepKind$outboundSchema;
}
/** @internal */
export const AiConfigsMetricListingRepSuccessCriteria$inboundSchema:
z.ZodNativeEnum<typeof AiConfigsMetricListingRepSuccessCriteria> = z
.nativeEnum(AiConfigsMetricListingRepSuccessCriteria);
/** @internal */
export const AiConfigsMetricListingRepSuccessCriteria$outboundSchema:
z.ZodNativeEnum<typeof AiConfigsMetricListingRepSuccessCriteria> =
AiConfigsMetricListingRepSuccessCriteria$inboundSchema;
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace AiConfigsMetricListingRepSuccessCriteria$ {
/** @deprecated use `AiConfigsMetricListingRepSuccessCriteria$inboundSchema` instead. */
export const inboundSchema =
AiConfigsMetricListingRepSuccessCriteria$inboundSchema;
/** @deprecated use `AiConfigsMetricListingRepSuccessCriteria$outboundSchema` instead. */
export const outboundSchema =
AiConfigsMetricListingRepSuccessCriteria$outboundSchema;
}
/** @internal */
export const AiConfigsMetricListingRepUnitAggregationType$inboundSchema:
z.ZodNativeEnum<typeof AiConfigsMetricListingRepUnitAggregationType> = z
.nativeEnum(AiConfigsMetricListingRepUnitAggregationType);
/** @internal */
export const AiConfigsMetricListingRepUnitAggregationType$outboundSchema:
z.ZodNativeEnum<typeof AiConfigsMetricListingRepUnitAggregationType> =
AiConfigsMetricListingRepUnitAggregationType$inboundSchema;
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace AiConfigsMetricListingRepUnitAggregationType$ {
/** @deprecated use `AiConfigsMetricListingRepUnitAggregationType$inboundSchema` instead. */
export const inboundSchema =
AiConfigsMetricListingRepUnitAggregationType$inboundSchema;
/** @deprecated use `AiConfigsMetricListingRepUnitAggregationType$outboundSchema` instead. */
export const outboundSchema =
AiConfigsMetricListingRepUnitAggregationType$outboundSchema;
}
/** @internal */
export const AiConfigsMetricListingRepAnalysisType$inboundSchema:
z.ZodNativeEnum<typeof AiConfigsMetricListingRepAnalysisType> = z.nativeEnum(
AiConfigsMetricListingRepAnalysisType,
);
/** @internal */
export const AiConfigsMetricListingRepAnalysisType$outboundSchema:
z.ZodNativeEnum<typeof AiConfigsMetricListingRepAnalysisType> =
AiConfigsMetricListingRepAnalysisType$inboundSchema;
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace AiConfigsMetricListingRepAnalysisType$ {
/** @deprecated use `AiConfigsMetricListingRepAnalysisType$inboundSchema` instead. */
export const inboundSchema =
AiConfigsMetricListingRepAnalysisType$inboundSchema;
/** @deprecated use `AiConfigsMetricListingRepAnalysisType$outboundSchema` instead. */
export const outboundSchema =
AiConfigsMetricListingRepAnalysisType$outboundSchema;
}
/** @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(),
_id: z.string(),
_versionId: z.string(),
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(),
filters: AiConfigsFilter$inboundSchema.optional(),
unitAggregationType:
AiConfigsMetricListingRepUnitAggregationType$inboundSchema.optional(),
analysisType: AiConfigsMetricListingRepAnalysisType$inboundSchema.optional(),
percentileValue: z.number().int().optional(),
eventDefault: AiConfigsMetricEventDefaultRep$inboundSchema.optional(),
}).transform((v) => {
return remap$(v, {
"_id": "id",
"_versionId": "versionId",
"_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;
_id: string;
_versionId: string;
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;
filters?: AiConfigsFilter$Outbound | undefined;
unitAggregationType?: string | undefined;
analysisType?: string | undefined;
percentileValue?: number | undefined;
eventDefault?: AiConfigsMetricEventDefaultRep$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(),
id: z.string(),
versionId: z.string(),
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(),
filters: AiConfigsFilter$outboundSchema.optional(),
unitAggregationType:
AiConfigsMetricListingRepUnitAggregationType$outboundSchema.optional(),
analysisType: AiConfigsMetricListingRepAnalysisType$outboundSchema.optional(),
percentileValue: z.number().int().optional(),
eventDefault: AiConfigsMetricEventDefaultRep$outboundSchema.optional(),
}).transform((v) => {
return remap$(v, {
id: "_id",
versionId: "_versionId",
attachedFlagCount: "_attachedFlagCount",
links: "_links",
site: "_site",
access: "_access",
creationDate: "_creationDate",
maintainer: "_maintainer",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace AiConfigsMetricListingRep$ {
/** @deprecated use `AiConfigsMetricListingRep$inboundSchema` instead. */
export const inboundSchema = AiConfigsMetricListingRep$inboundSchema;
/** @deprecated use `AiConfigsMetricListingRep$outboundSchema` instead. */
export const outboundSchema = AiConfigsMetricListingRep$outboundSchema;
/** @deprecated use `AiConfigsMetricListingRep$Outbound` instead. */
export type Outbound = AiConfigsMetricListingRep$Outbound;
}
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`,
);
}