attio-js
Version:
Developer-friendly & type-safe JS/TS SDK based on the official OpenAPI spec of Attio.
177 lines (161 loc) • 4.6 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 { SDKValidationError } from "../errors/sdkvalidationerror.js";
export type ObjectId = {
/**
* A UUID to identify the workspace this object belongs to.
*/
workspaceId: string;
/**
* A UUID to identify the object.
*/
objectId: string;
};
export type ObjectT = {
id: ObjectId;
/**
* A unique, human-readable slug to access the object through URLs and API calls. Formatted in snake case.
*/
apiSlug: string | null;
/**
* The singular form of the object's name.
*/
singularNoun: string | null;
/**
* The plural form of the object's name.
*/
pluralNoun: string | null;
/**
* When the object was created.
*/
createdAt: string;
};
/** @internal */
export const ObjectId$inboundSchema: z.ZodType<
ObjectId,
z.ZodTypeDef,
unknown
> = z.object({
workspace_id: z.string(),
object_id: z.string(),
}).transform((v) => {
return remap$(v, {
"workspace_id": "workspaceId",
"object_id": "objectId",
});
});
/** @internal */
export type ObjectId$Outbound = {
workspace_id: string;
object_id: string;
};
/** @internal */
export const ObjectId$outboundSchema: z.ZodType<
ObjectId$Outbound,
z.ZodTypeDef,
ObjectId
> = z.object({
workspaceId: z.string(),
objectId: z.string(),
}).transform((v) => {
return remap$(v, {
workspaceId: "workspace_id",
objectId: "object_id",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace ObjectId$ {
/** @deprecated use `ObjectId$inboundSchema` instead. */
export const inboundSchema = ObjectId$inboundSchema;
/** @deprecated use `ObjectId$outboundSchema` instead. */
export const outboundSchema = ObjectId$outboundSchema;
/** @deprecated use `ObjectId$Outbound` instead. */
export type Outbound = ObjectId$Outbound;
}
export function objectIdToJSON(objectId: ObjectId): string {
return JSON.stringify(ObjectId$outboundSchema.parse(objectId));
}
export function objectIdFromJSON(
jsonString: string,
): SafeParseResult<ObjectId, SDKValidationError> {
return safeParse(
jsonString,
(x) => ObjectId$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ObjectId' from JSON`,
);
}
/** @internal */
export const ObjectT$inboundSchema: z.ZodType<ObjectT, z.ZodTypeDef, unknown> =
z.object({
id: z.lazy(() => ObjectId$inboundSchema),
api_slug: z.nullable(z.string()),
singular_noun: z.nullable(z.string()),
plural_noun: z.nullable(z.string()),
created_at: z.string(),
}).transform((v) => {
return remap$(v, {
"api_slug": "apiSlug",
"singular_noun": "singularNoun",
"plural_noun": "pluralNoun",
"created_at": "createdAt",
});
});
/** @internal */
export type ObjectT$Outbound = {
id: ObjectId$Outbound;
api_slug: string | null;
singular_noun: string | null;
plural_noun: string | null;
created_at: string;
};
/** @internal */
export const ObjectT$outboundSchema: z.ZodType<
ObjectT$Outbound,
z.ZodTypeDef,
ObjectT
> = z.object({
id: z.lazy(() => ObjectId$outboundSchema),
apiSlug: z.nullable(z.string()),
singularNoun: z.nullable(z.string()),
pluralNoun: z.nullable(z.string()),
createdAt: z.string(),
}).transform((v) => {
return remap$(v, {
apiSlug: "api_slug",
singularNoun: "singular_noun",
pluralNoun: "plural_noun",
createdAt: "created_at",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace ObjectT$ {
/** @deprecated use `ObjectT$inboundSchema` instead. */
export const inboundSchema = ObjectT$inboundSchema;
/** @deprecated use `ObjectT$outboundSchema` instead. */
export const outboundSchema = ObjectT$outboundSchema;
/** @deprecated use `ObjectT$Outbound` instead. */
export type Outbound = ObjectT$Outbound;
}
export function objectToJSON(objectT: ObjectT): string {
return JSON.stringify(ObjectT$outboundSchema.parse(objectT));
}
export function objectFromJSON(
jsonString: string,
): SafeParseResult<ObjectT, SDKValidationError> {
return safeParse(
jsonString,
(x) => ObjectT$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ObjectT' from JSON`,
);
}