/* * 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 { Result as SafeParseResult } from "../types/fp.js"; import { SDKValidationError } from "./errors/sdkvalidationerror.js"; export type Canister = { canisterId: string; ledgerCanisterId: string; canisterType: string; subnetId?: string | undefined; controllers?: Array | undefined; moduleHash?: string | undefined; cycleBalance?: string | undefined; stableMemoryBytes?: string | undefined; updatedAt: string; }; /** @internal */ export const Canister$inboundSchema: z.ZodType< Canister, z.ZodTypeDef, unknown > = z.object({ canister_id: z.string(), ledger_canister_id: z.string(), canister_type: z.string(), subnet_id: z.string().optional(), controllers: z.array(z.string()).optional(), module_hash: z.string().optional(), cycle_balance: z.string().optional(), stable_memory_bytes: z.string().optional(), updated_at: z.string(), }).transform((v) => { return remap$(v, { "canister_id": "canisterId", "ledger_canister_id": "ledgerCanisterId", "canister_type": "canisterType", "subnet_id": "subnetId", "module_hash": "moduleHash", "cycle_balance": "cycleBalance", "stable_memory_bytes": "stableMemoryBytes", "updated_at": "updatedAt", }); }); /** @internal */ export type Canister$Outbound = { canister_id: string; ledger_canister_id: string; canister_type: string; subnet_id?: string | undefined; controllers?: Array | undefined; module_hash?: string | undefined; cycle_balance?: string | undefined; stable_memory_bytes?: string | undefined; updated_at: string; }; /** @internal */ export const Canister$outboundSchema: z.ZodType< Canister$Outbound, z.ZodTypeDef, Canister > = z.object({ canisterId: z.string(), ledgerCanisterId: z.string(), canisterType: z.string(), subnetId: z.string().optional(), controllers: z.array(z.string()).optional(), moduleHash: z.string().optional(), cycleBalance: z.string().optional(), stableMemoryBytes: z.string().optional(), updatedAt: z.string(), }).transform((v) => { return remap$(v, { canisterId: "canister_id", ledgerCanisterId: "ledger_canister_id", canisterType: "canister_type", subnetId: "subnet_id", moduleHash: "module_hash", cycleBalance: "cycle_balance", stableMemoryBytes: "stable_memory_bytes", updatedAt: "updated_at", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Canister$ { /** @deprecated use `Canister$inboundSchema` instead. */ export const inboundSchema = Canister$inboundSchema; /** @deprecated use `Canister$outboundSchema` instead. */ export const outboundSchema = Canister$outboundSchema; /** @deprecated use `Canister$Outbound` instead. */ export type Outbound = Canister$Outbound; } export function canisterToJSON(canister: Canister): string { return JSON.stringify(Canister$outboundSchema.parse(canister)); } export function canisterFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Canister$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Canister' from JSON`, ); }