attio-js
Version:
Developer-friendly & type-safe JS/TS SDK based on the official OpenAPI spec of Attio.
222 lines (199 loc) • 6.12 kB
text/typescript
/*
* 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 { Result as SafeParseResult } from "../../types/fp.js";
import {
ObjectT,
ObjectT$inboundSchema,
ObjectT$Outbound,
ObjectT$outboundSchema,
} from "../components/object.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
export type PostV2ObjectsData = {
/**
* A unique, human-readable slug to access the object through URLs and API calls. Should be formatted in snake case.
*/
apiSlug: string;
/**
* The singular form of the object's name.
*/
singularNoun: string;
/**
* The plural form of the object's name.
*/
pluralNoun: string;
};
export type PostV2ObjectsRequest = {
data: PostV2ObjectsData;
};
/**
* Success
*/
export type PostV2ObjectsResponse = {
data: ObjectT;
};
/** @internal */
export const PostV2ObjectsData$inboundSchema: z.ZodType<
PostV2ObjectsData,
z.ZodTypeDef,
unknown
> = z.object({
api_slug: z.string(),
singular_noun: z.string(),
plural_noun: z.string(),
}).transform((v) => {
return remap$(v, {
"api_slug": "apiSlug",
"singular_noun": "singularNoun",
"plural_noun": "pluralNoun",
});
});
/** @internal */
export type PostV2ObjectsData$Outbound = {
api_slug: string;
singular_noun: string;
plural_noun: string;
};
/** @internal */
export const PostV2ObjectsData$outboundSchema: z.ZodType<
PostV2ObjectsData$Outbound,
z.ZodTypeDef,
PostV2ObjectsData
> = z.object({
apiSlug: z.string(),
singularNoun: z.string(),
pluralNoun: z.string(),
}).transform((v) => {
return remap$(v, {
apiSlug: "api_slug",
singularNoun: "singular_noun",
pluralNoun: "plural_noun",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace PostV2ObjectsData$ {
/** @deprecated use `PostV2ObjectsData$inboundSchema` instead. */
export const inboundSchema = PostV2ObjectsData$inboundSchema;
/** @deprecated use `PostV2ObjectsData$outboundSchema` instead. */
export const outboundSchema = PostV2ObjectsData$outboundSchema;
/** @deprecated use `PostV2ObjectsData$Outbound` instead. */
export type Outbound = PostV2ObjectsData$Outbound;
}
export function postV2ObjectsDataToJSON(
postV2ObjectsData: PostV2ObjectsData,
): string {
return JSON.stringify(
PostV2ObjectsData$outboundSchema.parse(postV2ObjectsData),
);
}
export function postV2ObjectsDataFromJSON(
jsonString: string,
): SafeParseResult<PostV2ObjectsData, SDKValidationError> {
return safeParse(
jsonString,
(x) => PostV2ObjectsData$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'PostV2ObjectsData' from JSON`,
);
}
/** @internal */
export const PostV2ObjectsRequest$inboundSchema: z.ZodType<
PostV2ObjectsRequest,
z.ZodTypeDef,
unknown
> = z.object({
data: z.lazy(() => PostV2ObjectsData$inboundSchema),
});
/** @internal */
export type PostV2ObjectsRequest$Outbound = {
data: PostV2ObjectsData$Outbound;
};
/** @internal */
export const PostV2ObjectsRequest$outboundSchema: z.ZodType<
PostV2ObjectsRequest$Outbound,
z.ZodTypeDef,
PostV2ObjectsRequest
> = z.object({
data: z.lazy(() => PostV2ObjectsData$outboundSchema),
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace PostV2ObjectsRequest$ {
/** @deprecated use `PostV2ObjectsRequest$inboundSchema` instead. */
export const inboundSchema = PostV2ObjectsRequest$inboundSchema;
/** @deprecated use `PostV2ObjectsRequest$outboundSchema` instead. */
export const outboundSchema = PostV2ObjectsRequest$outboundSchema;
/** @deprecated use `PostV2ObjectsRequest$Outbound` instead. */
export type Outbound = PostV2ObjectsRequest$Outbound;
}
export function postV2ObjectsRequestToJSON(
postV2ObjectsRequest: PostV2ObjectsRequest,
): string {
return JSON.stringify(
PostV2ObjectsRequest$outboundSchema.parse(postV2ObjectsRequest),
);
}
export function postV2ObjectsRequestFromJSON(
jsonString: string,
): SafeParseResult<PostV2ObjectsRequest, SDKValidationError> {
return safeParse(
jsonString,
(x) => PostV2ObjectsRequest$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'PostV2ObjectsRequest' from JSON`,
);
}
/** @internal */
export const PostV2ObjectsResponse$inboundSchema: z.ZodType<
PostV2ObjectsResponse,
z.ZodTypeDef,
unknown
> = z.object({
data: ObjectT$inboundSchema,
});
/** @internal */
export type PostV2ObjectsResponse$Outbound = {
data: ObjectT$Outbound;
};
/** @internal */
export const PostV2ObjectsResponse$outboundSchema: z.ZodType<
PostV2ObjectsResponse$Outbound,
z.ZodTypeDef,
PostV2ObjectsResponse
> = z.object({
data: ObjectT$outboundSchema,
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace PostV2ObjectsResponse$ {
/** @deprecated use `PostV2ObjectsResponse$inboundSchema` instead. */
export const inboundSchema = PostV2ObjectsResponse$inboundSchema;
/** @deprecated use `PostV2ObjectsResponse$outboundSchema` instead. */
export const outboundSchema = PostV2ObjectsResponse$outboundSchema;
/** @deprecated use `PostV2ObjectsResponse$Outbound` instead. */
export type Outbound = PostV2ObjectsResponse$Outbound;
}
export function postV2ObjectsResponseToJSON(
postV2ObjectsResponse: PostV2ObjectsResponse,
): string {
return JSON.stringify(
PostV2ObjectsResponse$outboundSchema.parse(postV2ObjectsResponse),
);
}
export function postV2ObjectsResponseFromJSON(
jsonString: string,
): SafeParseResult<PostV2ObjectsResponse, SDKValidationError> {
return safeParse(
jsonString,
(x) => PostV2ObjectsResponse$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'PostV2ObjectsResponse' from JSON`,
);
}