New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question about new typings #219
Comments
|
Also, I used to have a React component that could render out the RichTextBlock like below: import * as React from "react"
import { Text, Link, StyleProps } from "@chakra-ui/react"
import type { Annotations, RichText } from "@notionhq/client/build/src/api-types"
interface RichTextBlockProps {
text: RichText[]
}
export function RichTextBlock(props: RichTextBlockProps) {
const textDecorationAttr = React.useCallback((annotations: Annotations): Omit<StyleProps, "apply"> => {
return {
fontWeight: annotations.bold ? 600 : undefined,
textDecor: `${annotations.underline ? "underline " : ""}${
annotations.strikethrough ? "line-through" : ""
}`,
fontStyle: annotations.italic ? "italic" : undefined,
}
}, [])
if (props.text.length === 0) return <br />
return (
<>
{props.text.map((text, i) => {
if (text.href) {
return (
<Link
key={i}
href={text.href}
isExternal
color="gray.600"
_hover={{ color: "gray.900" }}
{...textDecorationAttr(text.annotations)}
textDecor="underline"
>
{text.plain_text}
</Link>
)
} else {
return (
<Text as="span" key={i} {...textDecorationAttr(text.annotations)}>
{text.plain_text}
</Text>
)
}
})}
</>
)
}Which was super nice as I could just import the "RichText" type, now it seems I have to manually copy it from your types file: type RichText = {
type: "text"
text: {
content: string
link: {
url: string
} | null
}
annotations: {
bold: boolean
italic: boolean
strikethrough: boolean
underline: boolean
code: boolean
color:
| "default"
| "gray"
| "brown"
| "orange"
| "yellow"
| "green"
| "blue"
| "purple"
| "pink"
| "red"
| "gray_background"
| "brown_background"
| "orange_background"
| "yellow_background"
| "green_background"
| "blue_background"
| "purple_background"
| "pink_background"
| "red_background"
}
plain_text: string
href: string | null
} |
|
You can extract more to grt what you need. Check this out to see how I do it: https://github.com/nartc/notion-stuff/blob/6e22fbffafb528e41cc31258c34b5234048ebb25/libs/v4-types/src/lib/types.ts#L6 |
|
I'm also finding the removal/change of these types frustrating. Was really nice to just be able to import them directly. |
|
This made the client much much harder to work with when using typescript. |
|
Also finding this frustrating :( |
|
I was actually trying to build their types from scratch for them and raise a PR, but its extremely long |
|
I'm assuming they auto generated them? |
|
Apologies for the inconvenience of the new types. In an effort to provide a more accurate and up to date set of types we started auto-generating the types directly from our codebase but in the process we have made the types less ergonomic to work with. In the meantime, using the strategy suggested by @nartc should work to get access to specific block types as shown below: import { GetBlockResponse } from './api-endpoints'
type HeadingOneBlockResponse = Extract<GetBlockResponse, { type: "heading_1"}>
type ImageBlockResponse = Extract<GetBlockResponse, { type: "image"}>Note: The types will be slightly different for each endpoint request/responses. For example all responses will have |
|
Thanks @rhart92! I think this workaround is nice. However, I wanted to note that a major problem I'm having with the latest typings is that they appear to be so large that my VSCode refuses to allow me to introspect them in the way that I'm used to. For example, here's a snippet of code that I'd like to explore: import notion from "@notionhq/client";
const client = new notion.Client({});
const stuff = await client.databases.query({
database_id: "fake"
});
console.log(stuff);Version 0.3.3Using VSCode with version 0.3.3 of Furthermore, if I right-click on the variable and choose "Go to Type Definition", I am taken to the data type's definition in It also looks like version 0.3.3 has reasonably-sized typings: Version 0.4.0Now let's fast-forward to version 0.4.0 of the same library. Now right-clicking on I think this is because the typings are much larger in 0.4.0: Version 0.4.6Now let's go to the very latest version of the library, 0.4.6. At this point, hovering my mouse over I suspect this is because the typings have now become even larger: My guess is that TypeScript is seeing that In any case, it would be great if the typings could be nice and small again, as it would likely bring back the great developer ergonomics that version 0.3.3 had. |
|
Good news--it looks like the latest release, 0.4.8, has slimmed down the |
|
Hi @rhart92 , thanks for the work on the client. Thank you for your clarifications :) |
|
@rhart92 First of all, I want to say that I absolutely LOVE being able to use the notion API, let alone having an SDK for it. Thank you for your (and your colleague's) hard work on this, I'm sure it's no easy task ! I want to explain my understanding of my current problem with a simple example first and then explain my use case. I tried to see how I can apply your workaround with I'm using the SDK @ version Typescript ExampleI seem to notice a fundamental problem with the way some types seem to be generated, especially with how Union types are designed within Typescript. It took me a while to get to the root of the problem and I learned something new so there's that :D From the Handbook
This constraint is better explained with the example below Use Case with QueryDatabaseResponseI am using the The return value's type is Unfortunately, it seems that the type of Thoughts ? :/ CLICK TO EXPAND -Generated type definition for QueryDatabaseResponseexport declare type QueryDatabaseResponse = {
type: "rollup";
rollup: {
type: "number";
number: number | null;
function: "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" | "show_original";
} | {
type: "date";
date: {
start: string;
end: string | null;
time_zone: TimeZoneRequest | null;
} | null;
function: "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" | "show_original";
} | {
type: "array";
array: Array<{
type: "title";
title: Array<{
type: "text";
text: {
content: string;
link: {
url: TextRequest;
} | null;
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
} | {
type: "mention";
mention: {
type: "user";
user: {
id: IdRequest;
object: "user";
} | {
type: "person";
person: {
email?: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
type: "bot";
bot: EmptyObject | {
owner: {
type: "user";
user: {
type: "person";
person: {
email: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
id: IdRequest;
object: "user";
};
} | {
type: "workspace";
workspace: true;
};
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
};
} | {
type: "date";
date: {
start: string;
end: string | null;
time_zone: TimeZoneRequest | null;
};
} | {
type: "link_preview";
link_preview: {
url: TextRequest;
};
} | {
type: "page";
page: {
id: IdRequest;
};
} | {
type: "database";
database: {
id: IdRequest;
};
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
} | {
type: "equation";
equation: {
expression: TextRequest;
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
}>;
} | {
type: "rich_text";
rich_text: Array<{
type: "text";
text: {
content: string;
link: {
url: TextRequest;
} | null;
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
} | {
type: "mention";
mention: {
type: "user";
user: {
id: IdRequest;
object: "user";
} | {
type: "person";
person: {
email?: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
type: "bot";
bot: EmptyObject | {
owner: {
type: "user";
user: {
type: "person";
person: {
email: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
id: IdRequest;
object: "user";
};
} | {
type: "workspace";
workspace: true;
};
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
};
} | {
type: "date";
date: {
start: string;
end: string | null;
time_zone: TimeZoneRequest | null;
};
} | {
type: "link_preview";
link_preview: {
url: TextRequest;
};
} | {
type: "page";
page: {
id: IdRequest;
};
} | {
type: "database";
database: {
id: IdRequest;
};
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
} | {
type: "equation";
equation: {
expression: TextRequest;
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
}>;
} | {
type: "number";
number: number | null;
} | {
type: "url";
url: string | null;
} | {
type: "select";
select: {
id: StringRequest;
name: StringRequest;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red";
} | null;
} | {
type: "multi_select";
multi_select: Array<{
id: StringRequest;
name: StringRequest;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red";
}>;
} | {
type: "people";
people: Array<{
id: IdRequest;
object: "user";
} | {
type: "person";
person: {
email?: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
type: "bot";
bot: EmptyObject | {
owner: {
type: "user";
user: {
type: "person";
person: {
email: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
id: IdRequest;
object: "user";
};
} | {
type: "workspace";
workspace: true;
};
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
}>;
} | {
type: "email";
email: string | null;
} | {
type: "phone_number";
phone_number: string | null;
} | {
type: "date";
date: {
start: string;
end: string | null;
time_zone: TimeZoneRequest | null;
} | null;
} | {
type: "files";
files: Array<{
file: {
url: string;
expiry_time: string;
};
name: StringRequest;
type?: "file";
} | {
external: {
url: TextRequest;
};
name: StringRequest;
type?: "external";
}>;
} | {
type: "checkbox";
checkbox: boolean;
} | {
type: "formula";
formula: {
type: "string";
string: string | null;
} | {
type: "date";
date: {
start: string;
end: string | null;
time_zone: TimeZoneRequest | null;
} | null;
} | {
type: "number";
number: number | null;
} | {
type: "boolean";
boolean: boolean | null;
};
} | {
type: "relation";
relation: Array<{
id: string;
}>;
} | {
type: "created_time";
created_time: string;
} | {
type: "created_by";
created_by: {
id: IdRequest;
object: "user";
} | {
type: "person";
person: {
email?: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
type: "bot";
bot: EmptyObject | {
owner: {
type: "user";
user: {
type: "person";
person: {
email: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
id: IdRequest;
object: "user";
};
} | {
type: "workspace";
workspace: true;
};
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
};
} | {
type: "last_edited_time";
last_edited_time: string;
} | {
type: "last_edited_by";
last_edited_by: {
id: IdRequest;
object: "user";
} | {
type: "person";
person: {
email?: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
type: "bot";
bot: EmptyObject | {
owner: {
type: "user";
user: {
type: "person";
person: {
email: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
id: IdRequest;
object: "user";
};
} | {
type: "workspace";
workspace: true;
};
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
};
}>;
function: "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" | "show_original";
} | {
type: "unsupported";
unsupported: EmptyObject;
function: "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" | "show_original";
};
object: "list";
results: Array<{
parent: {
type: "database_id";
database_id: IdRequest;
} | {
type: "page_id";
page_id: IdRequest;
} | {
type: "workspace";
workspace: true;
};
properties: Record<string, {
type: "title";
title: Array<{
type: "text";
text: {
content: string;
link: {
url: TextRequest;
} | null;
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
} | {
type: "mention";
mention: {
type: "user";
user: {
id: IdRequest;
object: "user";
} | {
type: "person";
person: {
email?: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
type: "bot";
bot: EmptyObject | {
owner: {
type: "user";
user: {
type: "person";
person: {
email: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
id: IdRequest;
object: "user";
};
} | {
type: "workspace";
workspace: true;
};
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
};
} | {
type: "date";
date: {
start: string;
end: string | null;
time_zone: TimeZoneRequest | null;
};
} | {
type: "link_preview";
link_preview: {
url: TextRequest;
};
} | {
type: "page";
page: {
id: IdRequest;
};
} | {
type: "database";
database: {
id: IdRequest;
};
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
} | {
type: "equation";
equation: {
expression: TextRequest;
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
}>;
id: string;
} | {
type: "rich_text";
rich_text: Array<{
type: "text";
text: {
content: string;
link: {
url: TextRequest;
} | null;
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
} | {
type: "mention";
mention: {
type: "user";
user: {
id: IdRequest;
object: "user";
} | {
type: "person";
person: {
email?: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
type: "bot";
bot: EmptyObject | {
owner: {
type: "user";
user: {
type: "person";
person: {
email: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
id: IdRequest;
object: "user";
};
} | {
type: "workspace";
workspace: true;
};
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
};
} | {
type: "date";
date: {
start: string;
end: string | null;
time_zone: TimeZoneRequest | null;
};
} | {
type: "link_preview";
link_preview: {
url: TextRequest;
};
} | {
type: "page";
page: {
id: IdRequest;
};
} | {
type: "database";
database: {
id: IdRequest;
};
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
} | {
type: "equation";
equation: {
expression: TextRequest;
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
}>;
id: string;
} | {
type: "number";
number: number | null;
id: string;
} | {
type: "url";
url: string | null;
id: string;
} | {
type: "select";
select: {
id: StringRequest;
name: StringRequest;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red";
} | null;
id: string;
} | {
type: "multi_select";
multi_select: Array<{
id: StringRequest;
name: StringRequest;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red";
}>;
id: string;
} | {
type: "people";
people: Array<{
id: IdRequest;
object: "user";
} | {
type: "person";
person: {
email?: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
type: "bot";
bot: EmptyObject | {
owner: {
type: "user";
user: {
type: "person";
person: {
email: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
id: IdRequest;
object: "user";
};
} | {
type: "workspace";
workspace: true;
};
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
}>;
id: string;
} | {
type: "email";
email: string | null;
id: string;
} | {
type: "phone_number";
phone_number: string | null;
id: string;
} | {
type: "date";
date: {
start: string;
end: string | null;
time_zone: TimeZoneRequest | null;
} | null;
id: string;
} | {
type: "files";
files: Array<{
file: {
url: string;
expiry_time: string;
};
name: StringRequest;
type?: "file";
} | {
external: {
url: TextRequest;
};
name: StringRequest;
type?: "external";
}>;
id: string;
} | {
type: "checkbox";
checkbox: boolean;
id: string;
} | {
type: "formula";
formula: {
type: "string";
string: string | null;
} | {
type: "date";
date: {
start: string;
end: string | null;
time_zone: TimeZoneRequest | null;
} | null;
} | {
type: "number";
number: number | null;
} | {
type: "boolean";
boolean: boolean | null;
};
id: string;
} | {
type: "relation";
relation: Array<{
id: string;
}>;
id: string;
} | {
type: "created_time";
created_time: string;
id: string;
} | {
type: "created_by";
created_by: {
id: IdRequest;
object: "user";
} | {
type: "person";
person: {
email?: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
type: "bot";
bot: EmptyObject | {
owner: {
type: "user";
user: {
type: "person";
person: {
email: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
id: IdRequest;
object: "user";
};
} | {
type: "workspace";
workspace: true;
};
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
};
id: string;
} | {
type: "last_edited_time";
last_edited_time: string;
id: string;
} | {
type: "last_edited_by";
last_edited_by: {
id: IdRequest;
object: "user";
} | {
type: "person";
person: {
email?: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
type: "bot";
bot: EmptyObject | {
owner: {
type: "user";
user: {
type: "person";
person: {
email: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
id: IdRequest;
object: "user";
};
} | {
type: "workspace";
workspace: true;
};
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
};
id: string;
} | {
type: "rollup";
rollup: {
type: "number";
number: number | null;
function: "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" | "show_original";
} | {
type: "date";
date: {
start: string;
end: string | null;
time_zone: TimeZoneRequest | null;
} | null;
function: "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" | "show_original";
} | {
type: "array";
array: Array<{
type: "title";
title: Array<{
type: "text";
text: {
content: string;
link: {
url: TextRequest;
} | null;
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
} | {
type: "mention";
mention: {
type: "user";
user: {
id: IdRequest;
object: "user";
} | {
type: "person";
person: {
email?: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
type: "bot";
bot: EmptyObject | {
owner: {
type: "user";
user: {
type: "person";
person: {
email: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
id: IdRequest;
object: "user";
};
} | {
type: "workspace";
workspace: true;
};
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
};
} | {
type: "date";
date: {
start: string;
end: string | null;
time_zone: TimeZoneRequest | null;
};
} | {
type: "link_preview";
link_preview: {
url: TextRequest;
};
} | {
type: "page";
page: {
id: IdRequest;
};
} | {
type: "database";
database: {
id: IdRequest;
};
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
} | {
type: "equation";
equation: {
expression: TextRequest;
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
}>;
} | {
type: "rich_text";
rich_text: Array<{
type: "text";
text: {
content: string;
link: {
url: TextRequest;
} | null;
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
} | {
type: "mention";
mention: {
type: "user";
user: {
id: IdRequest;
object: "user";
} | {
type: "person";
person: {
email?: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
type: "bot";
bot: EmptyObject | {
owner: {
type: "user";
user: {
type: "person";
person: {
email: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
id: IdRequest;
object: "user";
};
} | {
type: "workspace";
workspace: true;
};
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
};
} | {
type: "date";
date: {
start: string;
end: string | null;
time_zone: TimeZoneRequest | null;
};
} | {
type: "link_preview";
link_preview: {
url: TextRequest;
};
} | {
type: "page";
page: {
id: IdRequest;
};
} | {
type: "database";
database: {
id: IdRequest;
};
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
} | {
type: "equation";
equation: {
expression: TextRequest;
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
}>;
} | {
type: "number";
number: number | null;
} | {
type: "url";
url: string | null;
} | {
type: "select";
select: {
id: StringRequest;
name: StringRequest;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red";
} | null;
} | {
type: "multi_select";
multi_select: Array<{
id: StringRequest;
name: StringRequest;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red";
}>;
} | {
type: "people";
people: Array<{
id: IdRequest;
object: "user";
} | {
type: "person";
person: {
email?: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
type: "bot";
bot: EmptyObject | {
owner: {
type: "user";
user: {
type: "person";
person: {
email: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
id: IdRequest;
object: "user";
};
} | {
type: "workspace";
workspace: true;
};
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
}>;
} | {
type: "email";
email: string | null;
} | {
type: "phone_number";
phone_number: string | null;
} | {
type: "date";
date: {
start: string;
end: string | null;
time_zone: TimeZoneRequest | null;
} | null;
} | {
type: "files";
files: Array<{
file: {
url: string;
expiry_time: string;
};
name: StringRequest;
type?: "file";
} | {
external: {
url: TextRequest;
};
name: StringRequest;
type?: "external";
}>;
} | {
type: "checkbox";
checkbox: boolean;
} | {
type: "formula";
formula: {
type: "string";
string: string | null;
} | {
type: "date";
date: {
start: string;
end: string | null;
time_zone: TimeZoneRequest | null;
} | null;
} | {
type: "number";
number: number | null;
} | {
type: "boolean";
boolean: boolean | null;
};
} | {
type: "relation";
relation: Array<{
id: string;
}>;
} | {
type: "created_time";
created_time: string;
} | {
type: "created_by";
created_by: {
id: IdRequest;
object: "user";
} | {
type: "person";
person: {
email?: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
type: "bot";
bot: EmptyObject | {
owner: {
type: "user";
user: {
type: "person";
person: {
email: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
id: IdRequest;
object: "user";
};
} | {
type: "workspace";
workspace: true;
};
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
};
} | {
type: "last_edited_time";
last_edited_time: string;
} | {
type: "last_edited_by";
last_edited_by: {
id: IdRequest;
object: "user";
} | {
type: "person";
person: {
email?: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
type: "bot";
bot: EmptyObject | {
owner: {
type: "user";
user: {
type: "person";
person: {
email: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
id: IdRequest;
object: "user";
};
} | {
type: "workspace";
workspace: true;
};
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
};
}>;
function: "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" | "show_original";
} | {
type: "unsupported";
unsupported: EmptyObject;
function: "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" | "show_original";
};
id: string;
}>;
icon: {
type: "emoji";
emoji: EmojiRequest;
} | null | {
type: "external";
external: {
url: TextRequest;
};
} | null | {
type: "file";
file: {
url: string;
expiry_time: string;
};
} | null;
cover: {
type: "external";
external: {
url: TextRequest;
};
} | null | {
type: "file";
file: {
url: string;
expiry_time: string;
};
} | null;
object: "page";
id: string;
created_time: string;
last_edited_time: string;
archived: boolean;
url: string;
} | {
object: "page";
id: string;
}>;
next_cursor: string | null;
has_more: boolean;
} | {
object: "list";
results: Array<{
parent: {
type: "database_id";
database_id: IdRequest;
} | {
type: "page_id";
page_id: IdRequest;
} | {
type: "workspace";
workspace: true;
};
properties: Record<string, {
type: "title";
title: Array<{
type: "text";
text: {
content: string;
link: {
url: TextRequest;
} | null;
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
} | {
type: "mention";
mention: {
type: "user";
user: {
id: IdRequest;
object: "user";
} | {
type: "person";
person: {
email?: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
type: "bot";
bot: EmptyObject | {
owner: {
type: "user";
user: {
type: "person";
person: {
email: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
id: IdRequest;
object: "user";
};
} | {
type: "workspace";
workspace: true;
};
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
};
} | {
type: "date";
date: {
start: string;
end: string | null;
time_zone: TimeZoneRequest | null;
};
} | {
type: "link_preview";
link_preview: {
url: TextRequest;
};
} | {
type: "page";
page: {
id: IdRequest;
};
} | {
type: "database";
database: {
id: IdRequest;
};
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
} | {
type: "equation";
equation: {
expression: TextRequest;
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
}>;
id: string;
} | {
type: "rich_text";
rich_text: Array<{
type: "text";
text: {
content: string;
link: {
url: TextRequest;
} | null;
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
} | {
type: "mention";
mention: {
type: "user";
user: {
id: IdRequest;
object: "user";
} | {
type: "person";
person: {
email?: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
type: "bot";
bot: EmptyObject | {
owner: {
type: "user";
user: {
type: "person";
person: {
email: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
id: IdRequest;
object: "user";
};
} | {
type: "workspace";
workspace: true;
};
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
};
} | {
type: "date";
date: {
start: string;
end: string | null;
time_zone: TimeZoneRequest | null;
};
} | {
type: "link_preview";
link_preview: {
url: TextRequest;
};
} | {
type: "page";
page: {
id: IdRequest;
};
} | {
type: "database";
database: {
id: IdRequest;
};
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
} | {
type: "equation";
equation: {
expression: TextRequest;
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
}>;
id: string;
} | {
type: "number";
number: number | null;
id: string;
} | {
type: "url";
url: string | null;
id: string;
} | {
type: "select";
select: {
id: StringRequest;
name: StringRequest;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red";
} | null;
id: string;
} | {
type: "multi_select";
multi_select: Array<{
id: StringRequest;
name: StringRequest;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red";
}>;
id: string;
} | {
type: "people";
people: Array<{
id: IdRequest;
object: "user";
} | {
type: "person";
person: {
email?: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
type: "bot";
bot: EmptyObject | {
owner: {
type: "user";
user: {
type: "person";
person: {
email: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
id: IdRequest;
object: "user";
};
} | {
type: "workspace";
workspace: true;
};
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
}>;
id: string;
} | {
type: "email";
email: string | null;
id: string;
} | {
type: "phone_number";
phone_number: string | null;
id: string;
} | {
type: "date";
date: {
start: string;
end: string | null;
time_zone: TimeZoneRequest | null;
} | null;
id: string;
} | {
type: "files";
files: Array<{
file: {
url: string;
expiry_time: string;
};
name: StringRequest;
type?: "file";
} | {
external: {
url: TextRequest;
};
name: StringRequest;
type?: "external";
}>;
id: string;
} | {
type: "checkbox";
checkbox: boolean;
id: string;
} | {
type: "formula";
formula: {
type: "string";
string: string | null;
} | {
type: "date";
date: {
start: string;
end: string | null;
time_zone: TimeZoneRequest | null;
} | null;
} | {
type: "number";
number: number | null;
} | {
type: "boolean";
boolean: boolean | null;
};
id: string;
} | {
type: "relation";
relation: Array<{
id: string;
}>;
id: string;
} | {
type: "created_time";
created_time: string;
id: string;
} | {
type: "created_by";
created_by: {
id: IdRequest;
object: "user";
} | {
type: "person";
person: {
email?: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
type: "bot";
bot: EmptyObject | {
owner: {
type: "user";
user: {
type: "person";
person: {
email: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
id: IdRequest;
object: "user";
};
} | {
type: "workspace";
workspace: true;
};
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
};
id: string;
} | {
type: "last_edited_time";
last_edited_time: string;
id: string;
} | {
type: "last_edited_by";
last_edited_by: {
id: IdRequest;
object: "user";
} | {
type: "person";
person: {
email?: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
type: "bot";
bot: EmptyObject | {
owner: {
type: "user";
user: {
type: "person";
person: {
email: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
id: IdRequest;
object: "user";
};
} | {
type: "workspace";
workspace: true;
};
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
};
id: string;
} | {
type: "rollup";
rollup: {
type: "number";
number: number | null;
function: "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" | "show_original";
} | {
type: "date";
date: {
start: string;
end: string | null;
time_zone: TimeZoneRequest | null;
} | null;
function: "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" | "show_original";
} | {
type: "array";
array: Array<{
type: "title";
title: Array<{
type: "text";
text: {
content: string;
link: {
url: TextRequest;
} | null;
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
} | {
type: "mention";
mention: {
type: "user";
user: {
id: IdRequest;
object: "user";
} | {
type: "person";
person: {
email?: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
type: "bot";
bot: EmptyObject | {
owner: {
type: "user";
user: {
type: "person";
person: {
email: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
id: IdRequest;
object: "user";
};
} | {
type: "workspace";
workspace: true;
};
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
};
} | {
type: "date";
date: {
start: string;
end: string | null;
time_zone: TimeZoneRequest | null;
};
} | {
type: "link_preview";
link_preview: {
url: TextRequest;
};
} | {
type: "page";
page: {
id: IdRequest;
};
} | {
type: "database";
database: {
id: IdRequest;
};
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
} | {
type: "equation";
equation: {
expression: TextRequest;
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
}>;
} | {
type: "rich_text";
rich_text: Array<{
type: "text";
text: {
content: string;
link: {
url: TextRequest;
} | null;
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
} | {
type: "mention";
mention: {
type: "user";
user: {
id: IdRequest;
object: "user";
} | {
type: "person";
person: {
email?: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
type: "bot";
bot: EmptyObject | {
owner: {
type: "user";
user: {
type: "person";
person: {
email: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
id: IdRequest;
object: "user";
};
} | {
type: "workspace";
workspace: true;
};
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
};
} | {
type: "date";
date: {
start: string;
end: string | null;
time_zone: TimeZoneRequest | null;
};
} | {
type: "link_preview";
link_preview: {
url: TextRequest;
};
} | {
type: "page";
page: {
id: IdRequest;
};
} | {
type: "database";
database: {
id: IdRequest;
};
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
} | {
type: "equation";
equation: {
expression: TextRequest;
};
annotations: {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
};
plain_text: string;
href: string | null;
}>;
} | {
type: "number";
number: number | null;
} | {
type: "url";
url: string | null;
} | {
type: "select";
select: {
id: StringRequest;
name: StringRequest;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red";
} | null;
} | {
type: "multi_select";
multi_select: Array<{
id: StringRequest;
name: StringRequest;
color: "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red";
}>;
} | {
type: "people";
people: Array<{
id: IdRequest;
object: "user";
} | {
type: "person";
person: {
email?: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
type: "bot";
bot: EmptyObject | {
owner: {
type: "user";
user: {
type: "person";
person: {
email: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
id: IdRequest;
object: "user";
};
} | {
type: "workspace";
workspace: true;
};
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
}>;
} | {
type: "email";
email: string | null;
} | {
type: "phone_number";
phone_number: string | null;
} | {
type: "date";
date: {
start: string;
end: string | null;
time_zone: TimeZoneRequest | null;
} | null;
} | {
type: "files";
files: Array<{
file: {
url: string;
expiry_time: string;
};
name: StringRequest;
type?: "file";
} | {
external: {
url: TextRequest;
};
name: StringRequest;
type?: "external";
}>;
} | {
type: "checkbox";
checkbox: boolean;
} | {
type: "formula";
formula: {
type: "string";
string: string | null;
} | {
type: "date";
date: {
start: string;
end: string | null;
time_zone: TimeZoneRequest | null;
} | null;
} | {
type: "number";
number: number | null;
} | {
type: "boolean";
boolean: boolean | null;
};
} | {
type: "relation";
relation: Array<{
id: string;
}>;
} | {
type: "created_time";
created_time: string;
} | {
type: "created_by";
created_by: {
id: IdRequest;
object: "user";
} | {
type: "person";
person: {
email?: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
type: "bot";
bot: EmptyObject | {
owner: {
type: "user";
user: {
type: "person";
person: {
email: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
id: IdRequest;
object: "user";
};
} | {
type: "workspace";
workspace: true;
};
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
};
} | {
type: "last_edited_time";
last_edited_time: string;
} | {
type: "last_edited_by";
last_edited_by: {
id: IdRequest;
object: "user";
} | {
type: "person";
person: {
email?: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
type: "bot";
bot: EmptyObject | {
owner: {
type: "user";
user: {
type: "person";
person: {
email: string;
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
} | {
id: IdRequest;
object: "user";
};
} | {
type: "workspace";
workspace: true;
};
};
name: string | null;
avatar_url: string | null;
id: IdRequest;
object: "user";
};
}>;
function: "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" | "show_original";
} | {
type: "unsupported";
unsupported: EmptyObject;
function: "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" | "show_original";
};
id: string;
}>;
icon: {
type: "emoji";
emoji: EmojiRequest;
} | null | {
type: "external";
external: {
url: TextRequest;
};
} | null | {
type: "file";
file: {
url: string;
expiry_time: string;
};
} | null;
cover: {
type: "external";
external: {
url: TextRequest;
};
} | null | {
type: "file";
file: {
url: string;
expiry_time: string;
};
} | null;
object: "page";
id: string;
created_time: string;
last_edited_time: string;
archived: boolean;
url: string;
} | {
object: "page";
id: string;
}>;
next_cursor: string | null;
has_more: boolean;
}; |
|
I've found that the const queryResponse = await notion.databases.query({
database_id: databaseId,
})
queryResponse.results.forEach(pageIn => {
// if (pageIn.object) return;
const page = pageIn as Extract<typeof pageIn, {parent: {}}>;I really expected the |
|
Hello, I have released my personal Notion API toolkit to NPM here: @jitl/notion-api. This package exports types like To re-write @danopia's example with my library: import { isFullPage, iteratePaginatedAPI } from '@jitl/notion-api';
for await (const page of iteratePaginatedAPI(notion.databases.query, {
database_id: databaseId,
})) {
if (isFullPage(page)) {
// page is a "full" page object
doThings(page.properties)
}
}To re-write @Niceplace's example with my library: import { isFullPage, iteratePaginatedAPI, asyncIterableToArray } from '@jitl/notion-api';
/**
* Query all pages and return all records from a Notion database object
* Will log a warning if database has no records
* @param parameters To specify database id, control sorting, filtering and
* pagination, directly using Notion's sdk types
* @returns A list of all the results from the database or an empty array
*/
export const queryAll = async (
parameters: QueryDatabaseParameters
): Promise<Page[]> => {
const params: typeof parameters = { ...parameters };
const resultsWithPartialPages = await asyncIterableToArray(
// getNotionClient() returns an authenticated instance of the notion SDK
iteratePaginatedAPI(getNotionClient().databases.query, parameters)
);
// Filter out partial pages
const fullPages = resultsWithPartialPages.filter(isFullPage);
if (!fullPages.length) {
logger.warn(`No results found in database ${params.database_id}`);
}
return fullPages;
};@jitl/notion-api is not an official Notion product. I wrote it for my own use, to support my website and other personal projects, although I welcome contributions of any kind. |
|
I'm experimenting with writing a Notion integration, but I cannot figure out how to use the types generated for search. The API documentation says that the results have properties like Even if I check the value of Am I missing something? |
|
@jonrimmer there are two types here - “partial” object types, which are returned for objects that an integration can locate, but not access, and “full” object types that have all of the properties referenced in the documentation. You need to check for the presence of a full-object-only key in the response to prove to Typescript that the object is “full”. This is annoying to do, so I published a helper library (linked in the above post) that exports functions like From my library’s README: The Notion API can sometimes return "partial" object data that contain only the block's ID: // In @notionhq/client typings:
type PartialBlockObjectResponse = { object: 'block'; id: string };
export type GetBlockResponse = PartialBlockObjectResponse | BlockObjectResponse;Checking that a GetBlockResponse (or similar type) is a "full" block gets old pretty fast, so this library exports type guard functions to handle common cases, like isFullPage(page) and isFullBlock(block). isFullBlock can optionally narrow the type of block as well: if (isFullBlock(block, 'paragraph')) {
// It's a full paragraph block
console.log(richTextAsPlainText(block.paragraph.text));
} |
|
@jonrimmer This is most likely because of the heavy usage of union types, as explained in my previous comment here: #219 (comment) It acts like a least common denominator for type properties that you can see. |
|
This is still a gross situation as of @notionhq/client@1.04 .... One way to solve is to use @justjake 's @jitl/notion-api as mentioned above, the types are good and utils are helpful. However they are not up to date with latest API types from notion (e.g. status) that have been recently released. Alternatively if you want to battle your way with pulling out the types from the unions here are some type util helpers: @rhart92 you guys should consider exporting these as helper types as it does take a lot of messing around to start getting value out of the notion database queries atm. |
|
Hi, I recently made some changes to name many more response types and export them from this package in #319, so I am going to close this issue. These changes are available in version 2.1.0 of the SDK. If there are any more specific issues around types please open a new GitHub issue, thank you! |




I see that the individual block types have been removed and replaced with a large generic union on the responses of some queries.
for example (have removed some properties for clarity):
So a Block I guess can now be represented by:
The same goes for the Database type
But when I have a database that has properties on it like "Name" or "Slug", how do I correctly extend the properties type so that its possible to access it without TS complaining, before I could do something like:
But now that the TitlePropertyValue type doesn't exist, not really sure to handle the custom properties?
Any ideas?
Thanks
The text was updated successfully, but these errors were encountered: