@jahands/notion-client
Version:
A simple and easy to use client for the Notion API
1,620 lines • 108 kB
TypeScript
type IdResponse = string;
export type PersonUserObjectResponse = {
type: 'person';
person: {
email?: string;
};
};
type EmptyObject = Record<string, never>;
type IdRequest = string;
export type PartialUserObjectResponse = {
id: IdResponse;
object: 'user';
};
type BotInfoResponse = {
owner: {
type: 'user';
user: {
id: IdResponse;
object: 'user';
name: string | null;
avatar_url: string | null;
type: 'person';
person: {
email?: string;
};
} | PartialUserObjectResponse;
} | {
type: 'workspace';
workspace: true;
};
workspace_name: string | null;
workspace_limits: {
max_file_upload_size_in_bytes: number;
};
};
export type BotUserObjectResponse = {
type: 'bot';
bot: EmptyObject | BotInfoResponse;
};
export type UserObjectResponse = UserObjectResponseCommon & (PersonUserObjectResponse | BotUserObjectResponse);
export type GroupObjectResponse = {
name: string | null;
id: IdResponse;
object: 'group';
};
type DatabaseParentResponse = {
type: 'database_id';
database_id: IdResponse;
};
type DataSourceParentResponse = {
type: 'data_source_id';
data_source_id: IdResponse;
database_id: IdResponse;
};
type PageIdParentForBlockBasedObjectResponse = {
type: 'page_id';
page_id: IdResponse;
};
type BlockIdParentForBlockBasedObjectResponse = {
type: 'block_id';
block_id: IdResponse;
};
type WorkspaceParentForBlockBasedObjectResponse = {
type: 'workspace';
workspace: true;
};
type ParentForBlockBasedObjectResponse = DatabaseParentResponse | DataSourceParentResponse | PageIdParentForBlockBasedObjectResponse | BlockIdParentForBlockBasedObjectResponse | WorkspaceParentForBlockBasedObjectResponse;
/**
* One of: `default`, `gray`, `brown`, `orange`, `yellow`, `green`, `blue`, `purple`,
* `pink`, `red`
*/
type SelectColor = 'default' | 'gray' | 'brown' | 'orange' | 'yellow' | 'green' | 'blue' | 'purple' | 'pink' | 'red';
type PartialSelectResponse = {
id: string;
name: string;
color: SelectColor;
};
type TimeZoneRequest = string;
type DateResponse = {
start: string;
end: string | null;
time_zone: TimeZoneRequest | null;
};
type InternalFileResponse = {
url: string;
expiry_time: string;
};
type StringRequest = string;
type FileInternalOrExternalFileWithNameResponse = {
type: 'file';
file: InternalFileResponse;
name: StringRequest;
};
type TextRequest = string;
type ExternalInternalOrExternalFileWithNameResponse = {
type: 'external';
external: {
url: TextRequest;
};
name: StringRequest;
};
type InternalOrExternalFileWithNameResponse = FileInternalOrExternalFileWithNameResponse | ExternalInternalOrExternalFileWithNameResponse;
type StringFormulaPropertyResponse = {
type: 'string';
string: string | null;
};
type DateFormulaPropertyResponse = {
type: 'date';
date: DateResponse | null;
};
type NumberFormulaPropertyResponse = {
type: 'number';
number: number | null;
};
type BooleanFormulaPropertyResponse = {
type: 'boolean';
boolean: boolean | null;
};
type FormulaPropertyResponse = StringFormulaPropertyResponse | DateFormulaPropertyResponse | NumberFormulaPropertyResponse | BooleanFormulaPropertyResponse;
type VerificationPropertyUnverifiedResponse = {
state: 'unverified';
date: null;
verified_by: null;
};
type VerificationPropertyResponse = {
state: 'verified' | 'expired';
date: DateResponse | null;
verified_by: PartialUserObjectResponse | null;
};
type VerificationPropertyValueResponse = VerificationPropertyUnverifiedResponse | VerificationPropertyResponse;
type AnnotationResponse = {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: ApiColor;
};
export type TextRichTextItemResponse = {
type: 'text';
text: {
content: string;
link: {
url: string;
} | null;
};
};
type LinkPreviewMentionResponse = {
url: string;
};
type LinkMentionResponse = {
href: string;
title?: string;
description?: string;
link_author?: string;
link_provider?: string;
thumbnail_url?: string;
icon_url?: string;
iframe_url?: string;
height?: number;
padding?: number;
padding_top?: number;
};
type TemplateMentionDateTemplateMentionResponse = {
type: 'template_mention_date';
template_mention_date: 'today' | 'now';
};
type TemplateMentionUserTemplateMentionResponse = {
type: 'template_mention_user';
template_mention_user: 'me';
};
type TemplateMentionResponse = TemplateMentionDateTemplateMentionResponse | TemplateMentionUserTemplateMentionResponse;
type CustomEmojiResponse = {
id: IdResponse;
name: string;
url: string;
};
export type MentionRichTextItemResponse = {
type: 'mention';
mention: {
type: 'user';
user: PartialUserObjectResponse | UserObjectResponse;
} | {
type: 'date';
date: DateResponse;
} | {
type: 'link_preview';
link_preview: LinkPreviewMentionResponse;
} | {
type: 'link_mention';
link_mention: LinkMentionResponse;
} | {
type: 'page';
page: {
id: IdResponse;
};
} | {
type: 'database';
database: {
id: IdResponse;
};
} | {
type: 'template_mention';
template_mention: TemplateMentionResponse;
} | {
type: 'custom_emoji';
custom_emoji: CustomEmojiResponse;
};
};
export type EquationRichTextItemResponse = {
type: 'equation';
equation: {
expression: string;
};
};
export type RichTextItemResponse = RichTextItemResponseCommon & (TextRichTextItemResponse | MentionRichTextItemResponse | EquationRichTextItemResponse);
type RollupFunction = 'count' | 'count_values' | 'empty' | 'not_empty' | 'unique' | 'show_unique' | 'percent_empty' | 'percent_not_empty' | 'sum' | 'average' | 'median' | 'min' | 'max' | 'range' | 'earliest_date' | 'latest_date' | 'date_range' | 'checked' | 'unchecked' | 'percent_checked' | 'percent_unchecked' | 'count_per_group' | 'percent_per_group' | 'show_original';
type EmojiRequest = string;
type EmojiPageIconResponse = {
type: 'emoji';
emoji: EmojiRequest;
};
type ExternalPageIconResponse = {
type: 'external';
external: {
url: string;
};
};
type FilePageIconResponse = {
type: 'file';
file: InternalFileResponse;
};
type CustomEmojiPageIconResponse = {
type: 'custom_emoji';
custom_emoji: CustomEmojiResponse;
};
type PageIconResponse = EmojiPageIconResponse | FilePageIconResponse | ExternalPageIconResponse | CustomEmojiPageIconResponse;
type ExternalPageCoverResponse = {
type: 'external';
external: {
url: string;
};
};
type FilePageCoverResponse = {
type: 'file';
file: InternalFileResponse;
};
type PageCoverResponse = FilePageCoverResponse | ExternalPageCoverResponse;
export type PageObjectResponse = {
parent: ParentForBlockBasedObjectResponse;
properties: Record<string, {
type: 'number';
number: number | null;
id: string;
} | {
type: 'url';
url: string | null;
id: string;
} | {
type: 'select';
select: PartialSelectResponse | null;
id: string;
} | {
type: 'multi_select';
multi_select: PartialSelectResponse[];
id: string;
} | {
type: 'status';
status: PartialSelectResponse | null;
id: string;
} | {
type: 'date';
date: DateResponse | null;
id: string;
} | {
type: 'email';
email: string | null;
id: string;
} | {
type: 'phone_number';
phone_number: string | null;
id: string;
} | {
type: 'checkbox';
checkbox: boolean;
id: string;
} | {
type: 'files';
files: InternalOrExternalFileWithNameResponse[];
id: string;
} | {
type: 'created_by';
created_by: PartialUserObjectResponse | UserObjectResponse;
id: string;
} | {
type: 'created_time';
created_time: string;
id: string;
} | {
type: 'last_edited_by';
last_edited_by: PartialUserObjectResponse | UserObjectResponse;
id: string;
} | {
type: 'last_edited_time';
last_edited_time: string;
id: string;
} | {
type: 'formula';
formula: FormulaPropertyResponse;
id: string;
} | {
type: 'button';
button: EmptyObject;
id: string;
} | {
type: 'unique_id';
unique_id: {
prefix: string | null;
number: number | null;
};
id: string;
} | {
type: 'verification';
verification: VerificationPropertyValueResponse | null;
id: string;
} | {
type: 'title';
title: RichTextItemResponse[];
id: string;
} | {
type: 'rich_text';
rich_text: RichTextItemResponse[];
id: string;
} | {
type: 'people';
people: Array<PartialUserObjectResponse | UserObjectResponse | GroupObjectResponse>;
id: string;
} | {
type: 'relation';
relation: Array<{
id: string;
}>;
id: string;
} | {
type: 'rollup';
rollup: {
type: 'number';
number: number | null;
function: RollupFunction;
} | {
type: 'date';
date: DateResponse | null;
function: RollupFunction;
} | {
type: 'array';
array: Array<{
type: 'number';
number: number | null;
} | {
type: 'url';
url: string | null;
} | {
type: 'select';
select: PartialSelectResponse | null;
} | {
type: 'multi_select';
multi_select: PartialSelectResponse[];
} | {
type: 'status';
status: PartialSelectResponse | null;
} | {
type: 'date';
date: DateResponse | null;
} | {
type: 'email';
email: string | null;
} | {
type: 'phone_number';
phone_number: string | null;
} | {
type: 'checkbox';
checkbox: boolean;
} | {
type: 'files';
files: InternalOrExternalFileWithNameResponse[];
} | {
type: 'created_by';
created_by: PartialUserObjectResponse | UserObjectResponse;
} | {
type: 'created_time';
created_time: string;
} | {
type: 'last_edited_by';
last_edited_by: PartialUserObjectResponse | UserObjectResponse;
} | {
type: 'last_edited_time';
last_edited_time: string;
} | {
type: 'formula';
formula: FormulaPropertyResponse;
} | {
type: 'button';
button: EmptyObject;
} | {
type: 'unique_id';
unique_id: {
prefix: string | null;
number: number | null;
};
} | {
type: 'verification';
verification: VerificationPropertyValueResponse | null;
} | {
type: 'title';
title: RichTextItemResponse[];
} | {
type: 'rich_text';
rich_text: RichTextItemResponse[];
} | {
type: 'people';
people: Array<PartialUserObjectResponse | UserObjectResponse | GroupObjectResponse>;
} | {
type: 'relation';
relation: Array<{
id: string;
}>;
}>;
function: RollupFunction;
};
id: string;
}>;
icon: PageIconResponse | null;
cover: PageCoverResponse | null;
created_by: PartialUserObjectResponse;
last_edited_by: PartialUserObjectResponse;
is_locked: boolean;
object: 'page';
id: string;
created_time: string;
last_edited_time: string;
archived: boolean;
in_trash: boolean;
url: string;
public_url: string | null;
};
export type PartialPageObjectResponse = {
object: 'page';
id: string;
};
type NumberFormat = string;
type PropertyDescriptionRequest = string;
type NumberDatabasePropertyConfigResponse = {
type: 'number';
number: {
format: NumberFormat;
};
};
type FormulaDatabasePropertyConfigResponse = {
type: 'formula';
formula: {
expression: string;
};
};
type SelectPropertyResponse = {
id: string;
name: string;
color: SelectColor;
description: string | null;
};
type SelectDatabasePropertyConfigResponse = {
type: 'select';
select: {
options: SelectPropertyResponse[];
};
};
type MultiSelectDatabasePropertyConfigResponse = {
type: 'multi_select';
multi_select: {
options: SelectPropertyResponse[];
};
};
type StatusPropertyResponse = {
id: string;
name: string;
color: SelectColor;
description: string | null;
};
type StatusDatabasePropertyConfigResponse = {
type: 'status';
status: {
options: StatusPropertyResponse[];
groups: Array<{
id: string;
name: string;
color: SelectColor;
option_ids: string[];
}>;
};
};
type SinglePropertyDatabasePropertyRelationConfigResponse = {
type: 'single_property';
single_property: EmptyObject;
};
type DualPropertyDatabasePropertyRelationConfigResponse = {
type?: 'dual_property';
dual_property: {
synced_property_id: string;
synced_property_name: string;
};
};
type DatabasePropertyRelationConfigResponse = DatabasePropertyRelationConfigResponseCommon & (SinglePropertyDatabasePropertyRelationConfigResponse | DualPropertyDatabasePropertyRelationConfigResponse);
type RelationDatabasePropertyConfigResponse = {
type: 'relation';
relation: DatabasePropertyRelationConfigResponse;
};
type RollupDatabasePropertyConfigResponse = {
type: 'rollup';
rollup: {
function: RollupFunction;
rollup_property_name: string;
relation_property_name: string;
rollup_property_id: string;
relation_property_id: string;
};
};
type UniqueIdDatabasePropertyConfigResponse = {
type: 'unique_id';
unique_id: {
prefix: string | null;
};
};
type TitleDatabasePropertyConfigResponse = {
type: 'title';
title: EmptyObject;
};
type RichTextDatabasePropertyConfigResponse = {
type: 'rich_text';
rich_text: EmptyObject;
};
type UrlDatabasePropertyConfigResponse = {
type: 'url';
url: EmptyObject;
};
type PeopleDatabasePropertyConfigResponse = {
type: 'people';
people: EmptyObject;
};
type FilesDatabasePropertyConfigResponse = {
type: 'files';
files: EmptyObject;
};
type EmailDatabasePropertyConfigResponse = {
type: 'email';
email: EmptyObject;
};
type PhoneNumberDatabasePropertyConfigResponse = {
type: 'phone_number';
phone_number: EmptyObject;
};
type DateDatabasePropertyConfigResponse = {
type: 'date';
date: EmptyObject;
};
type CheckboxDatabasePropertyConfigResponse = {
type: 'checkbox';
checkbox: EmptyObject;
};
type CreatedByDatabasePropertyConfigResponse = {
type: 'created_by';
created_by: EmptyObject;
};
type CreatedTimeDatabasePropertyConfigResponse = {
type: 'created_time';
created_time: EmptyObject;
};
type LastEditedByDatabasePropertyConfigResponse = {
type: 'last_edited_by';
last_edited_by: EmptyObject;
};
type LastEditedTimeDatabasePropertyConfigResponse = {
type: 'last_edited_time';
last_edited_time: EmptyObject;
};
type DatabasePropertyConfigResponse = DatabasePropertyConfigResponseCommon & (NumberDatabasePropertyConfigResponse | FormulaDatabasePropertyConfigResponse | SelectDatabasePropertyConfigResponse | MultiSelectDatabasePropertyConfigResponse | StatusDatabasePropertyConfigResponse | RelationDatabasePropertyConfigResponse | RollupDatabasePropertyConfigResponse | UniqueIdDatabasePropertyConfigResponse | TitleDatabasePropertyConfigResponse | RichTextDatabasePropertyConfigResponse | UrlDatabasePropertyConfigResponse | PeopleDatabasePropertyConfigResponse | FilesDatabasePropertyConfigResponse | EmailDatabasePropertyConfigResponse | PhoneNumberDatabasePropertyConfigResponse | DateDatabasePropertyConfigResponse | CheckboxDatabasePropertyConfigResponse | CreatedByDatabasePropertyConfigResponse | CreatedTimeDatabasePropertyConfigResponse | LastEditedByDatabasePropertyConfigResponse | LastEditedTimeDatabasePropertyConfigResponse);
export type PartialDataSourceObjectResponse = {
object: 'data_source';
id: IdResponse;
properties: Record<string, DatabasePropertyConfigResponse>;
};
/**
* The parent of the data source. This is typically a database (`database_id`), but for
* externally synced data sources, can be another data source (`data_source_id`).
*/
type ParentOfDataSourceResponse = DatabaseParentResponse | DataSourceParentResponse;
export type DataSourceObjectResponse = {
object: 'data_source';
id: IdResponse;
title: RichTextItemResponse[];
description: RichTextItemResponse[];
parent: ParentOfDataSourceResponse;
database_parent: ParentOfDatabaseResponse;
is_inline: boolean;
archived: boolean;
in_trash: boolean;
created_time: string;
last_edited_time: string;
created_by: PartialUserObjectResponse;
last_edited_by: PartialUserObjectResponse;
properties: Record<string, DatabasePropertyConfigResponse>;
icon: PageIconResponse | null;
cover: PageCoverResponse | null;
url: string;
public_url: string | null;
};
export type PartialBlockObjectResponse = {
object: 'block';
id: string;
};
/**
* One of: `default`, `gray`, `brown`, `orange`, `yellow`, `green`, `blue`, `purple`,
* `pink`, `red`, `default_background`, `gray_background`, `brown_background`,
* `orange_background`, `yellow_background`, `green_background`, `blue_background`,
* `purple_background`, `pink_background`, `red_background`
*/
type ApiColor = 'default' | 'gray' | 'brown' | 'orange' | 'yellow' | 'green' | 'blue' | 'purple' | 'pink' | 'red' | 'default_background' | 'gray_background' | 'brown_background' | 'orange_background' | 'yellow_background' | 'green_background' | 'blue_background' | 'purple_background' | 'pink_background' | 'red_background';
type ContentWithRichTextAndColorResponse = {
rich_text: RichTextItemResponse[];
color: ApiColor;
};
export type ParagraphBlockObjectResponse = {
type: 'paragraph';
paragraph: ContentWithRichTextAndColorResponse;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
type HeaderContentWithRichTextAndColorResponse = {
rich_text: RichTextItemResponse[];
color: ApiColor;
is_toggleable: boolean;
};
export type Heading1BlockObjectResponse = {
type: 'heading_1';
heading_1: HeaderContentWithRichTextAndColorResponse;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
export type Heading2BlockObjectResponse = {
type: 'heading_2';
heading_2: HeaderContentWithRichTextAndColorResponse;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
export type Heading3BlockObjectResponse = {
type: 'heading_3';
heading_3: HeaderContentWithRichTextAndColorResponse;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
export type BulletedListItemBlockObjectResponse = {
type: 'bulleted_list_item';
bulleted_list_item: ContentWithRichTextAndColorResponse;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
export type NumberedListItemBlockObjectResponse = {
type: 'numbered_list_item';
numbered_list_item: ContentWithRichTextAndColorResponse;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
export type QuoteBlockObjectResponse = {
type: 'quote';
quote: ContentWithRichTextAndColorResponse;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
export type ToDoBlockObjectResponse = {
type: 'to_do';
to_do: {
rich_text: RichTextItemResponse[];
color: ApiColor;
checked: boolean;
};
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
export type ToggleBlockObjectResponse = {
type: 'toggle';
toggle: ContentWithRichTextAndColorResponse;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
export type TemplateBlockObjectResponse = {
type: 'template';
template: {
rich_text: RichTextItemResponse[];
};
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
export type SyncedBlockBlockObjectResponse = {
type: 'synced_block';
synced_block: {
synced_from: {
type: 'block_id';
block_id: IdRequest;
} | null;
};
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
type TitleObjectResponse = {
title: string;
};
export type ChildPageBlockObjectResponse = {
type: 'child_page';
child_page: TitleObjectResponse;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
export type ChildDatabaseBlockObjectResponse = {
type: 'child_database';
child_database: TitleObjectResponse;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
type ExpressionObjectResponse = {
expression: string;
};
export type EquationBlockObjectResponse = {
type: 'equation';
equation: ExpressionObjectResponse;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
type LanguageRequest = 'abap' | 'abc' | 'agda' | 'arduino' | 'ascii art' | 'assembly' | 'bash' | 'basic' | 'bnf' | 'c' | 'c#' | 'c++' | 'clojure' | 'coffeescript' | 'coq' | 'css' | 'dart' | 'dhall' | 'diff' | 'docker' | 'ebnf' | 'elixir' | 'elm' | 'erlang' | 'f#' | 'flow' | 'fortran' | 'gherkin' | 'glsl' | 'go' | 'graphql' | 'groovy' | 'haskell' | 'hcl' | 'html' | 'idris' | 'java' | 'javascript' | 'json' | 'julia' | 'kotlin' | 'latex' | 'less' | 'lisp' | 'livescript' | 'llvm ir' | 'lua' | 'makefile' | 'markdown' | 'markup' | 'matlab' | 'mathematica' | 'mermaid' | 'nix' | 'notion formula' | 'objective-c' | 'ocaml' | 'pascal' | 'perl' | 'php' | 'plain text' | 'powershell' | 'prolog' | 'protobuf' | 'purescript' | 'python' | 'r' | 'racket' | 'reason' | 'ruby' | 'rust' | 'sass' | 'scala' | 'scheme' | 'scss' | 'shell' | 'smalltalk' | 'solidity' | 'sql' | 'swift' | 'toml' | 'typescript' | 'vb.net' | 'verilog' | 'vhdl' | 'visual basic' | 'webassembly' | 'xml' | 'yaml' | 'java/c/c++/c#';
export type CodeBlockObjectResponse = {
type: 'code';
code: {
rich_text: RichTextItemResponse[];
caption: RichTextItemResponse[];
language: LanguageRequest;
};
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
export type CalloutBlockObjectResponse = {
type: 'callout';
callout: {
rich_text: RichTextItemResponse[];
color: ApiColor;
icon: PageIconResponse | null;
};
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
export type DividerBlockObjectResponse = {
type: 'divider';
divider: EmptyObject;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
export type BreadcrumbBlockObjectResponse = {
type: 'breadcrumb';
breadcrumb: EmptyObject;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
export type TableOfContentsBlockObjectResponse = {
type: 'table_of_contents';
table_of_contents: {
color: ApiColor;
};
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
export type ColumnListBlockObjectResponse = {
type: 'column_list';
column_list: EmptyObject;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
type ColumnResponse = {
width_ratio?: number;
};
export type ColumnBlockObjectResponse = {
type: 'column';
column: ColumnResponse;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
export type LinkToPageBlockObjectResponse = {
type: 'link_to_page';
link_to_page: {
type: 'page_id';
page_id: IdRequest;
} | {
type: 'database_id';
database_id: IdRequest;
} | {
type: 'comment_id';
comment_id: IdRequest;
};
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
type ContentWithTableResponse = {
has_column_header: boolean;
has_row_header: boolean;
table_width: number;
};
export type TableBlockObjectResponse = {
type: 'table';
table: ContentWithTableResponse;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
type ContentWithTableRowResponse = {
cells: RichTextItemResponse[][];
};
export type TableRowBlockObjectResponse = {
type: 'table_row';
table_row: ContentWithTableRowResponse;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
type MediaContentWithUrlAndCaptionResponse = {
url: string;
caption: RichTextItemResponse[];
};
export type EmbedBlockObjectResponse = {
type: 'embed';
embed: MediaContentWithUrlAndCaptionResponse;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
export type BookmarkBlockObjectResponse = {
type: 'bookmark';
bookmark: MediaContentWithUrlAndCaptionResponse;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
type ExternalMediaContentWithFileAndCaptionResponse = {
type: 'external';
external: {
url: TextRequest;
};
caption: RichTextItemResponse[];
};
type FileMediaContentWithFileAndCaptionResponse = {
type: 'file';
file: InternalFileResponse;
caption: RichTextItemResponse[];
};
type MediaContentWithFileAndCaptionResponse = ExternalMediaContentWithFileAndCaptionResponse | FileMediaContentWithFileAndCaptionResponse;
export type ImageBlockObjectResponse = {
type: 'image';
image: MediaContentWithFileAndCaptionResponse;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
export type VideoBlockObjectResponse = {
type: 'video';
video: MediaContentWithFileAndCaptionResponse;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
export type PdfBlockObjectResponse = {
type: 'pdf';
pdf: MediaContentWithFileAndCaptionResponse;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
type ExternalMediaContentWithFileNameAndCaptionResponse = {
type: 'external';
external: {
url: TextRequest;
};
caption: RichTextItemResponse[];
name: string;
};
type FileMediaContentWithFileNameAndCaptionResponse = {
type: 'file';
file: InternalFileResponse;
caption: RichTextItemResponse[];
name: string;
};
type MediaContentWithFileNameAndCaptionResponse = ExternalMediaContentWithFileNameAndCaptionResponse | FileMediaContentWithFileNameAndCaptionResponse;
export type FileBlockObjectResponse = {
type: 'file';
file: MediaContentWithFileNameAndCaptionResponse;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
export type AudioBlockObjectResponse = {
type: 'audio';
audio: MediaContentWithFileAndCaptionResponse;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
type MediaContentWithUrlResponse = {
url: TextRequest;
};
export type LinkPreviewBlockObjectResponse = {
type: 'link_preview';
link_preview: MediaContentWithUrlResponse;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
export type UnsupportedBlockObjectResponse = {
type: 'unsupported';
unsupported: EmptyObject;
parent: ParentForBlockBasedObjectResponse;
object: 'block';
id: string;
created_time: string;
created_by: PartialUserObjectResponse;
last_edited_time: string;
last_edited_by: PartialUserObjectResponse;
has_children: boolean;
archived: boolean;
in_trash: boolean;
};
export type BlockObjectResponse = ParagraphBlockObjectResponse | Heading1BlockObjectResponse | Heading2BlockObjectResponse | Heading3BlockObjectResponse | BulletedListItemBlockObjectResponse | NumberedListItemBlockObjectResponse | QuoteBlockObjectResponse | ToDoBlockObjectResponse | ToggleBlockObjectResponse | TemplateBlockObjectResponse | SyncedBlockBlockObjectResponse | ChildPageBlockObjectResponse | ChildDatabaseBlockObjectResponse | EquationBlockObjectResponse | CodeBlockObjectResponse | CalloutBlockObjectResponse | DividerBlockObjectResponse | BreadcrumbBlockObjectResponse | TableOfContentsBlockObjectResponse | ColumnListBlockObjectResponse | ColumnBlockObjectResponse | LinkToPageBlockObjectResponse | TableBlockObjectResponse | TableRowBlockObjectResponse | EmbedBlockObjectResponse | BookmarkBlockObjectResponse | ImageBlockObjectResponse | VideoBlockObjectResponse | PdfBlockObjectResponse | FileBlockObjectResponse | AudioBlockObjectResponse | LinkPreviewBlockObjectResponse | UnsupportedBlockObjectResponse;
export type NumberPropertyItemObjectResponse = {
type: 'number';
number: number | null;
object: 'property_item';
id: string;
};
export type UrlPropertyItemObjectResponse = {
type: 'url';
url: string | null;
object: 'property_item';
id: string;
};
export type SelectPropertyItemObjectResponse = {
type: 'select';
select: PartialSelectResponse | null;
object: 'property_item';
id: string;
};
export type MultiSelectPropertyItemObjectResponse = {
type: 'multi_select';
multi_select: PartialSelectResponse[];
object: 'property_item';
id: string;
};
export type StatusPropertyItemObjectResponse = {
type: 'status';
status: PartialSelectResponse | null;
object: 'property_item';
id: string;
};
export type DatePropertyItemObjectResponse = {
type: 'date';
date: DateResponse | null;
object: 'property_item';
id: string;
};
export type EmailPropertyItemObjectResponse = {
type: 'email';
email: string | null;
object: 'property_item';
id: string;
};
export type PhoneNumberPropertyItemObjectResponse = {
type: 'phone_number';
phone_number: string | null;
object: 'property_item';
id: string;
};
export type CheckboxPropertyItemObjectResponse = {
type: 'checkbox';
checkbox: boolean;
object: 'property_item';
id: string;
};
export type FilesPropertyItemObjectResponse = {
type: 'files';
files: InternalOrExternalFileWithNameResponse[];
object: 'property_item';
id: string;
};
export type CreatedByPropertyItemObjectResponse = {
type: 'created_by';
created_by: PartialUserObjectResponse | UserObjectResponse;
object: 'property_item';
id: string;
};
export type CreatedTimePropertyItemObjectResponse = {
type: 'created_time';
created_time: string;
object: 'property_item';
id: string;
};
export type LastEditedByPropertyItemObjectResponse = {
type: 'last_edited_by';
last_edited_by: PartialUserObjectResponse | UserObjectResponse;
object: 'property_item';
id: string;
};
export type LastEditedTimePropertyItemObjectResponse = {
type: 'last_edited_time';
last_edited_time: string;
object: 'property_item';
id: string;
};
export type FormulaPropertyItemObjectResponse = {
type: 'formula';
formula: FormulaPropertyResponse;
object: 'property_item';
id: string;
};
export type ButtonPropertyItemObjectResponse = {
type: 'button';
button: EmptyObject;
object: 'property_item';
id: string;
};
export type UniqueIdPropertyItemObjectResponse = {
type: 'unique_id';
unique_id: {
prefix: string | null;
number: number | null;
};
object: 'property_item';
id: string;
};
export type VerificationPropertyItemObjectResponse = {
type: 'verification';
verification: VerificationPropertyValueResponse | null;
object: 'property_item';
id: string;
};
export type TitlePropertyItemObjectResponse = {
type: 'title';
title: RichTextItemResponse;
object: 'property_item';
id: string;
};
export type RichTextPropertyItemObjectResponse = {
type: 'rich_text';
rich_text: RichTextItemResponse;
object: 'property_item';
id: string;
};
export type PeoplePropertyItemObjectResponse = {
type: 'people';
people: PartialUserObjectResponse | UserObjectResponse;
object: 'property_item';
id: string;
};
export type RelationPropertyItemObjectResponse = {
type: 'relation';
relation: {
id: string;
};
object: 'property_item';
id: string;
};
export type RollupPropertyItemObjectResponse = {
type: 'rollup';
rollup: {
type: 'number';
number: number | null;
function: RollupFunction;
} | {
type: 'date';
date: DateResponse | null;
function: RollupFunction;
} | {
type: 'array';
array: EmptyObject[];
function: RollupFunction;
} | {
type: 'unsupported';
unsupported: EmptyObject;
function: RollupFunction;
} | {
type: 'incomplete';
incomplete: EmptyObject;
function: RollupFunction;
};
object: 'property_item';
id: string;
};
export type PropertyItemObjectResponse = NumberPropertyItemObjectResponse | UrlPropertyItemObjectResponse | SelectPropertyItemObjectResponse | MultiSelectPropertyItemObjectResponse | StatusPropertyItemObjectResponse | DatePropertyItemObjectResponse | EmailPropertyItemObjectResponse | PhoneNumberPropertyItemObjectResponse | CheckboxPropertyItemObjectResponse | FilesPropertyItemObjectResponse | CreatedByPropertyItemObjectResponse | CreatedTimePropertyItemObjectResponse | LastEditedByPropertyItemObjectResponse | LastEditedTimePropertyItemObjectResponse | FormulaPropertyItemObjectResponse | ButtonPropertyItemObjectResponse | UniqueIdPropertyItemObjectResponse | VerificationPropertyItemObjectResponse | TitlePropertyItemObjectResponse | RichTextPropertyItemObjectResponse | PeoplePropertyItemObjectResponse | RelationPropertyItemObjectResponse | RollupPropertyItemObjectResponse;
type PropertyItemPropertyItemListResponse = {
type: 'property_item';
property_item: {
type: 'title';
title: EmptyObject;
next_url: string | null;
id: string;
} | {
type: 'rich_text';
rich_text: EmptyObject;
next_url: string | null;
id: string;
} | {
type: 'people';
people: EmptyObject;
next_url: string | null;
id: string;
} | {
type: 'relation';
relation: EmptyObject;
next_url: string | null;
id: string;
} | {
type: 'rollup';
rollup: {
type: 'number';
number: number | null;
function: RollupFunction;
} | {
type: 'date';
date: DateResponse | null;
function: RollupFunction;
} | {
type: 'array';
array: EmptyObject[];
function: RollupFunction;
} | {
type: 'unsupported';
unsupported: EmptyObject;
function: RollupFunction;
} | {
type: 'incomplete';
incomplete: EmptyObject;
function: RollupFunction;
};
next_url: string | null;
id: string;
};
object: 'list';
next_cursor: string | null;
has_more: boolean;
results: PropertyItemObjectResponse[];
};
export type PropertyItemListResponse = PropertyItemPropertyItemListResponse;
type DatabasePropertyRelationConfigResponseCommon = {
database_id: IdResponse;
data_source_id: IdResponse;
};
type DatabasePropertyConfigResponseCommon = {
id: string;
name: string;
description: PropertyDescriptionRequest | null;
};
export type UserObjectResponseCommon = {
id: IdResponse;
object: 'user';
name: string | null;
avatar_url: string | null;
};
export type RichTextItemResponseCommon = {
plain_text: string;
href: string | null;
annotations: AnnotationResponse;
};
type ParentOfDatabaseResponse = PageIdParentForBlockBasedObjectResponse | WorkspaceParentForBlockBasedObjectResponse | DatabaseParentResponse | BlockIdParentForBlockBasedObjectResponse;
export type PartialCommentObjectResponse = {
object: 'comment';
id: IdResponse;
};
type PageIdCommentParentResponse = {
type: 'page_id';
page_id: IdResponse;
};
type BlockIdCommentParentResponse = {
type: 'block_id';
block_id: IdResponse;
};
type CommentParentResponse = PageIdCommentParentResponse | BlockIdCommentParentResponse;
export type CommentObjectResponse = {
object: 'comment';
id: IdResponse;
parent: CommentParentResponse;
discussion_id: IdResponse;
created_time: string;
last_edited_time: string;
created_by: PartialUserObjectResponse;
rich_text: RichTextItemResponse[];
display_name: {
type: 'custom' | 'user' | 'integration';
resolved_name: string | null;
};
attachments?: Array<{
category: 'audio' | 'image' | 'pdf' | 'productivity' | 'video';
file: InternalFileResponse;
}>;
};
export type FileUploadObjectResponse = {
object: 'file_upload';
id: IdResponse;
created_time: string;
created_by: {
id: IdResponse;
type: 'person' | 'bot' | 'agent';
};
last_edited_time: string;
archived: boolean;
expiry_time: string | null;
status: 'pending' | 'uploaded' | 'expired' | 'failed';
filename: string | null;
content_type: string | null;
content_length: number | null;
upload_url?: string;
complete_url?: string;
file_import_result?: {
imported_time: string;
} & ({
type: 'success';
success: EmptyObject;
} | {
type: 'error';
error: {
type: 'validation_error' | 'internal_system_error' | 'download_error' | 'upload_error';
code: string;
message: string;
parameter: string | null;
status_code: number | null;
};
});
number_of_parts?: {
total: number;
sent: number;
};
};
export type PartialDatabaseObjectResponse = {
object: 'database';
id: IdResponse;
};
type DataSourceReferenceResponse = {
id: IdResponse;
name: string;
};
export type DatabaseObjectResponse = {
object: 'database';
id: IdResponse;
title: RichTextItemResponse[];
description: RichTextItemResponse[];
parent: ParentOfDatabaseResponse;
is_inline: boolean;
in_trash: boolean;
is_locked: boolean;
created_time: string;
last_edited_time: string;
data_sources: DataSourceReferenceResponse[];
icon: PageIconResponse | null;
cover: PageCoverResponse | null;
url: string;
public_url: string | null;
};
type AnnotationRequest = {
bold?: boolean;
italic?: boolean;
strikethrough?: boolean;
underline?: boolean;
code?: boolean;
color?: ApiColor;
};
type PartialUserObjectRequest = {
id: IdRequest;
object?: 'user';
};
type DateRequest = {
start: string;
end?: string | null;
time_zone?: TimeZoneRequest | null;
};
type TemplateMentionRequest = TemplateMentionDateTemplateMentionRequest | TemplateMentionUserTemplateMentionRequest;
type RichTextItemRequest = RichTextItemRequestCommon & (TextRichTextItemRequest | MentionRichTextItemRequest | EquationRichTextItemRequest);
type GroupObjectRequest = {
id: IdRequest;
name?: string | null;
object?: 'group';
};
type RelationItemPropertyValueResponse = {
id: IdRequest;
};
type InternalFileRequest = {
url: string;
expiry_time?: string;
};
type ExternalFileRequest = {
url: TextRequest;
};
type InternalOrExternalFileWithNameRequest = {
file: InternalFileRequest;
name: StringRequest;
type?: 'file';
} | {
external: ExternalFileRequest;
name: StringRequest;
type?: 'external';
};
type FileUploadIdRequest = {
id: IdRequest;
};
type FileUploadWithOptionalNameRequest = {
file_upload: FileUploadIdRequest;
type?: 'file_upload';
name?: StringRequest;
};
type PageIconRequest = FileUploadPageIconRequest | EmojiPageIconRequest | ExternalPageIconRequest | CustomEmojiPageIconRequest;
type PageCoverRequest = FileUploadPageCoverRequest | ExternalPageCoverRequest;
type MediaContentWithUrlAndCaptionRequest = {
url: string;
caption?: RichTextItemRequest[];
};
type MediaContentWithFileAndCaptionRequest = {
external: ExternalFileRequest;
type?: 'external';
caption?: RichTextItemRequest[];
} | {
file_upload: FileUploadIdRequest;
type?: 'file_upload';
caption?: RichTextItemRequest[];
};
type MediaContentWithFileNameAndCaptionRequest = {
external: ExternalFileRequest;
type?: 'external';
caption?: RichTextItemRequest[];
name?: StringRequest;
} | {
file_upload: FileUploadIdRequest;
type?: 'file_upload';
caption?: RichTextItemRequest[];
name?: StringRequest;
};
type ContentWithExpressionRequest = {
expression: string;
};
type ContentWithTableRowRequest = {
cells: RichTextItemRequest[][];
};
type TableRowRequest = {
table_row: ContentWithTableRowRequest;
type?: 'table_row';
object?: 'block';
};
type TableRequestWithTableRowChildren = {
table_width: number;
children: TableRowRequest[];
has_column_header?: boolean;
has_row_header?: boolean;
};
type HeaderContentWithRichTextAndColorRequest = {
rich_text: RichTextItemRequest[];
color?: ApiColor;
is_toggleable?: boolean;
};
type ContentWithRichTextAndColorRequest = {
rich_text: RichTextItemRequest[];
color?: ApiColor;
};
type ContentWithRichTextRequest = {
rich_text: RichTextItemRequest[];
};
export type BlockObjectRequestWithoutChildren = {
embed: MediaContentWithUrlAndCaptionReques