attio-js
Version:
Developer-friendly & type-safe JS/TS SDK based on the official OpenAPI spec of Attio.
301 lines (274 loc) • 8.45 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 { ClosedEnum } from "../../types/enums.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
export type NoteId = {
/**
* The ID of the workspace the note belongs to.
*/
workspaceId: string;
/**
* The ID of the note.
*/
noteId: string;
};
/**
* The type of actor. [Read more information on actor types here](/docs/actors).
*/
export const NoteType = {
ApiToken: "api-token",
WorkspaceMember: "workspace-member",
System: "system",
App: "app",
} as const;
/**
* The type of actor. [Read more information on actor types here](/docs/actors).
*/
export type NoteType = ClosedEnum<typeof NoteType>;
/**
* The actor that created this note.
*/
export type NoteCreatedByActor = {
/**
* An ID to identify the actor.
*/
id?: string | null | undefined;
/**
* The type of actor. [Read more information on actor types here](/docs/actors).
*/
type?: NoteType | null | undefined;
};
export type Note = {
id: NoteId;
/**
* The slug or ID of the parent object the note belongs to.
*/
parentObject: string;
/**
* The ID of the parent record the note belongs to.
*/
parentRecordId: string;
/**
* The note title. The title is plaintext only and has no formatting.
*/
title: string;
/**
* The plaintext representation of the note content. The line feed character `\n` represents new lines within the note content.
*/
contentPlaintext: string;
/**
* The markdown representation of the note content with formatting applied based on block types and styles.
*/
contentMarkdown: string;
/**
* The actor that created this note.
*/
createdByActor: NoteCreatedByActor;
/**
* When the note was created.
*/
createdAt: string;
};
/** @internal */
export const NoteId$inboundSchema: z.ZodType<NoteId, z.ZodTypeDef, unknown> = z
.object({
workspace_id: z.string(),
note_id: z.string(),
}).transform((v) => {
return remap$(v, {
"workspace_id": "workspaceId",
"note_id": "noteId",
});
});
/** @internal */
export type NoteId$Outbound = {
workspace_id: string;
note_id: string;
};
/** @internal */
export const NoteId$outboundSchema: z.ZodType<
NoteId$Outbound,
z.ZodTypeDef,
NoteId
> = z.object({
workspaceId: z.string(),
noteId: z.string(),
}).transform((v) => {
return remap$(v, {
workspaceId: "workspace_id",
noteId: "note_id",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace NoteId$ {
/** @deprecated use `NoteId$inboundSchema` instead. */
export const inboundSchema = NoteId$inboundSchema;
/** @deprecated use `NoteId$outboundSchema` instead. */
export const outboundSchema = NoteId$outboundSchema;
/** @deprecated use `NoteId$Outbound` instead. */
export type Outbound = NoteId$Outbound;
}
export function noteIdToJSON(noteId: NoteId): string {
return JSON.stringify(NoteId$outboundSchema.parse(noteId));
}
export function noteIdFromJSON(
jsonString: string,
): SafeParseResult<NoteId, SDKValidationError> {
return safeParse(
jsonString,
(x) => NoteId$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'NoteId' from JSON`,
);
}
/** @internal */
export const NoteType$inboundSchema: z.ZodNativeEnum<typeof NoteType> = z
.nativeEnum(NoteType);
/** @internal */
export const NoteType$outboundSchema: z.ZodNativeEnum<typeof NoteType> =
NoteType$inboundSchema;
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace NoteType$ {
/** @deprecated use `NoteType$inboundSchema` instead. */
export const inboundSchema = NoteType$inboundSchema;
/** @deprecated use `NoteType$outboundSchema` instead. */
export const outboundSchema = NoteType$outboundSchema;
}
/** @internal */
export const NoteCreatedByActor$inboundSchema: z.ZodType<
NoteCreatedByActor,
z.ZodTypeDef,
unknown
> = z.object({
id: z.nullable(z.string()).optional(),
type: z.nullable(NoteType$inboundSchema).optional(),
});
/** @internal */
export type NoteCreatedByActor$Outbound = {
id?: string | null | undefined;
type?: string | null | undefined;
};
/** @internal */
export const NoteCreatedByActor$outboundSchema: z.ZodType<
NoteCreatedByActor$Outbound,
z.ZodTypeDef,
NoteCreatedByActor
> = z.object({
id: z.nullable(z.string()).optional(),
type: z.nullable(NoteType$outboundSchema).optional(),
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace NoteCreatedByActor$ {
/** @deprecated use `NoteCreatedByActor$inboundSchema` instead. */
export const inboundSchema = NoteCreatedByActor$inboundSchema;
/** @deprecated use `NoteCreatedByActor$outboundSchema` instead. */
export const outboundSchema = NoteCreatedByActor$outboundSchema;
/** @deprecated use `NoteCreatedByActor$Outbound` instead. */
export type Outbound = NoteCreatedByActor$Outbound;
}
export function noteCreatedByActorToJSON(
noteCreatedByActor: NoteCreatedByActor,
): string {
return JSON.stringify(
NoteCreatedByActor$outboundSchema.parse(noteCreatedByActor),
);
}
export function noteCreatedByActorFromJSON(
jsonString: string,
): SafeParseResult<NoteCreatedByActor, SDKValidationError> {
return safeParse(
jsonString,
(x) => NoteCreatedByActor$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'NoteCreatedByActor' from JSON`,
);
}
/** @internal */
export const Note$inboundSchema: z.ZodType<Note, z.ZodTypeDef, unknown> = z
.object({
id: z.lazy(() => NoteId$inboundSchema),
parent_object: z.string(),
parent_record_id: z.string(),
title: z.string(),
content_plaintext: z.string(),
content_markdown: z.string(),
created_by_actor: z.lazy(() => NoteCreatedByActor$inboundSchema),
created_at: z.string(),
}).transform((v) => {
return remap$(v, {
"parent_object": "parentObject",
"parent_record_id": "parentRecordId",
"content_plaintext": "contentPlaintext",
"content_markdown": "contentMarkdown",
"created_by_actor": "createdByActor",
"created_at": "createdAt",
});
});
/** @internal */
export type Note$Outbound = {
id: NoteId$Outbound;
parent_object: string;
parent_record_id: string;
title: string;
content_plaintext: string;
content_markdown: string;
created_by_actor: NoteCreatedByActor$Outbound;
created_at: string;
};
/** @internal */
export const Note$outboundSchema: z.ZodType<Note$Outbound, z.ZodTypeDef, Note> =
z.object({
id: z.lazy(() => NoteId$outboundSchema),
parentObject: z.string(),
parentRecordId: z.string(),
title: z.string(),
contentPlaintext: z.string(),
contentMarkdown: z.string(),
createdByActor: z.lazy(() => NoteCreatedByActor$outboundSchema),
createdAt: z.string(),
}).transform((v) => {
return remap$(v, {
parentObject: "parent_object",
parentRecordId: "parent_record_id",
contentPlaintext: "content_plaintext",
contentMarkdown: "content_markdown",
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 namespace Note$ {
/** @deprecated use `Note$inboundSchema` instead. */
export const inboundSchema = Note$inboundSchema;
/** @deprecated use `Note$outboundSchema` instead. */
export const outboundSchema = Note$outboundSchema;
/** @deprecated use `Note$Outbound` instead. */
export type Outbound = Note$Outbound;
}
export function noteToJSON(note: Note): string {
return JSON.stringify(Note$outboundSchema.parse(note));
}
export function noteFromJSON(
jsonString: string,
): SafeParseResult<Note, SDKValidationError> {
return safeParse(
jsonString,
(x) => Note$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'Note' from JSON`,
);
}