/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import * as discriminatedUnionTypes from "../../types/discriminated-union.js"; import { discriminatedUnion } from "../../types/discriminated-union.js"; import * as openEnums from "../../types/enums.js"; import { ClosedEnum, OpenEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as types from "../../types/primitives.js"; import { smartUnion } from "../../types/smart-union.js"; import { SDKValidationError } from "../errors/sdk-validation-error.js"; /** * Audio */ export type DataAudio = { type: "audio"; /** * The URL of the audio content */ url: string; }; /** * Video */ export type DataVideo = { type: "video"; /** * A public URL of the video content */ url: string; }; /** * Image */ export type DataImage = { type: "image"; /** * A public URL of the image content. Either url or data must be provided. */ url?: string | undefined; /** * Base64-encoded image data. Either url or data must be provided. Note: base64 images are not stored and will not appear in the review queue. */ data?: string | undefined; }; /** * Text */ export type DataText = { type: "text"; /** * The content text */ text: string; }; export type ContentLeafRequest = DataText | DataImage | DataVideo | DataAudio; /** * Object */ export type ObjectT = { type: "object"; /** * Values in the object. Can be mixed content types. */ data: { [k: string]: DataText | DataImage | DataVideo | DataAudio }; }; /** * Audio */ export type AudioRequest = { type: "audio"; /** * The URL of the audio content */ url: string; }; /** * Video */ export type VideoRequest = { type: "video"; /** * A public URL of the video content */ url: string; }; /** * Image */ export type ImageRequest = { type: "image"; /** * A public URL of the image content. Either url or data must be provided. */ url?: string | undefined; /** * Base64-encoded image data. Either url or data must be provided. Note: base64 images are not stored and will not appear in the review queue. */ data?: string | undefined; }; /** * Text */ export type TextRequest = { type: "text"; /** * The content text */ text: string; }; /** * The content sent for moderation */ export type ContentRequest = | TextRequest | ImageRequest | VideoRequest | AudioRequest | ObjectT; /** * The meta type of content being moderated */ export const MetaType = { Profile: "profile", Message: "message", Post: "post", Comment: "comment", Event: "event", Product: "product", Review: "review", Voice: "voice", Other: "other", } as const; /** * The meta type of content being moderated */ export type MetaType = ClosedEnum; /** * Your recommendation for the content: allow, review, or reject. */ export const ActionRequest = { Review: "review", Allow: "allow", Reject: "reject", } as const; /** * Your recommendation for the content: allow, review, or reject. */ export type ActionRequest = ClosedEnum; /** * How your recommendation combines with ours. Defaults to 'escalate', which only applies it when stricter than ours; 'override' replaces ours outright. */ export const Behavior = { Override: "override", Escalate: "escalate", } as const; /** * How your recommendation combines with ours. Defaults to 'escalate', which only applies it when stricter than ours; 'override' replaces ours outright. */ export type Behavior = ClosedEnum; /** * A recommendation from your own client-side flagging (e.g. a banned-IP list or a third-party tool). Feeds the rules engine and can escalate or override the recommended action. Does not change whether our analysis flagged the content. */ export type ClientAction = { /** * Your recommendation for the content: allow, review, or reject. */ action: ActionRequest; /** * How your recommendation combines with ours. Defaults to 'escalate', which only applies it when stricter than ours; 'override' replaces ours outright. */ behavior?: Behavior | undefined; /** * Where your recommendation came from, e.g. "banned-ip". */ source?: string | undefined; /** * A human-readable explanation for your recommendation. */ reason?: string | undefined; }; export type Guideline = { flag: boolean; threshold?: number | undefined; id: "guideline"; instructions: string; guidelineKey: string; }; export type URLRisk = { flag: boolean; threshold?: number | undefined; id: "url_risk"; /** * IDs of wordlists whose entries are treated as allowed URL domains. Matches short-circuit the risk model and are never flagged. */ allowlistWordlistIds?: Array | undefined; /** * IDs of wordlists whose entries are treated as blocked URL domains. Matches short-circuit the risk model and are always flagged. Blocklists take precedence over allowlists. */ blocklistWordlistIds?: Array | undefined; /** * When true, any URL detected as a free link shortener (bit.ly, t.co, tinyurl, etc.) is always flagged regardless of risk score. Allowlist matches still win. */ flagLinkShorteners?: boolean | undefined; }; export type Entities2 = { enable?: boolean | undefined; flag?: boolean | undefined; shouldMask?: boolean | undefined; mask?: string | undefined; [additionalProperties: string]: unknown; }; export type URLMasking = { id: "url"; entities: { [k: string]: Entities2 }; }; export type Entities1 = { enable?: boolean | undefined; flag?: boolean | undefined; shouldMask?: boolean | undefined; mask?: string | undefined; [additionalProperties: string]: unknown; }; export type PIIMasking = { id: "pii"; entities: { [k: string]: Entities1 }; }; export type SignalsRequest = { flag?: boolean | undefined; }; export type UnicodeSpoofing = { flag: boolean; threshold?: number | undefined; id: "unicode_spoofing"; /** * Per-signal flag toggles. Omitted spoofing signals are enabled; encoding_damage defaults to off because decode damage (U+FFFD) marks a broken pipeline, not an attack. A disabled signal is still detected and reported as a label, but does not by itself flag the policy. */ signals?: { [k: string]: SignalsRequest } | undefined; }; export type CodeAbuse = { flag: boolean; threshold?: number | undefined; id: "code_abuse"; }; export type Extremism = { flag: boolean; threshold?: number | undefined; id: "extremism"; }; export type Promotion = { flag: boolean; threshold?: number | undefined; id: "promotion"; }; export type Weapons = { flag: boolean; threshold?: number | undefined; id: "weapons"; }; export type Tobacco = { flag: boolean; threshold?: number | undefined; id: "tobacco"; }; export type Gambling = { flag: boolean; threshold?: number | undefined; id: "gambling"; }; export type Drugs = { flag: boolean; threshold?: number | undefined; id: "drugs"; }; export type Alcohol = { flag: boolean; threshold?: number | undefined; id: "alcohol"; }; export type IllegalTrade = { flag: boolean; threshold?: number | undefined; id: "illegal_trade"; }; export type ChannelCircumvention = { flag: boolean; threshold?: number | undefined; id: "channel_circumvent"; }; export type SexualSolicitation = { flag: boolean; threshold?: number | undefined; id: "sexual_solicitation"; }; export type Threat = { flag: boolean; threshold?: number | undefined; id: "threat"; }; export type Religion = { flag: boolean; threshold?: number | undefined; id: "religion"; }; export type Political = { flag: boolean; threshold?: number | undefined; id: "political"; }; export type SelfPromotion = { flag: boolean; threshold?: number | undefined; id: "self_promotion"; }; /** * Flag images that contain "at least" or "fewer than" the configured number of faces. Defaults to at_least. */ export const Comparator = { AtLeast: "at_least", FewerThan: "fewer_than", } as const; /** * Flag images that contain "at least" or "fewer than" the configured number of faces. Defaults to at_least. */ export type Comparator = ClosedEnum; export type FaceDetection = { flag: boolean; threshold?: number | undefined; id: "face_detection"; /** * Flag images that contain "at least" or "fewer than" the configured number of faces. Defaults to at_least. */ comparator?: Comparator | undefined; /** * Number of faces the comparator applies to. Defaults to 1, so the default rule flags any image containing a face. */ count?: number | undefined; }; export type LowQualityContent = { flag: boolean; threshold?: number | undefined; id: "low_quality"; /** * Flag content with fewer than this many words as low-effort. Defaults to 3. Set to disable by omitting. */ minWords?: number | undefined; }; export type Spam = { flag: boolean; threshold?: number | undefined; id: "spam"; }; export type SelfHarm = { flag: boolean; threshold?: number | undefined; id: "self_harm"; }; export type Violence = { flag: boolean; threshold?: number | undefined; id: "violence"; }; export type Profanity = { flag: boolean; threshold?: number | undefined; id: "profanity"; }; export type SexualMinors = { flag: boolean; threshold?: number | undefined; id: "sexual_minors"; }; export type Sexual = { flag: boolean; threshold?: number | undefined; id: "sexual"; }; export type Crypto = { flag: boolean; threshold?: number | undefined; id: "crypto"; }; export type Adult = { flag: boolean; threshold?: number | undefined; id: "adult"; }; export type Cannabis = { flag: boolean; threshold?: number | undefined; id: "cannabis"; }; export type IllicitGambling = { flag: boolean; threshold?: number | undefined; id: "illicit_gambling"; }; export type IllicitTobacco = { flag: boolean; threshold?: number | undefined; id: "illicit_tobacco"; }; export type IllicitFirearms = { flag: boolean; threshold?: number | undefined; id: "illicit_firearms"; }; export type IllicitAlcohol = { flag: boolean; threshold?: number | undefined; id: "illicit_alcohol"; }; export type IllicitDrugs = { flag: boolean; threshold?: number | undefined; id: "illicit_drugs"; }; export type Illicit = { flag: boolean; threshold?: number | undefined; id: "illicit"; }; export type Hate = { flag: boolean; threshold?: number | undefined; id: "hate"; }; export type PersonalInformation = { flag: boolean; threshold?: number | undefined; id: "personal_information"; }; export type Toxicity = { flag: boolean; threshold?: number | undefined; id: "toxicity"; }; export type PolicyRequest = | Toxicity | PersonalInformation | Hate | Illicit | IllicitDrugs | IllicitAlcohol | IllicitFirearms | IllicitTobacco | IllicitGambling | Cannabis | Adult | Crypto | Sexual | SexualMinors | Profanity | Violence | SelfHarm | Spam | LowQualityContent | FaceDetection | SelfPromotion | Political | Religion | Threat | SexualSolicitation | ChannelCircumvention | IllegalTrade | Alcohol | Drugs | Gambling | Tobacco | Weapons | Promotion | Extremism | CodeAbuse | UnicodeSpoofing | PIIMasking | URLMasking | URLRisk | Guideline; export type SubmitContentRequestBody = { /** * The content sent for moderation */ content: TextRequest | ImageRequest | VideoRequest | AudioRequest | ObjectT; /** * Unix timestamp (in milliseconds) of when the content was created. Use if content is not submitted in real-time. */ timestamp?: number | undefined; /** * Provide a channel ID or key. Will use the project's default channel if not provided. */ channel?: string | undefined; /** * The unique ID of the content in your database. */ contentId?: string | undefined; /** * The meta type of content being moderated */ metaType?: MetaType | undefined; /** * The author of the content. */ authorId?: string | undefined; /** * For example the ID of a chat room or a post */ conversationId?: string | undefined; /** * Any metadata you want to store with the content */ metadata?: { [k: string]: any } | undefined; /** * A recommendation from your own client-side flagging (e.g. a banned-IP list or a third-party tool). Feeds the rules engine and can escalate or override the recommended action. Does not change whether our analysis flagged the content. */ clientAction?: ClientAction | undefined; /** * Do not store the content. The content won't enter the review queue */ doNotStore?: boolean | undefined; /** * (Enterprise) override the channel policies for this moderation request only. */ policies?: | Array< | Toxicity | PersonalInformation | Hate | Illicit | IllicitDrugs | IllicitAlcohol | IllicitFirearms | IllicitTobacco | IllicitGambling | Cannabis | Adult | Crypto | Sexual | SexualMinors | Profanity | Violence | SelfHarm | Spam | LowQualityContent | FaceDetection | SelfPromotion | Political | Religion | Threat | SexualSolicitation | ChannelCircumvention | IllegalTrade | Alcohol | Drugs | Gambling | Tobacco | Weapons | Promotion | Extremism | CodeAbuse | UnicodeSpoofing | PIIMasking | URLMasking | URLRisk | Guideline > | undefined; }; export type SubmitContentRequest = { /** * The project to act on, when you call with an organization key. Optional when the organization has one project. A project key acts on its own project: naming another one is an error. */ projectId?: string | undefined; body: SubmitContentRequestBody; }; /** * Audio */ export type AudioResponse = { type: "audio"; /** * The URL of the audio content */ url: string; }; /** * Video */ export type VideoResponse = { type: "video"; /** * A public URL of the video content */ url: string; }; /** * Image */ export type ImageResponse = { type: "image"; /** * A public URL of the image content. Either url or data must be provided. */ url?: string | undefined; /** * Base64-encoded image data. Either url or data must be provided. Note: base64 images are not stored and will not appear in the review queue. */ data?: string | undefined; }; /** * Text */ export type TextResponse = { type: "text"; /** * The content text */ text: string; }; export type ContentLeafResponse = | TextResponse | ImageResponse | VideoResponse | AudioResponse | discriminatedUnionTypes.Unknown<"type">; export type Modified = string | { [k: string]: any } | { [k: string]: | TextResponse | ImageResponse | VideoResponse | AudioResponse | discriminatedUnionTypes.Unknown<"type">; }; /** * Potentially modified content. */ export type ContentResponse = { /** * The unique identifier for the content. Either the contentId provided by you or an autogenerated ID. */ id: string; /** * Whether any values have been masked. */ masked: boolean; /** * Whether Unicode spoofing normalization rewrote the content — confusables folded to their Latin lookalikes, invisible characters and combining-mark abuse stripped. */ unicodeCleaned: boolean; /** * The modified content, if any. */ modified: string | { [k: string]: any } | { [k: string]: | TextResponse | ImageResponse | VideoResponse | AudioResponse | discriminatedUnionTypes.Unknown<"type">; } | null; /** * The transcribed text from audio content. Only present when audio moderation is used and transcript inclusion is enabled on the channel. */ transcript?: string | null | undefined; }; export type Block = { /** * The timestamp until which they are blocked if the author is suspended. */ until?: number | null | undefined; /** * The moderators reason why the author was blocked or suspended. */ reason?: string | null | undefined; }; /** * Current author status */ export const AuthorStatus = { Enabled: "enabled", Suspended: "suspended", Blocked: "blocked", } as const; /** * Current author status */ export type AuthorStatus = OpenEnum; export type TrustLevel = { /** * Author trust level (-1, 0, 1, 2, 3, or 4) */ level: number; /** * True if the trust level was set manually by a moderator */ manual: boolean; }; export type Author = { /** * Author ID in Moderation API */ id: string; /** * The author's ID from your system */ externalId?: string | null | undefined; /** * Block or suspension details, if applicable. Null if the author is enabled. */ block: Block | null; /** * Current author status */ status: AuthorStatus; trustLevel: TrustLevel; }; /** * The evaluation of the content after running the channel policies. */ export type Evaluation = { /** * Whether the content was flagged by any policy. */ flagged: boolean; /** * The probability that the content should be flagged. */ flagProbability: number; /** * The severity score of the content. A higher score indicates more severe content. */ severityScore: number; /** * Whether the content was flagged for Unicode spoofing. */ unicodeSpoofed?: boolean | undefined; /** * Whether the content would have been flagged by analyze-only policies (flag: false). */ shadowFlagged?: boolean | undefined; }; /** * The action to take based on the recommendation */ export const SubmitContentRecommendationAction = { Review: "review", Allow: "allow", Reject: "reject", } as const; /** * The action to take based on the recommendation */ export type SubmitContentRecommendationAction = OpenEnum< typeof SubmitContentRecommendationAction >; export const ReasonCodeEnum = { SeverityReject: "severity_reject", SeverityReview: "severity_review", AuthorBlock: "author_block", DryRun: "dry_run", TrustedAllow: "trusted_allow", UntrustedSeverity: "untrusted_severity", RuleMatch: "rule_match", RuleDefault: "rule_default", RuleFallback: "rule_fallback", ClientOverride: "client_override", CasebookMatch: "casebook_match", } as const; export type ReasonCodeEnum = OpenEnum; export type ReasonCode = ReasonCodeEnum | string; export type MatchedRule = { key: string; name: string; }; /** * The recommendation for the content based on the evaluation. */ export type Recommendation = { /** * The action to take based on the recommendation */ action: SubmitContentRecommendationAction; /** * Reason codes for the recommendation. Standard codes plus a `rule:` code identifying the rule that produced the action. Can be used to display a reason to the user. */ reasonCodes: Array; /** * Rules that matched during evaluation, if rules engine is active. */ matchedRules?: Array | undefined; }; /** * The ruling your past decisions point to for this content. */ export const Verdict = { Allow: "allow", Reject: "reject", } as const; /** * The ruling your past decisions point to for this content. */ export type Verdict = OpenEnum; export type Topic = { id: string; label: string; }; export type Casebook = { /** * The ruling your past decisions point to for this content. */ verdict: Verdict; /** * How close the nearest matching case is, from 0 to 1. 1 means the content is identical to something you have already decided. */ similarity: number; /** * How unanimous the matching cases are, from 0 to 1: the share of them that decided this way, ignoring how many there are. Always at least 0.8 when a ruling is returned — below that the casebook reports a disagreement instead of picking a side — so it tells you how clean the consensus was, and is not a threshold to re-apply yourself. */ agreement: number; /** * How strongly the casebook holds this ruling, from 0 to 1: the agreement scaled by how much evidence backs it, so a handful of close, recent cases outweighs one distant one. Older cases count for less, halving in weight roughly every 180 days. This is the number to use in rules when you want a strength condition. */ confidence: number; /** * How many of your past cases backed this ruling. */ caseCount: number; /** * The topic the closest matching case is filed under, or null when it has not been grouped into one yet. */ topic: Topic | null; }; export const Method = { RegisteredDomainToken: "registered_domain_token", SubdomainToken: "subdomain_token", } as const; export type Method = OpenEnum; export type BrandImpersonation = { brand: string; method: Method; }; /** * Observable properties of a URL (URL Risk only). Absent for allow/block list matches. */ export type SignalsResponse = { brandImpersonation: BrandImpersonation | null; hasSuspiciousCharacters: boolean; isLinkShortener: boolean; domainAgeDays: number | null; hasEmailSetup: boolean | null; redirectCount: number | null; finalUrl: string | null; botProtection: boolean | null; isReported: boolean; }; export type Match = { probability: number; match: string; span: Array; /** * Stable codes explaining why a URL was flagged (URL Risk only). */ reasons?: Array | undefined; /** * Observable properties of a URL (URL Risk only). Absent for allow/block list matches. */ signals?: SignalsResponse | undefined; /** * Sub-type of the entity match — e.g. the NER key (email, phone, name, …) for PII matches. Absent for URL Risk and wordlist matches where the type is already encoded in the parent label. */ entityType?: string | undefined; }; /** * Entity matcher policy. */ export type EntityMatcherOutput = { id: string; type: "entity_matcher"; probability: number; flagged: boolean; flaggedFields?: Array | undefined; matches: Array; }; export type SubmitContentLabel = { id: string; probability: number; flagged: boolean; shadowFlagged?: boolean | undefined; }; /** * Classifier policy. */ export type ClassifierOutput = { /** * The unique identifier for the classifier output. */ id: string; type: "classifier"; probability: number; flagged: boolean; /** * The keys of the flagged fields if submitting an object. */ flaggedFields?: Array | undefined; labels?: Array | undefined; /** * Optional structured data produced by the policy. For face detection: { count, faces: [{ confidence, gender, age }] }. */ data?: { [k: string]: any } | undefined; }; /** * Policy output schema. */ export type PolicyResponse = | ClassifierOutput | EntityMatcherOutput | discriminatedUnionTypes.Unknown<"type">; /** * Compassion insight. Identifies with or shows concern, empathy, or support for the feelings/emotions of others. */ export type CompassionInsight = { id: "compassion"; type: "insight"; probability: number; /** * Whether the content shows compassion. */ value: boolean | null; }; /** * Personal story insight. Includes a personal experience or story as a source of support for the statements made in the comment. */ export type PersonalStoryInsight = { id: "personal_story"; type: "insight"; probability: number; /** * Whether the content shows personal story. */ value: boolean | null; }; /** * Respect insight. Shows deference or appreciation to others, or acknowledges the validity of another person. */ export type RespectInsight = { id: "respect"; type: "insight"; probability: number; /** * Whether the content shows respect. */ value: boolean | null; }; /** * Curiosity insight. Attempts to clarify or ask follow-up questions to better understand another person or idea. */ export type CuriosityInsight = { id: "curiosity"; type: "insight"; probability: number; /** * Whether the content shows curiosity. */ value: boolean | null; }; /** * Language insight */ export type LanguageInsight = { id: "language"; type: "insight"; probability: number; value: string | null; }; export const Value = { Positive: "positive", Neutral: "neutral", Negative: "negative", } as const; export type Value = OpenEnum; /** * Positive and negative scored independently: mixed content scores high on both. Present whenever `value` is set. */ export type Scores = { /** * How positive the content is, 0 to 1. */ positive: number; /** * How negative the content is, 0 to 1. */ negative: number; }; /** * Sentiment insight */ export type SentimentInsight = { id: "sentiment"; type: "insight"; probability: number; value: Value | null; /** * Positive and negative scored independently: mixed content scores high on both. Present whenever `value` is set. */ scores?: Scores | undefined; }; export type Insight = | SentimentInsight | LanguageInsight | CuriosityInsight | RespectInsight | PersonalStoryInsight | CompassionInsight | discriminatedUnionTypes.Unknown<"id">; export const MetaStatus = { Success: "success", PartialSuccess: "partial_success", } as const; export type MetaStatus = OpenEnum; /** * Metadata about the moderation request */ export type Meta = { status: MetaStatus; timestamp: number; /** * The unique key of the channel where the content was handled. Either the channel provided by you or automatically routed. */ channelKey: string; usage: number; processingTime?: string | undefined; }; export type ErrorT = { id: string; message: string; }; /** * Successful response */ export type SubmitContentResponse = { /** * Potentially modified content. */ content: ContentResponse; /** * The author of the content if your account has authors enabled. Requires you to send authorId when submitting content. */ author: Author | null; /** * The evaluation of the content after running the channel policies. */ evaluation: Evaluation; /** * The recommendation for the content based on the evaluation. */ recommendation: Recommendation; /** * What your casebook — the record of your past moderation decisions — found for this content, or null when it had nothing close enough to say, when the matching cases disagreed, or when casebook lookups are not switched on for this channel. Reports what the casebook found; whether it decided the outcome is shown in `recommendation`, where a higher-priority rule may have settled the item first. */ casebook: Casebook | null; /** * Results of all policies in the channel. Sorted by highest probability. */ policies: Array< | ClassifierOutput | EntityMatcherOutput | discriminatedUnionTypes.Unknown<"type"> >; /** * Results of all insights enabled in the channel. */ insights: Array< | SentimentInsight | LanguageInsight | CuriosityInsight | RespectInsight | PersonalStoryInsight | CompassionInsight | discriminatedUnionTypes.Unknown<"id"> >; /** * Metadata about the moderation request */ meta: Meta; /** * Policies that had errors */ errors?: Array | undefined; }; /** @internal */ export type DataAudio$Outbound = { type: "audio"; url: string; }; /** @internal */ export const DataAudio$outboundSchema: z.ZodMiniType< DataAudio$Outbound, DataAudio > = z.object({ type: z.literal("audio"), url: z.string(), }); export function dataAudioToJSON(dataAudio: DataAudio): string { return JSON.stringify(DataAudio$outboundSchema.parse(dataAudio)); } /** @internal */ export type DataVideo$Outbound = { type: "video"; url: string; }; /** @internal */ export const DataVideo$outboundSchema: z.ZodMiniType< DataVideo$Outbound, DataVideo > = z.object({ type: z.literal("video"), url: z.string(), }); export function dataVideoToJSON(dataVideo: DataVideo): string { return JSON.stringify(DataVideo$outboundSchema.parse(dataVideo)); } /** @internal */ export type DataImage$Outbound = { type: "image"; url?: string | undefined; data?: string | undefined; }; /** @internal */ export const DataImage$outboundSchema: z.ZodMiniType< DataImage$Outbound, DataImage > = z.object({ type: z.literal("image"), url: z.optional(z.string()), data: z.optional(z.string()), }); export function dataImageToJSON(dataImage: DataImage): string { return JSON.stringify(DataImage$outboundSchema.parse(dataImage)); } /** @internal */ export type DataText$Outbound = { type: "text"; text: string; }; /** @internal */ export const DataText$outboundSchema: z.ZodMiniType< DataText$Outbound, DataText > = z.object({ type: z.literal("text"), text: z.string(), }); export function dataTextToJSON(dataText: DataText): string { return JSON.stringify(DataText$outboundSchema.parse(dataText)); } /** @internal */ export type ContentLeafRequest$Outbound = | DataText$Outbound | DataImage$Outbound | DataVideo$Outbound | DataAudio$Outbound; /** @internal */ export const ContentLeafRequest$outboundSchema: z.ZodMiniType< ContentLeafRequest$Outbound, ContentLeafRequest > = z.union([ z.lazy(() => DataText$outboundSchema), z.lazy(() => DataImage$outboundSchema), z.lazy(() => DataVideo$outboundSchema), z.lazy(() => DataAudio$outboundSchema), ]); export function contentLeafRequestToJSON( contentLeafRequest: ContentLeafRequest, ): string { return JSON.stringify( ContentLeafRequest$outboundSchema.parse(contentLeafRequest), ); } /** @internal */ export type ObjectT$Outbound = { type: "object"; data: { [k: string]: | DataText$Outbound | DataImage$Outbound | DataVideo$Outbound | DataAudio$Outbound; }; }; /** @internal */ export const ObjectT$outboundSchema: z.ZodMiniType = z.object({ type: z.literal("object"), data: z.record( z.string(), z.union([ z.lazy(() => DataText$outboundSchema), z.lazy(() => DataImage$outboundSchema), z.lazy(() => DataVideo$outboundSchema), z.lazy(() => DataAudio$outboundSchema), ]), ), }); export function objectToJSON(objectT: ObjectT): string { return JSON.stringify(ObjectT$outboundSchema.parse(objectT)); } /** @internal */ export type AudioRequest$Outbound = { type: "audio"; url: string; }; /** @internal */ export const AudioRequest$outboundSchema: z.ZodMiniType< AudioRequest$Outbound, AudioRequest > = z.object({ type: z.literal("audio"), url: z.string(), }); export function audioRequestToJSON(audioRequest: AudioRequest): string { return JSON.stringify(AudioRequest$outboundSchema.parse(audioRequest)); } /** @internal */ export type VideoRequest$Outbound = { type: "video"; url: string; }; /** @internal */ export const VideoRequest$outboundSchema: z.ZodMiniType< VideoRequest$Outbound, VideoRequest > = z.object({ type: z.literal("video"), url: z.string(), }); export function videoRequestToJSON(videoRequest: VideoRequest): string { return JSON.stringify(VideoRequest$outboundSchema.parse(videoRequest)); } /** @internal */ export type ImageRequest$Outbound = { type: "image"; url?: string | undefined; data?: string | undefined; }; /** @internal */ export const ImageRequest$outboundSchema: z.ZodMiniType< ImageRequest$Outbound, ImageRequest > = z.object({ type: z.literal("image"), url: z.optional(z.string()), data: z.optional(z.string()), }); export function imageRequestToJSON(imageRequest: ImageRequest): string { return JSON.stringify(ImageRequest$outboundSchema.parse(imageRequest)); } /** @internal */ export type TextRequest$Outbound = { type: "text"; text: string; }; /** @internal */ export const TextRequest$outboundSchema: z.ZodMiniType< TextRequest$Outbound, TextRequest > = z.object({ type: z.literal("text"), text: z.string(), }); export function textRequestToJSON(textRequest: TextRequest): string { return JSON.stringify(TextRequest$outboundSchema.parse(textRequest)); } /** @internal */ export type ContentRequest$Outbound = | TextRequest$Outbound | ImageRequest$Outbound | VideoRequest$Outbound | AudioRequest$Outbound | ObjectT$Outbound; /** @internal */ export const ContentRequest$outboundSchema: z.ZodMiniType< ContentRequest$Outbound, ContentRequest > = z.union([ z.lazy(() => TextRequest$outboundSchema), z.lazy(() => ImageRequest$outboundSchema), z.lazy(() => VideoRequest$outboundSchema), z.lazy(() => AudioRequest$outboundSchema), z.lazy(() => ObjectT$outboundSchema), ]); export function contentRequestToJSON(contentRequest: ContentRequest): string { return JSON.stringify(ContentRequest$outboundSchema.parse(contentRequest)); } /** @internal */ export const MetaType$outboundSchema: z.ZodMiniEnum = z.enum( MetaType, ); /** @internal */ export const ActionRequest$outboundSchema: z.ZodMiniEnum = z.enum(ActionRequest); /** @internal */ export const Behavior$outboundSchema: z.ZodMiniEnum = z.enum( Behavior, ); /** @internal */ export type ClientAction$Outbound = { action: string; behavior?: string | undefined; source?: string | undefined; reason?: string | undefined; }; /** @internal */ export const ClientAction$outboundSchema: z.ZodMiniType< ClientAction$Outbound, ClientAction > = z.object({ action: ActionRequest$outboundSchema, behavior: z.optional(Behavior$outboundSchema), source: z.optional(z.string()), reason: z.optional(z.string()), }); export function clientActionToJSON(clientAction: ClientAction): string { return JSON.stringify(ClientAction$outboundSchema.parse(clientAction)); } /** @internal */ export type Guideline$Outbound = { flag: boolean; threshold?: number | undefined; id: "guideline"; instructions: string; guidelineKey: string; }; /** @internal */ export const Guideline$outboundSchema: z.ZodMiniType< Guideline$Outbound, Guideline > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("guideline"), instructions: z.string(), guidelineKey: z.string(), }); export function guidelineToJSON(guideline: Guideline): string { return JSON.stringify(Guideline$outboundSchema.parse(guideline)); } /** @internal */ export type URLRisk$Outbound = { flag: boolean; threshold?: number | undefined; id: "url_risk"; allowlistWordlistIds?: Array | undefined; blocklistWordlistIds?: Array | undefined; flagLinkShorteners?: boolean | undefined; }; /** @internal */ export const URLRisk$outboundSchema: z.ZodMiniType = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("url_risk"), allowlistWordlistIds: z.optional(z.array(z.string())), blocklistWordlistIds: z.optional(z.array(z.string())), flagLinkShorteners: z.optional(z.boolean()), }); export function urlRiskToJSON(urlRisk: URLRisk): string { return JSON.stringify(URLRisk$outboundSchema.parse(urlRisk)); } /** @internal */ export type Entities2$Outbound = { enable?: boolean | undefined; flag?: boolean | undefined; shouldMask?: boolean | undefined; mask?: string | undefined; [additionalProperties: string]: unknown; }; /** @internal */ export const Entities2$outboundSchema: z.ZodMiniType< Entities2$Outbound, Entities2 > = z.catchall( z.object({ enable: z.optional(z.boolean()), flag: z.optional(z.boolean()), shouldMask: z.optional(z.boolean()), mask: z.optional(z.string()), }), z.any(), ); export function entities2ToJSON(entities2: Entities2): string { return JSON.stringify(Entities2$outboundSchema.parse(entities2)); } /** @internal */ export type URLMasking$Outbound = { id: "url"; entities: { [k: string]: Entities2$Outbound }; }; /** @internal */ export const URLMasking$outboundSchema: z.ZodMiniType< URLMasking$Outbound, URLMasking > = z.object({ id: z.literal("url"), entities: z.record(z.string(), z.lazy(() => Entities2$outboundSchema)), }); export function urlMaskingToJSON(urlMasking: URLMasking): string { return JSON.stringify(URLMasking$outboundSchema.parse(urlMasking)); } /** @internal */ export type Entities1$Outbound = { enable?: boolean | undefined; flag?: boolean | undefined; shouldMask?: boolean | undefined; mask?: string | undefined; [additionalProperties: string]: unknown; }; /** @internal */ export const Entities1$outboundSchema: z.ZodMiniType< Entities1$Outbound, Entities1 > = z.catchall( z.object({ enable: z.optional(z.boolean()), flag: z.optional(z.boolean()), shouldMask: z.optional(z.boolean()), mask: z.optional(z.string()), }), z.any(), ); export function entities1ToJSON(entities1: Entities1): string { return JSON.stringify(Entities1$outboundSchema.parse(entities1)); } /** @internal */ export type PIIMasking$Outbound = { id: "pii"; entities: { [k: string]: Entities1$Outbound }; }; /** @internal */ export const PIIMasking$outboundSchema: z.ZodMiniType< PIIMasking$Outbound, PIIMasking > = z.object({ id: z.literal("pii"), entities: z.record(z.string(), z.lazy(() => Entities1$outboundSchema)), }); export function piiMaskingToJSON(piiMasking: PIIMasking): string { return JSON.stringify(PIIMasking$outboundSchema.parse(piiMasking)); } /** @internal */ export type SignalsRequest$Outbound = { flag?: boolean | undefined; }; /** @internal */ export const SignalsRequest$outboundSchema: z.ZodMiniType< SignalsRequest$Outbound, SignalsRequest > = z.object({ flag: z.optional(z.boolean()), }); export function signalsRequestToJSON(signalsRequest: SignalsRequest): string { return JSON.stringify(SignalsRequest$outboundSchema.parse(signalsRequest)); } /** @internal */ export type UnicodeSpoofing$Outbound = { flag: boolean; threshold?: number | undefined; id: "unicode_spoofing"; signals?: { [k: string]: SignalsRequest$Outbound } | undefined; }; /** @internal */ export const UnicodeSpoofing$outboundSchema: z.ZodMiniType< UnicodeSpoofing$Outbound, UnicodeSpoofing > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("unicode_spoofing"), signals: z.optional( z.record(z.string(), z.lazy(() => SignalsRequest$outboundSchema)), ), }); export function unicodeSpoofingToJSON( unicodeSpoofing: UnicodeSpoofing, ): string { return JSON.stringify(UnicodeSpoofing$outboundSchema.parse(unicodeSpoofing)); } /** @internal */ export type CodeAbuse$Outbound = { flag: boolean; threshold?: number | undefined; id: "code_abuse"; }; /** @internal */ export const CodeAbuse$outboundSchema: z.ZodMiniType< CodeAbuse$Outbound, CodeAbuse > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("code_abuse"), }); export function codeAbuseToJSON(codeAbuse: CodeAbuse): string { return JSON.stringify(CodeAbuse$outboundSchema.parse(codeAbuse)); } /** @internal */ export type Extremism$Outbound = { flag: boolean; threshold?: number | undefined; id: "extremism"; }; /** @internal */ export const Extremism$outboundSchema: z.ZodMiniType< Extremism$Outbound, Extremism > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("extremism"), }); export function extremismToJSON(extremism: Extremism): string { return JSON.stringify(Extremism$outboundSchema.parse(extremism)); } /** @internal */ export type Promotion$Outbound = { flag: boolean; threshold?: number | undefined; id: "promotion"; }; /** @internal */ export const Promotion$outboundSchema: z.ZodMiniType< Promotion$Outbound, Promotion > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("promotion"), }); export function promotionToJSON(promotion: Promotion): string { return JSON.stringify(Promotion$outboundSchema.parse(promotion)); } /** @internal */ export type Weapons$Outbound = { flag: boolean; threshold?: number | undefined; id: "weapons"; }; /** @internal */ export const Weapons$outboundSchema: z.ZodMiniType = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("weapons"), }); export function weaponsToJSON(weapons: Weapons): string { return JSON.stringify(Weapons$outboundSchema.parse(weapons)); } /** @internal */ export type Tobacco$Outbound = { flag: boolean; threshold?: number | undefined; id: "tobacco"; }; /** @internal */ export const Tobacco$outboundSchema: z.ZodMiniType = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("tobacco"), }); export function tobaccoToJSON(tobacco: Tobacco): string { return JSON.stringify(Tobacco$outboundSchema.parse(tobacco)); } /** @internal */ export type Gambling$Outbound = { flag: boolean; threshold?: number | undefined; id: "gambling"; }; /** @internal */ export const Gambling$outboundSchema: z.ZodMiniType< Gambling$Outbound, Gambling > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("gambling"), }); export function gamblingToJSON(gambling: Gambling): string { return JSON.stringify(Gambling$outboundSchema.parse(gambling)); } /** @internal */ export type Drugs$Outbound = { flag: boolean; threshold?: number | undefined; id: "drugs"; }; /** @internal */ export const Drugs$outboundSchema: z.ZodMiniType = z .object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("drugs"), }); export function drugsToJSON(drugs: Drugs): string { return JSON.stringify(Drugs$outboundSchema.parse(drugs)); } /** @internal */ export type Alcohol$Outbound = { flag: boolean; threshold?: number | undefined; id: "alcohol"; }; /** @internal */ export const Alcohol$outboundSchema: z.ZodMiniType = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("alcohol"), }); export function alcoholToJSON(alcohol: Alcohol): string { return JSON.stringify(Alcohol$outboundSchema.parse(alcohol)); } /** @internal */ export type IllegalTrade$Outbound = { flag: boolean; threshold?: number | undefined; id: "illegal_trade"; }; /** @internal */ export const IllegalTrade$outboundSchema: z.ZodMiniType< IllegalTrade$Outbound, IllegalTrade > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("illegal_trade"), }); export function illegalTradeToJSON(illegalTrade: IllegalTrade): string { return JSON.stringify(IllegalTrade$outboundSchema.parse(illegalTrade)); } /** @internal */ export type ChannelCircumvention$Outbound = { flag: boolean; threshold?: number | undefined; id: "channel_circumvent"; }; /** @internal */ export const ChannelCircumvention$outboundSchema: z.ZodMiniType< ChannelCircumvention$Outbound, ChannelCircumvention > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("channel_circumvent"), }); export function channelCircumventionToJSON( channelCircumvention: ChannelCircumvention, ): string { return JSON.stringify( ChannelCircumvention$outboundSchema.parse(channelCircumvention), ); } /** @internal */ export type SexualSolicitation$Outbound = { flag: boolean; threshold?: number | undefined; id: "sexual_solicitation"; }; /** @internal */ export const SexualSolicitation$outboundSchema: z.ZodMiniType< SexualSolicitation$Outbound, SexualSolicitation > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("sexual_solicitation"), }); export function sexualSolicitationToJSON( sexualSolicitation: SexualSolicitation, ): string { return JSON.stringify( SexualSolicitation$outboundSchema.parse(sexualSolicitation), ); } /** @internal */ export type Threat$Outbound = { flag: boolean; threshold?: number | undefined; id: "threat"; }; /** @internal */ export const Threat$outboundSchema: z.ZodMiniType = z .object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("threat"), }); export function threatToJSON(threat: Threat): string { return JSON.stringify(Threat$outboundSchema.parse(threat)); } /** @internal */ export type Religion$Outbound = { flag: boolean; threshold?: number | undefined; id: "religion"; }; /** @internal */ export const Religion$outboundSchema: z.ZodMiniType< Religion$Outbound, Religion > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("religion"), }); export function religionToJSON(religion: Religion): string { return JSON.stringify(Religion$outboundSchema.parse(religion)); } /** @internal */ export type Political$Outbound = { flag: boolean; threshold?: number | undefined; id: "political"; }; /** @internal */ export const Political$outboundSchema: z.ZodMiniType< Political$Outbound, Political > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("political"), }); export function politicalToJSON(political: Political): string { return JSON.stringify(Political$outboundSchema.parse(political)); } /** @internal */ export type SelfPromotion$Outbound = { flag: boolean; threshold?: number | undefined; id: "self_promotion"; }; /** @internal */ export const SelfPromotion$outboundSchema: z.ZodMiniType< SelfPromotion$Outbound, SelfPromotion > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("self_promotion"), }); export function selfPromotionToJSON(selfPromotion: SelfPromotion): string { return JSON.stringify(SelfPromotion$outboundSchema.parse(selfPromotion)); } /** @internal */ export const Comparator$outboundSchema: z.ZodMiniEnum = z .enum(Comparator); /** @internal */ export type FaceDetection$Outbound = { flag: boolean; threshold?: number | undefined; id: "face_detection"; comparator?: string | undefined; count?: number | undefined; }; /** @internal */ export const FaceDetection$outboundSchema: z.ZodMiniType< FaceDetection$Outbound, FaceDetection > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("face_detection"), comparator: z.optional(Comparator$outboundSchema), count: z.optional(z.int()), }); export function faceDetectionToJSON(faceDetection: FaceDetection): string { return JSON.stringify(FaceDetection$outboundSchema.parse(faceDetection)); } /** @internal */ export type LowQualityContent$Outbound = { flag: boolean; threshold?: number | undefined; id: "low_quality"; minWords?: number | undefined; }; /** @internal */ export const LowQualityContent$outboundSchema: z.ZodMiniType< LowQualityContent$Outbound, LowQualityContent > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("low_quality"), minWords: z.optional(z.int()), }); export function lowQualityContentToJSON( lowQualityContent: LowQualityContent, ): string { return JSON.stringify( LowQualityContent$outboundSchema.parse(lowQualityContent), ); } /** @internal */ export type Spam$Outbound = { flag: boolean; threshold?: number | undefined; id: "spam"; }; /** @internal */ export const Spam$outboundSchema: z.ZodMiniType = z.object( { flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("spam"), }, ); export function spamToJSON(spam: Spam): string { return JSON.stringify(Spam$outboundSchema.parse(spam)); } /** @internal */ export type SelfHarm$Outbound = { flag: boolean; threshold?: number | undefined; id: "self_harm"; }; /** @internal */ export const SelfHarm$outboundSchema: z.ZodMiniType< SelfHarm$Outbound, SelfHarm > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("self_harm"), }); export function selfHarmToJSON(selfHarm: SelfHarm): string { return JSON.stringify(SelfHarm$outboundSchema.parse(selfHarm)); } /** @internal */ export type Violence$Outbound = { flag: boolean; threshold?: number | undefined; id: "violence"; }; /** @internal */ export const Violence$outboundSchema: z.ZodMiniType< Violence$Outbound, Violence > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("violence"), }); export function violenceToJSON(violence: Violence): string { return JSON.stringify(Violence$outboundSchema.parse(violence)); } /** @internal */ export type Profanity$Outbound = { flag: boolean; threshold?: number | undefined; id: "profanity"; }; /** @internal */ export const Profanity$outboundSchema: z.ZodMiniType< Profanity$Outbound, Profanity > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("profanity"), }); export function profanityToJSON(profanity: Profanity): string { return JSON.stringify(Profanity$outboundSchema.parse(profanity)); } /** @internal */ export type SexualMinors$Outbound = { flag: boolean; threshold?: number | undefined; id: "sexual_minors"; }; /** @internal */ export const SexualMinors$outboundSchema: z.ZodMiniType< SexualMinors$Outbound, SexualMinors > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("sexual_minors"), }); export function sexualMinorsToJSON(sexualMinors: SexualMinors): string { return JSON.stringify(SexualMinors$outboundSchema.parse(sexualMinors)); } /** @internal */ export type Sexual$Outbound = { flag: boolean; threshold?: number | undefined; id: "sexual"; }; /** @internal */ export const Sexual$outboundSchema: z.ZodMiniType = z .object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("sexual"), }); export function sexualToJSON(sexual: Sexual): string { return JSON.stringify(Sexual$outboundSchema.parse(sexual)); } /** @internal */ export type Crypto$Outbound = { flag: boolean; threshold?: number | undefined; id: "crypto"; }; /** @internal */ export const Crypto$outboundSchema: z.ZodMiniType = z .object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("crypto"), }); export function cryptoToJSON(crypto: Crypto): string { return JSON.stringify(Crypto$outboundSchema.parse(crypto)); } /** @internal */ export type Adult$Outbound = { flag: boolean; threshold?: number | undefined; id: "adult"; }; /** @internal */ export const Adult$outboundSchema: z.ZodMiniType = z .object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("adult"), }); export function adultToJSON(adult: Adult): string { return JSON.stringify(Adult$outboundSchema.parse(adult)); } /** @internal */ export type Cannabis$Outbound = { flag: boolean; threshold?: number | undefined; id: "cannabis"; }; /** @internal */ export const Cannabis$outboundSchema: z.ZodMiniType< Cannabis$Outbound, Cannabis > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("cannabis"), }); export function cannabisToJSON(cannabis: Cannabis): string { return JSON.stringify(Cannabis$outboundSchema.parse(cannabis)); } /** @internal */ export type IllicitGambling$Outbound = { flag: boolean; threshold?: number | undefined; id: "illicit_gambling"; }; /** @internal */ export const IllicitGambling$outboundSchema: z.ZodMiniType< IllicitGambling$Outbound, IllicitGambling > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("illicit_gambling"), }); export function illicitGamblingToJSON( illicitGambling: IllicitGambling, ): string { return JSON.stringify(IllicitGambling$outboundSchema.parse(illicitGambling)); } /** @internal */ export type IllicitTobacco$Outbound = { flag: boolean; threshold?: number | undefined; id: "illicit_tobacco"; }; /** @internal */ export const IllicitTobacco$outboundSchema: z.ZodMiniType< IllicitTobacco$Outbound, IllicitTobacco > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("illicit_tobacco"), }); export function illicitTobaccoToJSON(illicitTobacco: IllicitTobacco): string { return JSON.stringify(IllicitTobacco$outboundSchema.parse(illicitTobacco)); } /** @internal */ export type IllicitFirearms$Outbound = { flag: boolean; threshold?: number | undefined; id: "illicit_firearms"; }; /** @internal */ export const IllicitFirearms$outboundSchema: z.ZodMiniType< IllicitFirearms$Outbound, IllicitFirearms > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("illicit_firearms"), }); export function illicitFirearmsToJSON( illicitFirearms: IllicitFirearms, ): string { return JSON.stringify(IllicitFirearms$outboundSchema.parse(illicitFirearms)); } /** @internal */ export type IllicitAlcohol$Outbound = { flag: boolean; threshold?: number | undefined; id: "illicit_alcohol"; }; /** @internal */ export const IllicitAlcohol$outboundSchema: z.ZodMiniType< IllicitAlcohol$Outbound, IllicitAlcohol > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("illicit_alcohol"), }); export function illicitAlcoholToJSON(illicitAlcohol: IllicitAlcohol): string { return JSON.stringify(IllicitAlcohol$outboundSchema.parse(illicitAlcohol)); } /** @internal */ export type IllicitDrugs$Outbound = { flag: boolean; threshold?: number | undefined; id: "illicit_drugs"; }; /** @internal */ export const IllicitDrugs$outboundSchema: z.ZodMiniType< IllicitDrugs$Outbound, IllicitDrugs > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("illicit_drugs"), }); export function illicitDrugsToJSON(illicitDrugs: IllicitDrugs): string { return JSON.stringify(IllicitDrugs$outboundSchema.parse(illicitDrugs)); } /** @internal */ export type Illicit$Outbound = { flag: boolean; threshold?: number | undefined; id: "illicit"; }; /** @internal */ export const Illicit$outboundSchema: z.ZodMiniType = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("illicit"), }); export function illicitToJSON(illicit: Illicit): string { return JSON.stringify(Illicit$outboundSchema.parse(illicit)); } /** @internal */ export type Hate$Outbound = { flag: boolean; threshold?: number | undefined; id: "hate"; }; /** @internal */ export const Hate$outboundSchema: z.ZodMiniType = z.object( { flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("hate"), }, ); export function hateToJSON(hate: Hate): string { return JSON.stringify(Hate$outboundSchema.parse(hate)); } /** @internal */ export type PersonalInformation$Outbound = { flag: boolean; threshold?: number | undefined; id: "personal_information"; }; /** @internal */ export const PersonalInformation$outboundSchema: z.ZodMiniType< PersonalInformation$Outbound, PersonalInformation > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("personal_information"), }); export function personalInformationToJSON( personalInformation: PersonalInformation, ): string { return JSON.stringify( PersonalInformation$outboundSchema.parse(personalInformation), ); } /** @internal */ export type Toxicity$Outbound = { flag: boolean; threshold?: number | undefined; id: "toxicity"; }; /** @internal */ export const Toxicity$outboundSchema: z.ZodMiniType< Toxicity$Outbound, Toxicity > = z.object({ flag: z.boolean(), threshold: z.optional(z.number()), id: z.literal("toxicity"), }); export function toxicityToJSON(toxicity: Toxicity): string { return JSON.stringify(Toxicity$outboundSchema.parse(toxicity)); } /** @internal */ export type PolicyRequest$Outbound = | Toxicity$Outbound | PersonalInformation$Outbound | Hate$Outbound | Illicit$Outbound | IllicitDrugs$Outbound | IllicitAlcohol$Outbound | IllicitFirearms$Outbound | IllicitTobacco$Outbound | IllicitGambling$Outbound | Cannabis$Outbound | Adult$Outbound | Crypto$Outbound | Sexual$Outbound | SexualMinors$Outbound | Profanity$Outbound | Violence$Outbound | SelfHarm$Outbound | Spam$Outbound | LowQualityContent$Outbound | FaceDetection$Outbound | SelfPromotion$Outbound | Political$Outbound | Religion$Outbound | Threat$Outbound | SexualSolicitation$Outbound | ChannelCircumvention$Outbound | IllegalTrade$Outbound | Alcohol$Outbound | Drugs$Outbound | Gambling$Outbound | Tobacco$Outbound | Weapons$Outbound | Promotion$Outbound | Extremism$Outbound | CodeAbuse$Outbound | UnicodeSpoofing$Outbound | PIIMasking$Outbound | URLMasking$Outbound | URLRisk$Outbound | Guideline$Outbound; /** @internal */ export const PolicyRequest$outboundSchema: z.ZodMiniType< PolicyRequest$Outbound, PolicyRequest > = z.union([ z.lazy(() => Toxicity$outboundSchema), z.lazy(() => PersonalInformation$outboundSchema), z.lazy(() => Hate$outboundSchema), z.lazy(() => Illicit$outboundSchema), z.lazy(() => IllicitDrugs$outboundSchema), z.lazy(() => IllicitAlcohol$outboundSchema), z.lazy(() => IllicitFirearms$outboundSchema), z.lazy(() => IllicitTobacco$outboundSchema), z.lazy(() => IllicitGambling$outboundSchema), z.lazy(() => Cannabis$outboundSchema), z.lazy(() => Adult$outboundSchema), z.lazy(() => Crypto$outboundSchema), z.lazy(() => Sexual$outboundSchema), z.lazy(() => SexualMinors$outboundSchema), z.lazy(() => Profanity$outboundSchema), z.lazy(() => Violence$outboundSchema), z.lazy(() => SelfHarm$outboundSchema), z.lazy(() => Spam$outboundSchema), z.lazy(() => LowQualityContent$outboundSchema), z.lazy(() => FaceDetection$outboundSchema), z.lazy(() => SelfPromotion$outboundSchema), z.lazy(() => Political$outboundSchema), z.lazy(() => Religion$outboundSchema), z.lazy(() => Threat$outboundSchema), z.lazy(() => SexualSolicitation$outboundSchema), z.lazy(() => ChannelCircumvention$outboundSchema), z.lazy(() => IllegalTrade$outboundSchema), z.lazy(() => Alcohol$outboundSchema), z.lazy(() => Drugs$outboundSchema), z.lazy(() => Gambling$outboundSchema), z.lazy(() => Tobacco$outboundSchema), z.lazy(() => Weapons$outboundSchema), z.lazy(() => Promotion$outboundSchema), z.lazy(() => Extremism$outboundSchema), z.lazy(() => CodeAbuse$outboundSchema), z.lazy(() => UnicodeSpoofing$outboundSchema), z.lazy(() => PIIMasking$outboundSchema), z.lazy(() => URLMasking$outboundSchema), z.lazy(() => URLRisk$outboundSchema), z.lazy(() => Guideline$outboundSchema), ]); export function policyRequestToJSON(policyRequest: PolicyRequest): string { return JSON.stringify(PolicyRequest$outboundSchema.parse(policyRequest)); } /** @internal */ export type SubmitContentRequestBody$Outbound = { content: | TextRequest$Outbound | ImageRequest$Outbound | VideoRequest$Outbound | AudioRequest$Outbound | ObjectT$Outbound; timestamp?: number | undefined; channel?: string | undefined; contentId?: string | undefined; metaType?: string | undefined; authorId?: string | undefined; conversationId?: string | undefined; metadata?: { [k: string]: any } | undefined; clientAction?: ClientAction$Outbound | undefined; doNotStore?: boolean | undefined; policies?: | Array< | Toxicity$Outbound | PersonalInformation$Outbound | Hate$Outbound | Illicit$Outbound | IllicitDrugs$Outbound | IllicitAlcohol$Outbound | IllicitFirearms$Outbound | IllicitTobacco$Outbound | IllicitGambling$Outbound | Cannabis$Outbound | Adult$Outbound | Crypto$Outbound | Sexual$Outbound | SexualMinors$Outbound | Profanity$Outbound | Violence$Outbound | SelfHarm$Outbound | Spam$Outbound | LowQualityContent$Outbound | FaceDetection$Outbound | SelfPromotion$Outbound | Political$Outbound | Religion$Outbound | Threat$Outbound | SexualSolicitation$Outbound | ChannelCircumvention$Outbound | IllegalTrade$Outbound | Alcohol$Outbound | Drugs$Outbound | Gambling$Outbound | Tobacco$Outbound | Weapons$Outbound | Promotion$Outbound | Extremism$Outbound | CodeAbuse$Outbound | UnicodeSpoofing$Outbound | PIIMasking$Outbound | URLMasking$Outbound | URLRisk$Outbound | Guideline$Outbound > | undefined; }; /** @internal */ export const SubmitContentRequestBody$outboundSchema: z.ZodMiniType< SubmitContentRequestBody$Outbound, SubmitContentRequestBody > = z.object({ content: z.union([ z.lazy(() => TextRequest$outboundSchema), z.lazy(() => ImageRequest$outboundSchema), z.lazy(() => VideoRequest$outboundSchema), z.lazy(() => AudioRequest$outboundSchema), z.lazy(() => ObjectT$outboundSchema), ]), timestamp: z.optional(z.number()), channel: z.optional(z.string()), contentId: z.optional(z.string()), metaType: z.optional(MetaType$outboundSchema), authorId: z.optional(z.string()), conversationId: z.optional(z.string()), metadata: z.optional(z.record(z.string(), z.any())), clientAction: z.optional(z.lazy(() => ClientAction$outboundSchema)), doNotStore: z.optional(z.boolean()), policies: z.optional( z.array(z.union([ z.lazy(() => Toxicity$outboundSchema), z.lazy(() => PersonalInformation$outboundSchema ), z.lazy(() => Hate$outboundSchema), z.lazy(() => Illicit$outboundSchema), z.lazy(() => IllicitDrugs$outboundSchema), z.lazy(() => IllicitAlcohol$outboundSchema), z.lazy(() => IllicitFirearms$outboundSchema), z.lazy(() => IllicitTobacco$outboundSchema), z.lazy(() => IllicitGambling$outboundSchema), z.lazy(() => Cannabis$outboundSchema), z.lazy(() => Adult$outboundSchema), z.lazy(() => Crypto$outboundSchema), z.lazy(() => Sexual$outboundSchema), z.lazy(() => SexualMinors$outboundSchema), z.lazy(() => Profanity$outboundSchema), z.lazy(() => Violence$outboundSchema), z.lazy(() => SelfHarm$outboundSchema), z.lazy(() => Spam$outboundSchema), z.lazy(() => LowQualityContent$outboundSchema), z.lazy(() => FaceDetection$outboundSchema), z.lazy(() => SelfPromotion$outboundSchema), z.lazy(() => Political$outboundSchema), z.lazy(() => Religion$outboundSchema), z.lazy(() => Threat$outboundSchema), z.lazy(() => SexualSolicitation$outboundSchema), z.lazy(() => ChannelCircumvention$outboundSchema), z.lazy(() => IllegalTrade$outboundSchema), z.lazy(() => Alcohol$outboundSchema), z.lazy(() => Drugs$outboundSchema), z.lazy(() => Gambling$outboundSchema), z.lazy(() => Tobacco$outboundSchema), z.lazy(() => Weapons$outboundSchema), z.lazy(() => Promotion$outboundSchema), z.lazy(() => Extremism$outboundSchema), z.lazy(() => CodeAbuse$outboundSchema), z.lazy(() => UnicodeSpoofing$outboundSchema), z.lazy(() => PIIMasking$outboundSchema), z.lazy(() => URLMasking$outboundSchema), z.lazy(() => URLRisk$outboundSchema), z.lazy(() => Guideline$outboundSchema), ])), ), }); export function submitContentRequestBodyToJSON( submitContentRequestBody: SubmitContentRequestBody, ): string { return JSON.stringify( SubmitContentRequestBody$outboundSchema.parse(submitContentRequestBody), ); } /** @internal */ export type SubmitContentRequest$Outbound = { projectId?: string | undefined; body: SubmitContentRequestBody$Outbound; }; /** @internal */ export const SubmitContentRequest$outboundSchema: z.ZodMiniType< SubmitContentRequest$Outbound, SubmitContentRequest > = z.object({ projectId: z.optional(z.string()), body: z.lazy(() => SubmitContentRequestBody$outboundSchema), }); export function submitContentRequestToJSON( submitContentRequest: SubmitContentRequest, ): string { return JSON.stringify( SubmitContentRequest$outboundSchema.parse(submitContentRequest), ); } /** @internal */ export const AudioResponse$inboundSchema: z.ZodMiniType< AudioResponse, unknown > = z.object({ type: types.literal("audio"), url: types.string(), }); export function audioResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AudioResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AudioResponse' from JSON`, ); } /** @internal */ export const VideoResponse$inboundSchema: z.ZodMiniType< VideoResponse, unknown > = z.object({ type: types.literal("video"), url: types.string(), }); export function videoResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => VideoResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'VideoResponse' from JSON`, ); } /** @internal */ export const ImageResponse$inboundSchema: z.ZodMiniType< ImageResponse, unknown > = z.object({ type: types.literal("image"), url: types.optional(types.string()), data: types.optional(types.string()), }); export function imageResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ImageResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ImageResponse' from JSON`, ); } /** @internal */ export const TextResponse$inboundSchema: z.ZodMiniType = z.object({ type: types.literal("text"), text: types.string(), }); export function textResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TextResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TextResponse' from JSON`, ); } /** @internal */ export const ContentLeafResponse$inboundSchema: z.ZodMiniType< ContentLeafResponse, unknown > = discriminatedUnion("type", { text: z.lazy(() => TextResponse$inboundSchema), image: z.lazy(() => ImageResponse$inboundSchema), video: z.lazy(() => VideoResponse$inboundSchema), audio: z.lazy(() => AudioResponse$inboundSchema), }); export function contentLeafResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ContentLeafResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContentLeafResponse' from JSON`, ); } /** @internal */ export const Modified$inboundSchema: z.ZodMiniType = smartUnion([ types.string(), z.record(z.string(), z.any()), z.record( z.string(), discriminatedUnion("type", { text: z.lazy(() => TextResponse$inboundSchema), image: z.lazy(() => ImageResponse$inboundSchema), video: z.lazy(() => VideoResponse$inboundSchema), audio: z.lazy(() => AudioResponse$inboundSchema), }), ), ]); export function modifiedFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Modified$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Modified' from JSON`, ); } /** @internal */ export const ContentResponse$inboundSchema: z.ZodMiniType< ContentResponse, unknown > = z.pipe( z.object({ id: types.string(), masked: types.boolean(), unicode_cleaned: types.boolean(), modified: types.nullable( smartUnion([ types.string(), z.record(z.string(), z.any()), z.record( z.string(), discriminatedUnion("type", { text: z.lazy(() => TextResponse$inboundSchema), image: z.lazy(() => ImageResponse$inboundSchema), video: z.lazy(() => VideoResponse$inboundSchema), audio: z.lazy(() => AudioResponse$inboundSchema), }), ), ]), ), transcript: z.optional(z.nullable(types.string())), }), z.transform((v) => { return remap$(v, { "unicode_cleaned": "unicodeCleaned", }); }), ); export function contentResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ContentResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContentResponse' from JSON`, ); } /** @internal */ export const Block$inboundSchema: z.ZodMiniType = z.object({ until: z.optional(z.nullable(types.number())), reason: z.optional(z.nullable(types.string())), }); export function blockFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Block$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Block' from JSON`, ); } /** @internal */ export const AuthorStatus$inboundSchema: z.ZodMiniType = openEnums.inboundSchema(AuthorStatus); /** @internal */ export const TrustLevel$inboundSchema: z.ZodMiniType = z .object({ level: types.number(), manual: types.boolean(), }); export function trustLevelFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TrustLevel$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TrustLevel' from JSON`, ); } /** @internal */ export const Author$inboundSchema: z.ZodMiniType = z.pipe( z.object({ id: types.string(), external_id: z.optional(z.nullable(types.string())), block: types.nullable(z.lazy(() => Block$inboundSchema)), status: AuthorStatus$inboundSchema, trust_level: z.lazy(() => TrustLevel$inboundSchema), }), z.transform((v) => { return remap$(v, { "external_id": "externalId", "trust_level": "trustLevel", }); }), ); export function authorFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Author$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Author' from JSON`, ); } /** @internal */ export const Evaluation$inboundSchema: z.ZodMiniType = z .pipe( z.object({ flagged: types.boolean(), flag_probability: types.number(), severity_score: types.number(), unicode_spoofed: types.optional(types.boolean()), shadow_flagged: types.optional(types.boolean()), }), z.transform((v) => { return remap$(v, { "flag_probability": "flagProbability", "severity_score": "severityScore", "unicode_spoofed": "unicodeSpoofed", "shadow_flagged": "shadowFlagged", }); }), ); export function evaluationFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Evaluation$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Evaluation' from JSON`, ); } /** @internal */ export const SubmitContentRecommendationAction$inboundSchema: z.ZodMiniType< SubmitContentRecommendationAction, unknown > = openEnums.inboundSchema(SubmitContentRecommendationAction); /** @internal */ export const ReasonCodeEnum$inboundSchema: z.ZodMiniType< ReasonCodeEnum, unknown > = openEnums.inboundSchema(ReasonCodeEnum); /** @internal */ export const ReasonCode$inboundSchema: z.ZodMiniType = smartUnion([ReasonCodeEnum$inboundSchema, types.string()]); export function reasonCodeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ReasonCode$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ReasonCode' from JSON`, ); } /** @internal */ export const MatchedRule$inboundSchema: z.ZodMiniType = z .object({ key: types.string(), name: types.string(), }); export function matchedRuleFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => MatchedRule$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'MatchedRule' from JSON`, ); } /** @internal */ export const Recommendation$inboundSchema: z.ZodMiniType< Recommendation, unknown > = z.pipe( z.object({ action: SubmitContentRecommendationAction$inboundSchema, reason_codes: z.array( smartUnion([ReasonCodeEnum$inboundSchema, types.string()]), ), matched_rules: types.optional( z.array(z.lazy(() => MatchedRule$inboundSchema)), ), }), z.transform((v) => { return remap$(v, { "reason_codes": "reasonCodes", "matched_rules": "matchedRules", }); }), ); export function recommendationFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Recommendation$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Recommendation' from JSON`, ); } /** @internal */ export const Verdict$inboundSchema: z.ZodMiniType = openEnums .inboundSchema(Verdict); /** @internal */ export const Topic$inboundSchema: z.ZodMiniType = z.object({ id: types.string(), label: types.string(), }); export function topicFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Topic$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Topic' from JSON`, ); } /** @internal */ export const Casebook$inboundSchema: z.ZodMiniType = z.pipe( z.object({ verdict: Verdict$inboundSchema, similarity: types.number(), agreement: types.number(), confidence: types.number(), case_count: types.number(), topic: types.nullable(z.lazy(() => Topic$inboundSchema)), }), z.transform((v) => { return remap$(v, { "case_count": "caseCount", }); }), ); export function casebookFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Casebook$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Casebook' from JSON`, ); } /** @internal */ export const Method$inboundSchema: z.ZodMiniType = openEnums .inboundSchema(Method); /** @internal */ export const BrandImpersonation$inboundSchema: z.ZodMiniType< BrandImpersonation, unknown > = z.object({ brand: types.string(), method: Method$inboundSchema, }); export function brandImpersonationFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BrandImpersonation$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BrandImpersonation' from JSON`, ); } /** @internal */ export const SignalsResponse$inboundSchema: z.ZodMiniType< SignalsResponse, unknown > = z.pipe( z.object({ brand_impersonation: types.nullable( z.lazy(() => BrandImpersonation$inboundSchema), ), has_suspicious_characters: types.boolean(), is_link_shortener: types.boolean(), domain_age_days: types.nullable(types.number()), has_email_setup: types.nullable(types.boolean()), redirect_count: types.nullable(types.number()), final_url: types.nullable(types.string()), bot_protection: types.nullable(types.boolean()), is_reported: types.boolean(), }), z.transform((v) => { return remap$(v, { "brand_impersonation": "brandImpersonation", "has_suspicious_characters": "hasSuspiciousCharacters", "is_link_shortener": "isLinkShortener", "domain_age_days": "domainAgeDays", "has_email_setup": "hasEmailSetup", "redirect_count": "redirectCount", "final_url": "finalUrl", "bot_protection": "botProtection", "is_reported": "isReported", }); }), ); export function signalsResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SignalsResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SignalsResponse' from JSON`, ); } /** @internal */ export const Match$inboundSchema: z.ZodMiniType = z.pipe( z.object({ probability: types.number(), match: types.string(), span: z.array(types.number()), reasons: types.optional(z.array(types.string())), signals: types.optional(z.lazy(() => SignalsResponse$inboundSchema)), entity_type: types.optional(types.string()), }), z.transform((v) => { return remap$(v, { "entity_type": "entityType", }); }), ); export function matchFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Match$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Match' from JSON`, ); } /** @internal */ export const EntityMatcherOutput$inboundSchema: z.ZodMiniType< EntityMatcherOutput, unknown > = z.pipe( z.object({ id: types.string(), type: types.literal("entity_matcher"), probability: types.number(), flagged: types.boolean(), flagged_fields: types.optional(z.array(types.string())), matches: z.array(z.lazy(() => Match$inboundSchema)), }), z.transform((v) => { return remap$(v, { "flagged_fields": "flaggedFields", }); }), ); export function entityMatcherOutputFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EntityMatcherOutput$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EntityMatcherOutput' from JSON`, ); } /** @internal */ export const SubmitContentLabel$inboundSchema: z.ZodMiniType< SubmitContentLabel, unknown > = z.object({ id: types.string(), probability: types.number(), flagged: types.boolean(), shadowFlagged: types.optional(types.boolean()), }); export function submitContentLabelFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SubmitContentLabel$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SubmitContentLabel' from JSON`, ); } /** @internal */ export const ClassifierOutput$inboundSchema: z.ZodMiniType< ClassifierOutput, unknown > = z.pipe( z.object({ id: types.string(), type: types.literal("classifier"), probability: types.number(), flagged: types.boolean(), flagged_fields: types.optional(z.array(types.string())), labels: types.optional( z.array(z.lazy(() => SubmitContentLabel$inboundSchema)), ), data: types.optional(z.record(z.string(), z.any())), }), z.transform((v) => { return remap$(v, { "flagged_fields": "flaggedFields", }); }), ); export function classifierOutputFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ClassifierOutput$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ClassifierOutput' from JSON`, ); } /** @internal */ export const PolicyResponse$inboundSchema: z.ZodMiniType< PolicyResponse, unknown > = discriminatedUnion("type", { classifier: z.lazy(() => ClassifierOutput$inboundSchema), entity_matcher: z.lazy(() => EntityMatcherOutput$inboundSchema), }); export function policyResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PolicyResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PolicyResponse' from JSON`, ); } /** @internal */ export const CompassionInsight$inboundSchema: z.ZodMiniType< CompassionInsight, unknown > = z.object({ id: types.literal("compassion"), type: types.literal("insight"), probability: types.number(), value: types.nullable(types.boolean()), }); export function compassionInsightFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CompassionInsight$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CompassionInsight' from JSON`, ); } /** @internal */ export const PersonalStoryInsight$inboundSchema: z.ZodMiniType< PersonalStoryInsight, unknown > = z.object({ id: types.literal("personal_story"), type: types.literal("insight"), probability: types.number(), value: types.nullable(types.boolean()), }); export function personalStoryInsightFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PersonalStoryInsight$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PersonalStoryInsight' from JSON`, ); } /** @internal */ export const RespectInsight$inboundSchema: z.ZodMiniType< RespectInsight, unknown > = z.object({ id: types.literal("respect"), type: types.literal("insight"), probability: types.number(), value: types.nullable(types.boolean()), }); export function respectInsightFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => RespectInsight$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'RespectInsight' from JSON`, ); } /** @internal */ export const CuriosityInsight$inboundSchema: z.ZodMiniType< CuriosityInsight, unknown > = z.object({ id: types.literal("curiosity"), type: types.literal("insight"), probability: types.number(), value: types.nullable(types.boolean()), }); export function curiosityInsightFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CuriosityInsight$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CuriosityInsight' from JSON`, ); } /** @internal */ export const LanguageInsight$inboundSchema: z.ZodMiniType< LanguageInsight, unknown > = z.object({ id: types.literal("language"), type: types.literal("insight"), probability: types.number(), value: types.nullable(types.string()), }); export function languageInsightFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => LanguageInsight$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'LanguageInsight' from JSON`, ); } /** @internal */ export const Value$inboundSchema: z.ZodMiniType = openEnums .inboundSchema(Value); /** @internal */ export const Scores$inboundSchema: z.ZodMiniType = z.object({ positive: types.number(), negative: types.number(), }); export function scoresFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Scores$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Scores' from JSON`, ); } /** @internal */ export const SentimentInsight$inboundSchema: z.ZodMiniType< SentimentInsight, unknown > = z.object({ id: types.literal("sentiment"), type: types.literal("insight"), probability: types.number(), value: types.nullable(Value$inboundSchema), scores: types.optional(z.lazy(() => Scores$inboundSchema)), }); export function sentimentInsightFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SentimentInsight$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SentimentInsight' from JSON`, ); } /** @internal */ export const Insight$inboundSchema: z.ZodMiniType = discriminatedUnion("id", { sentiment: z.lazy(() => SentimentInsight$inboundSchema), language: z.lazy(() => LanguageInsight$inboundSchema), curiosity: z.lazy(() => CuriosityInsight$inboundSchema), respect: z.lazy(() => RespectInsight$inboundSchema), personal_story: z.lazy(() => PersonalStoryInsight$inboundSchema), compassion: z.lazy(() => CompassionInsight$inboundSchema), }); export function insightFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Insight$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Insight' from JSON`, ); } /** @internal */ export const MetaStatus$inboundSchema: z.ZodMiniType = openEnums.inboundSchema(MetaStatus); /** @internal */ export const Meta$inboundSchema: z.ZodMiniType = z.pipe( z.object({ status: MetaStatus$inboundSchema, timestamp: types.number(), channel_key: types.string(), usage: types.number(), processing_time: types.optional(types.string()), }), z.transform((v) => { return remap$(v, { "channel_key": "channelKey", "processing_time": "processingTime", }); }), ); export function metaFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Meta$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Meta' from JSON`, ); } /** @internal */ export const ErrorT$inboundSchema: z.ZodMiniType = z.object({ id: types.string(), message: types.string(), }); export function errorFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ErrorT$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ErrorT' from JSON`, ); } /** @internal */ export const SubmitContentResponse$inboundSchema: z.ZodMiniType< SubmitContentResponse, unknown > = z.object({ content: z.lazy(() => ContentResponse$inboundSchema), author: types.nullable(z.lazy(() => Author$inboundSchema)), evaluation: z.lazy(() => Evaluation$inboundSchema), recommendation: z.lazy(() => Recommendation$inboundSchema), casebook: types.nullable(z.lazy(() => Casebook$inboundSchema)), policies: z.array( discriminatedUnion("type", { classifier: z.lazy(() => ClassifierOutput$inboundSchema), entity_matcher: z.lazy(() => EntityMatcherOutput$inboundSchema), }), ), insights: z.array(discriminatedUnion("id", { sentiment: z.lazy(() => SentimentInsight$inboundSchema), language: z.lazy(() => LanguageInsight$inboundSchema), curiosity: z.lazy(() => CuriosityInsight$inboundSchema), respect: z.lazy(() => RespectInsight$inboundSchema), personal_story: z.lazy(() => PersonalStoryInsight$inboundSchema), compassion: z.lazy(() => CompassionInsight$inboundSchema), })), meta: z.lazy(() => Meta$inboundSchema), errors: types.optional(z.array(z.lazy(() => ErrorT$inboundSchema))), }); export function submitContentResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SubmitContentResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SubmitContentResponse' from JSON`, ); }