/*
* 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 PeerMetadata = {};
/**
* A Peer is a representation of a node's peer.
*/
export type Peer = {
peerId: string;
metadata?: PeerMetadata | undefined;
};
/** @internal */
export const PeerMetadata$inboundSchema: z.ZodType<
PeerMetadata,
z.ZodTypeDef,
unknown
> = z.object({});
/** @internal */
export type PeerMetadata$Outbound = {};
/** @internal */
export const PeerMetadata$outboundSchema: z.ZodType<
PeerMetadata$Outbound,
z.ZodTypeDef,
PeerMetadata
> = z.object({});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace PeerMetadata$ {
/** @deprecated use `PeerMetadata$inboundSchema` instead. */
export const inboundSchema = PeerMetadata$inboundSchema;
/** @deprecated use `PeerMetadata$outboundSchema` instead. */
export const outboundSchema = PeerMetadata$outboundSchema;
/** @deprecated use `PeerMetadata$Outbound` instead. */
export type Outbound = PeerMetadata$Outbound;
}
export function peerMetadataToJSON(peerMetadata: PeerMetadata): string {
return JSON.stringify(PeerMetadata$outboundSchema.parse(peerMetadata));
}
export function peerMetadataFromJSON(
jsonString: string,
): SafeParseResult<PeerMetadata, SDKValidationError> {
return safeParse(
jsonString,
(x) => PeerMetadata$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'PeerMetadata' from JSON`,
);
}
/** @internal */
export const Peer$inboundSchema: z.ZodType<Peer, z.ZodTypeDef, unknown> = z
.object({
peer_id: z.string(),
metadata: z.lazy(() => PeerMetadata$inboundSchema).optional(),
}).transform((v) => {
return remap$(v, {
"peer_id": "peerId",
});
});
/** @internal */
export type Peer$Outbound = {
peer_id: string;
metadata?: PeerMetadata$Outbound | undefined;
};
/** @internal */
export const Peer$outboundSchema: z.ZodType<Peer$Outbound, z.ZodTypeDef, Peer> =
z.object({
peerId: z.string(),
metadata: z.lazy(() => PeerMetadata$outboundSchema).optional(),
}).transform((v) => {
return remap$(v, {
peerId: "peer_id",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace Peer$ {
/** @deprecated use `Peer$inboundSchema` instead. */
export const inboundSchema = Peer$inboundSchema;
/** @deprecated use `Peer$outboundSchema` instead. */
export const outboundSchema = Peer$outboundSchema;
/** @deprecated use `Peer$Outbound` instead. */
export type Outbound = Peer$Outbound;
}
export function peerToJSON(peer: Peer): string {
return JSON.stringify(Peer$outboundSchema.parse(peer));
}
export function peerFromJSON(
jsonString: string,
): SafeParseResult<Peer, SDKValidationError> {
return safeParse(
jsonString,
(x) => Peer$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'Peer' from JSON`,
);
}