access.ts•2.13 kB
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
AccessAllowedRep,
AccessAllowedRep$inboundSchema,
AccessAllowedRep$Outbound,
AccessAllowedRep$outboundSchema,
} from "./accessallowedrep.js";
import {
AccessDenied,
AccessDenied$inboundSchema,
AccessDenied$Outbound,
AccessDenied$outboundSchema,
} from "./accessdenied.js";
export type Access = {
denied: Array<AccessDenied>;
allowed: Array<AccessAllowedRep>;
};
/** @internal */
export const Access$inboundSchema: z.ZodType<Access, z.ZodTypeDef, unknown> = z
.object({
denied: z.array(AccessDenied$inboundSchema),
allowed: z.array(AccessAllowedRep$inboundSchema),
});
/** @internal */
export type Access$Outbound = {
denied: Array<AccessDenied$Outbound>;
allowed: Array<AccessAllowedRep$Outbound>;
};
/** @internal */
export const Access$outboundSchema: z.ZodType<
Access$Outbound,
z.ZodTypeDef,
Access
> = z.object({
denied: z.array(AccessDenied$outboundSchema),
allowed: z.array(AccessAllowedRep$outboundSchema),
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace Access$ {
/** @deprecated use `Access$inboundSchema` instead. */
export const inboundSchema = Access$inboundSchema;
/** @deprecated use `Access$outboundSchema` instead. */
export const outboundSchema = Access$outboundSchema;
/** @deprecated use `Access$Outbound` instead. */
export type Outbound = Access$Outbound;
}
export function accessToJSON(access: Access): string {
return JSON.stringify(Access$outboundSchema.parse(access));
}
export function accessFromJSON(
jsonString: string,
): SafeParseResult<Access, SDKValidationError> {
return safeParse(
jsonString,
(x) => Access$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'Access' from JSON`,
);
}