attio-js
Version:
Developer-friendly & type-safe JS/TS SDK based on the official OpenAPI spec of Attio.
253 lines • 9.66 kB
JavaScript
/*
* 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";
/**
* The type of actor. [Read more information on actor types here](/docs/actors).
*/
export const TaskReferencedActorType = {
ApiToken: "api-token",
WorkspaceMember: "workspace-member",
System: "system",
App: "app",
};
/**
* The type of actor. [Read more information on actor types here](/docs/actors).
*/
export const TaskType = {
ApiToken: "api-token",
WorkspaceMember: "workspace-member",
System: "system",
App: "app",
};
/** @internal */
export const TaskId$inboundSchema = z
.object({
workspace_id: z.string(),
task_id: z.string(),
}).transform((v) => {
return remap$(v, {
"workspace_id": "workspaceId",
"task_id": "taskId",
});
});
/** @internal */
export const TaskId$outboundSchema = z.object({
workspaceId: z.string(),
taskId: z.string(),
}).transform((v) => {
return remap$(v, {
workspaceId: "workspace_id",
taskId: "task_id",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export var TaskId$;
(function (TaskId$) {
/** @deprecated use `TaskId$inboundSchema` instead. */
TaskId$.inboundSchema = TaskId$inboundSchema;
/** @deprecated use `TaskId$outboundSchema` instead. */
TaskId$.outboundSchema = TaskId$outboundSchema;
})(TaskId$ || (TaskId$ = {}));
export function taskIdToJSON(taskId) {
return JSON.stringify(TaskId$outboundSchema.parse(taskId));
}
export function taskIdFromJSON(jsonString) {
return safeParse(jsonString, (x) => TaskId$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TaskId' from JSON`);
}
/** @internal */
export const LinkedRecord$inboundSchema = z.object({
target_object_id: z.string(),
target_record_id: z.string(),
}).transform((v) => {
return remap$(v, {
"target_object_id": "targetObjectId",
"target_record_id": "targetRecordId",
});
});
/** @internal */
export const LinkedRecord$outboundSchema = z.object({
targetObjectId: z.string(),
targetRecordId: z.string(),
}).transform((v) => {
return remap$(v, {
targetObjectId: "target_object_id",
targetRecordId: "target_record_id",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export var LinkedRecord$;
(function (LinkedRecord$) {
/** @deprecated use `LinkedRecord$inboundSchema` instead. */
LinkedRecord$.inboundSchema = LinkedRecord$inboundSchema;
/** @deprecated use `LinkedRecord$outboundSchema` instead. */
LinkedRecord$.outboundSchema = LinkedRecord$outboundSchema;
})(LinkedRecord$ || (LinkedRecord$ = {}));
export function linkedRecordToJSON(linkedRecord) {
return JSON.stringify(LinkedRecord$outboundSchema.parse(linkedRecord));
}
export function linkedRecordFromJSON(jsonString) {
return safeParse(jsonString, (x) => LinkedRecord$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'LinkedRecord' from JSON`);
}
/** @internal */
export const TaskReferencedActorType$inboundSchema = z.nativeEnum(TaskReferencedActorType);
/** @internal */
export const TaskReferencedActorType$outboundSchema = TaskReferencedActorType$inboundSchema;
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export var TaskReferencedActorType$;
(function (TaskReferencedActorType$) {
/** @deprecated use `TaskReferencedActorType$inboundSchema` instead. */
TaskReferencedActorType$.inboundSchema = TaskReferencedActorType$inboundSchema;
/** @deprecated use `TaskReferencedActorType$outboundSchema` instead. */
TaskReferencedActorType$.outboundSchema = TaskReferencedActorType$outboundSchema;
})(TaskReferencedActorType$ || (TaskReferencedActorType$ = {}));
/** @internal */
export const Assignee$inboundSchema = z.object({
referenced_actor_type: TaskReferencedActorType$inboundSchema,
referenced_actor_id: z.string(),
}).transform((v) => {
return remap$(v, {
"referenced_actor_type": "referencedActorType",
"referenced_actor_id": "referencedActorId",
});
});
/** @internal */
export const Assignee$outboundSchema = z.object({
referencedActorType: TaskReferencedActorType$outboundSchema,
referencedActorId: z.string(),
}).transform((v) => {
return remap$(v, {
referencedActorType: "referenced_actor_type",
referencedActorId: "referenced_actor_id",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export var Assignee$;
(function (Assignee$) {
/** @deprecated use `Assignee$inboundSchema` instead. */
Assignee$.inboundSchema = Assignee$inboundSchema;
/** @deprecated use `Assignee$outboundSchema` instead. */
Assignee$.outboundSchema = Assignee$outboundSchema;
})(Assignee$ || (Assignee$ = {}));
export function assigneeToJSON(assignee) {
return JSON.stringify(Assignee$outboundSchema.parse(assignee));
}
export function assigneeFromJSON(jsonString) {
return safeParse(jsonString, (x) => Assignee$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Assignee' from JSON`);
}
/** @internal */
export const TaskType$inboundSchema = z
.nativeEnum(TaskType);
/** @internal */
export const TaskType$outboundSchema = TaskType$inboundSchema;
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export var TaskType$;
(function (TaskType$) {
/** @deprecated use `TaskType$inboundSchema` instead. */
TaskType$.inboundSchema = TaskType$inboundSchema;
/** @deprecated use `TaskType$outboundSchema` instead. */
TaskType$.outboundSchema = TaskType$outboundSchema;
})(TaskType$ || (TaskType$ = {}));
/** @internal */
export const TaskCreatedByActor$inboundSchema = z.object({
id: z.nullable(z.string()).optional(),
type: z.nullable(TaskType$inboundSchema).optional(),
});
/** @internal */
export const TaskCreatedByActor$outboundSchema = z.object({
id: z.nullable(z.string()).optional(),
type: z.nullable(TaskType$outboundSchema).optional(),
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export var TaskCreatedByActor$;
(function (TaskCreatedByActor$) {
/** @deprecated use `TaskCreatedByActor$inboundSchema` instead. */
TaskCreatedByActor$.inboundSchema = TaskCreatedByActor$inboundSchema;
/** @deprecated use `TaskCreatedByActor$outboundSchema` instead. */
TaskCreatedByActor$.outboundSchema = TaskCreatedByActor$outboundSchema;
})(TaskCreatedByActor$ || (TaskCreatedByActor$ = {}));
export function taskCreatedByActorToJSON(taskCreatedByActor) {
return JSON.stringify(TaskCreatedByActor$outboundSchema.parse(taskCreatedByActor));
}
export function taskCreatedByActorFromJSON(jsonString) {
return safeParse(jsonString, (x) => TaskCreatedByActor$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TaskCreatedByActor' from JSON`);
}
/** @internal */
export const Task$inboundSchema = z
.object({
id: z.lazy(() => TaskId$inboundSchema),
content_plaintext: z.string(),
deadline_at: z.nullable(z.string()),
is_completed: z.boolean(),
linked_records: z.array(z.lazy(() => LinkedRecord$inboundSchema)),
assignees: z.array(z.lazy(() => Assignee$inboundSchema)),
created_by_actor: z.lazy(() => TaskCreatedByActor$inboundSchema),
created_at: z.string(),
}).transform((v) => {
return remap$(v, {
"content_plaintext": "contentPlaintext",
"deadline_at": "deadlineAt",
"is_completed": "isCompleted",
"linked_records": "linkedRecords",
"created_by_actor": "createdByActor",
"created_at": "createdAt",
});
});
/** @internal */
export const Task$outboundSchema = z.object({
id: z.lazy(() => TaskId$outboundSchema),
contentPlaintext: z.string(),
deadlineAt: z.nullable(z.string()),
isCompleted: z.boolean(),
linkedRecords: z.array(z.lazy(() => LinkedRecord$outboundSchema)),
assignees: z.array(z.lazy(() => Assignee$outboundSchema)),
createdByActor: z.lazy(() => TaskCreatedByActor$outboundSchema),
createdAt: z.string(),
}).transform((v) => {
return remap$(v, {
contentPlaintext: "content_plaintext",
deadlineAt: "deadline_at",
isCompleted: "is_completed",
linkedRecords: "linked_records",
createdByActor: "created_by_actor",
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 var Task$;
(function (Task$) {
/** @deprecated use `Task$inboundSchema` instead. */
Task$.inboundSchema = Task$inboundSchema;
/** @deprecated use `Task$outboundSchema` instead. */
Task$.outboundSchema = Task$outboundSchema;
})(Task$ || (Task$ = {}));
export function taskToJSON(task) {
return JSON.stringify(Task$outboundSchema.parse(task));
}
export function taskFromJSON(jsonString) {
return safeParse(jsonString, (x) => Task$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Task' from JSON`);
}
//# sourceMappingURL=task.js.map