/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: aa834a68b96c */ import * as z from "zod/v4"; 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"; /** * auto: run immediately. manual: needs customer approval before running. */ export const OperationsPolicyRuleDecision = { Auto: "auto", Manual: "manual", } as const; /** * auto: run immediately. manual: needs customer approval before running. */ export type OperationsPolicyRuleDecision = ClosedEnum< typeof OperationsPolicyRuleDecision >; /** * For a wildcard pattern (`plugin/*` or `*`) only: the highest risk tier a WILDCARD ACCESS REQUEST against this pattern may cover. Null/absent means no wildcard grant above read-only is allowed for this pattern — write and destructive wildcards require an explicit rule setting this field. Ignored for exact `plugin/operation` rules (a named operation's risk is already its own declared tier) and for the auto/manual invoke decision itself. */ export const OperationsPolicyRuleMaxRisk = { ReadOnly: "read-only", Mutating: "mutating", Destructive: "destructive", } as const; /** * For a wildcard pattern (`plugin/*` or `*`) only: the highest risk tier a WILDCARD ACCESS REQUEST against this pattern may cover. Null/absent means no wildcard grant above read-only is allowed for this pattern — write and destructive wildcards require an explicit rule setting this field. Ignored for exact `plugin/operation` rules (a named operation's risk is already its own declared tier) and for the auto/manual invoke decision itself. */ export type OperationsPolicyRuleMaxRisk = ClosedEnum< typeof OperationsPolicyRuleMaxRisk >; export type OperationsPolicyRule = { /** * `plugin/operation`, `plugin/*`, or `*`. */ pattern: string; /** * auto: run immediately. manual: needs customer approval before running. */ decision: OperationsPolicyRuleDecision; /** * For a wildcard pattern (`plugin/*` or `*`) only: the highest risk tier a WILDCARD ACCESS REQUEST against this pattern may cover. Null/absent means no wildcard grant above read-only is allowed for this pattern — write and destructive wildcards require an explicit rule setting this field. Ignored for exact `plugin/operation` rules (a named operation's risk is already its own declared tier) and for the auto/manual invoke decision itself. */ maxRisk?: OperationsPolicyRuleMaxRisk | null | undefined; }; /** @internal */ export const OperationsPolicyRuleDecision$inboundSchema: z.ZodEnum< typeof OperationsPolicyRuleDecision > = z.enum(OperationsPolicyRuleDecision); /** @internal */ export const OperationsPolicyRuleDecision$outboundSchema: z.ZodEnum< typeof OperationsPolicyRuleDecision > = OperationsPolicyRuleDecision$inboundSchema; /** @internal */ export const OperationsPolicyRuleMaxRisk$inboundSchema: z.ZodEnum< typeof OperationsPolicyRuleMaxRisk > = z.enum(OperationsPolicyRuleMaxRisk); /** @internal */ export const OperationsPolicyRuleMaxRisk$outboundSchema: z.ZodEnum< typeof OperationsPolicyRuleMaxRisk > = OperationsPolicyRuleMaxRisk$inboundSchema; /** @internal */ export const OperationsPolicyRule$inboundSchema: z.ZodType< OperationsPolicyRule, unknown > = z.object({ pattern: z.string(), decision: OperationsPolicyRuleDecision$inboundSchema, maxRisk: z.nullable(OperationsPolicyRuleMaxRisk$inboundSchema).optional(), }); /** @internal */ export type OperationsPolicyRule$Outbound = { pattern: string; decision: string; maxRisk?: string | null | undefined; }; /** @internal */ export const OperationsPolicyRule$outboundSchema: z.ZodType< OperationsPolicyRule$Outbound, OperationsPolicyRule > = z.object({ pattern: z.string(), decision: OperationsPolicyRuleDecision$outboundSchema, maxRisk: z.nullable(OperationsPolicyRuleMaxRisk$outboundSchema).optional(), }); export function operationsPolicyRuleToJSON( operationsPolicyRule: OperationsPolicyRule, ): string { return JSON.stringify( OperationsPolicyRule$outboundSchema.parse(operationsPolicyRule), ); } export function operationsPolicyRuleFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => OperationsPolicyRule$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OperationsPolicyRule' from JSON`, ); }