/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 9f5ce4a6cef5 */ 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 { Document, Document$inboundSchema, Document$Outbound, Document$outboundSchema, } from "./document.js"; import { ObjectPermissions, ObjectPermissions$inboundSchema, ObjectPermissions$Outbound, ObjectPermissions$outboundSchema, } from "./objectpermissions.js"; import { Person, Person$inboundSchema, Person$Outbound, Person$outboundSchema, } from "./person.js"; import { UserRoleSpecification, UserRoleSpecification$inboundSchema, UserRoleSpecification$Outbound, UserRoleSpecification$outboundSchema, } from "./userrolespecification.js"; export type Shortcut = { /** * The opaque id of the user generated content. */ id?: number | undefined; /** * Link text following go/ prefix as entered by the user. */ inputAlias: string; /** * Destination URL for the shortcut. */ destinationUrl?: string | undefined; /** * Glean Document ID for the URL, if known. */ destinationDocumentId?: string | undefined; /** * A short, plain text blurb to help people understand the intent of the shortcut. */ description?: string | undefined; /** * Whether this shortcut is unlisted or not. Unlisted shortcuts are visible to author + admins only. */ unlisted?: boolean | undefined; /** * For variable shortcuts, contains the URL template; note, `destinationUrl` contains default URL. */ urlTemplate?: string | undefined; /** * A list of user roles added for the Shortcut. */ addedRoles?: Array | undefined; /** * A list of user roles removed for the Shortcut. */ removedRoles?: Array | undefined; permissions?: ObjectPermissions | undefined; createdBy?: Person | undefined; /** * The time the shortcut was created in ISO format (ISO 8601). */ createTime?: Date | undefined; updatedBy?: Person | undefined; /** * The time the shortcut was updated in ISO format (ISO 8601). */ updateTime?: Date | undefined; destinationDocument?: Document | undefined; /** * The URL from which the user is then redirected to the destination URL. Full replacement for https://go/. */ intermediateUrl?: string | undefined; /** * The part of the shortcut preceding the input alias when used for showing shortcuts to users. Should end with "/". e.g. "go/" for native shortcuts. */ viewPrefix?: string | undefined; /** * Indicates whether a shortcut is native or external. */ isExternal?: boolean | undefined; /** * The URL using which the user can access the edit page of the shortcut. */ editUrl?: string | undefined; /** * canonical link text following go/ prefix where hyphen/underscore is removed. */ alias?: string | undefined; /** * Title for the Go Link */ title?: string | undefined; /** * A list of user roles for the Go Link. */ roles?: Array | undefined; }; /** @internal */ export const Shortcut$inboundSchema: z.ZodType< Shortcut, z.ZodTypeDef, unknown > = z.object({ id: z.number().int().optional(), inputAlias: z.string(), destinationUrl: z.string().optional(), destinationDocumentId: z.string().optional(), description: z.string().optional(), unlisted: z.boolean().optional(), urlTemplate: z.string().optional(), addedRoles: z.array(z.lazy(() => UserRoleSpecification$inboundSchema)) .optional(), removedRoles: z.array(z.lazy(() => UserRoleSpecification$inboundSchema)) .optional(), permissions: ObjectPermissions$inboundSchema.optional(), createdBy: z.lazy(() => Person$inboundSchema).optional(), createTime: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), updatedBy: z.lazy(() => Person$inboundSchema).optional(), updateTime: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), destinationDocument: z.lazy(() => Document$inboundSchema).optional(), intermediateUrl: z.string().optional(), viewPrefix: z.string().optional(), isExternal: z.boolean().optional(), editUrl: z.string().optional(), alias: z.string().optional(), title: z.string().optional(), roles: z.array(z.lazy(() => UserRoleSpecification$inboundSchema)).optional(), }); /** @internal */ export type Shortcut$Outbound = { id?: number | undefined; inputAlias: string; destinationUrl?: string | undefined; destinationDocumentId?: string | undefined; description?: string | undefined; unlisted?: boolean | undefined; urlTemplate?: string | undefined; addedRoles?: Array | undefined; removedRoles?: Array | undefined; permissions?: ObjectPermissions$Outbound | undefined; createdBy?: Person$Outbound | undefined; createTime?: string | undefined; updatedBy?: Person$Outbound | undefined; updateTime?: string | undefined; destinationDocument?: Document$Outbound | undefined; intermediateUrl?: string | undefined; viewPrefix?: string | undefined; isExternal?: boolean | undefined; editUrl?: string | undefined; alias?: string | undefined; title?: string | undefined; roles?: Array | undefined; }; /** @internal */ export const Shortcut$outboundSchema: z.ZodType< Shortcut$Outbound, z.ZodTypeDef, Shortcut > = z.object({ id: z.number().int().optional(), inputAlias: z.string(), destinationUrl: z.string().optional(), destinationDocumentId: z.string().optional(), description: z.string().optional(), unlisted: z.boolean().optional(), urlTemplate: z.string().optional(), addedRoles: z.array(z.lazy(() => UserRoleSpecification$outboundSchema)) .optional(), removedRoles: z.array(z.lazy(() => UserRoleSpecification$outboundSchema)) .optional(), permissions: ObjectPermissions$outboundSchema.optional(), createdBy: z.lazy(() => Person$outboundSchema).optional(), createTime: z.date().transform(v => v.toISOString()).optional(), updatedBy: z.lazy(() => Person$outboundSchema).optional(), updateTime: z.date().transform(v => v.toISOString()).optional(), destinationDocument: z.lazy(() => Document$outboundSchema).optional(), intermediateUrl: z.string().optional(), viewPrefix: z.string().optional(), isExternal: z.boolean().optional(), editUrl: z.string().optional(), alias: z.string().optional(), title: z.string().optional(), roles: z.array(z.lazy(() => UserRoleSpecification$outboundSchema)).optional(), }); export function shortcutToJSON(shortcut: Shortcut): string { return JSON.stringify(Shortcut$outboundSchema.parse(shortcut)); } export function shortcutFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Shortcut$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Shortcut' from JSON`, ); }