/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { lazySchema as lazySchema$, safeParse } from "../../lib/schemas.js"; import * as openEnums from "../../types/enums.js"; import { OpenEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as types from "../../types/primitives.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { PassThroughBody, PassThroughBody$inboundSchema, PassThroughBody$Outbound, PassThroughBody$outboundSchema, } from "./passthroughbody.js"; export const CustomObjectSchemaType = { String: "string", Number: "number", Integer: "integer", Boolean: "boolean", Date: "date", Datetime: "datetime", Currency: "currency", Email: "email", Phone: "phone", Reference: "reference", Select: "select", Multiselect: "multiselect", } as const; export type CustomObjectSchemaType = OpenEnum; export type CustomObjectSchemaOptions = { value?: string | undefined; label?: string | undefined; }; export type Fields = { id?: string | undefined; name?: string | undefined; description?: string | null | undefined; type?: CustomObjectSchemaType | undefined; required?: boolean | undefined; /** * Options for select and multiselect types */ options?: Array | null | undefined; /** * Default value for the field */ defaultValue?: string | null | undefined; }; export type CustomObjectSchema = { /** * The unique identifier of the custom object schema */ id?: string | undefined; /** * The name of the custom object schema */ name?: string | null | undefined; /** * The description of the custom object schema */ description?: string | null | undefined; /** * The fields defined in the schema */ fields?: Array | undefined; /** * Whether the custom object schema is visible in the UI */ visible?: boolean | null | undefined; /** * Whether the custom object schema is active */ active?: boolean | null | undefined; /** * The ID of the user who created the custom object schema */ createdBy?: string | null | undefined; /** * The ID of the user who last updated the custom object schema */ updatedBy?: string | null | undefined; /** * The timestamp when the custom object schema was last updated */ updatedAt?: string | null | undefined; /** * The timestamp when the custom object schema was created */ createdAt?: string | null | undefined; /** * The pass_through property allows passing service-specific, custom data or structured modifications in request body when creating or updating resources. */ passThrough?: Array | undefined; }; export type CustomObjectSchemaInput = { /** * The name of the custom object schema */ name?: string | null | undefined; /** * The description of the custom object schema */ description?: string | null | undefined; /** * The fields defined in the schema */ fields?: Array | undefined; /** * Whether the custom object schema is visible in the UI */ visible?: boolean | null | undefined; /** * Whether the custom object schema is active */ active?: boolean | null | undefined; /** * The pass_through property allows passing service-specific, custom data or structured modifications in request body when creating or updating resources. */ passThrough?: Array | undefined; }; /** @internal */ export const CustomObjectSchemaType$inboundSchema: z.ZodType< CustomObjectSchemaType, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(CustomObjectSchemaType) ); /** @internal */ export const CustomObjectSchemaType$outboundSchema: z.ZodType< string, z.ZodTypeDef, CustomObjectSchemaType > = /* @__PURE__ */ lazySchema$(() => openEnums.outboundSchema(CustomObjectSchemaType) ); /** @internal */ export const CustomObjectSchemaOptions$inboundSchema: z.ZodType< CustomObjectSchemaOptions, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ value: types.optional(types.string()), label: types.optional(types.string()), }) ); /** @internal */ export type CustomObjectSchemaOptions$Outbound = { value?: string | undefined; label?: string | undefined; }; /** @internal */ export const CustomObjectSchemaOptions$outboundSchema: z.ZodType< CustomObjectSchemaOptions$Outbound, z.ZodTypeDef, CustomObjectSchemaOptions > = /* @__PURE__ */ lazySchema$(() => z.object({ value: z.string().optional(), label: z.string().optional(), }) ); export function customObjectSchemaOptionsToJSON( customObjectSchemaOptions: CustomObjectSchemaOptions, ): string { return JSON.stringify( CustomObjectSchemaOptions$outboundSchema.parse(customObjectSchemaOptions), ); } export function customObjectSchemaOptionsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CustomObjectSchemaOptions$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CustomObjectSchemaOptions' from JSON`, ); } /** @internal */ export const Fields$inboundSchema: z.ZodType = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), name: types.optional(types.string()), description: z.nullable(types.string()).optional(), type: types.optional(CustomObjectSchemaType$inboundSchema), required: types.optional(types.boolean()), options: z.nullable( z.array(z.lazy(() => CustomObjectSchemaOptions$inboundSchema)), ).optional(), default_value: z.nullable(types.string()).optional(), }).transform((v) => { return remap$(v, { "default_value": "defaultValue", }); }) ); /** @internal */ export type Fields$Outbound = { id?: string | undefined; name?: string | undefined; description?: string | null | undefined; type?: string | undefined; required?: boolean | undefined; options?: Array | null | undefined; default_value?: string | null | undefined; }; /** @internal */ export const Fields$outboundSchema: z.ZodType< Fields$Outbound, z.ZodTypeDef, Fields > = /* @__PURE__ */ lazySchema$(() => z.object({ id: z.string().optional(), name: z.string().optional(), description: z.nullable(z.string()).optional(), type: CustomObjectSchemaType$outboundSchema.optional(), required: z.boolean().optional(), options: z.nullable( z.array(z.lazy(() => CustomObjectSchemaOptions$outboundSchema)), ).optional(), defaultValue: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { defaultValue: "default_value", }); }) ); export function fieldsToJSON(fields: Fields): string { return JSON.stringify(Fields$outboundSchema.parse(fields)); } export function fieldsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Fields$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Fields' from JSON`, ); } /** @internal */ export const CustomObjectSchema$inboundSchema: z.ZodType< CustomObjectSchema, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), name: z.nullable(types.string()).optional(), description: z.nullable(types.string()).optional(), fields: types.optional(z.array(z.lazy(() => Fields$inboundSchema))), visible: z.nullable(types.boolean()).optional(), active: z.nullable(types.boolean()).optional(), created_by: z.nullable(types.string()).optional(), updated_by: z.nullable(types.string()).optional(), updated_at: z.nullable(types.string()).optional(), created_at: z.nullable(types.string()).optional(), pass_through: types.optional(z.array(PassThroughBody$inboundSchema)), }).transform((v) => { return remap$(v, { "created_by": "createdBy", "updated_by": "updatedBy", "updated_at": "updatedAt", "created_at": "createdAt", "pass_through": "passThrough", }); }) ); export function customObjectSchemaFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CustomObjectSchema$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CustomObjectSchema' from JSON`, ); } /** @internal */ export type CustomObjectSchemaInput$Outbound = { name?: string | null | undefined; description?: string | null | undefined; fields?: Array | undefined; visible?: boolean | null | undefined; active?: boolean | null | undefined; pass_through?: Array | undefined; }; /** @internal */ export const CustomObjectSchemaInput$outboundSchema: z.ZodType< CustomObjectSchemaInput$Outbound, z.ZodTypeDef, CustomObjectSchemaInput > = /* @__PURE__ */ lazySchema$(() => z.object({ name: z.nullable(z.string()).optional(), description: z.nullable(z.string()).optional(), fields: z.array(z.lazy(() => Fields$outboundSchema)).optional(), visible: z.nullable(z.boolean()).optional(), active: z.nullable(z.boolean()).optional(), passThrough: z.array(PassThroughBody$outboundSchema).optional(), }).transform((v) => { return remap$(v, { passThrough: "pass_through", }); }) ); export function customObjectSchemaInputToJSON( customObjectSchemaInput: CustomObjectSchemaInput, ): string { return JSON.stringify( CustomObjectSchemaInput$outboundSchema.parse(customObjectSchemaInput), ); }