attio-js
Version:
Developer-friendly & type-safe JS/TS SDK based on the official OpenAPI spec of Attio.
448 lines (406 loc) • 13.4 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 ListId = {
/**
* A UUID to identify the workspace this list belongs to.
*/
workspaceId: string;
/**
* A UUID to identify this list.
*/
listId: string;
};
/**
* The level of access granted to all members of the workspace for this list. `null` values represent a private list that only grants access to specific workspace members via the `workspace_member_access` property.
*/
export const WorkspaceAccess = {
FullAccess: "full-access",
ReadAndWrite: "read-and-write",
ReadOnly: "read-only",
} as const;
/**
* The level of access granted to all members of the workspace for this list. `null` values represent a private list that only grants access to specific workspace members via the `workspace_member_access` property.
*/
export type WorkspaceAccess = ClosedEnum<typeof WorkspaceAccess>;
/**
* The level of access to the list.
*/
export const Level = {
FullAccess: "full-access",
ReadAndWrite: "read-and-write",
ReadOnly: "read-only",
} as const;
/**
* The level of access to the list.
*/
export type Level = ClosedEnum<typeof Level>;
export type WorkspaceMemberAccess = {
/**
* A UUID to identify the workspace member to grant access to.
*/
workspaceMemberId: string;
/**
* The level of access to the list.
*/
level: Level;
};
/**
* The type of actor. [Read more information on actor types here](/docs/actors).
*/
export const ListType = {
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 ListType = ClosedEnum<typeof ListType>;
/**
* The actor which created this list.
*/
export type ListCreatedByActor = {
/**
* An ID to identify the actor.
*/
id?: string | null | undefined;
/**
* The type of actor. [Read more information on actor types here](/docs/actors).
*/
type?: ListType | null | undefined;
};
export type List = {
id: ListId;
/**
* A human-readable slug for use in URLs and responses.
*/
apiSlug: string;
/**
* The name of the list, as viewed in the UI.
*/
name: string;
/**
* A UUID or slug to identify the allowed object type for records added to this list. All new Lists are expected to have exactly one parent object. However, some legacy lists may have multiple allowed parents so the return type of this field is an array.
*/
parentObject: Array<string>;
/**
* The level of access granted to all members of the workspace for this list. `null` values represent a private list that only grants access to specific workspace members via the `workspace_member_access` property.
*/
workspaceAccess: WorkspaceAccess | null;
/**
* The level of access granted to specific workspace members for this list. An empty array represents a list that has granted access to no workspace members.
*/
workspaceMemberAccess: Array<WorkspaceMemberAccess>;
/**
* The actor which created this list.
*/
createdByActor: ListCreatedByActor;
/**
* When the list was created.
*/
createdAt: string;
};
/** @internal */
export const ListId$inboundSchema: z.ZodType<ListId, z.ZodTypeDef, unknown> = z
.object({
workspace_id: z.string(),
list_id: z.string(),
}).transform((v) => {
return remap$(v, {
"workspace_id": "workspaceId",
"list_id": "listId",
});
});
/** @internal */
export type ListId$Outbound = {
workspace_id: string;
list_id: string;
};
/** @internal */
export const ListId$outboundSchema: z.ZodType<
ListId$Outbound,
z.ZodTypeDef,
ListId
> = z.object({
workspaceId: z.string(),
listId: z.string(),
}).transform((v) => {
return remap$(v, {
workspaceId: "workspace_id",
listId: "list_id",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace ListId$ {
/** @deprecated use `ListId$inboundSchema` instead. */
export const inboundSchema = ListId$inboundSchema;
/** @deprecated use `ListId$outboundSchema` instead. */
export const outboundSchema = ListId$outboundSchema;
/** @deprecated use `ListId$Outbound` instead. */
export type Outbound = ListId$Outbound;
}
export function listIdToJSON(listId: ListId): string {
return JSON.stringify(ListId$outboundSchema.parse(listId));
}
export function listIdFromJSON(
jsonString: string,
): SafeParseResult<ListId, SDKValidationError> {
return safeParse(
jsonString,
(x) => ListId$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ListId' from JSON`,
);
}
/** @internal */
export const WorkspaceAccess$inboundSchema: z.ZodNativeEnum<
typeof WorkspaceAccess
> = z.nativeEnum(WorkspaceAccess);
/** @internal */
export const WorkspaceAccess$outboundSchema: z.ZodNativeEnum<
typeof WorkspaceAccess
> = WorkspaceAccess$inboundSchema;
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace WorkspaceAccess$ {
/** @deprecated use `WorkspaceAccess$inboundSchema` instead. */
export const inboundSchema = WorkspaceAccess$inboundSchema;
/** @deprecated use `WorkspaceAccess$outboundSchema` instead. */
export const outboundSchema = WorkspaceAccess$outboundSchema;
}
/** @internal */
export const Level$inboundSchema: z.ZodNativeEnum<typeof Level> = z.nativeEnum(
Level,
);
/** @internal */
export const Level$outboundSchema: z.ZodNativeEnum<typeof Level> =
Level$inboundSchema;
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace Level$ {
/** @deprecated use `Level$inboundSchema` instead. */
export const inboundSchema = Level$inboundSchema;
/** @deprecated use `Level$outboundSchema` instead. */
export const outboundSchema = Level$outboundSchema;
}
/** @internal */
export const WorkspaceMemberAccess$inboundSchema: z.ZodType<
WorkspaceMemberAccess,
z.ZodTypeDef,
unknown
> = z.object({
workspace_member_id: z.string(),
level: Level$inboundSchema,
}).transform((v) => {
return remap$(v, {
"workspace_member_id": "workspaceMemberId",
});
});
/** @internal */
export type WorkspaceMemberAccess$Outbound = {
workspace_member_id: string;
level: string;
};
/** @internal */
export const WorkspaceMemberAccess$outboundSchema: z.ZodType<
WorkspaceMemberAccess$Outbound,
z.ZodTypeDef,
WorkspaceMemberAccess
> = z.object({
workspaceMemberId: z.string(),
level: Level$outboundSchema,
}).transform((v) => {
return remap$(v, {
workspaceMemberId: "workspace_member_id",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace WorkspaceMemberAccess$ {
/** @deprecated use `WorkspaceMemberAccess$inboundSchema` instead. */
export const inboundSchema = WorkspaceMemberAccess$inboundSchema;
/** @deprecated use `WorkspaceMemberAccess$outboundSchema` instead. */
export const outboundSchema = WorkspaceMemberAccess$outboundSchema;
/** @deprecated use `WorkspaceMemberAccess$Outbound` instead. */
export type Outbound = WorkspaceMemberAccess$Outbound;
}
export function workspaceMemberAccessToJSON(
workspaceMemberAccess: WorkspaceMemberAccess,
): string {
return JSON.stringify(
WorkspaceMemberAccess$outboundSchema.parse(workspaceMemberAccess),
);
}
export function workspaceMemberAccessFromJSON(
jsonString: string,
): SafeParseResult<WorkspaceMemberAccess, SDKValidationError> {
return safeParse(
jsonString,
(x) => WorkspaceMemberAccess$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'WorkspaceMemberAccess' from JSON`,
);
}
/** @internal */
export const ListType$inboundSchema: z.ZodNativeEnum<typeof ListType> = z
.nativeEnum(ListType);
/** @internal */
export const ListType$outboundSchema: z.ZodNativeEnum<typeof ListType> =
ListType$inboundSchema;
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace ListType$ {
/** @deprecated use `ListType$inboundSchema` instead. */
export const inboundSchema = ListType$inboundSchema;
/** @deprecated use `ListType$outboundSchema` instead. */
export const outboundSchema = ListType$outboundSchema;
}
/** @internal */
export const ListCreatedByActor$inboundSchema: z.ZodType<
ListCreatedByActor,
z.ZodTypeDef,
unknown
> = z.object({
id: z.nullable(z.string()).optional(),
type: z.nullable(ListType$inboundSchema).optional(),
});
/** @internal */
export type ListCreatedByActor$Outbound = {
id?: string | null | undefined;
type?: string | null | undefined;
};
/** @internal */
export const ListCreatedByActor$outboundSchema: z.ZodType<
ListCreatedByActor$Outbound,
z.ZodTypeDef,
ListCreatedByActor
> = z.object({
id: z.nullable(z.string()).optional(),
type: z.nullable(ListType$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 ListCreatedByActor$ {
/** @deprecated use `ListCreatedByActor$inboundSchema` instead. */
export const inboundSchema = ListCreatedByActor$inboundSchema;
/** @deprecated use `ListCreatedByActor$outboundSchema` instead. */
export const outboundSchema = ListCreatedByActor$outboundSchema;
/** @deprecated use `ListCreatedByActor$Outbound` instead. */
export type Outbound = ListCreatedByActor$Outbound;
}
export function listCreatedByActorToJSON(
listCreatedByActor: ListCreatedByActor,
): string {
return JSON.stringify(
ListCreatedByActor$outboundSchema.parse(listCreatedByActor),
);
}
export function listCreatedByActorFromJSON(
jsonString: string,
): SafeParseResult<ListCreatedByActor, SDKValidationError> {
return safeParse(
jsonString,
(x) => ListCreatedByActor$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ListCreatedByActor' from JSON`,
);
}
/** @internal */
export const List$inboundSchema: z.ZodType<List, z.ZodTypeDef, unknown> = z
.object({
id: z.lazy(() => ListId$inboundSchema),
api_slug: z.string(),
name: z.string(),
parent_object: z.array(z.string()),
workspace_access: z.nullable(WorkspaceAccess$inboundSchema),
workspace_member_access: z.array(
z.lazy(() => WorkspaceMemberAccess$inboundSchema),
),
created_by_actor: z.lazy(() => ListCreatedByActor$inboundSchema),
created_at: z.string(),
}).transform((v) => {
return remap$(v, {
"api_slug": "apiSlug",
"parent_object": "parentObject",
"workspace_access": "workspaceAccess",
"workspace_member_access": "workspaceMemberAccess",
"created_by_actor": "createdByActor",
"created_at": "createdAt",
});
});
/** @internal */
export type List$Outbound = {
id: ListId$Outbound;
api_slug: string;
name: string;
parent_object: Array<string>;
workspace_access: string | null;
workspace_member_access: Array<WorkspaceMemberAccess$Outbound>;
created_by_actor: ListCreatedByActor$Outbound;
created_at: string;
};
/** @internal */
export const List$outboundSchema: z.ZodType<List$Outbound, z.ZodTypeDef, List> =
z.object({
id: z.lazy(() => ListId$outboundSchema),
apiSlug: z.string(),
name: z.string(),
parentObject: z.array(z.string()),
workspaceAccess: z.nullable(WorkspaceAccess$outboundSchema),
workspaceMemberAccess: z.array(
z.lazy(() => WorkspaceMemberAccess$outboundSchema),
),
createdByActor: z.lazy(() => ListCreatedByActor$outboundSchema),
createdAt: z.string(),
}).transform((v) => {
return remap$(v, {
apiSlug: "api_slug",
parentObject: "parent_object",
workspaceAccess: "workspace_access",
workspaceMemberAccess: "workspace_member_access",
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 List$ {
/** @deprecated use `List$inboundSchema` instead. */
export const inboundSchema = List$inboundSchema;
/** @deprecated use `List$outboundSchema` instead. */
export const outboundSchema = List$outboundSchema;
/** @deprecated use `List$Outbound` instead. */
export type Outbound = List$Outbound;
}
export function listToJSON(list: List): string {
return JSON.stringify(List$outboundSchema.parse(list));
}
export function listFromJSON(
jsonString: string,
): SafeParseResult<List, SDKValidationError> {
return safeParse(
jsonString,
(x) => List$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'List' from JSON`,
);
}