/* * 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 * as components from "../components/index.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ExecutePolicyRequest = { /** * The path separator is used to access values inside object and array documents. If the path indexes into an array, the server will attempt to convert the array index to an integer. If the path element cannot be converted to an integer, the server will respond with 404. */ path?: string | undefined; /** * Indicates the server should respond with a gzip encoded body. The server will send the compressed response only if its length is above `server.encoding.gzip.min_length` value. See the configuration section */ acceptEncoding?: components.GzipAcceptEncoding | undefined; /** * If parameter is `true`, response will formatted for humans. */ pretty?: boolean | undefined; /** * If parameter is true, response will include build/version info in addition to the result. */ provenance?: boolean | undefined; /** * Return query explanation in addition to result. */ explain?: components.Explain | undefined; /** * Return query performance metrics in addition to result. */ metrics?: boolean | undefined; /** * Instrument query evaluation and return a superset of performance metrics in addition to result. */ instrument?: boolean | undefined; /** * Treat built-in function call errors as fatal and return an error immediately. */ strictBuiltinErrors?: boolean | undefined; }; export type ExecutePolicyResponse = { httpMeta: components.HTTPMetadata; /** * Success. * * @remarks * The server also returns 200 if the path refers to an undefined document. In this case, the response will not contain a result property. */ successfulPolicyResponse?: components.SuccessfulPolicyResponse | undefined; headers: { [k: string]: Array }; }; /** @internal */ export const ExecutePolicyRequest$inboundSchema: z.ZodType< ExecutePolicyRequest, z.ZodTypeDef, unknown > = z.object({ path: z.string().default(""), "Accept-Encoding": components.GzipAcceptEncoding$inboundSchema.optional(), pretty: z.boolean().optional(), provenance: z.boolean().optional(), explain: components.Explain$inboundSchema.optional(), metrics: z.boolean().optional(), instrument: z.boolean().optional(), "strict-builtin-errors": z.boolean().optional(), }).transform((v) => { return remap$(v, { "Accept-Encoding": "acceptEncoding", "strict-builtin-errors": "strictBuiltinErrors", }); }); /** @internal */ export type ExecutePolicyRequest$Outbound = { path: string; "Accept-Encoding"?: string | undefined; pretty?: boolean | undefined; provenance?: boolean | undefined; explain?: string | undefined; metrics?: boolean | undefined; instrument?: boolean | undefined; "strict-builtin-errors"?: boolean | undefined; }; /** @internal */ export const ExecutePolicyRequest$outboundSchema: z.ZodType< ExecutePolicyRequest$Outbound, z.ZodTypeDef, ExecutePolicyRequest > = z.object({ path: z.string().default(""), acceptEncoding: components.GzipAcceptEncoding$outboundSchema.optional(), pretty: z.boolean().optional(), provenance: z.boolean().optional(), explain: components.Explain$outboundSchema.optional(), metrics: z.boolean().optional(), instrument: z.boolean().optional(), strictBuiltinErrors: z.boolean().optional(), }).transform((v) => { return remap$(v, { acceptEncoding: "Accept-Encoding", strictBuiltinErrors: "strict-builtin-errors", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ExecutePolicyRequest$ { /** @deprecated use `ExecutePolicyRequest$inboundSchema` instead. */ export const inboundSchema = ExecutePolicyRequest$inboundSchema; /** @deprecated use `ExecutePolicyRequest$outboundSchema` instead. */ export const outboundSchema = ExecutePolicyRequest$outboundSchema; /** @deprecated use `ExecutePolicyRequest$Outbound` instead. */ export type Outbound = ExecutePolicyRequest$Outbound; } export function executePolicyRequestToJSON( executePolicyRequest: ExecutePolicyRequest, ): string { return JSON.stringify( ExecutePolicyRequest$outboundSchema.parse(executePolicyRequest), ); } export function executePolicyRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ExecutePolicyRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ExecutePolicyRequest' from JSON`, ); } /** @internal */ export const ExecutePolicyResponse$inboundSchema: z.ZodType< ExecutePolicyResponse, z.ZodTypeDef, unknown > = z.object({ HttpMeta: components.HTTPMetadata$inboundSchema, SuccessfulPolicyResponse: components.SuccessfulPolicyResponse$inboundSchema .optional(), Headers: z.record(z.array(z.string())), }).transform((v) => { return remap$(v, { "HttpMeta": "httpMeta", "SuccessfulPolicyResponse": "successfulPolicyResponse", "Headers": "headers", }); }); /** @internal */ export type ExecutePolicyResponse$Outbound = { HttpMeta: components.HTTPMetadata$Outbound; SuccessfulPolicyResponse?: | components.SuccessfulPolicyResponse$Outbound | undefined; Headers: { [k: string]: Array }; }; /** @internal */ export const ExecutePolicyResponse$outboundSchema: z.ZodType< ExecutePolicyResponse$Outbound, z.ZodTypeDef, ExecutePolicyResponse > = z.object({ httpMeta: components.HTTPMetadata$outboundSchema, successfulPolicyResponse: components.SuccessfulPolicyResponse$outboundSchema .optional(), headers: z.record(z.array(z.string())), }).transform((v) => { return remap$(v, { httpMeta: "HttpMeta", successfulPolicyResponse: "SuccessfulPolicyResponse", headers: "Headers", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ExecutePolicyResponse$ { /** @deprecated use `ExecutePolicyResponse$inboundSchema` instead. */ export const inboundSchema = ExecutePolicyResponse$inboundSchema; /** @deprecated use `ExecutePolicyResponse$outboundSchema` instead. */ export const outboundSchema = ExecutePolicyResponse$outboundSchema; /** @deprecated use `ExecutePolicyResponse$Outbound` instead. */ export type Outbound = ExecutePolicyResponse$Outbound; } export function executePolicyResponseToJSON( executePolicyResponse: ExecutePolicyResponse, ): string { return JSON.stringify( ExecutePolicyResponse$outboundSchema.parse(executePolicyResponse), ); } export function executePolicyResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ExecutePolicyResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ExecutePolicyResponse' from JSON`, ); }