/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 908fbd640ca2 */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ConnectorType, ConnectorType$inboundSchema, ConnectorType$outboundSchema, } from "./connectortype.js"; import { DocumentContent, DocumentContent$inboundSchema, DocumentContent$Outbound, DocumentContent$outboundSchema, } from "./documentcontent.js"; import { DocumentMetadata, DocumentMetadata$inboundSchema, DocumentMetadata$Outbound, DocumentMetadata$outboundSchema, } from "./documentmetadata.js"; import { DocumentSection, DocumentSection$inboundSchema, DocumentSection$Outbound, DocumentSection$outboundSchema, } from "./documentsection.js"; export type Document = { /** * The Glean Document ID. */ id?: string | undefined; /** * The app or other repository type from which the document was extracted */ datasource?: string | undefined; /** * The source from which document content was pulled, e.g. an API crawl or browser history */ connectorType?: ConnectorType | undefined; /** * The datasource-specific type of the document (e.g. for Jira issues, this is the issue type such as Bug or Feature Request). */ docType?: string | undefined; content?: DocumentContent | undefined; containerDocument?: Document | undefined; parentDocument?: Document | undefined; /** * The title of the document. */ title?: string | undefined; /** * A permalink for the document. */ url?: string | undefined; metadata?: DocumentMetadata | undefined; /** * A list of content sub-sections in the document, e.g. text blocks with different headings in a Drive doc or Confluence page. */ sections?: Array | undefined; }; /** @internal */ export const Document$inboundSchema: z.ZodType< Document, z.ZodTypeDef, unknown > = z.object({ id: z.string().optional(), datasource: z.string().optional(), connectorType: ConnectorType$inboundSchema.optional(), docType: z.string().optional(), content: DocumentContent$inboundSchema.optional(), containerDocument: z.lazy(() => Document$inboundSchema).optional(), parentDocument: z.lazy(() => Document$inboundSchema).optional(), title: z.string().optional(), url: z.string().optional(), metadata: z.lazy(() => DocumentMetadata$inboundSchema).optional(), sections: z.array(DocumentSection$inboundSchema).optional(), }); /** @internal */ export type Document$Outbound = { id?: string | undefined; datasource?: string | undefined; connectorType?: string | undefined; docType?: string | undefined; content?: DocumentContent$Outbound | undefined; containerDocument?: Document$Outbound | undefined; parentDocument?: Document$Outbound | undefined; title?: string | undefined; url?: string | undefined; metadata?: DocumentMetadata$Outbound | undefined; sections?: Array | undefined; }; /** @internal */ export const Document$outboundSchema: z.ZodType< Document$Outbound, z.ZodTypeDef, Document > = z.object({ id: z.string().optional(), datasource: z.string().optional(), connectorType: ConnectorType$outboundSchema.optional(), docType: z.string().optional(), content: DocumentContent$outboundSchema.optional(), containerDocument: z.lazy(() => Document$outboundSchema).optional(), parentDocument: z.lazy(() => Document$outboundSchema).optional(), title: z.string().optional(), url: z.string().optional(), metadata: z.lazy(() => DocumentMetadata$outboundSchema).optional(), sections: z.array(DocumentSection$outboundSchema).optional(), }); export function documentToJSON(document: Document): string { return JSON.stringify(Document$outboundSchema.parse(document)); } export function documentFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Document$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Document' from JSON`, ); }