@notionhq/client
Version:
A simple and easy to use client for the Notion API
507 lines • 17.7 kB
TypeScript
import type { CreateViewQueryRequest, CreateViewRequest, DataSourceViewReferenceResponse, DatabaseParentResponse, EmptyObject, IdRequest, IdResponse, PartialPageObjectResponse, PartialUserObjectResponse, RequestStatusResponse, UpdateViewRequest } from "./common";
type BoardViewConfigResponse = {
type: "board";
group_by: GroupByConfigResponse;
sub_group_by?: GroupByConfigResponse;
properties?: Array<ViewPropertyConfigResponse>;
cover?: CoverConfigResponse;
cover_size?: "small" | "medium" | "large";
cover_aspect?: "contain" | "cover";
card_layout?: "list" | "compact";
};
type CalendarViewConfigResponse = {
type: "calendar";
date_property_id: string;
date_property_name?: string;
properties?: Array<ViewPropertyConfigResponse>;
view_range?: "week" | "month";
show_weekends?: boolean;
};
type ChartAggregationResponse = {
aggregator: "count" | "count_values" | "sum" | "average" | "median" | "min" | "max" | "range" | "unique" | "empty" | "not_empty" | "percent_empty" | "percent_not_empty" | "checked" | "unchecked" | "percent_checked" | "percent_unchecked" | "earliest_date" | "latest_date" | "date_range";
property_id?: string;
};
type ChartReferenceLineResponse = {
id: string;
value: number;
label: string;
color: "gray" | "lightgray" | "brown" | "yellow" | "orange" | "green" | "blue" | "purple" | "pink" | "red";
dash_style: "solid" | "dash";
};
type ChartViewConfigResponse = {
type: "chart";
chart_type: "column" | "bar" | "line" | "donut" | "number";
x_axis?: GroupByConfigResponse | null;
y_axis?: ChartAggregationResponse | null;
x_axis_property_id?: string;
y_axis_property_id?: string;
value?: ChartAggregationResponse;
sort?: "manual" | "x_ascending" | "x_descending" | "y_ascending" | "y_descending";
color_theme?: "gray" | "blue" | "yellow" | "green" | "purple" | "teal" | "orange" | "pink" | "red" | "auto" | "colorful";
height?: "small" | "medium" | "large" | "extra_large";
hide_empty_groups?: boolean;
legend_position?: "off" | "bottom" | "side";
show_data_labels?: boolean;
axis_labels?: "none" | "x_axis" | "y_axis" | "both";
grid_lines?: "none" | "horizontal" | "vertical" | "both";
cumulative?: boolean;
smooth_line?: boolean;
hide_line_fill_area?: boolean;
group_style?: "normal" | "percent" | "side_by_side";
y_axis_min?: number | null;
y_axis_max?: number | null;
donut_labels?: "none" | "value" | "name" | "name_and_value";
hide_title?: boolean;
stack_by?: GroupByConfigResponse | null;
reference_lines?: Array<ChartReferenceLineResponse> | null;
caption?: string | null;
color_by_value?: boolean;
};
type CheckboxGroupByConfigResponse = {
type: "checkbox";
property_id: string;
sort: GroupSortResponse;
property_name?: string;
hide_empty_groups?: boolean;
};
type CoverConfigResponse = {
type: "page_cover" | "page_content" | "page_content_first" | "property";
property_id?: string;
};
export type DashboardRowResponse = {
id: string;
widgets: Array<DashboardWidgetResponse>;
height?: number;
};
type DashboardViewConfigResponse = {
type: "dashboard";
rows: Array<DashboardRowResponse>;
};
export type DashboardWidgetResponse = {
id: string;
view_id: string;
width?: number;
row_index?: number;
};
export type DataSourceViewObjectResponse = {
object: "view";
id: IdResponse;
parent: DatabaseParentResponse;
name: string;
type: "table" | "board" | "list" | "calendar" | "timeline" | "gallery" | "form" | "chart" | "map" | "dashboard";
created_time: string;
last_edited_time: string;
url: string;
data_source_id?: string | null;
created_by?: PartialUserObjectResponse | null;
last_edited_by?: PartialUserObjectResponse | null;
filter?: ViewFilterResponse | null;
sorts?: Array<ViewSortResponse> | null;
quick_filters?: Record<string, QuickFilterConditionResponse> | null;
configuration?: ViewConfigResponse | null;
dashboard_view_id?: string;
};
type DateGroupByConfigResponse = {
type: "date" | "created_time" | "last_edited_time";
property_id: string;
group_by: "relative" | "day" | "week" | "month" | "year";
sort: GroupSortResponse;
property_name?: string;
hide_empty_groups?: boolean;
start_day_of_week?: 0 | 1;
};
export type DeletedViewQueryResponse = {
object: "view_query";
id: IdResponse;
deleted: boolean;
};
type FormViewConfigResponse = {
type: "form";
is_form_closed?: boolean;
anonymous_submissions?: boolean;
submission_permissions?: "none" | "comment_only" | "reader" | "read_and_write" | "editor";
};
type FormulaCheckboxSubGroupByResponse = {
type: "checkbox";
sort: GroupSortResponse;
};
type FormulaDateSubGroupByResponse = {
type: "date";
group_by: "relative" | "day" | "week" | "month" | "year";
sort: GroupSortResponse;
start_day_of_week?: 0 | 1;
};
type FormulaGroupByConfigResponse = {
type: "formula";
property_id: string;
group_by: FormulaSubGroupByResponse;
property_name?: string;
hide_empty_groups?: boolean;
};
type FormulaNumberSubGroupByResponse = {
type: "number";
sort: GroupSortResponse;
range_start?: number;
range_end?: number;
range_size?: number;
};
/**
* Sub-group-by configuration for formula properties based on result type.
*/
type FormulaSubGroupByResponse = FormulaDateSubGroupByResponse | FormulaTextSubGroupByResponse | FormulaNumberSubGroupByResponse | FormulaCheckboxSubGroupByResponse;
type FormulaTextSubGroupByResponse = {
type: "text";
group_by: "exact" | "alphabet_prefix";
sort: GroupSortResponse;
};
type GalleryViewConfigResponse = {
type: "gallery";
properties?: Array<ViewPropertyConfigResponse>;
cover?: CoverConfigResponse;
cover_size?: "small" | "medium" | "large";
cover_aspect?: "contain" | "cover";
card_layout?: "list" | "compact";
};
/**
* Group-by configuration based on property type.
*/
type GroupByConfigResponse = SelectGroupByConfigResponse | StatusGroupByConfigResponse | PersonGroupByConfigResponse | RelationGroupByConfigResponse | DateGroupByConfigResponse | TextGroupByConfigResponse | NumberGroupByConfigResponse | CheckboxGroupByConfigResponse | FormulaGroupByConfigResponse;
type GroupSortResponse = {
type: "manual" | "ascending" | "descending";
};
type ListViewConfigResponse = {
type: "list";
properties?: Array<ViewPropertyConfigResponse>;
};
type MapViewConfigResponse = {
type: "map";
height?: "small" | "medium" | "large" | "extra_large";
map_by?: string;
map_by_property_name?: string;
properties?: Array<ViewPropertyConfigResponse>;
};
type NumberGroupByConfigResponse = {
type: "number";
property_id: string;
sort: GroupSortResponse;
property_name?: string;
hide_empty_groups?: boolean;
range_start?: number;
range_end?: number;
range_size?: number;
};
type PageReferenceResponse = {
object: string;
id: IdResponse;
};
export type PartialDataSourceViewObjectResponse = {
object: "view";
id: IdResponse;
parent: DatabaseParentResponse;
type: "table" | "board" | "list" | "calendar" | "timeline" | "gallery" | "form" | "chart" | "map" | "dashboard";
};
type PersonGroupByConfigResponse = {
type: "person" | "created_by" | "last_edited_by";
property_id: string;
sort: GroupSortResponse;
property_name?: string;
hide_empty_groups?: boolean;
};
type PropertySortResponse = {
property: string;
direction: "ascending" | "descending";
};
/**
* A property filter condition. Same shape as a property filter but without the
* "property" field. For example: { "select": { "equals": "High" } }.
*/
type QuickFilterConditionResponse = Record<string, never>;
type RelationGroupByConfigResponse = {
type: "relation";
property_id: string;
sort: GroupSortResponse;
property_name?: string;
hide_empty_groups?: boolean;
};
type SelectGroupByConfigResponse = {
type: "select" | "multi_select";
property_id: string;
sort: GroupSortResponse;
property_name?: string;
hide_empty_groups?: boolean;
};
type StatusGroupByConfigResponse = {
type: "status";
property_id: string;
group_by: "group" | "option";
sort: GroupSortResponse;
property_name?: string;
hide_empty_groups?: boolean;
};
type SubtaskConfigResponse = {
property_id?: string;
display_mode?: "show" | "hidden" | "flattened" | "disabled";
filter_scope?: "parents" | "parents_and_subitems" | "subitems";
toggle_column_id?: string;
};
type TableViewConfigResponse = {
type: "table";
properties?: Array<ViewPropertyConfigResponse>;
group_by?: GroupByConfigResponse;
subtasks?: SubtaskConfigResponse;
wrap_cells?: boolean;
frozen_column_index?: number;
show_vertical_lines?: boolean;
};
type TextGroupByConfigResponse = {
type: "text" | "title" | "url" | "email" | "phone_number";
property_id: string;
group_by: "exact" | "alphabet_prefix";
sort: GroupSortResponse;
property_name?: string;
hide_empty_groups?: boolean;
};
type TimelineArrowsByResponse = {
property_id?: string | null;
};
type TimelinePreferenceResponse = {
zoom_level: "hours" | "day" | "week" | "bi_week" | "month" | "quarter" | "year" | "5_years";
center_timestamp?: number;
};
type TimelineViewConfigResponse = {
type: "timeline";
date_property_id: string;
date_property_name?: string;
end_date_property_id?: string;
end_date_property_name?: string;
properties?: Array<ViewPropertyConfigResponse>;
show_table?: boolean;
table_properties?: Array<ViewPropertyConfigResponse>;
preference?: TimelinePreferenceResponse;
arrows_by?: TimelineArrowsByResponse;
color_by?: boolean;
};
type TimestampSortResponse = {
timestamp: "created_time" | "last_edited_time";
direction: "ascending" | "descending";
};
/**
* View configuration, typed by view type (table, board, calendar, etc.).
*/
type ViewConfigResponse = TableViewConfigResponse | BoardViewConfigResponse | CalendarViewConfigResponse | TimelineViewConfigResponse | GalleryViewConfigResponse | ListViewConfigResponse | MapViewConfigResponse | FormViewConfigResponse | ChartViewConfigResponse | DashboardViewConfigResponse;
/**
* Filter for the view. Can be a property filter (filter by property value), timestamp
* filter (filter by created_time or last_edited_time), or compound filter (combine
* filters with and/or logic). Compound filters support up to 2 levels of nesting.
*/
type ViewFilterResponse = (Record<string, unknown> & {
property: string;
}) | (Record<string, unknown> & {
timestamp: "created_time" | "last_edited_time";
}) | {
or?: Array<(Record<string, unknown> & {
property: string;
}) | (Record<string, unknown> & {
timestamp: "created_time" | "last_edited_time";
}) | {
or?: Array<(Record<string, unknown> & {
property: string;
}) | (Record<string, unknown> & {
timestamp: "created_time" | "last_edited_time";
})>;
and?: Array<(Record<string, unknown> & {
property: string;
}) | (Record<string, unknown> & {
timestamp: "created_time" | "last_edited_time";
})>;
}>;
and?: Array<(Record<string, unknown> & {
property: string;
}) | (Record<string, unknown> & {
timestamp: "created_time" | "last_edited_time";
}) | {
or?: Array<(Record<string, unknown> & {
property: string;
}) | (Record<string, unknown> & {
timestamp: "created_time" | "last_edited_time";
})>;
and?: Array<(Record<string, unknown> & {
property: string;
}) | (Record<string, unknown> & {
timestamp: "created_time" | "last_edited_time";
})>;
}>;
};
type ViewPropertyConfigResponse = {
property_id: string;
property_name?: string;
visible?: boolean;
width?: number;
wrap?: boolean;
status_show_as?: "select" | "checkbox";
card_property_width_mode?: "full_line" | "inline";
date_format?: "full" | "short" | "month_day_year" | "day_month_year" | "year_month_day" | "relative";
time_format?: "12_hour" | "24_hour" | "hidden";
};
export type ViewQueryResponse = {
object: "view_query";
id: IdResponse;
view_id: IdResponse;
expires_at: string;
total_count: number;
results: Array<PageReferenceResponse>;
next_cursor: IdResponse | null;
has_more: boolean;
request_status?: RequestStatusResponse;
};
/**
* Sort for the view. Can sort by property or timestamp.
*/
type ViewSortResponse = PropertySortResponse | TimestampSortResponse;
type ListDatabaseViewsQueryParameters = {
database_id?: IdRequest;
data_source_id?: IdRequest;
start_cursor?: string;
page_size?: number;
};
export type ListDatabaseViewsParameters = ListDatabaseViewsQueryParameters;
export type ListDatabaseViewsResponse = {
object: "list";
next_cursor: IdResponse | null;
has_more: boolean;
results: Array<DataSourceViewReferenceResponse>;
type: "view";
view: EmptyObject;
request_status?: RequestStatusResponse;
};
/**
* List views
*/
export declare const listDatabaseViews: {
readonly method: "get";
readonly pathParams: readonly [];
readonly queryParams: readonly ["database_id", "data_source_id", "start_cursor", "page_size"];
readonly bodyParams: readonly [];
readonly path: () => string;
};
type CreateViewBodyParameters = CreateViewRequest;
export type CreateViewParameters = CreateViewBodyParameters;
export type CreateViewResponse = PartialDataSourceViewObjectResponse | DataSourceViewObjectResponse;
/**
* Create a view
*/
export declare const createView: {
readonly method: "post";
readonly pathParams: readonly [];
readonly queryParams: readonly [];
readonly bodyParams: readonly [];
readonly path: () => string;
};
type GetViewPathParameters = {
view_id: IdRequest;
};
export type GetViewParameters = GetViewPathParameters;
export type GetViewResponse = PartialDataSourceViewObjectResponse | DataSourceViewObjectResponse;
/**
* Retrieve a view
*/
export declare const getView: {
readonly method: "get";
readonly pathParams: readonly ["view_id"];
readonly queryParams: readonly [];
readonly bodyParams: readonly [];
readonly path: (p: GetViewPathParameters) => string;
};
type UpdateViewPathParameters = {
view_id: IdRequest;
};
type UpdateViewBodyParameters = UpdateViewRequest;
export type UpdateViewParameters = UpdateViewPathParameters & UpdateViewBodyParameters;
export type UpdateViewResponse = PartialDataSourceViewObjectResponse | DataSourceViewObjectResponse;
/**
* Update a view
*/
export declare const updateView: {
readonly method: "patch";
readonly pathParams: readonly ["view_id"];
readonly queryParams: readonly [];
readonly bodyParams: readonly [];
readonly path: (p: UpdateViewPathParameters) => string;
};
type DeleteViewPathParameters = {
view_id: IdRequest;
};
export type DeleteViewParameters = DeleteViewPathParameters;
export type DeleteViewResponse = PartialDataSourceViewObjectResponse;
/**
* Delete a view
*/
export declare const deleteView: {
readonly method: "delete";
readonly pathParams: readonly ["view_id"];
readonly queryParams: readonly [];
readonly bodyParams: readonly [];
readonly path: (p: DeleteViewPathParameters) => string;
};
type CreateViewQueryPathParameters = {
view_id: IdRequest;
};
type CreateViewQueryBodyParameters = CreateViewQueryRequest;
export type CreateViewQueryParameters = CreateViewQueryPathParameters & CreateViewQueryBodyParameters;
export type CreateViewQueryResponse = ViewQueryResponse;
/**
* Create a view query
*/
export declare const createViewQuery: {
readonly method: "post";
readonly pathParams: readonly ["view_id"];
readonly queryParams: readonly [];
readonly bodyParams: readonly [];
readonly path: (p: CreateViewQueryPathParameters) => string;
};
type GetViewQueryResultsPathParameters = {
view_id: IdRequest;
query_id: IdRequest;
};
type GetViewQueryResultsQueryParameters = {
start_cursor?: string;
page_size?: number;
};
export type GetViewQueryResultsParameters = GetViewQueryResultsPathParameters & GetViewQueryResultsQueryParameters;
export type GetViewQueryResultsResponse = {
object: "list";
next_cursor: IdResponse | null;
has_more: boolean;
results: Array<PartialPageObjectResponse>;
type: "page";
page: EmptyObject;
request_status?: RequestStatusResponse;
};
/**
* Get view query results
*/
export declare const getViewQueryResults: {
readonly method: "get";
readonly pathParams: readonly ["view_id", "query_id"];
readonly queryParams: readonly ["start_cursor", "page_size"];
readonly bodyParams: readonly [];
readonly path: (p: GetViewQueryResultsPathParameters) => string;
};
type DeleteViewQueryPathParameters = {
view_id: IdRequest;
query_id: IdRequest;
};
export type DeleteViewQueryParameters = DeleteViewQueryPathParameters;
export type DeleteViewQueryResponse = DeletedViewQueryResponse;
/**
* Delete a view query
*/
export declare const deleteViewQuery: {
readonly method: "delete";
readonly pathParams: readonly ["view_id", "query_id"];
readonly queryParams: readonly [];
readonly bodyParams: readonly [];
readonly path: (p: DeleteViewQueryPathParameters) => string;
};
export {};
//# sourceMappingURL=views.d.ts.map