/* * 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"; /** * The query, input, and other settings for partial evaluation. */ export type CompileQueryWithPartialEvaluationRequestApplicationJSONRequestBody = { /** * Additional options to use during partial evaluation. Only the disableInlining option is currently supported in OPA. Enterprise OPA may support additional options. */ options?: components.CompileOptions | undefined; /** * The terms to treat as unknown during partial evaluation. */ unknowns?: Array | undefined; /** * Arbitrary JSON used within your policies by accessing `input` */ input?: components.Input | undefined; }; export type CompileQueryWithPartialEvaluationRequest = { /** * 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; /** * Indicates that the request body is gzip encoded */ contentEncoding?: components.GzipContentEncoding | undefined; /** * If parameter is `true`, response will formatted for humans. */ pretty?: 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; /** * The query, input, and other settings for partial evaluation. */ requestBody: CompileQueryWithPartialEvaluationRequestApplicationJSONRequestBody; }; export type CompileQueryWithPartialEvaluationResponse = { httpMeta: components.HTTPMetadata; /** * Successful response */ compileResultJSON?: components.CompileResultJSON | undefined; /** * Successful response */ compileResultMultitarget?: components.CompileResultMultitarget | undefined; /** * Successful response */ compileResultUCAST?: components.CompileResultUCAST | undefined; /** * Successful response */ compileResultSQL?: components.CompileResultSQL | undefined; }; /** @internal */ export const CompileQueryWithPartialEvaluationRequestApplicationJSONRequestBody$inboundSchema: z.ZodType< CompileQueryWithPartialEvaluationRequestApplicationJSONRequestBody, z.ZodTypeDef, unknown > = z.object({ options: components.CompileOptions$inboundSchema.optional(), unknowns: z.array(z.string()).optional(), input: components.Input$inboundSchema.optional(), }); /** @internal */ export type CompileQueryWithPartialEvaluationRequestApplicationJSONRequestBody$Outbound = { options?: components.CompileOptions$Outbound | undefined; unknowns?: Array | undefined; input?: components.Input$Outbound | undefined; }; /** @internal */ export const CompileQueryWithPartialEvaluationRequestApplicationJSONRequestBody$outboundSchema: z.ZodType< CompileQueryWithPartialEvaluationRequestApplicationJSONRequestBody$Outbound, z.ZodTypeDef, CompileQueryWithPartialEvaluationRequestApplicationJSONRequestBody > = z.object({ options: components.CompileOptions$outboundSchema.optional(), unknowns: z.array(z.string()).optional(), input: components.Input$outboundSchema.optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CompileQueryWithPartialEvaluationRequestApplicationJSONRequestBody$ { /** @deprecated use `CompileQueryWithPartialEvaluationRequestApplicationJSONRequestBody$inboundSchema` instead. */ export const inboundSchema = CompileQueryWithPartialEvaluationRequestApplicationJSONRequestBody$inboundSchema; /** @deprecated use `CompileQueryWithPartialEvaluationRequestApplicationJSONRequestBody$outboundSchema` instead. */ export const outboundSchema = CompileQueryWithPartialEvaluationRequestApplicationJSONRequestBody$outboundSchema; /** @deprecated use `CompileQueryWithPartialEvaluationRequestApplicationJSONRequestBody$Outbound` instead. */ export type Outbound = CompileQueryWithPartialEvaluationRequestApplicationJSONRequestBody$Outbound; } export function compileQueryWithPartialEvaluationRequestApplicationJSONRequestBodyToJSON( compileQueryWithPartialEvaluationRequestApplicationJSONRequestBody: CompileQueryWithPartialEvaluationRequestApplicationJSONRequestBody, ): string { return JSON.stringify( CompileQueryWithPartialEvaluationRequestApplicationJSONRequestBody$outboundSchema .parse( compileQueryWithPartialEvaluationRequestApplicationJSONRequestBody, ), ); } export function compileQueryWithPartialEvaluationRequestApplicationJSONRequestBodyFromJSON( jsonString: string, ): SafeParseResult< CompileQueryWithPartialEvaluationRequestApplicationJSONRequestBody, SDKValidationError > { return safeParse( jsonString, (x) => CompileQueryWithPartialEvaluationRequestApplicationJSONRequestBody$inboundSchema .parse(JSON.parse(x)), `Failed to parse 'CompileQueryWithPartialEvaluationRequestApplicationJSONRequestBody' from JSON`, ); } /** @internal */ export const CompileQueryWithPartialEvaluationRequest$inboundSchema: z.ZodType< CompileQueryWithPartialEvaluationRequest, z.ZodTypeDef, unknown > = z.object({ path: z.string().default(""), "Accept-Encoding": components.GzipAcceptEncoding$inboundSchema.optional(), "Content-Encoding": components.GzipContentEncoding$inboundSchema.optional(), pretty: z.boolean().optional(), explain: components.Explain$inboundSchema.optional(), metrics: z.boolean().optional(), instrument: z.boolean().optional(), RequestBody: z.lazy(() => CompileQueryWithPartialEvaluationRequestApplicationJSONRequestBody$inboundSchema ), }).transform((v) => { return remap$(v, { "Accept-Encoding": "acceptEncoding", "Content-Encoding": "contentEncoding", "RequestBody": "requestBody", }); }); /** @internal */ export type CompileQueryWithPartialEvaluationRequest$Outbound = { path: string; "Accept-Encoding"?: string | undefined; "Content-Encoding"?: string | undefined; pretty?: boolean | undefined; explain?: string | undefined; metrics?: boolean | undefined; instrument?: boolean | undefined; RequestBody: CompileQueryWithPartialEvaluationRequestApplicationJSONRequestBody$Outbound; }; /** @internal */ export const CompileQueryWithPartialEvaluationRequest$outboundSchema: z.ZodType< CompileQueryWithPartialEvaluationRequest$Outbound, z.ZodTypeDef, CompileQueryWithPartialEvaluationRequest > = z.object({ path: z.string().default(""), acceptEncoding: components.GzipAcceptEncoding$outboundSchema.optional(), contentEncoding: components.GzipContentEncoding$outboundSchema.optional(), pretty: z.boolean().optional(), explain: components.Explain$outboundSchema.optional(), metrics: z.boolean().optional(), instrument: z.boolean().optional(), requestBody: z.lazy(() => CompileQueryWithPartialEvaluationRequestApplicationJSONRequestBody$outboundSchema ), }).transform((v) => { return remap$(v, { acceptEncoding: "Accept-Encoding", contentEncoding: "Content-Encoding", requestBody: "RequestBody", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CompileQueryWithPartialEvaluationRequest$ { /** @deprecated use `CompileQueryWithPartialEvaluationRequest$inboundSchema` instead. */ export const inboundSchema = CompileQueryWithPartialEvaluationRequest$inboundSchema; /** @deprecated use `CompileQueryWithPartialEvaluationRequest$outboundSchema` instead. */ export const outboundSchema = CompileQueryWithPartialEvaluationRequest$outboundSchema; /** @deprecated use `CompileQueryWithPartialEvaluationRequest$Outbound` instead. */ export type Outbound = CompileQueryWithPartialEvaluationRequest$Outbound; } export function compileQueryWithPartialEvaluationRequestToJSON( compileQueryWithPartialEvaluationRequest: CompileQueryWithPartialEvaluationRequest, ): string { return JSON.stringify( CompileQueryWithPartialEvaluationRequest$outboundSchema.parse( compileQueryWithPartialEvaluationRequest, ), ); } export function compileQueryWithPartialEvaluationRequestFromJSON( jsonString: string, ): SafeParseResult< CompileQueryWithPartialEvaluationRequest, SDKValidationError > { return safeParse( jsonString, (x) => CompileQueryWithPartialEvaluationRequest$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'CompileQueryWithPartialEvaluationRequest' from JSON`, ); } /** @internal */ export const CompileQueryWithPartialEvaluationResponse$inboundSchema: z.ZodType< CompileQueryWithPartialEvaluationResponse, z.ZodTypeDef, unknown > = z.object({ HttpMeta: components.HTTPMetadata$inboundSchema, CompileResultJSON: components.CompileResultJSON$inboundSchema.optional(), CompileResultMultitarget: components.CompileResultMultitarget$inboundSchema .optional(), CompileResultUCAST: components.CompileResultUCAST$inboundSchema.optional(), CompileResultSQL: components.CompileResultSQL$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "HttpMeta": "httpMeta", "CompileResultJSON": "compileResultJSON", "CompileResultMultitarget": "compileResultMultitarget", "CompileResultUCAST": "compileResultUCAST", "CompileResultSQL": "compileResultSQL", }); }); /** @internal */ export type CompileQueryWithPartialEvaluationResponse$Outbound = { HttpMeta: components.HTTPMetadata$Outbound; CompileResultJSON?: components.CompileResultJSON$Outbound | undefined; CompileResultMultitarget?: | components.CompileResultMultitarget$Outbound | undefined; CompileResultUCAST?: components.CompileResultUCAST$Outbound | undefined; CompileResultSQL?: components.CompileResultSQL$Outbound | undefined; }; /** @internal */ export const CompileQueryWithPartialEvaluationResponse$outboundSchema: z.ZodType< CompileQueryWithPartialEvaluationResponse$Outbound, z.ZodTypeDef, CompileQueryWithPartialEvaluationResponse > = z.object({ httpMeta: components.HTTPMetadata$outboundSchema, compileResultJSON: components.CompileResultJSON$outboundSchema.optional(), compileResultMultitarget: components.CompileResultMultitarget$outboundSchema .optional(), compileResultUCAST: components.CompileResultUCAST$outboundSchema.optional(), compileResultSQL: components.CompileResultSQL$outboundSchema.optional(), }).transform((v) => { return remap$(v, { httpMeta: "HttpMeta", compileResultJSON: "CompileResultJSON", compileResultMultitarget: "CompileResultMultitarget", compileResultUCAST: "CompileResultUCAST", compileResultSQL: "CompileResultSQL", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CompileQueryWithPartialEvaluationResponse$ { /** @deprecated use `CompileQueryWithPartialEvaluationResponse$inboundSchema` instead. */ export const inboundSchema = CompileQueryWithPartialEvaluationResponse$inboundSchema; /** @deprecated use `CompileQueryWithPartialEvaluationResponse$outboundSchema` instead. */ export const outboundSchema = CompileQueryWithPartialEvaluationResponse$outboundSchema; /** @deprecated use `CompileQueryWithPartialEvaluationResponse$Outbound` instead. */ export type Outbound = CompileQueryWithPartialEvaluationResponse$Outbound; } export function compileQueryWithPartialEvaluationResponseToJSON( compileQueryWithPartialEvaluationResponse: CompileQueryWithPartialEvaluationResponse, ): string { return JSON.stringify( CompileQueryWithPartialEvaluationResponse$outboundSchema.parse( compileQueryWithPartialEvaluationResponse, ), ); } export function compileQueryWithPartialEvaluationResponseFromJSON( jsonString: string, ): SafeParseResult< CompileQueryWithPartialEvaluationResponse, SDKValidationError > { return safeParse( jsonString, (x) => CompileQueryWithPartialEvaluationResponse$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'CompileQueryWithPartialEvaluationResponse' from JSON`, ); }