/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { CustomMappings, CustomMappings$inboundSchema, CustomMappings$Outbound, CustomMappings$outboundSchema, } from "./custommappings.js"; import { FileType, FileType$inboundSchema, FileType$outboundSchema, } from "./filetype.js"; import { LinkedFolder, LinkedFolder$inboundSchema, LinkedFolder$Outbound, LinkedFolder$outboundSchema, } from "./linkedfolder.js"; import { Owner, Owner$inboundSchema, Owner$Outbound, Owner$outboundSchema, } from "./owner.js"; /** * Permissions the current user has on this file. */ export type Permissions = { /** * Whether the current user can download this file. */ download?: boolean | undefined; }; export type UnifiedFile = { /** * A unique identifier for an object. */ id: string; /** * The third-party API ID of original entity */ downstreamId?: string | null | undefined; /** * The name of the file */ name: string | null; /** * Optional description of the file */ description?: string | null | undefined; /** * The type of resource. Could be file, folder or url */ type: FileType | null; /** * The full path of the file or folder (includes the file name) */ path?: string | null | undefined; /** * The MIME type of the file. */ mimeType?: string | null | undefined; /** * Whether the current user can download this file */ downloadable?: boolean | undefined; /** * The size of the file in bytes */ size?: number | null | undefined; owner?: Owner | undefined; /** * The parent folders of the file, starting from the root */ parentFolders?: Array | undefined; /** * Whether the list of parent folders is complete. Some connectors only return the direct parent of a file */ parentFoldersComplete?: boolean | undefined; /** * Permissions the current user has on this file. */ permissions?: Permissions | undefined; /** * Whether the current file is exportable to other file formats. This property is relevant for proprietary file formats such as Google Docs or Dropbox Paper. */ exportable?: boolean | undefined; /** * The available file formats when exporting this file. */ exportFormats?: Array | null | undefined; /** * When custom mappings are configured on the resource, the result is included here. */ customMappings?: CustomMappings | null | undefined; /** * The user who last updated the object. */ updatedBy?: string | null | undefined; /** * The user who created the object. */ createdBy?: string | null | undefined; /** * The date and time when the object was last updated. */ updatedAt?: Date | null | undefined; /** * The date and time when the object was created. */ createdAt?: Date | null | undefined; }; /** @internal */ export const Permissions$inboundSchema: z.ZodType< Permissions, z.ZodTypeDef, unknown > = z.object({ download: z.boolean().optional(), }); /** @internal */ export type Permissions$Outbound = { download?: boolean | undefined; }; /** @internal */ export const Permissions$outboundSchema: z.ZodType< Permissions$Outbound, z.ZodTypeDef, Permissions > = z.object({ download: z.boolean().optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Permissions$ { /** @deprecated use `Permissions$inboundSchema` instead. */ export const inboundSchema = Permissions$inboundSchema; /** @deprecated use `Permissions$outboundSchema` instead. */ export const outboundSchema = Permissions$outboundSchema; /** @deprecated use `Permissions$Outbound` instead. */ export type Outbound = Permissions$Outbound; } export function permissionsToJSON(permissions: Permissions): string { return JSON.stringify(Permissions$outboundSchema.parse(permissions)); } export function permissionsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Permissions$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Permissions' from JSON`, ); } /** @internal */ export const UnifiedFile$inboundSchema: z.ZodType< UnifiedFile, z.ZodTypeDef, unknown > = z.object({ id: z.string(), downstream_id: z.nullable(z.string()).optional(), name: z.nullable(z.string()), description: z.nullable(z.string()).optional(), type: z.nullable(FileType$inboundSchema), path: z.nullable(z.string()).optional(), mime_type: z.nullable(z.string()).optional(), downloadable: z.boolean().optional(), size: z.nullable(z.number().int()).optional(), owner: Owner$inboundSchema.optional(), parent_folders: z.array(LinkedFolder$inboundSchema).optional(), parent_folders_complete: z.boolean().optional(), permissions: z.lazy(() => Permissions$inboundSchema).optional(), exportable: z.boolean().optional(), export_formats: z.nullable(z.array(z.string())).optional(), custom_mappings: z.nullable(CustomMappings$inboundSchema).optional(), updated_by: z.nullable(z.string()).optional(), created_by: z.nullable(z.string()).optional(), updated_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), created_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), }).transform((v) => { return remap$(v, { "downstream_id": "downstreamId", "mime_type": "mimeType", "parent_folders": "parentFolders", "parent_folders_complete": "parentFoldersComplete", "export_formats": "exportFormats", "custom_mappings": "customMappings", "updated_by": "updatedBy", "created_by": "createdBy", "updated_at": "updatedAt", "created_at": "createdAt", }); }); /** @internal */ export type UnifiedFile$Outbound = { id: string; downstream_id?: string | null | undefined; name: string | null; description?: string | null | undefined; type: string | null; path?: string | null | undefined; mime_type?: string | null | undefined; downloadable?: boolean | undefined; size?: number | null | undefined; owner?: Owner$Outbound | undefined; parent_folders?: Array | undefined; parent_folders_complete?: boolean | undefined; permissions?: Permissions$Outbound | undefined; exportable?: boolean | undefined; export_formats?: Array | null | undefined; custom_mappings?: CustomMappings$Outbound | null | undefined; updated_by?: string | null | undefined; created_by?: string | null | undefined; updated_at?: string | null | undefined; created_at?: string | null | undefined; }; /** @internal */ export const UnifiedFile$outboundSchema: z.ZodType< UnifiedFile$Outbound, z.ZodTypeDef, UnifiedFile > = z.object({ id: z.string(), downstreamId: z.nullable(z.string()).optional(), name: z.nullable(z.string()), description: z.nullable(z.string()).optional(), type: z.nullable(FileType$outboundSchema), path: z.nullable(z.string()).optional(), mimeType: z.nullable(z.string()).optional(), downloadable: z.boolean().optional(), size: z.nullable(z.number().int()).optional(), owner: Owner$outboundSchema.optional(), parentFolders: z.array(LinkedFolder$outboundSchema).optional(), parentFoldersComplete: z.boolean().optional(), permissions: z.lazy(() => Permissions$outboundSchema).optional(), exportable: z.boolean().optional(), exportFormats: z.nullable(z.array(z.string())).optional(), customMappings: z.nullable(CustomMappings$outboundSchema).optional(), updatedBy: z.nullable(z.string()).optional(), createdBy: z.nullable(z.string()).optional(), updatedAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), createdAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), }).transform((v) => { return remap$(v, { downstreamId: "downstream_id", mimeType: "mime_type", parentFolders: "parent_folders", parentFoldersComplete: "parent_folders_complete", exportFormats: "export_formats", customMappings: "custom_mappings", updatedBy: "updated_by", createdBy: "created_by", updatedAt: "updated_at", createdAt: "created_at", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace UnifiedFile$ { /** @deprecated use `UnifiedFile$inboundSchema` instead. */ export const inboundSchema = UnifiedFile$inboundSchema; /** @deprecated use `UnifiedFile$outboundSchema` instead. */ export const outboundSchema = UnifiedFile$outboundSchema; /** @deprecated use `UnifiedFile$Outbound` instead. */ export type Outbound = UnifiedFile$Outbound; } export function unifiedFileToJSON(unifiedFile: UnifiedFile): string { return JSON.stringify(UnifiedFile$outboundSchema.parse(unifiedFile)); } export function unifiedFileFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => UnifiedFile$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UnifiedFile' from JSON`, ); }