/* * 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 { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { PassThroughBody, PassThroughBody$inboundSchema, PassThroughBody$Outbound, PassThroughBody$outboundSchema, } from "./passthroughbody.js"; import { SharedLinkTarget, SharedLinkTarget$inboundSchema, SharedLinkTarget$Outbound, SharedLinkTarget$outboundSchema, } from "./sharedlinktarget.js"; /** * The scope of the shared link. */ export const Scope = { Public: "public", Company: "company", } as const; /** * The scope of the shared link. */ export type Scope = ClosedEnum; export type SharedLink = { /** * The URL that can be used to view the file. */ url?: string | null | undefined; /** * The URL that can be used to download the file. */ downloadUrl?: string | null | undefined; target?: SharedLinkTarget | undefined; /** * The scope of the shared link. */ scope?: Scope | null | undefined; /** * Indicated if the shared link is password protected. */ passwordProtected?: boolean | null | undefined; expiresAt?: Date | 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; /** * The pass_through property allows passing service-specific, custom data or structured modifications in request body when creating or updating resources. */ passThrough?: Array | undefined; }; export type SharedLinkInput = { /** * The URL that can be used to download the file. */ downloadUrl?: string | null | undefined; /** * The ID of the file or folder to link. */ targetId: string | null; /** * The scope of the shared link. */ scope?: Scope | null | undefined; /** * Optional password for the shared link. */ password?: string | null | undefined; /** * The pass_through property allows passing service-specific, custom data or structured modifications in request body when creating or updating resources. */ passThrough?: Array | undefined; }; /** @internal */ export const Scope$inboundSchema: z.ZodNativeEnum = z.nativeEnum( Scope, ); /** @internal */ export const Scope$outboundSchema: z.ZodNativeEnum = Scope$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Scope$ { /** @deprecated use `Scope$inboundSchema` instead. */ export const inboundSchema = Scope$inboundSchema; /** @deprecated use `Scope$outboundSchema` instead. */ export const outboundSchema = Scope$outboundSchema; } /** @internal */ export const SharedLink$inboundSchema: z.ZodType< SharedLink, z.ZodTypeDef, unknown > = z.object({ url: z.nullable(z.string()).optional(), download_url: z.nullable(z.string()).optional(), target: SharedLinkTarget$inboundSchema.optional(), scope: z.nullable(Scope$inboundSchema).optional(), password_protected: z.nullable(z.boolean()).optional(), expires_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).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(), pass_through: z.array(PassThroughBody$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "download_url": "downloadUrl", "password_protected": "passwordProtected", "expires_at": "expiresAt", "updated_at": "updatedAt", "created_at": "createdAt", "pass_through": "passThrough", }); }); /** @internal */ export type SharedLink$Outbound = { url?: string | null | undefined; download_url?: string | null | undefined; target?: SharedLinkTarget$Outbound | undefined; scope?: string | null | undefined; password_protected?: boolean | null | undefined; expires_at?: string | null | undefined; updated_at?: string | null | undefined; created_at?: string | null | undefined; pass_through?: Array | undefined; }; /** @internal */ export const SharedLink$outboundSchema: z.ZodType< SharedLink$Outbound, z.ZodTypeDef, SharedLink > = z.object({ url: z.nullable(z.string()).optional(), downloadUrl: z.nullable(z.string()).optional(), target: SharedLinkTarget$outboundSchema.optional(), scope: z.nullable(Scope$outboundSchema).optional(), passwordProtected: z.nullable(z.boolean()).optional(), expiresAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), updatedAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), createdAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), passThrough: z.array(PassThroughBody$outboundSchema).optional(), }).transform((v) => { return remap$(v, { downloadUrl: "download_url", passwordProtected: "password_protected", expiresAt: "expires_at", updatedAt: "updated_at", createdAt: "created_at", passThrough: "pass_through", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace SharedLink$ { /** @deprecated use `SharedLink$inboundSchema` instead. */ export const inboundSchema = SharedLink$inboundSchema; /** @deprecated use `SharedLink$outboundSchema` instead. */ export const outboundSchema = SharedLink$outboundSchema; /** @deprecated use `SharedLink$Outbound` instead. */ export type Outbound = SharedLink$Outbound; } export function sharedLinkToJSON(sharedLink: SharedLink): string { return JSON.stringify(SharedLink$outboundSchema.parse(sharedLink)); } export function sharedLinkFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SharedLink$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SharedLink' from JSON`, ); } /** @internal */ export const SharedLinkInput$inboundSchema: z.ZodType< SharedLinkInput, z.ZodTypeDef, unknown > = z.object({ download_url: z.nullable(z.string()).optional(), target_id: z.nullable(z.string()), scope: z.nullable(Scope$inboundSchema).optional(), password: z.nullable(z.string()).optional(), pass_through: z.array(PassThroughBody$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "download_url": "downloadUrl", "target_id": "targetId", "pass_through": "passThrough", }); }); /** @internal */ export type SharedLinkInput$Outbound = { download_url?: string | null | undefined; target_id: string | null; scope?: string | null | undefined; password?: string | null | undefined; pass_through?: Array | undefined; }; /** @internal */ export const SharedLinkInput$outboundSchema: z.ZodType< SharedLinkInput$Outbound, z.ZodTypeDef, SharedLinkInput > = z.object({ downloadUrl: z.nullable(z.string()).optional(), targetId: z.nullable(z.string()), scope: z.nullable(Scope$outboundSchema).optional(), password: z.nullable(z.string()).optional(), passThrough: z.array(PassThroughBody$outboundSchema).optional(), }).transform((v) => { return remap$(v, { downloadUrl: "download_url", targetId: "target_id", passThrough: "pass_through", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace SharedLinkInput$ { /** @deprecated use `SharedLinkInput$inboundSchema` instead. */ export const inboundSchema = SharedLinkInput$inboundSchema; /** @deprecated use `SharedLinkInput$outboundSchema` instead. */ export const outboundSchema = SharedLinkInput$outboundSchema; /** @deprecated use `SharedLinkInput$Outbound` instead. */ export type Outbound = SharedLinkInput$Outbound; } export function sharedLinkInputToJSON( sharedLinkInput: SharedLinkInput, ): string { return JSON.stringify(SharedLinkInput$outboundSchema.parse(sharedLinkInput)); } export function sharedLinkInputFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SharedLinkInput$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SharedLinkInput' from JSON`, ); }