@jitl/notion-api / Exports
- PropertyFilterDataMap
- PropertyType
- Property
- PropertyDataMap
- SelectPropertyValue
- MultiSelectPropertyValue
- FormulaPropertyValueType
- FormulaPropertyValue
- FormulaPropertyValueData
- PropertyPointerWithOutput
- Filter
- AnyPropertyFilter
- PropertyFilterType
- PropertyFilter
- CompoundFilter
- AndFilter
- OrFilter
- Sorts
- Sort
- TimestampSort
- PropertySort
- FilterOperatorTypeMap
- ExistenceFilterOperator
- TextFilterOperator
- NumberFilterOperator
- CheckboxFilterOperator
- SelectFilterOperator
- MultiSelectFilterOperator
- DateFilterOperator
- PeopleFilterOperator
- RelationFilterOperator
- FormulaFilterOperator
- RollupSubfilterOperator
- RollupFilterOperator
- PropertyToToFilterOperator
- PropertyFilterBuilder
- DatabaseFilterBuilder
- DatabaseSortBuilder
- Database
- DatabaseSchema
- PropertySchema
- PropertySchemaDataMap
- PartialPropertySchema
- PartialDatabaseSchema
- PartialDatabaseSchemaWithOnlyType
- PartialDatabaseSchemaFromSchemaWithOnlyType
- DatabaseSchemaDiff
- DatabasePropertyValues
- FilterOperator
- FilterOperatorType
- isFullBlock
- isFullBlockFilter
- getBlockData
- isBlockWithChildren
- getChildBlocks
- getChildBlocksWithChildrenRecursively
- getBlockWithChildren
- visitChildBlocks
- getAssetRequestKey
- getAssetRequestUrl
- getAssetRequestPathname
- parseAssetRequestQuery
- parseAssetRequestUrl
- performAssetRequest
- getAssetKey
- ensureImageDownloaded
- ensureEmojiCopied
- ensureAssetInDirectory
- isFullDatabase
- getPropertySchemaData
- inferDatabaseSchema
- diffDatabaseSchemas
- databaseSchemaDiffToString
- getAllProperties
- databaseFilterBuilder
- Filter
- Sort
- EXISTENCE_FILTER_OPERATORS
- TEXT_FILTER_OPERATORS
- NUMBER_FILTER_OPERATORS
- CHECKBOX_FILTER_OPERATORS
- SELECT_FILTER_OPERATORS
- MULTI_SELECT_FILTER_OPERATORS
- DATE_FILTER_OPERATORS
- PEOPLE_FILTER_OPERATORS
- RELATION_FILTER_OPERATORS
- FORMULA_FILTER_OPERATORS
- ROLLUP_FILTER_OPERATORS
- PROPERTY_FILTER_OPERATORS
- ALL_PROPERTY_FILTER_OPERATORS
- ASSET_REQUEST_QUERY_PATH_PARAM
- ASSET_REQUEST_LAST_EDITED_TIME_PARAM
- DOWNLOAD_PERMISSION_ERROR
- DOWNLOAD_HTTP_ERROR
A logger for the @notionhq/client Client that logs to the @jitl/notion-api namespace. Variables
- CMSCustomPropertyDerived
- CMSConfig
- CMSDefaultFrontmatter
- CMSPage
- CMSRetrieveOptions
- CMSQueryParametersOptions
- CMSScopeOptions
- CMSScope
Ƭ NotionClientDebugLogger: Logger
& NotionClientLoggers
A logger for the @notionhq/client Client that logs to the @jitl/notion-api namespace.
Ƭ EmptyObject: Record
<string
, never
>
Object with no properties.
Ƭ IdRequest: string
IDs in the Notion API are strings containing UUIDs.
Ƭ Page: Extract
<GetPageResponse
, { parent
: unknown
}>
A full Notion API page.
Ƭ PageWithChildren: Page
& { children
: BlockWithChildren
[] }
An extension of the Notion API page type that ads a children
attribute
forming a recursive tree of blocks.
Ƭ BlockType: AnyBlock
["type"
]
Type of any block.
Ƭ Block<Type
>: Extract
<AnyBlock
, { type
: Type
}>
A full Notion API block.
Name | Type |
---|---|
Type |
extends BlockType = BlockType |
Ƭ BlockDataMap: { [K in BlockType]: BlockTypeMap[K] extends { [key in K]: unknown } ? BlockTypeMap[K][K] : never }
Type-level map from a BlockType to the data of that block.
source
export type BlockDataMap = {
[K in BlockType]: BlockTypeMap[K] extends {
[key in K]: unknown;
} ? BlockTypeMap[K][K] : never;
};
Ƭ BlockWithChildren<Type
>: Block
<Type
> & { children
: BlockWithChildren
[] }
An extension of the Notion API block type that adds a children
attribute
forming a recursive tree of blocks.
Name | Type |
---|---|
Type |
extends BlockType = BlockType |
Ƭ RichText: Block
<"paragraph"
>["paragraph"
][typeof RICH_TEXT_BLOCK_PROPERTY
]
Notion API rich text. An array of rich text tokens.
Ƭ RichTextToken: any
[][number
]
A single token of rich text.
Ƭ MentionType: AnyMention
["mention"
]["type"
]
The type of mention.
Ƭ MentionData<Type
>: Extract
<AnyMention
["mention"
], { type
: Type
}>
The data of a mention type.
Name | Type |
---|---|
Type |
extends MentionType |
Ƭ Mention<Type
>: Omit
<AnyMention
, "mention"
> & { mention
: MentionData
<Type
> }
A mention token. (This type doesn't seem to work very well.)
Name | Type |
---|---|
Type |
extends MentionType = MentionType |
Ƭ PropertyFilterDataMap: { [K in PropertyType]: PropertyFilterTypeMap[K] extends { [key in K]: unknown } ? PropertyFilterTypeMap[K][K] : never }
Type-level map from property type to the inner filter of that property
source
export type PropertyFilterDataMap = {
[K in PropertyType]: PropertyFilterTypeMap[K] extends {
[key in K]: unknown;
} ? PropertyFilterTypeMap[K][K] : never;
};
Ƭ PropertyType: AnyProperty
["type"
]
The type of a property.
Ƭ Property<Type
>: Extract
<AnyProperty
, { type
: Type
}>
A property of a Notion page.
Name | Type |
---|---|
Type |
extends PropertyType = PropertyType |
Ƭ PropertyDataMap: { [K in PropertyType]: PropertyTypeMap[K] extends { [key in K]: unknown } ? PropertyTypeMap[K][K] : never }
Type-level map from property type to the data of that property.
source
export type PropertyDataMap = {
[K in PropertyType]: PropertyTypeMap[K] extends {
[key in K]: unknown;
} ? PropertyTypeMap[K][K] : never;
};
Ƭ SelectPropertyValue: NonNullable
<PropertyDataMap
["select"
]>
Ƭ MultiSelectPropertyValue: NonNullable
<PropertyDataMap
["multi_select"
]>
Ƭ FormulaPropertyValueType: AnyFormulaPropertyValue
["type"
]
Ƭ FormulaPropertyValue<Type
>: Extract
<AnyFormulaPropertyValue
, { type
: Type
}>
Name | Type |
---|---|
Type |
extends FormulaPropertyValueType = FormulaPropertyValueType |
Ƭ FormulaPropertyValueData: string
| number
| boolean
| DateResponse
| null
Ƭ PropertyPointerWithOutput<T
>: { [P in keyof PropertyDataMap]: PropertyDataMap[P] extends T | null ? PropertyPointer<P> : never }[PropertyType
]
A pointer to a property in a Notion API page of any property type that has
T
as the property data.
Name |
---|
T |
Ƭ DateResponse: DateMentionData
["date"
]
Notion date type.
Ƭ Filter: NonNullable
<QueryDatabaseParameters
["filter"
]>
Any kind of filter in a database query.
Ƭ AnyPropertyFilter: Extract
<Filter
, { type?
: string
}>
Ƭ PropertyFilterType: AnyPropertyFilter
["type"
]
Type of a property filter.
Ƭ PropertyFilter<Type
>: Extract
<AnyPropertyFilter
, { type?
: Type
}>
Property filters in a database query.
Name | Type |
---|---|
Type |
extends PropertyFilterType = PropertyFilterType |
Ƭ CompoundFilter: Exclude
<Filter
, PropertyFilter
>
Compound filters, like and
or or
.
Ƭ AndFilter: Extract
<CompoundFilter
, { and
: any
}>
Ƭ OrFilter: Extract
<CompoundFilter
, { or
: any
}>
Ƭ Sorts: NonNullable
<QueryDatabaseParameters
["sorts"
]>
Sorting for a database query.
Ƭ Sort: any
[][number
]
A single sort in a database query.
Ƭ TimestampSort: Extract
<Sort
, { timestamp
: any
}>
Ƭ PropertySort: Extract
<Sort
, { property
: any
}>
Ƭ FilterOperatorTypeMap<T
>: { [K in keyof UnionToIntersection<T>]: true }
An object mapping from filter operator name to true
.
Name |
---|
T |
Ƭ ExistenceFilterOperator: { is_empty
: true
} | { is_not_empty
: true
}
Ƭ TextFilterOperator: { equals
: string
} | { does_not_equal
: string
} | { contains
: string
} | { does_not_contain
: string
} | { starts_with
: string
} | { ends_with
: string
} | ExistenceFilterOperator
source
export type TextFilterOperator = {
equals: string;
} | {
does_not_equal: string;
} | {
contains: string;
} | {
does_not_contain: string;
} | {
starts_with: string;
} | {
ends_with: string;
} | ExistenceFilterOperator;
Ƭ NumberFilterOperator: { equals
: number
} | { does_not_equal
: number
} | { greater_than
: number
} | { less_than
: number
} | { greater_than_or_equal_to
: number
} | { less_than_or_equal_to
: number
} | ExistenceFilterOperator
source
export type NumberFilterOperator = {
equals: number;
} | {
does_not_equal: number;
} | {
greater_than: number;
} | {
less_than: number;
} | {
greater_than_or_equal_to: number;
} | {
less_than_or_equal_to: number;
} | ExistenceFilterOperator;
Ƭ CheckboxFilterOperator: { equals
: boolean
} | { does_not_equal
: boolean
}
source
export type CheckboxFilterOperator = {
equals: boolean;
} | {
does_not_equal: boolean;
};
Ƭ SelectFilterOperator: { equals
: string
} | { does_not_equal
: string
} | ExistenceFilterOperator
source
export type SelectFilterOperator = {
equals: string;
} | {
does_not_equal: string;
} | ExistenceFilterOperator;
Ƭ MultiSelectFilterOperator: { contains
: string
} | { does_not_contain
: string
} | ExistenceFilterOperator
source
export type MultiSelectFilterOperator = {
contains: string;
} | {
does_not_contain: string;
} | ExistenceFilterOperator;
Ƭ DateFilterOperator: { equals
: string
} | { before
: string
} | { after
: string
} | { on_or_before
: string
} | { on_or_after
: string
} | { past_week
: EmptyObject
} | { past_month
: EmptyObject
} | { past_year
: EmptyObject
} | { next_week
: EmptyObject
} | { next_month
: EmptyObject
} | { next_year
: EmptyObject
} | ExistenceFilterOperator
source
export type DateFilterOperator = {
equals: string;
} | {
before: string;
} | {
after: string;
} | {
on_or_before: string;
} | {
on_or_after: string;
} | {
past_week: EmptyObject;
} | {
past_month: EmptyObject;
} | {
past_year: EmptyObject;
} | {
next_week: EmptyObject;
} | {
next_month: EmptyObject;
} | {
next_year: EmptyObject;
} | ExistenceFilterOperator;
Ƭ PeopleFilterOperator: { contains
: IdRequest
} | { does_not_contain
: IdRequest
} | ExistenceFilterOperator
source
export type PeopleFilterOperator = {
contains: IdRequest;
} | {
does_not_contain: IdRequest;
} | ExistenceFilterOperator;
Ƭ RelationFilterOperator: { contains
: IdRequest
} | { does_not_contain
: IdRequest
} | ExistenceFilterOperator
source
export type RelationFilterOperator = {
contains: IdRequest;
} | {
does_not_contain: IdRequest;
} | ExistenceFilterOperator;
Ƭ FormulaFilterOperator: { string
: TextFilterOperator
} | { checkbox
: CheckboxFilterOperator
} | { number
: NumberFilterOperator
} | { date
: DateFilterOperator
}
source
export type FormulaFilterOperator = {
string: TextFilterOperator;
} | {
checkbox: CheckboxFilterOperator;
} | {
number: NumberFilterOperator;
} | {
date: DateFilterOperator;
};
Ƭ RollupSubfilterOperator: { rich_text
: TextFilterOperator
} | { number
: NumberFilterOperator
} | { checkbox
: CheckboxFilterOperator
} | { select
: SelectFilterOperator
} | { multi_select
: MultiSelectFilterOperator
} | { relation
: RelationFilterOperator
} | { date
: DateFilterOperator
} | { people
: PeopleFilterOperator
} | { files
: ExistenceFilterOperator
}
source
export type RollupSubfilterOperator = {
rich_text: TextFilterOperator;
} | {
number: NumberFilterOperator;
} | {
checkbox: CheckboxFilterOperator;
} | {
select: SelectFilterOperator;
} | {
multi_select: MultiSelectFilterOperator;
} | {
relation: RelationFilterOperator;
} | {
date: DateFilterOperator;
} | {
people: PeopleFilterOperator;
} | {
files: ExistenceFilterOperator;
};
Ƭ RollupFilterOperator: { any
: RollupSubfilterOperator
} | { none
: RollupSubfilterOperator
} | { every
: RollupSubfilterOperator
} | { date
: DateFilterOperator
} | { number
: NumberFilterOperator
}
source
export type RollupFilterOperator = {
any: RollupSubfilterOperator;
} | {
none: RollupSubfilterOperator;
} | {
every: RollupSubfilterOperator;
} | {
date: DateFilterOperator;
} | {
number: NumberFilterOperator;
};
Ƭ PropertyToToFilterOperator: Object
This duplicates PropertyFilterDataMap, but seems more correct.
source
export type PropertyToToFilterOperator = {
title: TextFilterOperator;
rich_text: TextFilterOperator;
number: NumberFilterOperator;
checkbox: CheckboxFilterOperator;
select: SelectFilterOperator;
multi_select: MultiSelectFilterOperator;
date: DateFilterOperator;
people: PeopleFilterOperator;
files: ExistenceFilterOperator;
url: TextFilterOperator;
email: TextFilterOperator;
phone_number: TextFilterOperator;
relation: RelationFilterOperator;
created_by: PeopleFilterOperator;
created_time: DateFilterOperator;
last_edited_by: PeopleFilterOperator;
last_edited_time: DateFilterOperator;
formula: FormulaFilterOperator;
rollup: RollupFilterOperator;
};
Name | Type |
---|---|
title |
TextFilterOperator |
rich_text |
TextFilterOperator |
number |
NumberFilterOperator |
checkbox |
CheckboxFilterOperator |
select |
SelectFilterOperator |
multi_select |
MultiSelectFilterOperator |
date |
DateFilterOperator |
people |
PeopleFilterOperator |
files |
ExistenceFilterOperator |
url |
TextFilterOperator |
email |
TextFilterOperator |
phone_number |
TextFilterOperator |
relation |
RelationFilterOperator |
created_by |
PeopleFilterOperator |
created_time |
DateFilterOperator |
last_edited_by |
PeopleFilterOperator |
last_edited_time |
DateFilterOperator |
formula |
FormulaFilterOperator |
rollup |
RollupFilterOperator |
Ƭ PropertyFilterBuilder<Type
>: { schema
: PropertyPointer
<Type
> } & { [K in FilterOperatorType<Type>]: Function }
Contains a key for each filter operator for this property type. This allows easy tab completion when building filters for a database query.
Create with propertyFilterBuilder, or use one created as part of CMS.filter or databaseFilterBuilder.
Name | Type |
---|---|
Type |
extends PropertyType |
Ƭ DatabaseFilterBuilder<T
>: { [K in keyof T]: PropertyFilterBuilder<T[K]["type"]> } & typeof Filter
& { schema
: T
}
Contains a PropertyFilterBuilder for each property in a PartialDatabaseSchema.
Create one with databaseFilterBuilder, or use the filter builders from CMS.filter.
Name | Type |
---|---|
T |
extends PartialDatabaseSchema |
Ƭ DatabaseSortBuilder<T
>: TimestampSortBuilder
& { [K in keyof T]: Object & SortBuilder<PropertySort> }
For each property in PartialDatabaseSchema
Create one with databaseSortBuilder or use the sort builders from CMS.sort.
Name | Type |
---|---|
T |
extends PartialDatabaseSchema |
Ƭ User: GetUserResponse
Person or Bot
Ƭ Person: Extract
<User
, { type
: "person"
}>
Person
Ƭ Bot: Extract
<User
, { type
: "bot"
}>
Bot
Ƭ CMSCustomPropertyPointer<T
>: Object
Specifies that the CMS should look up a custom property from regular Page property. Consider using this with a formula property for maximum flexibility.
See CMSConfig.
source
export type CMSCustomPropertyPointer<T> = {
type: 'property';
/** Indicates which property to fetch data from */
property: PropertyPointerWithOutput<T>;
};
Name |
---|
T |
Name | Type | Description |
---|---|---|
type |
"property" |
- |
property |
PropertyPointerWithOutput <T > |
Indicates which property to fetch data from |
lib/content-management-system.ts:71
Ƭ CMSSchemaPropertyPointer<T
, Schema
>: { [K in keyof Schema]: Schema[K] extends PropertyPointerWithOutput<T> ? K : never }[keyof Schema
]
Property key name in a database schema. Specifies that the CMS should look up a property in the page's schema.
For a database schema { name: { type: 'rich_text', name: 'Name', id: 'qX124' } }
,
a valid CMSSchemaPropertyPointer<RichText, typeof schema> would be 'name'
.
See CMSConfig, CMSConfig.schema.
Name | Type |
---|---|
T |
T |
Schema |
extends PartialDatabaseSchema |
lib/content-management-system.ts:109
Ƭ CMSCustomProperty<T
, CustomFrontmatter
, Schema
>: CMSSchemaPropertyPointer
<T
, Schema
> | CMSCustomPropertyPointer
<T
> | CMSCustomPropertyDerived
<T
, CustomFrontmatter
, Schema
>
Specifies how a CMS should get a custom property.
See CMSConfig.
source
export type CMSCustomProperty<T, CustomFrontmatter, Schema extends PartialDatabaseSchema> = CMSSchemaPropertyPointer<T, Schema> | CMSCustomPropertyPointer<T> | CMSCustomPropertyDerived<T, CustomFrontmatter, Schema>;
Name | Type |
---|---|
T |
T |
CustomFrontmatter |
CustomFrontmatter |
Schema |
extends PartialDatabaseSchema |
lib/content-management-system.ts:121
Ƭ CMSFrontmatter<CustomFrontmatter
>: CMSDefaultFrontmatter
& Omit
<CustomFrontmatter
, keyof CMSDefaultFrontmatter
>
The frontmatter of a CMSPage.
source
export type CMSFrontmatter<CustomFrontmatter> = CMSDefaultFrontmatter & Omit<CustomFrontmatter, keyof CMSDefaultFrontmatter>;
Name |
---|
CustomFrontmatter |
lib/content-management-system.ts:345
Ƭ CMSPageOf<T
>: T
extends CMS
<infer CustomFrontmatter, any
> ? CMSPage
<CustomFrontmatter
> : never
Get the CMSPage type from a CMS.
const MyCMS = new CMS({ ... })
type MyPage = CMSPageOf<typeof MyCMS>;
Name | Type |
---|---|
T |
extends CMS <any , any > |
lib/content-management-system.ts:365
Ƭ Asset: NonNullable
<Page
["icon"
]>
An internal, external or emoji asset from the Notion API.
Ƭ AssetRequest: { object
: "page"
; id
: string
; field
: "icon"
} | { object
: "page"
; id
: string
; field
: "cover"
} | { object
: "page"
; id
: string
; field
: "properties"
; property
: PropertyPointer
<any
> ; propertyIndex?
: number
} | { object
: "block"
; id
: string
; field
: "image"
} | { object
: "block"
; id
: string
; field
: "file"
} | { object
: "block"
; id
: string
; field
: "icon"
} | { object
: "user"
; id
: string
; field
: "avatar_url"
}
An AssetRequest indicates an asset within a Notion API object, such as a page icon or a image block's image.
source
export type AssetRequest = {
object: 'page';
id: string;
field: 'icon';
} | {
object: 'page';
id: string;
field: 'cover';
} | {
object: 'page';
id: string;
field: 'properties';
property: PropertyPointer<any>;
propertyIndex?: number; // assumed to be 0
} | {
object: 'block';
id: string;
field: 'image';
} | {
object: 'block';
id: string;
field: 'file';
} | {
object: 'block';
id: string;
field: 'icon';
} // eg, for callout block
| {
object: 'user';
id: string;
field: 'avatar_url';
};
Ƭ CacheBehavior: "read-only"
| "fill"
| "refresh"
source
export type CacheBehavior =
/** Read from the cache, but don't update it */
'read-only'
/** Read from the cache, or update it if needed. */
| 'fill'
/** Don't read from the cache, and update it with new values */
| 'refresh';
Ƭ Database: Extract
<GetDatabaseResponse
, { title
: unknown
}>
A full database from the Notion API.
Ƭ DatabaseSchema: Database
["properties"
]
The properties that a Database has.
Ƭ PropertySchema<Type
>: Extract
<AnyPropertySchema
, { type
: Type
}>
A property type of the pages in a Database. Think of this like a column in a SQL database.
WARNING: the documented name of this is "Property", WARNING: the documented name of page properties is "PropertyValue".
Name | Type |
---|---|
Type |
extends PropertyType = PropertyType |
Ƭ PropertySchemaDataMap: { [K in PropertyType]: PropertySchemaTypeMap[K] extends { [key in K]: unknown } ? PropertySchemaTypeMap[K][K] : never }
Type-level map from property type to the schema data of that property.
source
export type PropertySchemaDataMap = {
[K in PropertyType]: PropertySchemaTypeMap[K] extends {
[key in K]: unknown;
} ? PropertySchemaTypeMap[K][K] : never;
};
Ƭ PartialPropertySchema<Type
>: Partial
<PropertySchema
<Type
>> & { name
: string
; type
: Type
}
A partial PropertySchema that contains at least the type
field.
Used to create a PartialDatabaseSchema.
Name | Type |
---|---|
Type |
extends PropertyType = PropertyType |
Ƭ PartialDatabaseSchema: Record
<string
, PartialPropertySchema
>
A partial DatabaseSchema that contains at least the type
field of any defined property.
Ƭ PartialDatabaseSchemaWithOnlyType: Record
<string
, Partial
<PropertySchema
> & { type
: PropertyType
}>
Used in inferDatabaseSchema.
Ƭ PartialDatabaseSchemaFromSchemaWithOnlyType<T
>: Assert
<PartialDatabaseSchema
, { [K in keyof T]: T[K] & PartialPropertySchema<T[K]["type"]> }>
Used in inferDatabaseSchema.
Name | Type |
---|---|
T |
extends PartialDatabaseSchemaWithOnlyType |
Ƭ DatabaseSchemaDiff<Before
, After
>: { type
: "key"
; property
: PropertyDiffPointer
; before
: keyof Before
; after
: keyof After
} | { type
: `property.id.${"added" | "removed"}` ; property
: { name
: string
} ; id
: string
} | { type
: "property.type"
; property
: PropertyDiffPointer
; before
: PropertyType
; after
: PropertyType
} | { type
: "property.name"
; property
: { id
: string
} ; before
: string
; after
: string
} | { type
: "property.schema"
; before
: PropertySchema
; after
: PropertySchema
} | { type
: "removed"
; property
: Assert
<PropertyDiffPointer
, PartialPropertySchema
> ; before
: keyof Before
} | { type
: "added"
; property
: Assert
<PropertyDiffPointer
, PartialPropertySchema
> ; after
: keyof After
}
Name | Type |
---|---|
Before |
extends PartialDatabaseSchema |
After |
extends PartialDatabaseSchema |
Ƭ DatabasePropertyValues<T
>: { [K in keyof T]?: PropertyDataMap[T[K]["type"]] }
Name | Type |
---|---|
T |
extends PartialDatabaseSchema |
Ƭ FilterOperator<Type
>: PropertyToToFilterOperator
[Type
]
Name | Type |
---|---|
Type |
extends PropertyType = PropertyType |
Ƭ FilterOperatorType<Type
>: keyof UnionToIntersection
<FilterOperator
<Type
>>
Name | Type |
---|---|
Type |
extends PropertyType = PropertyType |
▸ isNotionDomain(domain
): boolean
Name | Type |
---|---|
domain |
string |
boolean
▸ uuidWithDashes(id
): string
Ensure a UUID has dashes, since sometimes Notion IDs don't have dashes.
Name | Type |
---|---|
id |
string |
string
▸ iteratePaginatedAPI<Args
, Item
>(listFn
, firstPageArgs
): AsyncIterableIterator
<Item
>
Iterate over all results in a paginated list API.
for await (const block of iteratePaginatedAPI(notion.blocks.children.list, {
block_id: parentBlockId,
})) {
// Do something with block.
}
Name | Type |
---|---|
Args |
extends PaginatedArgs |
Item |
Item |
Name | Type | Description |
---|---|---|
listFn |
(args : Args ) => Promise <PaginatedList <Item >> |
API to call |
firstPageArgs |
Args |
These arguments are used for each page, with an updated start_cursor . |
AsyncIterableIterator
<Item
>
▸ asyncIterableToArray<T
>(iterable
): Promise
<T
[]>
Gather all an async iterable's items into an array.
const iterator = iteratePaginatedAPI(notion.blocks.children.list, { block_id: parentBlockId });
const blocks = await asyncIterableToArray(iterator);
const paragraphs = blocks.filter(block => isFullBlock(block, 'paragraph'))
Name |
---|
T |
Name | Type |
---|---|
iterable |
AsyncIterable <T > |
Promise
<T
[]>
▸ getPageTitle(page
): any
[]
Name | Type |
---|---|
page |
Object |
any
[]
The title of page
, as RichText.
lib/content-management-system.ts:1052
▸ isFullPage(page
): page is Object
The Notion API may return a "partial" page object if your API token can't access the page.
This function confirms that all page data is available.
Name | Type |
---|---|
page |
GetPageResponse |
page is Object
▸ isPageWithChildren(page
): page is PageWithChildren
Name | Type |
---|---|
page |
GetPageResponse |
page is PageWithChildren
▸ isFullBlock(block
): block is Block<"paragraph" | "heading_1" | "heading_2" | "heading_3" | "bulleted_list_item" | "numbered_list_item" | "quote" | "to_do" | "toggle" | "template" | "synced_block" | "child_page" | "child_database" | "equation" | "code" | "callout" | "divider" | "breadcrumb" | "table_of_contents" | "column_list" | "column" | "link_to_page" | "table" | "table_row" | "embed" | "bookmark" | "image" | "video" | "pdf" | "file" | "audio" | "link_preview" | "unsupported">
The Notion API may return a "partial" block object if your API token can't access the block.
This function confirms that all block data is available.
Name | Type |
---|---|
block |
GetBlockResponse |
block is Block<"paragraph" | "heading_1" | "heading_2" | "heading_3" | "bulleted_list_item" | "numbered_list_item" | "quote" | "to_do" | "toggle" | "template" | "synced_block" | "child_page" | "child_database" | "equation" | "code" | "callout" | "divider" | "breadcrumb" | "table_of_contents" | "column_list" | "column" | "link_to_page" | "table" | "table_row" | "embed" | "bookmark" | "image" | "video" | "pdf" | "file" | "audio" | "link_preview" | "unsupported">
▸ isFullBlock<Type
>(block
, blockType
): block is Block<Type>
The Notion API may return a "partial" block object if your API token can't access the block.
This function confirms that all block data is available, and the block has
type blockType
.
Name | Type |
---|---|
Type |
extends "paragraph" | "heading_1" | "heading_2" | "heading_3" | "bulleted_list_item" | "numbered_list_item" | "quote" | "to_do" | "toggle" | "template" | "synced_block" | "child_page" | "child_database" | "equation" | "code" | "callout" | "divider" | "breadcrumb" | "table_of_contents" | "column_list" | "column" | "link_to_page" | "table" | "table_row" | "embed" | "bookmark" | "image" | "video" | "pdf" | "file" | "audio" | "link_preview" | "unsupported" |
Name | Type |
---|---|
block |
GetBlockResponse |
blockType |
Type |
block is Block<Type>
▸ isFullBlockFilter<Type
>(type
): BlockFilterFunction
<Type
>
Returns a filter type guard for blocks of the given type
.
See isFullBlock for more information.
const paragraphs: Array<Block<"paragraph">> = blocks.filter(isFullBlockFilter("paragraph"));
Name | Type |
---|---|
Type |
extends "paragraph" | "heading_1" | "heading_2" | "heading_3" | "bulleted_list_item" | "numbered_list_item" | "quote" | "to_do" | "toggle" | "template" | "synced_block" | "child_page" | "child_database" | "equation" | "code" | "callout" | "divider" | "breadcrumb" | "table_of_contents" | "column_list" | "column" | "link_to_page" | "table" | "table_row" | "embed" | "bookmark" | "image" | "video" | "pdf" | "file" | "audio" | "link_preview" | "unsupported" |
Name | Type |
---|---|
type |
Type |
BlockFilterFunction
<Type
>
▸ getBlockData<Type
>(block
): BlockDataMap
[Type
]
Generic way to get a block's data.
Name | Type |
---|---|
Type |
extends "paragraph" | "heading_1" | "heading_2" | "heading_3" | "bulleted_list_item" | "numbered_list_item" | "quote" | "to_do" | "toggle" | "template" | "synced_block" | "child_page" | "child_database" | "equation" | "code" | "callout" | "divider" | "breadcrumb" | "table_of_contents" | "column_list" | "column" | "link_to_page" | "table" | "table_row" | "embed" | "bookmark" | "image" | "video" | "pdf" | "file" | "audio" | "link_preview" | "unsupported" |
Name | Type |
---|---|
block |
Block <Type > |
BlockDataMap
[Type
]
▸ isBlockWithChildren(block
): block is BlockWithChildren<"paragraph" | "heading_1" | "heading_2" | "heading_3" | "bulleted_list_item" | "numbered_list_item" | "quote" | "to_do" | "toggle" | "template" | "synced_block" | "child_page" | "child_database" | "equation" | "code" | "callout" | "divider" | "breadcrumb" | "table_of_contents" | "column_list" | "column" | "link_to_page" | "table" | "table_row" | "embed" | "bookmark" | "image" | "video" | "pdf" | "file" | "audio" | "link_preview" | "unsupported">
Name | Type |
---|---|
block |
GetBlockResponse |
block is BlockWithChildren<"paragraph" | "heading_1" | "heading_2" | "heading_3" | "bulleted_list_item" | "numbered_list_item" | "quote" | "to_do" | "toggle" | "template" | "synced_block" | "child_page" | "child_database" | "equation" | "code" | "callout" | "divider" | "breadcrumb" | "table_of_contents" | "column_list" | "column" | "link_to_page" | "table" | "table_row" | "embed" | "bookmark" | "image" | "video" | "pdf" | "file" | "audio" | "link_preview" | "unsupported">
▸ getChildBlocks(notion
, parentBlockId
): Promise
<Block
[]>
Fetch all supported children of a block.
Name | Type |
---|---|
notion |
default |
parentBlockId |
string |
Promise
<Block
[]>
▸ getChildBlocksWithChildrenRecursively(notion
, parentId
): Promise
<BlockWithChildren
[]>
Recursively fetch all children of parentBlockId
as BlockWithChildren
.
This function can be used to fetch an entire page's contents in one call.
Name | Type |
---|---|
notion |
default |
parentId |
string |
Promise
<BlockWithChildren
[]>
▸ getBlockWithChildren(notion
, blockId
): Promise
<BlockWithChildren
| undefined
>
Name | Type |
---|---|
notion |
default |
blockId |
string |
Promise
<BlockWithChildren
| undefined
>
▸ visitChildBlocks(blocks
, fn
): void
Recurse over the blocks and their children, calling fn
on each block.
Name | Type |
---|---|
blocks |
BlockWithChildren <"paragraph" | "heading_1" | "heading_2" | "heading_3" | "bulleted_list_item" | "numbered_list_item" | "quote" | "to_do" | "toggle" | "template" | "synced_block" | "child_page" | "child_database" | "equation" | "code" | "callout" | "divider" | "breadcrumb" | "table_of_contents" | "column_list" | "column" | "link_to_page" | "table" | "table_row" | "embed" | "bookmark" | "image" | "video" | "pdf" | "file" | "audio" | "link_preview" | "unsupported" >[] |
fn |
(block : BlockWithChildren <"paragraph" | "heading_1" | "heading_2" | "heading_3" | "bulleted_list_item" | "numbered_list_item" | "quote" | "to_do" | "toggle" | "template" | "synced_block" | "child_page" | "child_database" | "equation" | "code" | "callout" | "divider" | "breadcrumb" | "table_of_contents" | "column_list" | "column" | "link_to_page" | "table" | "table_row" | "embed" | "bookmark" | "image" | "video" | "pdf" | "file" | "audio" | "link_preview" | "unsupported" >) => void |
void
▸ richTextAsPlainText(richText
): string
Name | Type |
---|---|
richText |
undefined | string | RichTextItemResponse [] |
string
Plaintext string of rich text.
▸ visitTextTokens(object
, fn
): void
Visit all text tokens in a block or page. Relations are treated as mention tokens. Does not consider children.
Name | Type |
---|---|
object |
{} | Block <"paragraph" | "heading_1" | "heading_2" | "heading_3" | "bulleted_list_item" | "numbered_list_item" | "quote" | "to_do" | "toggle" | "template" | "synced_block" | "child_page" | "child_database" | "equation" | "code" | "callout" | "divider" | "breadcrumb" | "table_of_contents" | "column_list" | "column" | "link_to_page" | "table" | "table_row" | "embed" | "bookmark" | "image" | "video" | "pdf" | "file" | "audio" | "link_preview" | "unsupported" > |
fn |
(token : RichTextItemResponse ) => void |
void
▸ getPropertyData<Type
>(property
): PropertyDataMap
[Type
]
Generic way to get a property's data. Suggested usage is with a switch statement on property.type to narrow the result.
switch (prop.type) {
case 'title':
case 'rich_text':
getPropertyData(prop).forEach((token) => fn(token));
break;
// ...
}
Name | Type |
---|---|
Type |
extends "number" | "rich_text" | "date" | "url" | "select" | "multi_select" | "email" | "phone_number" | "checkbox" | "files" | "created_by" | "created_time" | "last_edited_by" | "last_edited_time" | "formula" | "title" | "people" | "relation" | "rollup" |
Name | Type |
---|---|
property |
Property <Type > |
PropertyDataMap
[Type
]
▸ getFormulaPropertyValueData(propertyValue
): FormulaPropertyValueData
Name | Type |
---|---|
propertyValue |
FormulaPropertyValue <"string" | "number" | "boolean" | "date" > |
▸ getProperty(page
, property
): Property
| undefined
Get the property with name
and/or id
from page
.
Name | Type | Description |
---|---|---|
page |
Object |
|
property |
Pick <PropertyPointer <"number" | "rich_text" | "date" | "url" | "select" | "multi_select" | "email" | "phone_number" | "checkbox" | "files" | "created_by" | "created_time" | "last_edited_by" | "last_edited_time" | "formula" | "title" | "people" | "relation" | "rollup" >, "name" | "id" > |
Which property? |
Property
| undefined
The property with that name or id, or undefined if not found.
▸ getPropertyValue<Type
>(page
, propertyPointer
): PropertyDataMap
[Type
] | undefined
Get the value of property propertyPointer
in page
.
Name | Type |
---|---|
Type |
extends "number" | "rich_text" | "date" | "url" | "select" | "multi_select" | "email" | "phone_number" | "checkbox" | "files" | "created_by" | "created_time" | "last_edited_by" | "last_edited_time" | "formula" | "title" | "people" | "relation" | "rollup" |
Name | Type |
---|---|
page |
Object |
propertyPointer |
PropertyPointer <Type > |
PropertyDataMap
[Type
] | undefined
The value of the property, or undefined
if the property isn't found, or has a different type.
▸ getPropertyValue<Type
, T
>(page
, propertyPointer
, transform
): T
| undefined
Get the value of property propertyPointer
in page
, transformed by transform
.
Name | Type |
---|---|
Type |
extends "number" | "rich_text" | "date" | "url" | "select" | "multi_select" | "email" | "phone_number" | "checkbox" | "files" | "created_by" | "created_time" | "last_edited_by" | "last_edited_time" | "formula" | "title" | "people" | "relation" | "rollup" |
T |
T |
Name | Type |
---|---|
page |
Object |
propertyPointer |
PropertyPointer <Type > |
transform |
(propertyValue : PropertyDataMap [Type ]) => T |
T
| undefined
The result of as(propertyValue)
, or undefined
if the property isn't found or has a different type.
▸ getPropertyValue<T
>(page
, propertyPointer
): T
| undefined
Get the value of property propertyPointer
in page
.
Name |
---|
T |
Name | Type |
---|---|
page |
Object |
propertyPointer |
PropertyPointerWithOutput <T > |
T
| undefined
The value of the property, or undefined
if the property isn't found, or has a different type.
▸ getPropertyValue<P
, T
>(page
, propertyPointer
, transform
): T
| undefined
Get the value of property propertyPointer
in page
, transformed by transform
.
Name |
---|
P |
T |
Name | Type |
---|---|
page |
Object |
propertyPointer |
PropertyPointerWithOutput <P > |
transform |
(propertyValue : P ) => T |
T
| undefined
The result of as(propertyValue)
, or undefined
if the property isn't found or has a different type.
▸ getAllProperties<Schema
>(page
, schema
): DatabasePropertyValues
<Schema
>
Get all properties in a schema from the database.
Name | Type |
---|---|
Schema |
extends PartialDatabaseSchema |
Name | Type |
---|---|
page |
Object |
schema |
Schema |
DatabasePropertyValues
<Schema
>
▸ notionDateStartAsDate(date
): Date
Convert a Notion date's start into a Javascript Date object.
Name | Type |
---|---|
date |
DateResponse | Date |
Date
▸ notionDateStartAsDate(date
): Date
| undefined
Convert a Notion date's start into a Javascript Date object.
Name | Type |
---|---|
date |
undefined | DateResponse | Date |
Date
| undefined
▸ propertyFilterBuilder<Type
>(property
): PropertyFilterBuilder
<Type
>
Helper object for building PropertyFilters for the given property
.
Name | Type |
---|---|
Type |
extends "number" | "rich_text" | "date" | "url" | "select" | "multi_select" | "email" | "phone_number" | "checkbox" | "files" | "created_by" | "created_time" | "last_edited_by" | "last_edited_time" | "formula" | "title" | "people" | "relation" | "rollup" |
Name | Type | Description |
---|---|---|
property |
PropertyPointer <Type > |
Property to build a filter for. |
PropertyFilterBuilder
<Type
>
a property filter builder.
▸ databaseFilterBuilder<T
>(schema
): DatabaseFilterBuilder
<T
>
Helper object for building PropertyFilters for the properties in the given schema
.
Name | Type |
---|---|
T |
extends PartialDatabaseSchema |
Name | Type | Description |
---|---|---|
schema |
T |
Database schema to build filters for. |
A property filter builder for schema property, plus compound filter builders.
▸ databaseSortBuilder<T
>(schema
): DatabaseSortBuilder
<T
>
Name | Type |
---|---|
T |
extends PartialDatabaseSchema |
Name | Type |
---|---|
schema |
T |
▸ extendQueryParameters(base
, extension
): QueryDatabaseParameters
Extend a base query with additional filters, sorts, etc.
Filters will be and
ed together and sorts concatenated.
Name | Type |
---|---|
base |
QueryDatabaseParameters |
extension |
Partial <QueryDatabaseParameters > |
QueryDatabaseParameters
▸ defaultSlug(page
): string
Name | Type |
---|---|
page |
Object |
string
The default slug for the page, based on the page's ID.
lib/content-management-system.ts:1042
▸ getPageTitle(page
): any
[]
Name | Type |
---|---|
page |
Object |
any
[]
The title of page
, as RichText.
lib/content-management-system.ts:1052
▸ getCustomPropertyValue<T
, CustomFrontmatter
, Schema
>(customProperty
, page
, cms
): Promise
<T
| undefined
>
Compute a custom property.
Name | Type |
---|---|
T |
T |
CustomFrontmatter |
CustomFrontmatter |
Schema |
extends PartialDatabaseSchema |
Name | Type | Description |
---|---|---|
customProperty |
CMSCustomProperty <T , CustomFrontmatter , Schema > |
The custom property to compute. |
page |
{} | PageWithChildren |
|
cms |
CMS <CustomFrontmatter , Schema > |
Promise
<T
| undefined
>
lib/content-management-system.ts:1091
▸ getAssetRequestKey(assetRequest
): string
Get a unique string key for de-duplicating AssetRequests
Name | Type |
---|---|
assetRequest |
AssetRequest |
string
▸ getAssetRequestUrl(assetRequest
, baseUrl
, last_edited_time
): URL
Build a URL to GET an asset.
Name | Type | Description |
---|---|---|
assetRequest |
AssetRequest |
- |
baseUrl |
URL |
The base URL where the asset request handler is mounted (ending with a /), eg https://mydomain.com/api/notion-assets/ . |
last_edited_time |
undefined | string |
- |
URL
▸ getAssetRequestPathname(assetRequest
, basePathOrURL
, last_edited_time
): string
Get an absolute pathname (eg /api/notion-assets/...
) for the given asset request.
Name | Type | Description |
---|---|---|
assetRequest |
AssetRequest |
The asset request. |
basePathOrURL |
string | URL |
Eg /api/notion-assets/ . A path or URL ending with a '/'. |
last_edited_time |
undefined | string |
The last_edited_time of the object that contains this asset, for immutable caching. |
string
▸ parseAssetRequestQuery(query
): ParsedAssetRequest
Parse an AssetRequest from a NextJS-style query object.
Name | Type |
---|---|
query |
AssetRequestNextJSQuery | NextJSQuery |
▸ parseAssetRequestUrl(assetUrl
, baseURL
): ParsedAssetRequest
Inverse of getAssetRequestUrl.
Name | Type |
---|---|
assetUrl |
string | URL |
baseURL |
URL |
▸ performAssetRequest(args
): Promise
<undefined
| Asset
>
Look up an asset from the Notion API.
Name | Type |
---|---|
args |
Object |
args.notion |
default |
args.cache |
NotionObjectIndex |
args.request |
AssetRequest |
Promise
<undefined
| Asset
>
▸ getAssetKey(asset
): string
Name | Type |
---|---|
asset |
Asset |
string
a string key unique for the asset, suitable for use in a hashmap, cache, or filename.
▸ ensureImageDownloaded(args
): Promise
<string
| undefined
>
Download image at url
to a path in directory
starting with
filenamePrefix
if it does not exist, or return the existing path on disk
that has that prefix.
Name | Type |
---|---|
args |
Object |
args.url |
string |
args.filenamePrefix |
string |
args.directory |
string |
args.cacheBehavior? |
CacheBehavior |
Promise
<string
| undefined
>
Promise Relative path from directory
to image on disk.
▸ ensureEmojiCopied(args
): Promise
<string
| undefined
>
Copy an emoji image for emoji
into directory
.
Name | Type | Description |
---|---|---|
args |
Object |
- |
args.emoji |
string |
- |
args.directory |
string |
- |
args.filenamePrefix |
string |
- |
args.emojiSourceDirectory? |
string |
Path to directory containing emoji images. The directory should have contents like this: https://github.com/iamcal/emoji-data/tree/1ddc9ca67c1379c372b4ca39824659f71caa2825/img-apple-160 If undefined, this path will be looked up using require.resolve('emoji-datasource-apple') , or fall back to ${process.cwd()}/node_modules/emoji-datasource-apple/img/apple/64 . |
args.cacheBehavior? |
CacheBehavior |
- |
Promise
<string
| undefined
>
relative path from directory
to the image.
▸ ensureAssetInDirectory(args
): Promise
<string
| undefined
>
Ensure asset
is present on disk in directory
.
Name | Type | Description |
---|---|---|
args |
Object |
- |
args.asset |
Asset |
- |
args.directory |
string |
- |
args.emojiSourceDirectory? |
string |
See ensureEmojiCopied |
args.cacheBehavior? |
CacheBehavior |
- |
Promise
<string
| undefined
>
Relative path from directory
to the asset on disk, or undefined.
▸ buildBacklinks(pages
, backlinks?
): Backlinks
Crawl the given pages
and build all the backlinks between them into backlinks
.
If no Backlinks is given, a new one will be created and returned.
Name | Type |
---|---|
pages |
PageWithChildren [] |
backlinks |
Backlinks |
▸ getFromCache<T1
, T2
>(cacheBehavior
, fromCache
, fromScratch
): [T1
, true
] | Promise
<[T2
, false
]>
Either returns a value by calling fromCache
, or by calling fromScratch
,
depending on cacheBehavior
.
Name |
---|
T1 |
T2 |
Name | Type | Description |
---|---|---|
cacheBehavior |
undefined | CacheBehavior |
"fill" by default. |
fromCache |
() => undefined | T1 |
Function to read the value from the cache. |
fromScratch |
() => Promise <T2 > |
Function to compute the value from scratch. |
[T1
, true
] | Promise
<[T2
, false
]>
[value, hit]
where hit
is true
if the value was fetched from the cache.
▸ fillCache(cacheBehavior
, fill
): void
Possibly call fill
to fill the cache, depending on cacheBehavior
.
Name | Type | Description |
---|---|---|
cacheBehavior |
undefined | CacheBehavior |
"fill" by default. |
fill |
() => void |
Function to fill the cache. |
void
▸ fillCache(cacheBehavior
, hit
, fill
): void
Possibly call fill
to fill the cache, depending on cacheBehavior
and hit
.
If hit
is true, or cacheBehavior
is "read-only"
, then fill
is not called.
Name | Type | Description |
---|---|---|
cacheBehavior |
undefined | CacheBehavior |
"fill" by default. |
hit |
boolean |
- |
fill |
() => void |
Function to fill the cache. |
void
▸ isFullDatabase(database
): database is Object
The Notion API may return a "partial" database object if your API token doesn't have permission for the full database.
This function confirms that all database data is available.
Name | Type |
---|---|
database |
GetDatabaseResponse |
database is Object
▸ getPropertySchemaData<Type
>(propertySchema
): PropertySchemaDataMap
[Type
]
Get the type-specific schema data of propertySchema
.
Name | Type |
---|---|
Type |
extends "number" | "rich_text" | "date" | "url" | "select" | "multi_select" | "email" | "phone_number" | "checkbox" | "files" | "created_by" | "created_time" | "last_edited_by" | "last_edited_time" | "formula" | "title" | "people" | "relation" | "rollup" |
Name | Type |
---|---|
propertySchema |
PropertySchema <Type > |
PropertySchemaDataMap
[Type
]
▸ inferDatabaseSchema<T
>(schema
): PartialDatabaseSchemaFromSchemaWithOnlyType
<T
>
This function helps you infer a concrete subtype of PartialDatabaseSchema
for use with other APIs in this package. It will fill in missing name
fields of each PartialPropertySchema with the object's key.
Use the fields of the returned schema to access a page's properties via getPropertyValue or getProperty.
You can check or update your inferred schema against data fetched from the API with [[compareDatabaseSchema]].
const mySchema = inferDatabaseSchema({
Title: { type: 'title' },
SubTitle: { type: 'rich_text', name: 'Subtitle' },
PublishedDate: { type: 'date', name: 'Published Date' },
IsPublished: {
type: 'checkbox',
name: 'Show In Production',
id: 'asdf123',
},
});
// inferDatabaseSchema infers a concrete type with the same shape as the input,
// so you can reference properties easily. It also adds `name` to each [PropertySchema](modules.md#propertyschema)
// based on the key name.
console.log(mySchema.Title.name); // "Title"
// You can use the properties in the inferred schema to access the corresponding
// property value on a Page.
for await (const page of iteratePaginatedAPI(notion.databases.query, {
database_id,
})) {
if (isFullPage(page)) {
const titleRichText = getPropertyValue(page, mySchema.Title);
console.log('Title: ', richTextAsPlainText(titleRichText));
const isPublished = getPropertyValue(page, mySchema.IsPublished);
console.log('Is published: ', isPublished);
}
}
Name | Type |
---|---|
T |
extends PartialDatabaseSchemaWithOnlyType |
Name | Type | Description |
---|---|---|
schema |
T |
A partial database schema object literal. |
PartialDatabaseSchemaFromSchemaWithOnlyType
<T
>
The inferred PartialDatabaseSchema subtype.
▸ diffDatabaseSchemas<Before
, After
>(args
): DatabaseSchemaDiff
<Before
, After
>[]
Diff a before
and after
database schemas.
You can use this to validate an inferred schema literal against the actual schema fetched from the Notion API.
const mySchema = inferDatabaseSchema({
Title: { type: 'title' },
SubTitle: { type: 'rich_text', name: 'Subtitle' },
PublishedDate: { type: 'date', name: 'Published Date' },
IsPublished: {
type: 'checkbox',
name: 'Show In Production',
id: 'asdf123',
},
});
// Print schema differences between our literal and the API.
const database = await notion.databases.retrieve({ database_id });
const diffs = diffDatabaseSchemas({ before: mySchema, after: database.properties });
for (const change of diffs) {
console.log(
databaseSchemaDiffToString(change, { beforeName: "mySchema", afterName: "API database" })
);
}
warning
This is O(N * M) over length of the schemas currently, but may be optimized in the future.
Name | Type |
---|---|
Before |
extends PartialDatabaseSchema |
After |
extends PartialDatabaseSchema |
Name | Type |
---|---|
args |
Object |
args.before |
Before |
args.after |
After |
DatabaseSchemaDiff
<Before
, After
>[]
An array of diffs between the before
and after
schemas.
▸ databaseSchemaDiffToString<Before
, After
>(diff
, options?
): string
See diffDatabaseSchemas.
Name | Type |
---|---|
Before |
extends PartialDatabaseSchema |
After |
extends PartialDatabaseSchema |
Name | Type | Description |
---|---|---|
diff |
DatabaseSchemaDiff <Before , After > |
- |
options |
Object |
- |
options.beforeName? |
string |
Show "before" as this string |
options.afterName? |
string |
show "after" as this string |
string
A string describing a diff between two database schemas.
▸ getAllProperties<Schema
>(page
, schema
): DatabasePropertyValues
<Schema
>
Get all properties in a schema from the database.
Name | Type |
---|---|
Schema |
extends PartialDatabaseSchema |
Name | Type |
---|---|
page |
Object |
schema |
Schema |
DatabasePropertyValues
<Schema
>
▸ databaseFilterBuilder<T
>(schema
): DatabaseFilterBuilder
<T
>
Helper object for building PropertyFilters for the properties in the given schema
.
Name | Type |
---|---|
T |
extends PartialDatabaseSchema |
Name | Type | Description |
---|---|---|
schema |
T |
Database schema to build filters for. |
A property filter builder for schema property, plus compound filter builders.
• Filter: Object
Filter builder functions.
Name | Type |
---|---|
property |
<Type>(filter : PropertyFilter <Type >) => PropertyFilter <Type > |
compound |
(type : "or" | "and" , ...filters : (undefined | false | Filter )[]) => undefined | Filter |
isCompound |
(filter : Filter ) => filter is CompoundFilter |
and |
(...filters : (undefined | false | Filter )[]) => undefined | Filter |
isAnd |
(filter : Filter ) => filter is Object |
or |
(...filters : (undefined | false | Filter )[]) => undefined | Filter |
isOr |
(filter : Filter ) => filter is Object |
• Sort: Object
Sort builder functions.
Name | Type |
---|---|
property |
{ ascending : (property : string ) => {} ; descending : (property : string ) => {} } |
property.ascending |
(property : string ) => {} |
property.descending |
(property : string ) => {} |
created_time |
{ ascending : { timestamp : "created_time" = 'created_time'; direction : "ascending" = 'ascending' } ; descending : { timestamp : "created_time" = 'created_time'; direction : "descending" = 'descending' } } |
created_time.ascending |
{ timestamp : "created_time" = 'created_time'; direction : "ascending" = 'ascending' } |
created_time.ascending.timestamp |
"created_time" |
created_time.ascending.direction |
"ascending" |
created_time.descending |
{ timestamp : "created_time" = 'created_time'; direction : "descending" = 'descending' } |
created_time.descending.timestamp |
"created_time" |
created_time.descending.direction |
"descending" |
last_edited_time |
{ ascending : { timestamp : "last_edited_time" = 'last_edited_time'; direction : "ascending" = 'ascending' } ; descending : { timestamp : "last_edited_time" = 'last_edited_time'; direction : "descending" = 'descending' } } |
last_edited_time.ascending |
{ timestamp : "last_edited_time" = 'last_edited_time'; direction : "ascending" = 'ascending' } |
last_edited_time.ascending.timestamp |
"last_edited_time" |
last_edited_time.ascending.direction |
"ascending" |
last_edited_time.descending |
{ timestamp : "last_edited_time" = 'last_edited_time'; direction : "descending" = 'descending' } |
last_edited_time.descending.timestamp |
"last_edited_time" |
last_edited_time.descending.direction |
"descending" |
• Const
EXISTENCE_FILTER_OPERATORS: FilterOperatorTypeMap
<ExistenceFilterOperator
>
Runtime type information for ExistenceFilterOperator.
• Const
TEXT_FILTER_OPERATORS: FilterOperatorTypeMap
<TextFilterOperator
>
Runtime type information for TextFilterOperator.
• Const
NUMBER_FILTER_OPERATORS: FilterOperatorTypeMap
<NumberFilterOperator
>
Runtime type information for NumberFilterOperator.
• Const
CHECKBOX_FILTER_OPERATORS: FilterOperatorTypeMap
<CheckboxFilterOperator
> = EQUALITY_OPERATORS
Runtime type information for NumberFilterOperator.
• Const
SELECT_FILTER_OPERATORS: FilterOperatorTypeMap
<SelectFilterOperator
>
Runtime type information for SelectFilterOperator.
• Const
MULTI_SELECT_FILTER_OPERATORS: FilterOperatorTypeMap
<MultiSelectFilterOperator
>
Runtime type information for MultiSelectFilterOperator.
• Const
DATE_FILTER_OPERATORS: FilterOperatorTypeMap
<DateFilterOperator
>
Runtime type information for DateFilterOperator.
• Const
PEOPLE_FILTER_OPERATORS: FilterOperatorTypeMap
<PeopleFilterOperator
>
Runtime type information for PeopleFilterOperator.
• Const
RELATION_FILTER_OPERATORS: FilterOperatorTypeMap
<RelationFilterOperator
>
Runtime type information for RelationFilterOperator.
• Const
FORMULA_FILTER_OPERATORS: FilterOperatorTypeMap
<FormulaFilterOperator
>
Runtime type information for FormulaFilterOperator.
• Const
ROLLUP_FILTER_OPERATORS: FilterOperatorTypeMap
<RollupFilterOperator
>
Runtime type information for RollupFilterOperator.
• Const
PROPERTY_FILTER_OPERATORS: { [T in PropertyType]: { [O in FilterOperatorType<T>]: true } }
Runtime type information for PropertyToToFilterOperator.
• Const
ALL_PROPERTY_FILTER_OPERATORS: Record
<AnyFilterOperator
, true
>
Runtime information for all known filter operators.
• Const
ASSET_REQUEST_QUERY_PATH_PARAM: "asset_request"
• Const
ASSET_REQUEST_LAST_EDITED_TIME_PARAM: "last_edited_time"
• Const
DOWNLOAD_PERMISSION_ERROR: "DownloadPermissionError"
[[Error.name]] of errors thrown by ensureImageDownloaded when encountering a permission error, eg if the asset is expired.
• Const
DOWNLOAD_HTTP_ERROR: "DownloadHTTPError"
[[Error.name]] of errors thrown by ensureImageDownloaded when encountering other HTTP error codes.
A logger for the @notionhq/client Client that logs to the @jitl/notion-api namespace. Variables
• NotionClientDebugLogger: NotionClientDebugLogger
example
const client = new NotionClient({
logger: NotionClientDebugLogger,
// ...
})