/* * 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 UCAST. */ export type CompileResultUCASTResult = { /** * UCAST JSON object describing the conditions under which the query is true. */ query?: { [k: string]: any } | undefined; /** * Column masking rules, 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 UCAST format. Result will be empty if the query is never true. */ export type CompileResultUCAST = { /** * The partially evaluated result of the query as UCAST. */ result?: CompileResultUCASTResult | undefined; }; /** @internal */ export const CompileResultUCASTResult$inboundSchema: z.ZodType< CompileResultUCASTResult, z.ZodTypeDef, unknown > = collectExtraKeys$( z.object({ query: z.record(z.any()).optional(), masks: z.record(z.record(MaskingRule$inboundSchema)).optional(), }).catchall(z.any()), "additionalProperties", true, ); /** @internal */ export type CompileResultUCASTResult$Outbound = { query?: { [k: string]: any } | undefined; masks?: { [k: string]: { [k: string]: MaskingRule$Outbound } } | undefined; [additionalProperties: string]: unknown; }; /** @internal */ export const CompileResultUCASTResult$outboundSchema: z.ZodType< CompileResultUCASTResult$Outbound, z.ZodTypeDef, CompileResultUCASTResult > = z.object({ query: z.record(z.any()).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 CompileResultUCASTResult$ { /** @deprecated use `CompileResultUCASTResult$inboundSchema` instead. */ export const inboundSchema = CompileResultUCASTResult$inboundSchema; /** @deprecated use `CompileResultUCASTResult$outboundSchema` instead. */ export const outboundSchema = CompileResultUCASTResult$outboundSchema; /** @deprecated use `CompileResultUCASTResult$Outbound` instead. */ export type Outbound = CompileResultUCASTResult$Outbound; } export function compileResultUCASTResultToJSON( compileResultUCASTResult: CompileResultUCASTResult, ): string { return JSON.stringify( CompileResultUCASTResult$outboundSchema.parse(compileResultUCASTResult), ); } export function compileResultUCASTResultFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CompileResultUCASTResult$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CompileResultUCASTResult' from JSON`, ); } /** @internal */ export const CompileResultUCAST$inboundSchema: z.ZodType< CompileResultUCAST, z.ZodTypeDef, unknown > = z.object({ result: z.lazy(() => CompileResultUCASTResult$inboundSchema).optional(), }); /** @internal */ export type CompileResultUCAST$Outbound = { result?: CompileResultUCASTResult$Outbound | undefined; }; /** @internal */ export const CompileResultUCAST$outboundSchema: z.ZodType< CompileResultUCAST$Outbound, z.ZodTypeDef, CompileResultUCAST > = z.object({ result: z.lazy(() => CompileResultUCASTResult$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 CompileResultUCAST$ { /** @deprecated use `CompileResultUCAST$inboundSchema` instead. */ export const inboundSchema = CompileResultUCAST$inboundSchema; /** @deprecated use `CompileResultUCAST$outboundSchema` instead. */ export const outboundSchema = CompileResultUCAST$outboundSchema; /** @deprecated use `CompileResultUCAST$Outbound` instead. */ export type Outbound = CompileResultUCAST$Outbound; } export function compileResultUCASTToJSON( compileResultUCAST: CompileResultUCAST, ): string { return JSON.stringify( CompileResultUCAST$outboundSchema.parse(compileResultUCAST), ); } export function compileResultUCASTFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CompileResultUCAST$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CompileResultUCAST' from JSON`, ); }