/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { lazySchema as lazySchema$, safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as types from "../../types/primitives.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { FileType, FileType$inboundSchema } from "./filetype.js"; import { LinkedFolder, LinkedFolder$inboundSchema } from "./linkedfolder.js"; import { Owner, Owner$inboundSchema } 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?: { [k: string]: any } | 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 > = /* @__PURE__ */ lazySchema$(() => z.object({ download: types.optional(types.boolean()), }) ); 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 > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.string(), downstream_id: z.nullable(types.string()).optional(), name: types.nullable(types.string()), description: z.nullable(types.string()).optional(), type: types.nullable(FileType$inboundSchema), path: z.nullable(types.string()).optional(), mime_type: z.nullable(types.string()).optional(), downloadable: types.optional(types.boolean()), size: z.nullable(types.number()).optional(), owner: types.optional(Owner$inboundSchema), parent_folders: types.optional(z.array(LinkedFolder$inboundSchema)), parent_folders_complete: types.optional(types.boolean()), permissions: types.optional(z.lazy(() => Permissions$inboundSchema)), exportable: types.optional(types.boolean()), export_formats: z.nullable(z.array(types.string())).optional(), custom_mappings: z.nullable(z.record(z.any())).optional(), updated_by: z.nullable(types.string()).optional(), created_by: z.nullable(types.string()).optional(), updated_at: z.nullable(types.date()).optional(), created_at: z.nullable(types.date()).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", }); }) ); export function unifiedFileFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => UnifiedFile$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UnifiedFile' from JSON`, ); }