@notionhq/client
Version:
A simple and easy to use client for the Notion API
434 lines • 14.3 kB
TypeScript
import type { DataSourceParentResponse, DatabaseParentResponse, EmptyObject, GroupFilterOperatorArray, IdRequest, IdResponse, NumberFormat, PageCoverResponse, PageIconRequest, PageIconResponse, PageObjectResponse, ParentOfDataSourceRequest, ParentOfDatabaseResponse, PartialPageObjectResponse, PartialUserObjectResponse, PropertyConfigurationRequest, PropertyDescriptionRequest, PropertyFilter, RichTextItemRequest, RichTextItemResponse, RollupFunction, SelectColor, StatusPropertyConfigUpdateRequest, TimestampFilter } from "./common";
type CheckboxDatabasePropertyConfigResponse = {
type: "checkbox";
checkbox: EmptyObject;
};
type CreatedByDatabasePropertyConfigResponse = {
type: "created_by";
created_by: EmptyObject;
};
type CreatedTimeDatabasePropertyConfigResponse = {
type: "created_time";
created_time: EmptyObject;
};
export type DataSourceObjectResponse = {
object: "data_source";
id: IdResponse;
title: Array<RichTextItemResponse>;
description: Array<RichTextItemResponse>;
parent: ParentOfDataSourceResponse;
database_parent: ParentOfDatabaseResponse;
is_inline: boolean;
in_trash: boolean;
/** @deprecated Use `in_trash` instead. Present for backwards compatibility with API versions prior to 2026-03-11. */
archived: 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;
};
type DatabasePropertyConfigResponse = DatabasePropertyConfigResponseCommon & (NumberDatabasePropertyConfigResponse | FormulaDatabasePropertyConfigResponse | SelectDatabasePropertyConfigResponse | MultiSelectDatabasePropertyConfigResponse | StatusDatabasePropertyConfigResponse | RelationDatabasePropertyConfigResponse | RollupDatabasePropertyConfigResponse | UniqueIdDatabasePropertyConfigResponse | TitleDatabasePropertyConfigResponse | RichTextDatabasePropertyConfigResponse | UrlDatabasePropertyConfigResponse | PeopleDatabasePropertyConfigResponse | FilesDatabasePropertyConfigResponse | EmailDatabasePropertyConfigResponse | PhoneNumberDatabasePropertyConfigResponse | DateDatabasePropertyConfigResponse | CheckboxDatabasePropertyConfigResponse | CreatedByDatabasePropertyConfigResponse | CreatedTimeDatabasePropertyConfigResponse | LastEditedByDatabasePropertyConfigResponse | LastEditedTimeDatabasePropertyConfigResponse);
type DatabasePropertyConfigResponseCommon = {
id: string;
name: string;
description: PropertyDescriptionRequest | null;
};
type DatabasePropertyRelationConfigResponse = DatabasePropertyRelationConfigResponseCommon & (SinglePropertyDatabasePropertyRelationConfigResponse | DualPropertyDatabasePropertyRelationConfigResponse);
type DatabasePropertyRelationConfigResponseCommon = {
database_id: IdResponse;
data_source_id: IdResponse;
};
type DateDatabasePropertyConfigResponse = {
type: "date";
date: EmptyObject;
};
type DualPropertyDatabasePropertyRelationConfigResponse = {
type?: "dual_property";
dual_property: {
synced_property_id: string;
synced_property_name: string;
};
};
type EmailDatabasePropertyConfigResponse = {
type: "email";
email: EmptyObject;
};
type FilesDatabasePropertyConfigResponse = {
type: "files";
files: EmptyObject;
};
type FormulaDatabasePropertyConfigResponse = {
type: "formula";
formula: {
expression: string;
};
};
type LastEditedByDatabasePropertyConfigResponse = {
type: "last_edited_by";
last_edited_by: EmptyObject;
};
type LastEditedTimeDatabasePropertyConfigResponse = {
type: "last_edited_time";
last_edited_time: EmptyObject;
};
type MultiSelectDatabasePropertyConfigResponse = {
type: "multi_select";
multi_select: {
options: Array<SelectPropertyResponse>;
};
};
type NumberDatabasePropertyConfigResponse = {
type: "number";
number: {
format: NumberFormat;
};
};
/**
* 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 PartialDataSourceObjectResponse = {
object: "data_source";
id: IdResponse;
properties: Record<string, DatabasePropertyConfigResponse>;
};
type PeopleDatabasePropertyConfigResponse = {
type: "people";
people: EmptyObject;
};
type PhoneNumberDatabasePropertyConfigResponse = {
type: "phone_number";
phone_number: EmptyObject;
};
type RelationDatabasePropertyConfigResponse = {
type: "relation";
relation: DatabasePropertyRelationConfigResponse;
};
type RichTextDatabasePropertyConfigResponse = {
type: "rich_text";
rich_text: EmptyObject;
};
type RollupDatabasePropertyConfigResponse = {
type: "rollup";
rollup: {
function: RollupFunction;
rollup_property_name: string;
relation_property_name: string;
rollup_property_id: string;
relation_property_id: string;
};
};
type SelectDatabasePropertyConfigResponse = {
type: "select";
select: {
options: Array<SelectPropertyResponse>;
};
};
type SelectPropertyResponse = {
id: string;
name: string;
color: SelectColor;
description: string | null;
};
type SinglePropertyDatabasePropertyRelationConfigResponse = {
type: "single_property";
single_property: EmptyObject;
};
type StatusDatabasePropertyConfigResponse = {
type: "status";
status: {
options: Array<StatusPropertyResponse>;
groups: Array<{
id: string;
name: string;
color: SelectColor;
option_ids: Array<string>;
}>;
};
};
type StatusPropertyResponse = {
id: string;
name: string;
color: SelectColor;
description: string | null;
};
type TitleDatabasePropertyConfigResponse = {
type: "title";
title: EmptyObject;
};
type UniqueIdDatabasePropertyConfigResponse = {
type: "unique_id";
unique_id: {
prefix: string | null;
};
};
type UrlDatabasePropertyConfigResponse = {
type: "url";
url: EmptyObject;
};
type GetDataSourcePathParameters = {
data_source_id: IdRequest;
};
export type GetDataSourceParameters = GetDataSourcePathParameters;
export type GetDataSourceResponse = PartialDataSourceObjectResponse | DataSourceObjectResponse;
/**
* Retrieve a data source
*/
export declare const getDataSource: {
readonly method: "get";
readonly pathParams: readonly ["data_source_id"];
readonly queryParams: readonly [];
readonly bodyParams: readonly [];
readonly path: (p: GetDataSourcePathParameters) => string;
};
type UpdateDataSourcePathParameters = {
data_source_id: IdRequest;
};
type UpdateDataSourceBodyParameters = {
title?: Array<RichTextItemRequest>;
icon?: PageIconRequest | null;
properties?: Record<string, ({
name?: string;
description?: PropertyDescriptionRequest | null;
} & ({
type?: "number";
number: {
format?: NumberFormat;
};
} | {
type?: "formula";
formula: {
expression?: string;
};
} | {
type?: "select";
select: {
options?: Array<{
color?: SelectColor;
description?: string | null;
} & ({
name: string;
id?: string;
} | {
id: string;
name?: string;
})>;
};
} | {
type?: "multi_select";
multi_select: {
options?: Array<{
color?: SelectColor;
description?: string | null;
} & ({
name: string;
id?: string;
} | {
id: string;
name?: string;
})>;
};
} | {
type?: "status";
status: StatusPropertyConfigUpdateRequest;
} | {
type?: "relation";
relation: {
data_source_id: IdRequest;
} & ({
type?: "single_property";
single_property: EmptyObject;
} | {
type?: "dual_property";
dual_property: {
synced_property_id?: string;
synced_property_name?: string;
};
});
} | {
type?: "rollup";
rollup: {
function: RollupFunction;
} & ({
relation_property_name: string;
rollup_property_name: string;
} | {
relation_property_id: string;
rollup_property_name: string;
} | {
relation_property_name: string;
rollup_property_id: string;
} | {
relation_property_id: string;
rollup_property_id: string;
});
} | {
type?: "unique_id";
unique_id: {
prefix?: string | null;
};
} | {
type?: "title";
title: EmptyObject;
} | {
type?: "rich_text";
rich_text: EmptyObject;
} | {
type?: "url";
url: EmptyObject;
} | {
type?: "people";
people: EmptyObject;
} | {
type?: "files";
files: EmptyObject;
} | {
type?: "email";
email: EmptyObject;
} | {
type?: "phone_number";
phone_number: EmptyObject;
} | {
type?: "date";
date: EmptyObject;
} | {
type?: "checkbox";
checkbox: EmptyObject;
} | {
type?: "created_by";
created_by: EmptyObject;
} | {
type?: "created_time";
created_time: EmptyObject;
} | {
type?: "last_edited_by";
last_edited_by: EmptyObject;
} | {
type?: "last_edited_time";
last_edited_time: EmptyObject;
} | {
type?: "place";
place: EmptyObject;
})) | {
name: string;
} | null>;
in_trash?: boolean;
/** @deprecated Use `in_trash` instead. */
archived?: boolean;
parent?: ParentOfDataSourceRequest;
};
export type UpdateDataSourceParameters = UpdateDataSourcePathParameters & UpdateDataSourceBodyParameters;
export type UpdateDataSourceResponse = PartialDataSourceObjectResponse | DataSourceObjectResponse;
/**
* Update a data source
*/
export declare const updateDataSource: {
readonly method: "patch";
readonly pathParams: readonly ["data_source_id"];
readonly queryParams: readonly [];
readonly bodyParams: readonly ["archived", "title", "icon", "properties", "in_trash", "parent"];
readonly path: (p: UpdateDataSourcePathParameters) => string;
};
type QueryDataSourcePathParameters = {
data_source_id: IdRequest;
};
type QueryDataSourceQueryParameters = {
filter_properties?: Array<string>;
};
type QueryDataSourceBodyParameters = {
sorts?: Array<{
property: string;
direction: "ascending" | "descending";
} | {
timestamp: "created_time" | "last_edited_time";
direction: "ascending" | "descending";
}>;
filter?: {
or: GroupFilterOperatorArray;
} | {
and: GroupFilterOperatorArray;
} | PropertyFilter | TimestampFilter;
start_cursor?: string;
page_size?: number;
in_trash?: boolean;
/** @deprecated Use `in_trash` instead. */
archived?: boolean;
result_type?: "page" | "data_source";
};
export type QueryDataSourceParameters = QueryDataSourcePathParameters & QueryDataSourceQueryParameters & QueryDataSourceBodyParameters;
export type QueryDataSourceResponse = {
type: "page_or_data_source";
page_or_data_source: EmptyObject;
object: "list";
next_cursor: string | null;
has_more: boolean;
results: Array<PageObjectResponse | PartialPageObjectResponse | PartialDataSourceObjectResponse | DataSourceObjectResponse>;
request_status?: {
type: "complete" | "incomplete";
incomplete_reason?: "query_result_limit_reached";
};
};
/**
* Query a data source
*/
export declare const queryDataSource: {
readonly method: "post";
readonly pathParams: readonly ["data_source_id"];
readonly queryParams: readonly ["filter_properties"];
readonly bodyParams: readonly ["archived", "sorts", "filter", "start_cursor", "page_size", "in_trash", "result_type"];
readonly path: (p: QueryDataSourcePathParameters) => string;
};
type CreateDataSourceBodyParameters = {
parent: ParentOfDataSourceRequest;
properties: Record<string, PropertyConfigurationRequest>;
title?: Array<RichTextItemRequest>;
icon?: PageIconRequest | null;
};
export type CreateDataSourceParameters = CreateDataSourceBodyParameters;
export type CreateDataSourceResponse = PartialDataSourceObjectResponse | DataSourceObjectResponse;
/**
* Create a data source
*/
export declare const createDataSource: {
readonly method: "post";
readonly pathParams: readonly [];
readonly queryParams: readonly [];
readonly bodyParams: readonly ["parent", "properties", "title", "icon"];
readonly path: () => string;
};
type ListDataSourceTemplatesPathParameters = {
data_source_id: IdRequest;
};
type ListDataSourceTemplatesQueryParameters = {
name?: string;
start_cursor?: string;
page_size?: number;
};
export type ListDataSourceTemplatesParameters = ListDataSourceTemplatesPathParameters & ListDataSourceTemplatesQueryParameters;
export type ListDataSourceTemplatesResponse = {
templates: Array<{
id: IdResponse;
name: string;
is_default: boolean;
}>;
has_more: boolean;
next_cursor: IdResponse | null;
};
/**
* List templates in a data source
*/
export declare const listDataSourceTemplates: {
readonly method: "get";
readonly pathParams: readonly ["data_source_id"];
readonly queryParams: readonly ["name", "start_cursor", "page_size"];
readonly bodyParams: readonly [];
readonly path: (p: ListDataSourceTemplatesPathParameters) => string;
};
export {};
//# sourceMappingURL=data-sources.d.ts.map