page
@nishans/core / Exports / Page
#
Class: PageA class to represent Page type block of Notion
noinheritdoc
#
HierarchyBlock<IPage, IPageCreateInput>
↳ Page
#
Index#
Constructors#
Properties#
Methods- addPublicPermission
- addSharedUser
- addSharedUsers
- addToChildArray
- convertTo
- createBlocks
- delete
- deleteBlock
- deleteBlocks
- deleteCachedData
- deleteIterate
- duplicate
- emptyStack
- executeOperation
- export
- getBlock
- getBlocks
- getCachedData
- getCachedParentData
- getIterate
- getLastEditedProps
- getProps
- initializeCache
- initializeCacheForSpecificData
- initializeCacheForThisData
- printStack
- removePublicPermission
- removeSharedUser
- removeSharedUsers
- removeSpacePermission
- reposition
- returnNonCachedData
- saveToCache
- toggleFavourite
- transfer
- update
- updateBlock
- updateBlocks
- updateCacheIfNotPresent
- updateCacheLocally
- updateCacheManually
- updateCachedData
- updateIterate
- updateLastEditedProps
- updatePublicPermission
- updateSharedUser
- updateSharedUsers
- updateSpacePermission
#
Constructors#
constructor+ new Page(arg
: NishanArg): Page
#
Parameters:Name | Type |
---|---|
arg | NishanArg |
Returns: Page
Inherited from: Block
Defined in: core/src/Page.ts:14
#
Properties#
cache• cache: ICache
Defined in: endpoints/dist/src/Cache.d.ts:4
#
getConfigs• Protected
getConfigs: () => Configs
Inherited from: Block.getConfigs
Defined in: endpoints/dist/src/Cache.d.ts:15
#
headers• headers: { headers
: { cookie
: string ; x-notion-active-user-header
: string } }
#
Type declaration:Name | Type |
---|---|
headers | { cookie : string ; x-notion-active-user-header : string } |
Defined in: endpoints/dist/src/Cache.d.ts:7
#
id• id: string
Defined in: core/src/Data.ts:33
#
init_cache• init_cache: boolean= false
Inherited from: Block.init_cache
Defined in: core/src/Data.ts:35
#
interval• interval: number
Inherited from: Block.interval
Defined in: endpoints/dist/src/Cache.d.ts:6
#
logger• Protected
logger: Logger
Defined in: core/src/Data.ts:36
#
shard_id• shard_id: number
Inherited from: Block.shard_id
Defined in: core/src/Operations.ts:9
#
space_id• space_id: string
Inherited from: Block.space_id
Defined in: core/src/Operations.ts:8
#
stack• stack: IOperation[]
Defined in: core/src/Operations.ts:7
#
token• token: string
Defined in: endpoints/dist/src/Cache.d.ts:5
#
type• type: block | collection | collection_view | space | notion_user | space_view | user_root | user_settings
Defined in: core/src/Data.ts:34
#
user_id• user_id: string
Defined in: endpoints/dist/src/Cache.d.ts:13
#
Methods#
addPublicPermissionâ–¸ addPublicPermission(role
: TPublicPermissionRole, options?
: Partial<IPublicPermissionOptions>): void
#
Parameters:Name | Type |
---|---|
role | TPublicPermissionRole |
options? | Partial<IPublicPermissionOptions> |
Returns: void
Defined in: core/src/Page.ts:271
#
addSharedUserâ–¸ addSharedUser(email
: string, role
: TUserPermissionRole): Promise<INotionUser>
#
Parameters:Name | Type |
---|---|
email | string |
role | TUserPermissionRole |
Returns: Promise<INotionUser>
Defined in: core/src/Page.ts:190
#
addSharedUsersâ–¸ addSharedUsers(args
: [string, TUserPermissionRole][]): Promise<INotionUser[]>
Share page to users with specific permissions
#
Parameters:Name | Type | Description |
---|---|---|
args | [string, TUserPermissionRole][] | array of userid and role of user to share pages to |
Returns: Promise<INotionUser[]>
Defined in: core/src/Page.ts:198
#
addToChildArrayâ–¸ Protected
addToChildArray(parent
: TData, position
: RepositionParams): void
Adds the passed block id in the child container array of parent
#
Parameters:Name | Type |
---|---|
parent | TData |
position | RepositionParams |
Returns: void
created Operation and a function to update the cache and the class data
Inherited from: Block
Defined in: core/src/Data.ts:86
#
convertToâ–¸ convertTo(type
: TBasicBlockType): void
Convert the current block to a different basic block
#
Parameters:Name | Type | Description |
---|---|---|
type | TBasicBlockType | TBasicBlockType basic block types |
Returns: void
Inherited from: Block
Defined in: core/src/Block.ts:107
#
createBlocksâ–¸ createBlocks(contents
: TBlockCreateInput[]): Promise<ITBlock>
Batch add multiple block as contents
#
Parameters:Name | Type | Description |
---|---|---|
contents | TBlockCreateInput[] | array of options for configuring each content |
Returns: Promise<ITBlock>
Array of newly created block content objects
Defined in: core/src/Page.ts:120
#
deleteâ–¸ delete(): void
Delete the current block
Returns: void
Inherited from: Block
Defined in: core/src/Block.ts:117
#
deleteBlockâ–¸ deleteBlock(arg?
: FilterType<TBlock>): Promise<void>
Delete a single block from a page
#
Parameters:Name | Type | Description |
---|---|---|
arg? | FilterType<TBlock> | id string or a predicate acting as a filter |
Returns: Promise<void>
Defined in: core/src/Page.ts:173
#
deleteBlocksâ–¸ deleteBlocks(args?
: FilterTypes<TBlock>, multiple?
: boolean): Promise<void>
Delete multiple blocks from a page
#
Parameters:Name | Type |
---|---|
args? | FilterTypes<TBlock> |
multiple? | boolean |
Returns: Promise<void>
Defined in: core/src/Page.ts:181
#
deleteCachedDataâ–¸ Protected
deleteCachedData(): void
Delete the cached data using the id
Returns: void
Inherited from: Block
Defined in: core/src/Data.ts:76
#
deleteIterateâ–¸ Protected
deleteIterate<TD>(args
: FilterTypes<TD>, options
: IterateAndDeleteOptions<IPage>, transform
: (id
: string) => undefined | TD, cb?
: (id
: string, data
: TD) => void | Promise<any>): Promise<TD[]>
#
Type parameters:Name |
---|
TD |
#
Parameters:Name | Type |
---|---|
args | FilterTypes<TD> |
options | IterateAndDeleteOptions<IPage> |
transform | (id : string) => undefined | TD |
cb? | (id : string, data : TD) => void | Promise<any> |
Returns: Promise<TD[]>
Inherited from: Block
Defined in: core/src/Data.ts:118
#
duplicateâ–¸ duplicate(infos
: { id?
: undefined | string }[]): Promise<ITBlock>
Duplicate the current block
#
Parameters:Name | Type | Description |
---|---|---|
infos | { id? : undefined | string }[] | Array of objects containing information regarding the position and id of the duplicated block |
Returns: Promise<ITBlock>
A block map
Inherited from: Block
Defined in: core/src/Block.ts:32
#
emptyStackâ–¸ emptyStack(): void
Returns: void
Inherited from: Block
Defined in: core/src/Operations.ts:18
#
executeOperationâ–¸ executeOperation(): Promise<void>
Returns: Promise<void>
Inherited from: Block
Defined in: core/src/Operations.ts:26
#
exportâ–¸ export(arg
: Partial<{ exportType
: TExportType ; recursive
: boolean ; timeZone
: string }>): Promise<void>
Export the page and its content as a zip
#
Parameters:Name | Type | Description |
---|---|---|
arg | Partial<{ exportType : TExportType ; recursive : boolean ; timeZone : string }> | Options used for setting up export |
Returns: Promise<void>
Defined in: core/src/Page.ts:77
#
getBlockâ–¸ getBlock(arg?
: FilterType<TBlock>): Promise<ITBlock>
#
Parameters:Name | Type |
---|---|
arg? | FilterType<TBlock> |
Returns: Promise<ITBlock>
Defined in: core/src/Page.ts:124
#
getBlocksâ–¸ getBlocks(args?
: FilterTypes<TBlock>, multiple?
: boolean): Promise<ITBlock>
Get all the blocks of the page as an object
#
Parameters:Name | Type |
---|---|
args? | FilterTypes<TBlock> |
multiple? | boolean |
Returns: Promise<ITBlock>
An array of block object
Defined in: core/src/Page.ts:132
#
getCachedDataâ–¸ getCachedData(): IPage
Get the cached data using the current data id
Returns: IPage
Inherited from: Block
Defined in: core/src/Data.ts:62
#
getCachedParentDataâ–¸ getCachedParentData(): IPage | ISpace
Returns: IPage | ISpace
Overrides: Block
Defined in: core/src/Page.ts:19
#
getIterateâ–¸ Protected
getIterate<RD, C>(args
: FilterTypes<RD>, options
: IterateAndGetOptions<IPage, C>, transform
: (id
: string) => undefined | RD, cb?
: (id
: string, data
: RD, container
: C) => any): Promise<C>
#
Type parameters:Name |
---|
RD |
C |
#
Parameters:Name | Type |
---|---|
args | FilterTypes<RD> |
options | IterateAndGetOptions<IPage, C> |
transform | (id : string) => undefined | RD |
cb? | (id : string, data : RD, container : C) => any |
Returns: Promise<C>
Inherited from: Block
Defined in: core/src/Data.ts:138
#
getLastEditedPropsâ–¸ Protected
getLastEditedProps(): object
Returns: object
Name | Type |
---|---|
last_edited_by_id | string |
last_edited_by_table | string |
last_edited_time | number |
Inherited from: Block
Defined in: core/src/Data.ts:48
#
getPropsâ–¸ getProps(): object
Returns: object
Name | Type |
---|---|
cache | ICache |
interval | number |
logger | Logger |
shard_id | number |
space_id | string |
stack | IOperation[] |
token | string |
user_id | string |
Inherited from: Block
Defined in: core/src/Data.ts:148
#
initializeCacheâ–¸ initializeCache(): Promise<void>
Returns: Promise<void>
Inherited from: Block
Defined in: endpoints/dist/src/Cache.d.ts:22
#
initializeCacheForSpecificDataâ–¸ initializeCacheForSpecificData(id
: string, type
: block | collection | collection_view | space | notion_user | space_view | user_root | user_settings): Promise<void>
#
Parameters:Name | Type |
---|---|
id | string |
type | block | collection | collection_view | space | notion_user | space_view | user_root | user_settings |
Returns: Promise<void>
Inherited from: Block
Defined in: endpoints/dist/src/Cache.d.ts:25
#
initializeCacheForThisDataâ–¸ Protected
initializeCacheForThisData(): Promise<void>
Returns: Promise<void>
Inherited from: Block
Defined in: core/src/Data.ts:111
#
printStackâ–¸ printStack(): void
Returns: void
Inherited from: Block
Defined in: core/src/Operations.ts:22
#
removePublicPermissionâ–¸ removePublicPermission(): void
Returns: void
Defined in: core/src/Page.ts:290
#
removeSharedUserâ–¸ removeSharedUser(id
: string): void
Remove a single user from the pages permission option
#
Parameters:Name | Type | Description |
---|---|---|
id | string | Id of the user to remove from permission |
Returns: void
Defined in: core/src/Page.ts:259
#
removeSharedUsersâ–¸ removeSharedUsers(ids
: string[]): void
Remove multiple users from the pages permission option
#
Parameters:Name | Type |
---|---|
ids | string[] |
Returns: void
Defined in: core/src/Page.ts:267
#
removeSpacePermissionâ–¸ removeSpacePermission(): void
Returns: void
Defined in: core/src/Page.ts:304
#
repositionâ–¸ reposition(arg
: RepositionParams): void
#
Parameters:Name | Type |
---|---|
arg | RepositionParams |
Returns: void
Inherited from: Block
Defined in: core/src/Block.ts:22
#
returnNonCachedDataâ–¸ returnNonCachedData(ids
: UpdateCacheManuallyParam): UpdateCacheManuallyParam
#
Parameters:Name | Type |
---|---|
ids | UpdateCacheManuallyParam |
Returns: UpdateCacheManuallyParam
Inherited from: Block
Defined in: endpoints/dist/src/Cache.d.ts:21
#
saveToCacheâ–¸ saveToCache(recordMap
: Partial<RecordMap>): void
Save the passed recordMap to cache
#
Parameters:Name | Type | Description |
---|---|---|
recordMap | Partial<RecordMap> | RecordMap map to save to cache |
Returns: void
Inherited from: Block
Defined in: endpoints/dist/src/Cache.d.ts:20
#
toggleFavouriteâ–¸ toggleFavourite(): Promise<void>
Add/remove this page from the favourite list
Returns: Promise<void>
Defined in: core/src/Page.ts:51
#
transferâ–¸ transfer(new_parent_id
: string): void
Transfer a block from one parent page to another page
#
Parameters:Name | Type | Description |
---|---|---|
new_parent_id | string | Id of the new parent page |
Returns: void
Inherited from: Block
Defined in: core/src/Block.ts:149
#
updateâ–¸ update(args
: Partial<IPageCreateInput>): void
Update a block's properties and format
#
Parameters:Name | Type | Description |
---|---|---|
args | Partial<IPageCreateInput> | Block update format and properties options |
Returns: void
Inherited from: Block
Defined in: core/src/Block.ts:89
#
updateBlockâ–¸ updateBlock(args
: UpdateType<TBlock, TBlockInput>): Promise<ITBlock>
#
Parameters:Name | Type |
---|---|
args | UpdateType<TBlock, TBlockInput> |
Returns: Promise<ITBlock>
Defined in: core/src/Page.ts:146
#
updateBlocksâ–¸ updateBlocks(args
: UpdateTypes<TBlock, TBlockInput>, multiple?
: boolean): Promise<ITBlock>
#
Parameters:Name | Type |
---|---|
args | UpdateTypes<TBlock, TBlockInput> |
multiple? | boolean |
Returns: Promise<ITBlock>
Defined in: core/src/Page.ts:150
#
updateCacheIfNotPresentâ–¸ updateCacheIfNotPresent(arg
: UpdateCacheManuallyParam): Promise<void>
#
Parameters:Name | Type |
---|---|
arg | UpdateCacheManuallyParam |
Returns: Promise<void>
Inherited from: Block
Defined in: endpoints/dist/src/Cache.d.ts:24
#
updateCacheLocallyâ–¸ updateCacheLocally(arg
: Partial<IPage>, keys
: readonly (id | space_id | shard_id | type | properties | format | alive | version | parent_id | parent_table | created_time | last_edited_time | created_by_id | created_by_table | last_edited_by_id | last_edited_by_table | permissions | content | is_template | file_ids)[], appendToStack?
: boolean): void
Update the cache of the data using only the passed keys
#
Parameters:Name | Type | Description |
---|---|---|
arg | Partial<IPage> | |
keys | readonly (id | space_id | shard_id | type | properties | format | alive | version | parent_id | parent_table | created_time | last_edited_time | created_by_id | created_by_table | last_edited_by_id | last_edited_by_table | permissions | content | is_template | file_ids)[] | |
appendToStack? | boolean | - |
Returns: void
Inherited from: Block
Defined in: core/src/Data.ts:95
#
updateCacheManuallyâ–¸ updateCacheManually(arg
: string | UpdateCacheManuallyParam): Promise<void>
#
Parameters:Name | Type |
---|---|
arg | string | UpdateCacheManuallyParam |
Returns: Promise<void>
Inherited from: Block
Defined in: endpoints/dist/src/Cache.d.ts:23
#
updateCachedDataâ–¸ updateCachedData(): Promise<void>
Returns: Promise<void>
Inherited from: Block
Defined in: core/src/Data.ts:69
#
updateIterateâ–¸ Protected
updateIterate<TD, RD, C>(args
: UpdateTypes<TD, RD>, options
: IterateAndUpdateOptions<IPage, C>, transform
: (id
: string) => undefined | TD, cb?
: (id
: string, data
: TD, updated\_data
: RD, container
: C) => any): Promise<C>
#
Type parameters:Name | Default |
---|---|
TD | - |
RD | - |
C | any |
#
Parameters:Name | Type |
---|---|
args | UpdateTypes<TD, RD> |
options | IterateAndUpdateOptions<IPage, C> |
transform | (id : string) => undefined | TD |
cb? | (id : string, data : TD, updated\_data : RD, container : C) => any |
Returns: Promise<C>
Inherited from: Block
Defined in: core/src/Data.ts:128
#
updateLastEditedPropsâ–¸ Protected
updateLastEditedProps(data?
: INotionUser | IText | ITodo | IHeader | ISubHeader | ISubSubHeader | IBulletedList | INumberedList | IToggle | IQuote | IDivider | ICallout | IPage | ICollectionView | ICollectionViewPage | ILinkToPage | IVideo | IAudio | IImage | IWebBookmark | ICode | IFile | ITOC | IEquation | IBreadcrumb | IFactory | IEmbed | ITweet | ICodepen | IMaps | IFigma | IDrive | IGist | IColumnList | IColumn | ICollection | ITableView | IListView | IBoardView | IGalleryView | ICalendarView | ITimelineView | ISpace | ISpaceView | IUserRoot | IUserSettings): void
#
Parameters:Name | Type |
---|---|
data? | INotionUser | IText | ITodo | IHeader | ISubHeader | ISubSubHeader | IBulletedList | INumberedList | IToggle | IQuote | IDivider | ICallout | IPage | ICollectionView | ICollectionViewPage | ILinkToPage | IVideo | IAudio | IImage | IWebBookmark | ICode | IFile | ITOC | IEquation | IBreadcrumb | IFactory | IEmbed | ITweet | ICodepen | IMaps | IFigma | IDrive | IGist | IColumnList | IColumn | ICollection | ITableView | IListView | IBoardView | IGalleryView | ICalendarView | ITimelineView | ISpace | ISpaceView | IUserRoot | IUserSettings |
Returns: void
Inherited from: Block
Defined in: core/src/Data.ts:52
#
updatePublicPermissionâ–¸ updatePublicPermission(role
: TPublicPermissionRole, options?
: Partial<IPublicPermissionOptions>): void
#
Parameters:Name | Type |
---|---|
role | TPublicPermissionRole |
options? | Partial<IPublicPermissionOptions> |
Returns: void
Defined in: core/src/Page.ts:275
#
updateSharedUserâ–¸ updateSharedUser(id
: string, role
: TUserPermissionRole): Promise<void>
Update the role of the current user based on their id
#
Parameters:Name | Type | Description |
---|---|---|
id | string | Id of the user to update |
role | TUserPermissionRole | new Role of the user to update |
Returns: Promise<void>
Defined in: core/src/Page.ts:229
#
updateSharedUsersâ–¸ updateSharedUsers(args
: [string, TUserPermissionRole][]): void
Update the role of the current users based on their id
#
Parameters:Name | Type | Description |
---|---|---|
args | [string, TUserPermissionRole][] | array of array [id of the user, role type for the user] |
Returns: void
Defined in: core/src/Page.ts:237
#
updateSpacePermissionâ–¸ updateSpacePermission(role
: TUserPermissionRole): void
#
Parameters:Name | Type |
---|---|
role | TUserPermissionRole |
Returns: void
Defined in: core/src/Page.ts:294