/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../../lib/primitives.js"; import { collectExtraKeys as collectExtraKeys$, safeParse, } from "../../../lib/schemas.js"; import { Result as SafeParseResult } from "../../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { MaskingRule, MaskingRule$inboundSchema, MaskingRule$Outbound, MaskingRule$outboundSchema, } from "./maskingrule.js"; /** * The partially evaluated result of the query as SQL. */ export type CompileResultSQLResult = { /** * String representing the SQL equivalent of the conditions under which the query is true. */ query?: string | undefined; /** * Column masking functions, where the key is the column name, and the value describes which masking function to use. */ masks?: { [k: string]: { [k: string]: MaskingRule } } | undefined; additionalProperties?: { [k: string]: any }; }; /** * The partially evaluated result of the query, in SQL format. Result will be empty if the query is never true. */ export type CompileResultSQL = { /** * The partially evaluated result of the query as SQL. */ result?: CompileResultSQLResult | undefined; }; /** @internal */ export const CompileResultSQLResult$inboundSchema: z.ZodType< CompileResultSQLResult, z.ZodTypeDef, unknown > = collectExtraKeys$( z.object({ query: z.string().optional(), masks: z.record(z.record(MaskingRule$inboundSchema)).optional(), }).catchall(z.any()), "additionalProperties", true, ); /** @internal */ export type CompileResultSQLResult$Outbound = { query?: string | undefined; masks?: { [k: string]: { [k: string]: MaskingRule$Outbound } } | undefined; [additionalProperties: string]: unknown; }; /** @internal */ export const CompileResultSQLResult$outboundSchema: z.ZodType< CompileResultSQLResult$Outbound, z.ZodTypeDef, CompileResultSQLResult > = z.object({ query: z.string().optional(), masks: z.record(z.record(MaskingRule$outboundSchema)).optional(), additionalProperties: z.record(z.any()), }).transform((v) => { return { ...v.additionalProperties, ...remap$(v, { additionalProperties: null, }), }; }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CompileResultSQLResult$ { /** @deprecated use `CompileResultSQLResult$inboundSchema` instead. */ export const inboundSchema = CompileResultSQLResult$inboundSchema; /** @deprecated use `CompileResultSQLResult$outboundSchema` instead. */ export const outboundSchema = CompileResultSQLResult$outboundSchema; /** @deprecated use `CompileResultSQLResult$Outbound` instead. */ export type Outbound = CompileResultSQLResult$Outbound; } export function compileResultSQLResultToJSON( compileResultSQLResult: CompileResultSQLResult, ): string { return JSON.stringify( CompileResultSQLResult$outboundSchema.parse(compileResultSQLResult), ); } export function compileResultSQLResultFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CompileResultSQLResult$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CompileResultSQLResult' from JSON`, ); } /** @internal */ export const CompileResultSQL$inboundSchema: z.ZodType< CompileResultSQL, z.ZodTypeDef, unknown > = z.object({ result: z.lazy(() => CompileResultSQLResult$inboundSchema).optional(), }); /** @internal */ export type CompileResultSQL$Outbound = { result?: CompileResultSQLResult$Outbound | undefined; }; /** @internal */ export const CompileResultSQL$outboundSchema: z.ZodType< CompileResultSQL$Outbound, z.ZodTypeDef, CompileResultSQL > = z.object({ result: z.lazy(() => CompileResultSQLResult$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 CompileResultSQL$ { /** @deprecated use `CompileResultSQL$inboundSchema` instead. */ export const inboundSchema = CompileResultSQL$inboundSchema; /** @deprecated use `CompileResultSQL$outboundSchema` instead. */ export const outboundSchema = CompileResultSQL$outboundSchema; /** @deprecated use `CompileResultSQL$Outbound` instead. */ export type Outbound = CompileResultSQL$Outbound; } export function compileResultSQLToJSON( compileResultSQL: CompileResultSQL, ): string { return JSON.stringify( CompileResultSQL$outboundSchema.parse(compileResultSQL), ); } export function compileResultSQLFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CompileResultSQL$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CompileResultSQL' from JSON`, ); }