@vercel/sdk
Version:
<p align="center"> <a href="https://vercel.com"> <img src="https://assets.vercel.com/image/upload/v1588805858/repositories/vercel/logo.png" height="96"> <h3 align="center">Vercel</h3> </a> <p align="center">Develop. Preview. Ship.</p> </p>
82 lines (75 loc) • 2.81 kB
text/typescript
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod/v3";
import { safeParse } from "../lib/schemas.js";
import { ClosedEnum } from "../types/enums.js";
import { Result as SafeParseResult } from "../types/fp.js";
import * as types from "../types/primitives.js";
import {
SandboxInjectionRule,
SandboxInjectionRule$inboundSchema,
} from "./sandboxinjectionrule.js";
import { SDKValidationError } from "./sdkvalidationerror.js";
/**
* The network policy mode. - 'allow-all': All traffic is allowed. - 'deny-all': All traffic is blocked. - 'custom': Traffic is controlled by explicit allow/deny rules.
*/
export const Mode = {
AllowAll: "allow-all",
Custom: "custom",
DenyAll: "deny-all",
} as const;
/**
* The network policy mode. - 'allow-all': All traffic is allowed. - 'deny-all': All traffic is blocked. - 'custom': Traffic is controlled by explicit allow/deny rules.
*/
export type Mode = ClosedEnum<typeof Mode>;
/**
* The network policy applied to this sandbox, if any.
*/
export type SandboxNetworkPolicy = {
/**
* The network policy mode. - 'allow-all': All traffic is allowed. - 'deny-all': All traffic is blocked. - 'custom': Traffic is controlled by explicit allow/deny rules.
*/
mode: Mode;
/**
* List of domain names the sandbox is allowed to connect to. Supports wildcard patterns (e.g., "*.vercel.com" matches all subdomains).
*/
allowedDomains?: Array<string> | undefined;
/**
* List of IP address ranges (in CIDR notation) the sandbox is allowed to connect to.
*/
allowedCIDRs?: Array<string> | undefined;
/**
* List of IP address ranges (in CIDR notation) the sandbox is blocked from connecting to. These rules take precedence over all allowed rules.
*/
deniedCIDRs?: Array<string> | undefined;
/**
* HTTP header injection rules for outgoing requests matching specific domains.
*/
injectionRules?: Array<SandboxInjectionRule> | undefined;
};
/** @internal */
export const Mode$inboundSchema: z.ZodNativeEnum<typeof Mode> = z.nativeEnum(
Mode,
);
/** @internal */
export const SandboxNetworkPolicy$inboundSchema: z.ZodType<
SandboxNetworkPolicy,
z.ZodTypeDef,
unknown
> = z.object({
mode: Mode$inboundSchema,
allowedDomains: types.optional(z.array(types.string())),
allowedCIDRs: types.optional(z.array(types.string())),
deniedCIDRs: types.optional(z.array(types.string())),
injectionRules: types.optional(z.array(SandboxInjectionRule$inboundSchema)),
});
export function sandboxNetworkPolicyFromJSON(
jsonString: string,
): SafeParseResult<SandboxNetworkPolicy, SDKValidationError> {
return safeParse(
jsonString,
(x) => SandboxNetworkPolicy$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'SandboxNetworkPolicy' from JSON`,
);
}