/* * 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 { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The tag IDs to filter the links by. */ export type QueryParamTagIds = string | Array; /** * The unique name of the tags assigned to the short link (case insensitive). */ export type QueryParamTagNames = string | Array; /** * The field to sort the links by. The default is `createdAt`. */ export const SortBy = { CreatedAt: "createdAt", Clicks: "clicks", SaleAmount: "saleAmount", LastClicked: "lastClicked", } as const; /** * The field to sort the links by. The default is `createdAt`. */ export type SortBy = ClosedEnum; /** * The sort order. The default is `desc`. */ export const SortOrder = { Asc: "asc", Desc: "desc", } as const; /** * The sort order. The default is `desc`. */ export type SortOrder = ClosedEnum; /** * DEPRECATED. Use `sortBy` instead. * * @deprecated enum: This will be removed in a future release, please migrate away from it as soon as possible. */ export const Sort = { CreatedAt: "createdAt", Clicks: "clicks", SaleAmount: "saleAmount", LastClicked: "lastClicked", } as const; /** * DEPRECATED. Use `sortBy` instead. * * @deprecated enum: This will be removed in a future release, please migrate away from it as soon as possible. */ export type Sort = ClosedEnum; export type GetLinksRequest = { /** * The domain to filter the links by. E.g. `ac.me`. If not provided, all links for the workspace will be returned. */ domain?: string | undefined; /** * Deprecated: Use `tagIds` instead. The tag ID to filter the links by. */ tagId?: string | undefined; /** * The tag IDs to filter the links by. */ tagIds?: string | Array | undefined; /** * The unique name of the tags assigned to the short link (case insensitive). */ tagNames?: string | Array | undefined; /** * The folder ID to filter the links by. */ folderId?: string | undefined; /** * The search term to filter the links by. The search term will be matched against the short link slug and the destination url. */ search?: string | undefined; /** * The user ID to filter the links by. */ userId?: string | undefined; /** * The ID of the tenant that created the link inside your system. If set, will only return links for the specified tenant. */ tenantId?: string | undefined; /** * Whether to include archived links in the response. Defaults to `false` if not provided. */ showArchived?: boolean | undefined; /** * DEPRECATED. Filter for links that have at least one tag assigned to them. */ withTags?: boolean | undefined; /** * The field to sort the links by. The default is `createdAt`. */ sortBy?: SortBy | undefined; /** * The sort order. The default is `desc`. */ sortOrder?: SortOrder | undefined; /** * DEPRECATED. Use `sortBy` instead. */ sort?: Sort | undefined; /** * If specified, the query only searches for results before this cursor. Mutually exclusive with `startingAfter`. */ endingBefore?: string | undefined; /** * If specified, the query only searches for results after this cursor. Mutually exclusive with `endingBefore`. */ startingAfter?: string | undefined; /** * DEPRECATED. Use `startingAfter` instead. */ page?: number | undefined; /** * The number of items per page. */ pageSize?: number | undefined; }; export type GetLinksResponse = { result: Array; }; /** @internal */ export type QueryParamTagIds$Outbound = string | Array; /** @internal */ export const QueryParamTagIds$outboundSchema: z.ZodType< QueryParamTagIds$Outbound, z.ZodTypeDef, QueryParamTagIds > = z.union([z.string(), z.array(z.string())]); export function queryParamTagIdsToJSON( queryParamTagIds: QueryParamTagIds, ): string { return JSON.stringify( QueryParamTagIds$outboundSchema.parse(queryParamTagIds), ); } /** @internal */ export type QueryParamTagNames$Outbound = string | Array; /** @internal */ export const QueryParamTagNames$outboundSchema: z.ZodType< QueryParamTagNames$Outbound, z.ZodTypeDef, QueryParamTagNames > = z.union([z.string(), z.array(z.string())]); export function queryParamTagNamesToJSON( queryParamTagNames: QueryParamTagNames, ): string { return JSON.stringify( QueryParamTagNames$outboundSchema.parse(queryParamTagNames), ); } /** @internal */ export const SortBy$outboundSchema: z.ZodNativeEnum = z .nativeEnum(SortBy); /** @internal */ export const SortOrder$outboundSchema: z.ZodNativeEnum = z .nativeEnum(SortOrder); /** @internal */ export const Sort$outboundSchema: z.ZodNativeEnum = z.nativeEnum( Sort, ); /** @internal */ export type GetLinksRequest$Outbound = { domain?: string | undefined; tagId?: string | undefined; tagIds?: string | Array | undefined; tagNames?: string | Array | undefined; folderId?: string | undefined; search?: string | undefined; userId?: string | undefined; tenantId?: string | undefined; showArchived: boolean; withTags: boolean; sortBy: string; sortOrder: string; sort: string; endingBefore?: string | undefined; startingAfter?: string | undefined; page?: number | undefined; pageSize: number; }; /** @internal */ export const GetLinksRequest$outboundSchema: z.ZodType< GetLinksRequest$Outbound, z.ZodTypeDef, GetLinksRequest > = z.object({ domain: z.string().optional(), tagId: z.string().optional(), tagIds: z.union([z.string(), z.array(z.string())]).optional(), tagNames: z.union([z.string(), z.array(z.string())]).optional(), folderId: z.string().optional(), search: z.string().optional(), userId: z.string().optional(), tenantId: z.string().optional(), showArchived: z.boolean().default(false), withTags: z.boolean().default(false), sortBy: SortBy$outboundSchema.default("createdAt"), sortOrder: SortOrder$outboundSchema.default("desc"), sort: Sort$outboundSchema.default("createdAt"), endingBefore: z.string().optional(), startingAfter: z.string().optional(), page: z.number().optional(), pageSize: z.number().default(100), }); export function getLinksRequestToJSON( getLinksRequest: GetLinksRequest, ): string { return JSON.stringify(GetLinksRequest$outboundSchema.parse(getLinksRequest)); } /** @internal */ export const GetLinksResponse$inboundSchema: z.ZodType< GetLinksResponse, z.ZodTypeDef, unknown > = z.object({ Result: z.array(components.LinkSchema$inboundSchema), }).transform((v) => { return remap$(v, { "Result": "result", }); }); export function getLinksResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetLinksResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetLinksResponse' from JSON`, ); }