/* * 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 { EnvironmentMode, EnvironmentMode$inboundSchema, EnvironmentMode$outboundSchema, } from "./environmentmode.js"; import { LicenseStatus, LicenseStatus$inboundSchema, LicenseStatus$outboundSchema, } from "./licensestatus.js"; /** * The status of the license instance. */ export const LicenseEntityStatus = { Active: "active", Deactivated: "deactivated", } as const; /** * The status of the license instance. */ export type LicenseEntityStatus = ClosedEnum; /** * Associated license instances. */ export type Instance = { /** * Unique identifier for the object. */ id: string; /** * String representing the environment. */ mode: EnvironmentMode; /** * A string representing the object’s type. Objects of the same type share the same value. */ object: string; /** * The name of the license instance. */ name: string; /** * The status of the license instance. */ status: LicenseEntityStatus; /** * The creation date of the license instance. */ createdAt: Date; }; export type LicenseEntity = { /** * Unique identifier for the object. */ id: string; /** * String representing the environment. */ mode: EnvironmentMode; /** * A string representing the object’s type. Objects of the same type share the same value. */ object: string; /** * The ID of the product this license belongs to. */ productId: string; /** * The current status of the license key. */ status: LicenseStatus; /** * The license key. */ key: string; /** * The number of instances that this license key was activated. */ activation: number; /** * The activation limit. Null if activations are unlimited. */ activationLimit?: number | null | undefined; /** * The date the license key expires. Null if it does not have an expiration date. */ expiresAt?: Date | null | undefined; /** * The creation date of the license key. */ createdAt: Date; /** * Associated license instances. */ instance?: Instance | null | undefined; }; /** @internal */ export const LicenseEntityStatus$inboundSchema: z.ZodNativeEnum< typeof LicenseEntityStatus > = z.nativeEnum(LicenseEntityStatus); /** @internal */ export const LicenseEntityStatus$outboundSchema: z.ZodNativeEnum< typeof LicenseEntityStatus > = LicenseEntityStatus$inboundSchema; /** @internal */ export const Instance$inboundSchema: z.ZodType< Instance, z.ZodTypeDef, unknown > = z.object({ id: z.string(), mode: EnvironmentMode$inboundSchema, object: z.string(), name: z.string(), status: LicenseEntityStatus$inboundSchema, created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), }).transform((v) => { return remap$(v, { "created_at": "createdAt", }); }); /** @internal */ export type Instance$Outbound = { id: string; mode: string; object: string; name: string; status: string; created_at: string; }; /** @internal */ export const Instance$outboundSchema: z.ZodType< Instance$Outbound, z.ZodTypeDef, Instance > = z.object({ id: z.string(), mode: EnvironmentMode$outboundSchema, object: z.string(), name: z.string(), status: LicenseEntityStatus$outboundSchema, createdAt: z.date().transform(v => v.toISOString()), }).transform((v) => { return remap$(v, { createdAt: "created_at", }); }); export function instanceToJSON(instance: Instance): string { return JSON.stringify(Instance$outboundSchema.parse(instance)); } export function instanceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Instance$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Instance' from JSON`, ); } /** @internal */ export const LicenseEntity$inboundSchema: z.ZodType< LicenseEntity, z.ZodTypeDef, unknown > = z.object({ id: z.string(), mode: EnvironmentMode$inboundSchema, object: z.string(), product_id: z.string(), status: LicenseStatus$inboundSchema, key: z.string(), activation: z.number(), activation_limit: z.nullable(z.number()).optional(), expires_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), instance: z.nullable(z.lazy(() => Instance$inboundSchema)).optional(), }).transform((v) => { return remap$(v, { "product_id": "productId", "activation_limit": "activationLimit", "expires_at": "expiresAt", "created_at": "createdAt", }); }); /** @internal */ export type LicenseEntity$Outbound = { id: string; mode: string; object: string; product_id: string; status: string; key: string; activation: number; activation_limit?: number | null | undefined; expires_at?: string | null | undefined; created_at: string; instance?: Instance$Outbound | null | undefined; }; /** @internal */ export const LicenseEntity$outboundSchema: z.ZodType< LicenseEntity$Outbound, z.ZodTypeDef, LicenseEntity > = z.object({ id: z.string(), mode: EnvironmentMode$outboundSchema, object: z.string(), productId: z.string(), status: LicenseStatus$outboundSchema, key: z.string(), activation: z.number(), activationLimit: z.nullable(z.number()).optional(), expiresAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), createdAt: z.date().transform(v => v.toISOString()), instance: z.nullable(z.lazy(() => Instance$outboundSchema)).optional(), }).transform((v) => { return remap$(v, { productId: "product_id", activationLimit: "activation_limit", expiresAt: "expires_at", createdAt: "created_at", }); }); export function licenseEntityToJSON(licenseEntity: LicenseEntity): string { return JSON.stringify(LicenseEntity$outboundSchema.parse(licenseEntity)); } export function licenseEntityFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => LicenseEntity$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'LicenseEntity' from JSON`, ); }