/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod";
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";
/**
* Status of the flag
*/
export const Name = {
New: "new",
Inactive: "inactive",
Active: "active",
Launched: "launched",
} as const;
/**
* Status of the flag
*/
export type Name = ClosedEnum<typeof Name>;
export type FeatureFlagStatus = {
/**
* Status of the flag
*/
name: Name;
/**
* Timestamp of last time flag was requested
*/
lastRequested?: Date | null | undefined;
/**
* Default value seen from code
*/
default?: any | undefined;
};
/** @internal */
export const Name$inboundSchema: z.ZodNativeEnum<typeof Name> = z.nativeEnum(
Name,
);
/** @internal */
export const Name$outboundSchema: z.ZodNativeEnum<typeof Name> =
Name$inboundSchema;
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace Name$ {
/** @deprecated use `Name$inboundSchema` instead. */
export const inboundSchema = Name$inboundSchema;
/** @deprecated use `Name$outboundSchema` instead. */
export const outboundSchema = Name$outboundSchema;
}
/** @internal */
export const FeatureFlagStatus$inboundSchema: z.ZodType<
FeatureFlagStatus,
z.ZodTypeDef,
unknown
> = z.object({
name: Name$inboundSchema,
lastRequested: z.nullable(
z.string().datetime({ offset: true }).transform(v => new Date(v)),
).optional(),
default: z.any().optional(),
});
/** @internal */
export type FeatureFlagStatus$Outbound = {
name: string;
lastRequested?: string | null | undefined;
default?: any | undefined;
};
/** @internal */
export const FeatureFlagStatus$outboundSchema: z.ZodType<
FeatureFlagStatus$Outbound,
z.ZodTypeDef,
FeatureFlagStatus
> = z.object({
name: Name$outboundSchema,
lastRequested: z.nullable(z.date().transform(v => v.toISOString()))
.optional(),
default: z.any().optional(),
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace FeatureFlagStatus$ {
/** @deprecated use `FeatureFlagStatus$inboundSchema` instead. */
export const inboundSchema = FeatureFlagStatus$inboundSchema;
/** @deprecated use `FeatureFlagStatus$outboundSchema` instead. */
export const outboundSchema = FeatureFlagStatus$outboundSchema;
/** @deprecated use `FeatureFlagStatus$Outbound` instead. */
export type Outbound = FeatureFlagStatus$Outbound;
}
export function featureFlagStatusToJSON(
featureFlagStatus: FeatureFlagStatus,
): string {
return JSON.stringify(
FeatureFlagStatus$outboundSchema.parse(featureFlagStatus),
);
}
export function featureFlagStatusFromJSON(
jsonString: string,
): SafeParseResult<FeatureFlagStatus, SDKValidationError> {
return safeParse(
jsonString,
(x) => FeatureFlagStatus$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'FeatureFlagStatus' from JSON`,
);
}