@notionhq/client
Version:
A simple and easy to use client for the Notion API
644 lines • 19.7 kB
TypeScript
import type { BlockObjectRequest, DateRequest, DateResponse, EmptyObject, FileUploadWithOptionalNameRequest, GroupObjectRequest, IdRequest, InternalOrExternalFileWithNameRequest, InternalOrExternalFileWithNameResponse, PageCoverRequest, PageIconRequest, PageMarkdownResponse, PageObjectResponse, PagePositionSchema, PartialPageObjectResponse, PartialUserObjectRequest, PartialUserObjectResponse, RelationItemPropertyValueResponse, RichTextItemRequest, RichTextItemResponse, RollupFunction, SelectColor, StringRequest, TemplateTimezone, TextRequest, UserObjectResponse, VerificationPropertyValueResponse } from "./common";
type BooleanFormulaPropertyResponse = {
type: "boolean";
boolean: boolean | null;
};
export type ButtonPropertyItemObjectResponse = {
type: "button";
button: EmptyObject;
object: "property_item";
id: string;
};
export type CheckboxPropertyItemObjectResponse = {
type: "checkbox";
checkbox: boolean;
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;
};
type DateFormulaPropertyResponse = {
type: "date";
date: DateResponse | null;
};
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 FilesPropertyItemObjectResponse = {
type: "files";
files: Array<InternalOrExternalFileWithNameResponse>;
object: "property_item";
id: string;
};
export type FormulaPropertyItemObjectResponse = {
type: "formula";
formula: FormulaPropertyResponse;
object: "property_item";
id: string;
};
type FormulaPropertyResponse = StringFormulaPropertyResponse | DateFormulaPropertyResponse | NumberFormulaPropertyResponse | BooleanFormulaPropertyResponse;
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 MultiSelectPropertyItemObjectResponse = {
type: "multi_select";
multi_select: Array<PartialSelectResponse>;
object: "property_item";
id: string;
};
type NumberFormulaPropertyResponse = {
type: "number";
number: number | null;
};
export type NumberPropertyItemObjectResponse = {
type: "number";
number: number | null;
object: "property_item";
id: string;
};
type PartialSelectResponse = {
id: string;
name: string;
color: SelectColor;
};
export type PeoplePropertyItemObjectResponse = {
type: "people";
people: PartialUserObjectResponse | UserObjectResponse;
object: "property_item";
id: string;
};
export type PhoneNumberPropertyItemObjectResponse = {
type: "phone_number";
phone_number: string | null;
object: "property_item";
id: string;
};
export type PlacePropertyItemObjectResponse = {
type: "place";
place: {
lat: number;
lon: number;
name?: string | null;
address?: string | null;
aws_place_id?: string | null;
google_place_id?: string | null;
} | null;
object: "property_item";
id: string;
};
export type PropertyItemListResponse = PropertyItemPropertyItemListResponse;
export type PropertyItemObjectResponse = NumberPropertyItemObjectResponse | UrlPropertyItemObjectResponse | SelectPropertyItemObjectResponse | MultiSelectPropertyItemObjectResponse | StatusPropertyItemObjectResponse | DatePropertyItemObjectResponse | EmailPropertyItemObjectResponse | PhoneNumberPropertyItemObjectResponse | CheckboxPropertyItemObjectResponse | FilesPropertyItemObjectResponse | CreatedByPropertyItemObjectResponse | CreatedTimePropertyItemObjectResponse | LastEditedByPropertyItemObjectResponse | LastEditedTimePropertyItemObjectResponse | FormulaPropertyItemObjectResponse | ButtonPropertyItemObjectResponse | UniqueIdPropertyItemObjectResponse | VerificationPropertyItemObjectResponse | PlacePropertyItemObjectResponse | 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: 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: Array<PropertyItemObjectResponse>;
};
export type RelationPropertyItemObjectResponse = {
type: "relation";
relation: {
id: string;
};
object: "property_item";
id: string;
};
export type RichTextPropertyItemObjectResponse = {
type: "rich_text";
rich_text: RichTextItemResponse;
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: Array<EmptyObject>;
function: RollupFunction;
} | {
type: "unsupported";
unsupported: EmptyObject;
function: RollupFunction;
} | {
type: "incomplete";
incomplete: EmptyObject;
function: RollupFunction;
};
object: "property_item";
id: string;
};
export type SelectPropertyItemObjectResponse = {
type: "select";
select: PartialSelectResponse | null;
object: "property_item";
id: string;
};
export type StatusPropertyItemObjectResponse = {
type: "status";
status: PartialSelectResponse | null;
object: "property_item";
id: string;
};
type StringFormulaPropertyResponse = {
type: "string";
string: string | null;
};
export type TitlePropertyItemObjectResponse = {
type: "title";
title: RichTextItemResponse;
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 UrlPropertyItemObjectResponse = {
type: "url";
url: string | null;
object: "property_item";
id: string;
};
export type VerificationPropertyItemObjectResponse = {
type: "verification";
verification: VerificationPropertyValueResponse | null;
object: "property_item";
id: string;
};
type CreatePageBodyParameters = {
parent?: {
page_id: IdRequest;
type?: "page_id";
} | {
database_id: IdRequest;
type?: "database_id";
} | {
data_source_id: IdRequest;
type?: "data_source_id";
} | {
workspace: true;
type?: "workspace";
};
properties?: Record<string, {
title: Array<RichTextItemRequest>;
type?: "title";
} | {
rich_text: Array<RichTextItemRequest>;
type?: "rich_text";
} | {
number: number | null;
type?: "number";
} | {
url: TextRequest | null;
type?: "url";
} | {
select: {
id: StringRequest;
name?: TextRequest;
color?: SelectColor;
description?: TextRequest | null;
} | {
name: TextRequest;
id?: StringRequest;
color?: SelectColor;
description?: TextRequest | null;
} | null;
type?: "select";
} | {
multi_select: Array<{
id: StringRequest;
name?: TextRequest;
color?: SelectColor;
description?: TextRequest | null;
} | {
name: TextRequest;
id?: StringRequest;
color?: SelectColor;
description?: TextRequest | null;
}>;
type?: "multi_select";
} | {
people: Array<PartialUserObjectRequest | GroupObjectRequest>;
type?: "people";
} | {
email: StringRequest | null;
type?: "email";
} | {
phone_number: StringRequest | null;
type?: "phone_number";
} | {
date: DateRequest | null;
type?: "date";
} | {
checkbox: boolean;
type?: "checkbox";
} | {
relation: Array<RelationItemPropertyValueResponse>;
type?: "relation";
} | {
files: Array<InternalOrExternalFileWithNameRequest | FileUploadWithOptionalNameRequest>;
type?: "files";
} | {
status: {
id: StringRequest;
name?: TextRequest;
color?: SelectColor;
description?: TextRequest | null;
} | {
name: TextRequest;
id?: StringRequest;
color?: SelectColor;
description?: TextRequest | null;
} | null;
type?: "status";
} | {
place: {
lat: number;
lon: number;
name?: string | null;
address?: string | null;
aws_place_id?: string | null;
google_place_id?: string | null;
} | null;
type?: "place";
} | {
verification: {
state: "verified";
date?: DateRequest;
} | {
state: "unverified";
};
type?: "verification";
}>;
icon?: PageIconRequest | null;
cover?: PageCoverRequest | null;
content?: Array<BlockObjectRequest>;
children?: Array<BlockObjectRequest>;
markdown?: string;
template?: {
type: "none";
} | {
type: "default";
timezone?: TemplateTimezone;
} | {
type: "template_id";
template_id: IdRequest;
timezone?: TemplateTimezone;
};
position?: PagePositionSchema;
};
export type CreatePageParameters = CreatePageBodyParameters;
export type CreatePageResponse = PageObjectResponse | PartialPageObjectResponse;
/**
* Create a page
*/
export declare const createPage: {
readonly method: "post";
readonly pathParams: readonly [];
readonly queryParams: readonly [];
readonly bodyParams: readonly ["parent", "properties", "icon", "cover", "content", "children", "markdown", "template", "position"];
readonly path: () => string;
};
type GetPagePathParameters = {
page_id: IdRequest;
};
type GetPageQueryParameters = {
filter_properties?: Array<string>;
};
export type GetPageParameters = GetPagePathParameters & GetPageQueryParameters;
export type GetPageResponse = PartialPageObjectResponse | PageObjectResponse;
/**
* Retrieve a page
*/
export declare const getPage: {
readonly method: "get";
readonly pathParams: readonly ["page_id"];
readonly queryParams: readonly ["filter_properties"];
readonly bodyParams: readonly [];
readonly path: (p: GetPagePathParameters) => string;
};
type UpdatePagePathParameters = {
page_id: IdRequest;
};
type UpdatePageBodyParameters = {
properties?: Record<string, {
title: Array<RichTextItemRequest>;
type?: "title";
} | {
rich_text: Array<RichTextItemRequest>;
type?: "rich_text";
} | {
number: number | null;
type?: "number";
} | {
url: TextRequest | null;
type?: "url";
} | {
select: {
id: StringRequest;
name?: TextRequest;
color?: SelectColor;
description?: TextRequest | null;
} | {
name: TextRequest;
id?: StringRequest;
color?: SelectColor;
description?: TextRequest | null;
} | null;
type?: "select";
} | {
multi_select: Array<{
id: StringRequest;
name?: TextRequest;
color?: SelectColor;
description?: TextRequest | null;
} | {
name: TextRequest;
id?: StringRequest;
color?: SelectColor;
description?: TextRequest | null;
}>;
type?: "multi_select";
} | {
people: Array<PartialUserObjectRequest | GroupObjectRequest>;
type?: "people";
} | {
email: StringRequest | null;
type?: "email";
} | {
phone_number: StringRequest | null;
type?: "phone_number";
} | {
date: DateRequest | null;
type?: "date";
} | {
checkbox: boolean;
type?: "checkbox";
} | {
relation: Array<RelationItemPropertyValueResponse>;
type?: "relation";
} | {
files: Array<InternalOrExternalFileWithNameRequest | FileUploadWithOptionalNameRequest>;
type?: "files";
} | {
status: {
id: StringRequest;
name?: TextRequest;
color?: SelectColor;
description?: TextRequest | null;
} | {
name: TextRequest;
id?: StringRequest;
color?: SelectColor;
description?: TextRequest | null;
} | null;
type?: "status";
} | {
place: {
lat: number;
lon: number;
name?: string | null;
address?: string | null;
aws_place_id?: string | null;
google_place_id?: string | null;
} | null;
type?: "place";
} | {
verification: {
state: "verified";
date?: DateRequest;
} | {
state: "unverified";
};
type?: "verification";
}>;
icon?: PageIconRequest | null;
cover?: PageCoverRequest | null;
is_locked?: boolean;
template?: {
type: "default";
timezone?: TemplateTimezone;
} | {
type: "template_id";
template_id: IdRequest;
timezone?: TemplateTimezone;
};
erase_content?: boolean;
in_trash?: boolean;
/** @deprecated Use `in_trash` instead. */
archived?: boolean;
is_archived?: boolean;
};
export type UpdatePageParameters = UpdatePagePathParameters & UpdatePageBodyParameters;
export type UpdatePageResponse = PageObjectResponse | PartialPageObjectResponse;
/**
* Update page
*/
export declare const updatePage: {
readonly method: "patch";
readonly pathParams: readonly ["page_id"];
readonly queryParams: readonly [];
readonly bodyParams: readonly ["archived", "properties", "icon", "cover", "is_locked", "template", "erase_content", "in_trash", "is_archived"];
readonly path: (p: UpdatePagePathParameters) => string;
};
type MovePagePathParameters = {
page_id: IdRequest;
};
type MovePageBodyParameters = {
parent: {
page_id: IdRequest;
type?: "page_id";
} | {
data_source_id: IdRequest;
type?: "data_source_id";
};
};
export type MovePageParameters = MovePagePathParameters & MovePageBodyParameters;
export type MovePageResponse = PartialPageObjectResponse | PageObjectResponse;
/**
* Move a page
*/
export declare const movePage: {
readonly method: "post";
readonly pathParams: readonly ["page_id"];
readonly queryParams: readonly [];
readonly bodyParams: readonly ["parent"];
readonly path: (p: MovePagePathParameters) => string;
};
type GetPagePropertyPathParameters = {
page_id: IdRequest;
property_id: string;
};
type GetPagePropertyQueryParameters = {
start_cursor?: string;
page_size?: number;
};
export type GetPagePropertyParameters = GetPagePropertyPathParameters & GetPagePropertyQueryParameters;
export type GetPagePropertyResponse = PropertyItemObjectResponse | PropertyItemListResponse;
/**
* Retrieve a page property item
*/
export declare const getPageProperty: {
readonly method: "get";
readonly pathParams: readonly ["page_id", "property_id"];
readonly queryParams: readonly ["start_cursor", "page_size"];
readonly bodyParams: readonly [];
readonly path: (p: GetPagePropertyPathParameters) => string;
};
type GetPageMarkdownPathParameters = {
page_id: IdRequest;
};
type GetPageMarkdownQueryParameters = {
include_transcript?: boolean;
};
export type GetPageMarkdownParameters = GetPageMarkdownPathParameters & GetPageMarkdownQueryParameters;
export type GetPageMarkdownResponse = PageMarkdownResponse;
/**
* Retrieve a page as markdown
*/
export declare const getPageMarkdown: {
readonly method: "get";
readonly pathParams: readonly ["page_id"];
readonly queryParams: readonly ["include_transcript"];
readonly bodyParams: readonly [];
readonly path: (p: GetPageMarkdownPathParameters) => string;
};
type UpdatePageMarkdownPathParameters = {
page_id: IdRequest;
};
type UpdatePageMarkdownBodyParameters = {
type: "insert_content";
insert_content: {
content: string;
after?: string;
position?: {
type: "start";
} | {
type: "end";
};
};
} | {
type: "replace_content_range";
replace_content_range: {
content: string;
content_range: string;
allow_deleting_content?: boolean;
};
} | {
type: "update_content";
update_content: {
content_updates: Array<{
old_str: string;
new_str: string;
replace_all_matches?: boolean;
}>;
allow_deleting_content?: boolean;
};
} | {
type: "replace_content";
replace_content: {
new_str: string;
allow_deleting_content?: boolean;
};
};
export type UpdatePageMarkdownParameters = UpdatePageMarkdownPathParameters & UpdatePageMarkdownBodyParameters;
export type UpdatePageMarkdownResponse = PageMarkdownResponse;
/**
* Update a page's content as markdown
*/
export declare const updatePageMarkdown: {
readonly method: "patch";
readonly pathParams: readonly ["page_id"];
readonly queryParams: readonly [];
readonly bodyParams: readonly ["type", "insert_content", "replace_content_range", "update_content", "replace_content"];
readonly path: (p: UpdatePageMarkdownPathParameters) => string;
};
export {};
//# sourceMappingURL=pages.d.ts.map