UNPKG

attio-js

Version:

Developer-friendly & type-safe JS/TS SDK based on the official OpenAPI spec of Attio.

208 lines (188 loc) 6.53 kB
/* * 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 { Task, Task$inboundSchema, Task$Outbound, Task$outboundSchema, } from "../components/task.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Optionally sort the results. "created_at:asc" returns oldest results first, "created_at:desc" returns the newest results first. If unspecified, defaults to "created_at:asc" (oldest results first). */ export const GetV2TasksSort = { CreatedAtAsc: "created_at:asc", CreatedAtDesc: "created_at:desc", } as const; /** * Optionally sort the results. "created_at:asc" returns oldest results first, "created_at:desc" returns the newest results first. If unspecified, defaults to "created_at:asc" (oldest results first). */ export type GetV2TasksSort = ClosedEnum<typeof GetV2TasksSort>; export type GetV2TasksRequest = { limit?: number | undefined; offset?: number | undefined; /** * Optionally sort the results. "created_at:asc" returns oldest results first, "created_at:desc" returns the newest results first. If unspecified, defaults to "created_at:asc" (oldest results first). */ sort?: GetV2TasksSort | undefined; linkedObject?: string | undefined; linkedRecordId?: string | undefined; assignee?: string | null | undefined; isCompleted?: boolean | undefined; }; /** * Success */ export type GetV2TasksResponse = { data: Array<Task>; }; /** @internal */ export const GetV2TasksSort$inboundSchema: z.ZodNativeEnum< typeof GetV2TasksSort > = z.nativeEnum(GetV2TasksSort); /** @internal */ export const GetV2TasksSort$outboundSchema: z.ZodNativeEnum< typeof GetV2TasksSort > = GetV2TasksSort$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetV2TasksSort$ { /** @deprecated use `GetV2TasksSort$inboundSchema` instead. */ export const inboundSchema = GetV2TasksSort$inboundSchema; /** @deprecated use `GetV2TasksSort$outboundSchema` instead. */ export const outboundSchema = GetV2TasksSort$outboundSchema; } /** @internal */ export const GetV2TasksRequest$inboundSchema: z.ZodType< GetV2TasksRequest, z.ZodTypeDef, unknown > = z.object({ limit: z.number().int().optional(), offset: z.number().int().optional(), sort: GetV2TasksSort$inboundSchema.optional(), linked_object: z.string().optional(), linked_record_id: z.string().optional(), assignee: z.nullable(z.string()).optional(), is_completed: z.boolean().optional(), }).transform((v) => { return remap$(v, { "linked_object": "linkedObject", "linked_record_id": "linkedRecordId", "is_completed": "isCompleted", }); }); /** @internal */ export type GetV2TasksRequest$Outbound = { limit?: number | undefined; offset?: number | undefined; sort?: string | undefined; linked_object?: string | undefined; linked_record_id?: string | undefined; assignee?: string | null | undefined; is_completed?: boolean | undefined; }; /** @internal */ export const GetV2TasksRequest$outboundSchema: z.ZodType< GetV2TasksRequest$Outbound, z.ZodTypeDef, GetV2TasksRequest > = z.object({ limit: z.number().int().optional(), offset: z.number().int().optional(), sort: GetV2TasksSort$outboundSchema.optional(), linkedObject: z.string().optional(), linkedRecordId: z.string().optional(), assignee: z.nullable(z.string()).optional(), isCompleted: z.boolean().optional(), }).transform((v) => { return remap$(v, { linkedObject: "linked_object", linkedRecordId: "linked_record_id", isCompleted: "is_completed", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetV2TasksRequest$ { /** @deprecated use `GetV2TasksRequest$inboundSchema` instead. */ export const inboundSchema = GetV2TasksRequest$inboundSchema; /** @deprecated use `GetV2TasksRequest$outboundSchema` instead. */ export const outboundSchema = GetV2TasksRequest$outboundSchema; /** @deprecated use `GetV2TasksRequest$Outbound` instead. */ export type Outbound = GetV2TasksRequest$Outbound; } export function getV2TasksRequestToJSON( getV2TasksRequest: GetV2TasksRequest, ): string { return JSON.stringify( GetV2TasksRequest$outboundSchema.parse(getV2TasksRequest), ); } export function getV2TasksRequestFromJSON( jsonString: string, ): SafeParseResult<GetV2TasksRequest, SDKValidationError> { return safeParse( jsonString, (x) => GetV2TasksRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetV2TasksRequest' from JSON`, ); } /** @internal */ export const GetV2TasksResponse$inboundSchema: z.ZodType< GetV2TasksResponse, z.ZodTypeDef, unknown > = z.object({ data: z.array(Task$inboundSchema), }); /** @internal */ export type GetV2TasksResponse$Outbound = { data: Array<Task$Outbound>; }; /** @internal */ export const GetV2TasksResponse$outboundSchema: z.ZodType< GetV2TasksResponse$Outbound, z.ZodTypeDef, GetV2TasksResponse > = z.object({ data: z.array(Task$outboundSchema), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetV2TasksResponse$ { /** @deprecated use `GetV2TasksResponse$inboundSchema` instead. */ export const inboundSchema = GetV2TasksResponse$inboundSchema; /** @deprecated use `GetV2TasksResponse$outboundSchema` instead. */ export const outboundSchema = GetV2TasksResponse$outboundSchema; /** @deprecated use `GetV2TasksResponse$Outbound` instead. */ export type Outbound = GetV2TasksResponse$Outbound; } export function getV2TasksResponseToJSON( getV2TasksResponse: GetV2TasksResponse, ): string { return JSON.stringify( GetV2TasksResponse$outboundSchema.parse(getV2TasksResponse), ); } export function getV2TasksResponseFromJSON( jsonString: string, ): SafeParseResult<GetV2TasksResponse, SDKValidationError> { return safeParse( jsonString, (x) => GetV2TasksResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetV2TasksResponse' from JSON`, ); }