/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; /** * The unique IDs of the tags assigned to the short link. */ export type UpdateLinkTagIds = string | Array; /** * The unique name of the tags assigned to the short link (case insensitive). */ export type UpdateLinkTagNames = string | Array; export type UpdateLinkTestVariants = { url: string; percentage: number; }; export type UpdateLinkRequestBody = { /** * The destination URL of the short link. */ url?: string | undefined; /** * The domain of the short link (without protocol). If not provided, the primary domain for the workspace will be used (or `dub.sh` if the workspace has no domains). */ domain?: string | undefined; /** * The short link slug. If not provided, a random 7-character slug will be generated. */ key?: string | undefined; /** * The ID of the link in your database. If set, it can be used to identify the link in future API requests (must be prefixed with 'ext_' when passed as a query parameter). This key is unique across your workspace. */ externalId?: string | null | undefined; /** * The ID of the tenant that created the link inside your system. If set, it can be used to fetch all links for a tenant. */ tenantId?: string | null | undefined; /** * The ID of the program the short link is associated with. */ programId?: string | null | undefined; /** * The ID of the partner the short link is associated with. */ partnerId?: string | null | undefined; /** * Whether to track conversions for the short link. Defaults to `false` if not provided. */ trackConversion?: boolean | undefined; /** * Whether the short link is archived. Defaults to `false` if not provided. */ archived?: boolean | undefined; /** * The unique IDs of the tags assigned to the short link. */ tagIds?: string | Array | undefined; /** * The unique name of the tags assigned to the short link (case insensitive). */ tagNames?: string | Array | undefined; /** * The unique ID existing folder to assign the short link to. */ folderId?: string | null | undefined; /** * The comments for the short link. */ comments?: string | null | undefined; /** * The date and time when the short link will expire at. */ expiresAt?: string | null | undefined; /** * The URL to redirect to when the short link has expired. */ expiredUrl?: string | null | undefined; /** * The password required to access the destination URL of the short link. */ password?: string | null | undefined; /** * Whether the short link uses Custom Link Previews feature. Defaults to `false` if not provided. */ proxy?: boolean | undefined; /** * The custom link preview title (og:title). Will be used for Custom Link Previews if `proxy` is true. Learn more: https://d.to/og */ title?: string | null | undefined; /** * The custom link preview description (og:description). Will be used for Custom Link Previews if `proxy` is true. Learn more: https://d.to/og */ description?: string | null | undefined; image?: string | null | undefined; /** * The custom link preview video (og:video). Will be used for Custom Link Previews if `proxy` is true. Learn more: https://d.to/og */ video?: string | null | undefined; /** * Whether the short link uses link cloaking. Defaults to `false` if not provided. */ rewrite?: boolean | undefined; /** * The iOS destination URL for the short link for iOS device targeting. */ ios?: string | null | undefined; /** * The Android destination URL for the short link for Android device targeting. */ android?: string | null | undefined; geo?: { [k: string]: string } | null | undefined; /** * Allow search engines to index your short link. Defaults to `false` if not provided. Learn more: https://d.to/noindex */ doIndex?: boolean | undefined; /** * The UTM source of the short link. If set, this will populate or override the UTM source in the destination URL. */ utmSource?: string | null | undefined; /** * The UTM medium of the short link. If set, this will populate or override the UTM medium in the destination URL. */ utmMedium?: string | null | undefined; /** * The UTM campaign of the short link. If set, this will populate or override the UTM campaign in the destination URL. */ utmCampaign?: string | null | undefined; /** * The UTM term of the short link. If set, this will populate or override the UTM term in the destination URL. */ utmTerm?: string | null | undefined; /** * The UTM content of the short link. If set, this will populate or override the UTM content in the destination URL. */ utmContent?: string | null | undefined; /** * The referral tag of the short link. If set, this will populate or override the `ref` query parameter in the destination URL. */ ref?: string | null | undefined; /** * An array of webhook IDs to trigger when the link is clicked. These webhooks will receive click event data. */ webhookIds?: Array | null | undefined; /** * An array of A/B test URLs and the percentage of traffic to send to each URL. */ testVariants?: Array | null | undefined; /** * The date and time when the tests started. */ testStartedAt?: string | null | undefined; /** * The date and time when the tests were or will be completed. */ testCompletedAt?: string | null | undefined; /** * Deprecated: Use `dashboard` instead. Whether the short link's stats are publicly accessible. Defaults to `false` if not provided. * * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. */ publicStats?: boolean | undefined; /** * Deprecated: Use `tagIds` instead. The unique ID of the tag assigned to the short link. * * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. */ tagId?: string | null | undefined; }; export type UpdateLinkRequest = { /** * The id of the link to update. You may use either `linkId` (obtained via `/links/info` endpoint) or `externalId` prefixed with `ext_`. */ linkId: string; requestBody?: UpdateLinkRequestBody | undefined; }; /** @internal */ export type UpdateLinkTagIds$Outbound = string | Array; /** @internal */ export const UpdateLinkTagIds$outboundSchema: z.ZodType< UpdateLinkTagIds$Outbound, z.ZodTypeDef, UpdateLinkTagIds > = z.union([z.string(), z.array(z.string())]); export function updateLinkTagIdsToJSON( updateLinkTagIds: UpdateLinkTagIds, ): string { return JSON.stringify( UpdateLinkTagIds$outboundSchema.parse(updateLinkTagIds), ); } /** @internal */ export type UpdateLinkTagNames$Outbound = string | Array; /** @internal */ export const UpdateLinkTagNames$outboundSchema: z.ZodType< UpdateLinkTagNames$Outbound, z.ZodTypeDef, UpdateLinkTagNames > = z.union([z.string(), z.array(z.string())]); export function updateLinkTagNamesToJSON( updateLinkTagNames: UpdateLinkTagNames, ): string { return JSON.stringify( UpdateLinkTagNames$outboundSchema.parse(updateLinkTagNames), ); } /** @internal */ export type UpdateLinkTestVariants$Outbound = { url: string; percentage: number; }; /** @internal */ export const UpdateLinkTestVariants$outboundSchema: z.ZodType< UpdateLinkTestVariants$Outbound, z.ZodTypeDef, UpdateLinkTestVariants > = z.object({ url: z.string(), percentage: z.number(), }); export function updateLinkTestVariantsToJSON( updateLinkTestVariants: UpdateLinkTestVariants, ): string { return JSON.stringify( UpdateLinkTestVariants$outboundSchema.parse(updateLinkTestVariants), ); } /** @internal */ export type UpdateLinkRequestBody$Outbound = { url?: string | undefined; domain?: string | undefined; key?: string | undefined; externalId?: string | null | undefined; tenantId?: string | null | undefined; programId?: string | null | undefined; partnerId?: string | null | undefined; trackConversion?: boolean | undefined; archived?: boolean | undefined; tagIds?: string | Array | undefined; tagNames?: string | Array | undefined; folderId?: string | null | undefined; comments?: string | null | undefined; expiresAt?: string | null | undefined; expiredUrl?: string | null | undefined; password?: string | null | undefined; proxy?: boolean | undefined; title?: string | null | undefined; description?: string | null | undefined; image?: string | null | undefined; video?: string | null | undefined; rewrite?: boolean | undefined; ios?: string | null | undefined; android?: string | null | undefined; geo?: { [k: string]: string } | null | undefined; doIndex?: boolean | undefined; utm_source?: string | null | undefined; utm_medium?: string | null | undefined; utm_campaign?: string | null | undefined; utm_term?: string | null | undefined; utm_content?: string | null | undefined; ref?: string | null | undefined; webhookIds?: Array | null | undefined; testVariants?: Array | null | undefined; testStartedAt?: string | null | undefined; testCompletedAt?: string | null | undefined; publicStats?: boolean | undefined; tagId?: string | null | undefined; }; /** @internal */ export const UpdateLinkRequestBody$outboundSchema: z.ZodType< UpdateLinkRequestBody$Outbound, z.ZodTypeDef, UpdateLinkRequestBody > = z.object({ url: z.string().optional(), domain: z.string().optional(), key: z.string().optional(), externalId: z.nullable(z.string()).optional(), tenantId: z.nullable(z.string()).optional(), programId: z.nullable(z.string()).optional(), partnerId: z.nullable(z.string()).optional(), trackConversion: z.boolean().optional(), archived: z.boolean().optional(), tagIds: z.union([z.string(), z.array(z.string())]).optional(), tagNames: z.union([z.string(), z.array(z.string())]).optional(), folderId: z.nullable(z.string()).optional(), comments: z.nullable(z.string()).optional(), expiresAt: z.nullable(z.string()).optional(), expiredUrl: z.nullable(z.string()).optional(), password: z.nullable(z.string()).optional(), proxy: z.boolean().optional(), title: z.nullable(z.string()).optional(), description: z.nullable(z.string()).optional(), image: z.nullable(z.string()).optional(), video: z.nullable(z.string()).optional(), rewrite: z.boolean().optional(), ios: z.nullable(z.string()).optional(), android: z.nullable(z.string()).optional(), geo: z.nullable(z.record(z.string())).optional(), doIndex: z.boolean().optional(), utmSource: z.nullable(z.string()).optional(), utmMedium: z.nullable(z.string()).optional(), utmCampaign: z.nullable(z.string()).optional(), utmTerm: z.nullable(z.string()).optional(), utmContent: z.nullable(z.string()).optional(), ref: z.nullable(z.string()).optional(), webhookIds: z.nullable(z.array(z.string())).optional(), testVariants: z.nullable( z.array(z.lazy(() => UpdateLinkTestVariants$outboundSchema)), ).optional(), testStartedAt: z.nullable(z.string()).optional(), testCompletedAt: z.nullable(z.string()).optional(), publicStats: z.boolean().optional(), tagId: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { utmSource: "utm_source", utmMedium: "utm_medium", utmCampaign: "utm_campaign", utmTerm: "utm_term", utmContent: "utm_content", }); }); export function updateLinkRequestBodyToJSON( updateLinkRequestBody: UpdateLinkRequestBody, ): string { return JSON.stringify( UpdateLinkRequestBody$outboundSchema.parse(updateLinkRequestBody), ); } /** @internal */ export type UpdateLinkRequest$Outbound = { linkId: string; RequestBody?: UpdateLinkRequestBody$Outbound | undefined; }; /** @internal */ export const UpdateLinkRequest$outboundSchema: z.ZodType< UpdateLinkRequest$Outbound, z.ZodTypeDef, UpdateLinkRequest > = z.object({ linkId: z.string(), requestBody: z.lazy(() => UpdateLinkRequestBody$outboundSchema).optional(), }).transform((v) => { return remap$(v, { requestBody: "RequestBody", }); }); export function updateLinkRequestToJSON( updateLinkRequest: UpdateLinkRequest, ): string { return JSON.stringify( UpdateLinkRequest$outboundSchema.parse(updateLinkRequest), ); }