attio-js
Version:
Developer-friendly & type-safe JS/TS SDK based on the official OpenAPI spec of Attio.
193 lines (177 loc) • 5.03 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 StatusId = {
/**
* 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 status
*/
statusId: string;
};
export type Status = {
id: StatusId;
/**
* The title of the status
*/
title: string;
/**
* Whether or not to archive the status. See our [archiving guide](/docs/archiving-vs-deleting) for more information on archiving.
*/
isArchived: boolean;
/**
* Whether arriving at this status triggers a celebration effect in the UI
*/
celebrationEnabled: boolean;
/**
* Target time for a record to spend in given status expressed as a ISO-8601 duration string
*/
targetTimeInStatus: string | null;
};
/** @internal */
export const StatusId$inboundSchema: z.ZodType<
StatusId,
z.ZodTypeDef,
unknown
> = z.object({
workspace_id: z.string(),
object_id: z.string(),
attribute_id: z.string(),
status_id: z.string(),
}).transform((v) => {
return remap$(v, {
"workspace_id": "workspaceId",
"object_id": "objectId",
"attribute_id": "attributeId",
"status_id": "statusId",
});
});
/** @internal */
export type StatusId$Outbound = {
workspace_id: string;
object_id: string;
attribute_id: string;
status_id: string;
};
/** @internal */
export const StatusId$outboundSchema: z.ZodType<
StatusId$Outbound,
z.ZodTypeDef,
StatusId
> = z.object({
workspaceId: z.string(),
objectId: z.string(),
attributeId: z.string(),
statusId: z.string(),
}).transform((v) => {
return remap$(v, {
workspaceId: "workspace_id",
objectId: "object_id",
attributeId: "attribute_id",
statusId: "status_id",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace StatusId$ {
/** @deprecated use `StatusId$inboundSchema` instead. */
export const inboundSchema = StatusId$inboundSchema;
/** @deprecated use `StatusId$outboundSchema` instead. */
export const outboundSchema = StatusId$outboundSchema;
/** @deprecated use `StatusId$Outbound` instead. */
export type Outbound = StatusId$Outbound;
}
export function statusIdToJSON(statusId: StatusId): string {
return JSON.stringify(StatusId$outboundSchema.parse(statusId));
}
export function statusIdFromJSON(
jsonString: string,
): SafeParseResult<StatusId, SDKValidationError> {
return safeParse(
jsonString,
(x) => StatusId$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'StatusId' from JSON`,
);
}
/** @internal */
export const Status$inboundSchema: z.ZodType<Status, z.ZodTypeDef, unknown> = z
.object({
id: z.lazy(() => StatusId$inboundSchema),
title: z.string(),
is_archived: z.boolean(),
celebration_enabled: z.boolean(),
target_time_in_status: z.nullable(z.string()),
}).transform((v) => {
return remap$(v, {
"is_archived": "isArchived",
"celebration_enabled": "celebrationEnabled",
"target_time_in_status": "targetTimeInStatus",
});
});
/** @internal */
export type Status$Outbound = {
id: StatusId$Outbound;
title: string;
is_archived: boolean;
celebration_enabled: boolean;
target_time_in_status: string | null;
};
/** @internal */
export const Status$outboundSchema: z.ZodType<
Status$Outbound,
z.ZodTypeDef,
Status
> = z.object({
id: z.lazy(() => StatusId$outboundSchema),
title: z.string(),
isArchived: z.boolean(),
celebrationEnabled: z.boolean(),
targetTimeInStatus: z.nullable(z.string()),
}).transform((v) => {
return remap$(v, {
isArchived: "is_archived",
celebrationEnabled: "celebration_enabled",
targetTimeInStatus: "target_time_in_status",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace Status$ {
/** @deprecated use `Status$inboundSchema` instead. */
export const inboundSchema = Status$inboundSchema;
/** @deprecated use `Status$outboundSchema` instead. */
export const outboundSchema = Status$outboundSchema;
/** @deprecated use `Status$Outbound` instead. */
export type Outbound = Status$Outbound;
}
export function statusToJSON(status: Status): string {
return JSON.stringify(Status$outboundSchema.parse(status));
}
export function statusFromJSON(
jsonString: string,
): SafeParseResult<Status, SDKValidationError> {
return safeParse(
jsonString,
(x) => Status$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'Status' from JSON`,
);
}