attio-js
Version:
Developer-friendly & type-safe JS/TS SDK based on the official OpenAPI spec of Attio.
178 lines (162 loc) • 4.64 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 SelectOptionId = {
/**
* The ID of the workspace
*/
workspaceId: string;
/**
* The ID of the object
*/
objectId: string;
/**
* The ID of the attribute
*/
attributeId: string;
/**
* The ID of the select option
*/
optionId: string;
};
export type SelectOption = {
id: SelectOptionId;
/**
* The title of the select option
*/
title: string;
/**
* Whether or not to archive the select option. See our [archiving guide](/docs/archiving-vs-deleting) for more information on archiving.
*/
isArchived: boolean;
};
/** @internal */
export const SelectOptionId$inboundSchema: z.ZodType<
SelectOptionId,
z.ZodTypeDef,
unknown
> = z.object({
workspace_id: z.string(),
object_id: z.string(),
attribute_id: z.string(),
option_id: z.string(),
}).transform((v) => {
return remap$(v, {
"workspace_id": "workspaceId",
"object_id": "objectId",
"attribute_id": "attributeId",
"option_id": "optionId",
});
});
/** @internal */
export type SelectOptionId$Outbound = {
workspace_id: string;
object_id: string;
attribute_id: string;
option_id: string;
};
/** @internal */
export const SelectOptionId$outboundSchema: z.ZodType<
SelectOptionId$Outbound,
z.ZodTypeDef,
SelectOptionId
> = z.object({
workspaceId: z.string(),
objectId: z.string(),
attributeId: z.string(),
optionId: z.string(),
}).transform((v) => {
return remap$(v, {
workspaceId: "workspace_id",
objectId: "object_id",
attributeId: "attribute_id",
optionId: "option_id",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace SelectOptionId$ {
/** @deprecated use `SelectOptionId$inboundSchema` instead. */
export const inboundSchema = SelectOptionId$inboundSchema;
/** @deprecated use `SelectOptionId$outboundSchema` instead. */
export const outboundSchema = SelectOptionId$outboundSchema;
/** @deprecated use `SelectOptionId$Outbound` instead. */
export type Outbound = SelectOptionId$Outbound;
}
export function selectOptionIdToJSON(selectOptionId: SelectOptionId): string {
return JSON.stringify(SelectOptionId$outboundSchema.parse(selectOptionId));
}
export function selectOptionIdFromJSON(
jsonString: string,
): SafeParseResult<SelectOptionId, SDKValidationError> {
return safeParse(
jsonString,
(x) => SelectOptionId$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'SelectOptionId' from JSON`,
);
}
/** @internal */
export const SelectOption$inboundSchema: z.ZodType<
SelectOption,
z.ZodTypeDef,
unknown
> = z.object({
id: z.lazy(() => SelectOptionId$inboundSchema),
title: z.string(),
is_archived: z.boolean(),
}).transform((v) => {
return remap$(v, {
"is_archived": "isArchived",
});
});
/** @internal */
export type SelectOption$Outbound = {
id: SelectOptionId$Outbound;
title: string;
is_archived: boolean;
};
/** @internal */
export const SelectOption$outboundSchema: z.ZodType<
SelectOption$Outbound,
z.ZodTypeDef,
SelectOption
> = z.object({
id: z.lazy(() => SelectOptionId$outboundSchema),
title: z.string(),
isArchived: z.boolean(),
}).transform((v) => {
return remap$(v, {
isArchived: "is_archived",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace SelectOption$ {
/** @deprecated use `SelectOption$inboundSchema` instead. */
export const inboundSchema = SelectOption$inboundSchema;
/** @deprecated use `SelectOption$outboundSchema` instead. */
export const outboundSchema = SelectOption$outboundSchema;
/** @deprecated use `SelectOption$Outbound` instead. */
export type Outbound = SelectOption$Outbound;
}
export function selectOptionToJSON(selectOption: SelectOption): string {
return JSON.stringify(SelectOption$outboundSchema.parse(selectOption));
}
export function selectOptionFromJSON(
jsonString: string,
): SafeParseResult<SelectOption, SDKValidationError> {
return safeParse(
jsonString,
(x) => SelectOption$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'SelectOption' from JSON`,
);
}