notionuser
@nishans/core / Exports / NotionUser
Class: NotionUser#
A class to represent NotionUser of Notion
noinheritdoc
Hierarchy#
Data<INotionUser>
↳ NotionUser
Index#
Constructors#
Properties#
Methods#
- #getSpaceIds
- addToChildArray
- createSpace
- createSpaces
- deleteCachedData
- deleteIterate
- deleteSpace
- deleteSpaces
- emptyStack
- executeOperation
- getCachedData
- getIterate
- getLastEditedProps
- getProps
- getSpace
- getSpaces
- getTPagesById
- getUserRoot
- getUserSettings
- initializeCache
- initializeCacheForSpecificData
- initializeCacheForThisData
- printStack
- returnNonCachedData
- saveToCache
- update
- updateCacheIfNotPresent
- updateCacheLocally
- updateCacheManually
- updateCachedData
- updateIterate
- updateLastEditedProps
- updateSpace
- updateSpaces
Constructors#
constructor#
+ new NotionUser(arg: NishanArg): NotionUser
Parameters:#
| Name | Type |
|---|---|
arg | NishanArg |
Returns: NotionUser
Defined in: core/src/NotionUser.ts:19
Properties#
cache#
• cache: ICache
Defined in: endpoints/dist/src/Cache.d.ts:4
getConfigs#
• Protected getConfigs: () => Configs
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
Defined in: core/src/Data.ts:35
interval#
• interval: number
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
Defined in: core/src/Operations.ts:9
space_id#
• space_id: string
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#
#getSpaceIds#
â–¸ #getSpaceIds(): string[]
Returns: string[]
Defined in: core/src/NotionUser.ts:24
addToChildArray#
â–¸ ProtectedaddToChildArray(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
Defined in: core/src/Data.ts:86
createSpace#
â–¸ createSpace(opt: Partial<Pick<ISpace, name | icon | disable_public_access | disable_guests | disable_move_to_space | disable_export | domain | invite_link_enabled | beta_enabled>>): Promise<Space>
Create and return a new Space
Parameters:#
| Name | Type | Description |
|---|---|---|
opt | Partial<Pick<ISpace, name | icon | disable_public_access | disable_guests | disable_move_to_space | disable_export | domain | invite_link_enabled | beta_enabled>> | Object for configuring the Space options |
Returns: Promise<Space>
Newly created Space object
Defined in: core/src/NotionUser.ts:66
createSpaces#
â–¸ createSpaces(opts: Partial<Pick<ISpace, name | icon | disable_public_access | disable_guests | disable_move_to_space | disable_export | domain | invite_link_enabled | beta_enabled>>[]): Promise<Space[]>
Parameters:#
| Name | Type |
|---|---|
opts | Partial<Pick<ISpace, name | icon | disable_public_access | disable_guests | disable_move_to_space | disable_export | domain | invite_link_enabled | beta_enabled>>[] |
Returns: Promise<Space[]>
Defined in: core/src/NotionUser.ts:71
deleteCachedData#
â–¸ ProtecteddeleteCachedData(): void
Delete the cached data using the id
Returns: void
Defined in: core/src/Data.ts:76
deleteIterate#
â–¸ ProtecteddeleteIterate<TD>(args: FilterTypes<TD>, options: IterateAndDeleteOptions<INotionUser>, 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<INotionUser> |
transform | (id: string) => undefined | TD |
cb? | (id: string, data: TD) => void | Promise<any> |
Returns: Promise<TD[]>
Defined in: core/src/Data.ts:118
deleteSpace#
â–¸ deleteSpace(arg: FilterType<ISpace>): Promise<void>
Parameters:#
| Name | Type |
|---|---|
arg | FilterType<ISpace> |
Returns: Promise<void>
Defined in: core/src/NotionUser.ts:200
deleteSpaces#
â–¸ deleteSpaces(args: FilterTypes<ISpace>, multiple?: boolean): Promise<void>
Parameters:#
| Name | Type |
|---|---|
args | FilterTypes<ISpace> |
multiple? | boolean |
Returns: Promise<void>
Defined in: core/src/NotionUser.ts:204
emptyStack#
â–¸ emptyStack(): void
Returns: void
Defined in: core/src/Operations.ts:18
executeOperation#
â–¸ executeOperation(): Promise<void>
Returns: Promise<void>
Defined in: core/src/Operations.ts:26
getCachedData#
â–¸ getCachedData(): INotionUser
Get the cached data using the current data id
Returns: INotionUser
Defined in: core/src/Data.ts:62
getIterate#
â–¸ ProtectedgetIterate<RD, C>(args: FilterTypes<RD>, options: IterateAndGetOptions<INotionUser, 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<INotionUser, C> |
transform | (id: string) => undefined | RD |
cb? | (id: string, data: RD, container: C) => any |
Returns: Promise<C>
Defined in: core/src/Data.ts:138
getLastEditedProps#
â–¸ ProtectedgetLastEditedProps(): object
Returns: object
| Name | Type |
|---|---|
last_edited_by_id | string |
last_edited_by_table | string |
last_edited_time | number |
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 |
Defined in: core/src/Data.ts:148
getSpace#
â–¸ getSpace(arg?: FilterType<ISpace>): Promise<Space>
Get a space that is available on the user's account
Parameters:#
| Name | Type | Description |
|---|---|---|
arg? | FilterType<ISpace> | A predicate filter function or a string |
Returns: Promise<Space>
The obtained Space object
Defined in: core/src/NotionUser.ts:162
getSpaces#
â–¸ getSpaces(args?: FilterTypes<ISpace>, multiple?: boolean): Promise<Space[]>
Get multiple space objects on the user's account as an array
Parameters:#
| Name | Type |
|---|---|
args? | FilterTypes<ISpace> |
multiple? | boolean |
Returns: Promise<Space[]>
An array of space objects
Defined in: core/src/NotionUser.ts:171
getTPagesById#
â–¸ getTPagesById(ids: string[]): Promise<ITPage>
Parameters:#
| Name | Type |
|---|---|
ids | string[] |
Returns: Promise<ITPage>
Defined in: core/src/NotionUser.ts:222
getUserRoot#
â–¸ getUserRoot(): UserRoot
Returns: UserRoot
Defined in: core/src/NotionUser.ts:43
getUserSettings#
â–¸ getUserSettings(): UserSettings
Get the current logged in user settings
Returns: UserSettings
Returns the logged in UserSettings object
Defined in: core/src/NotionUser.ts:34
initializeCache#
â–¸ initializeCache(): Promise<void>
Returns: Promise<void>
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>
Defined in: endpoints/dist/src/Cache.d.ts:25
initializeCacheForThisData#
â–¸ ProtectedinitializeCacheForThisData(): Promise<void>
Returns: Promise<void>
Defined in: core/src/Data.ts:111
printStack#
â–¸ printStack(): void
Returns: void
Defined in: core/src/Operations.ts:22
returnNonCachedData#
â–¸ returnNonCachedData(ids: UpdateCacheManuallyParam): UpdateCacheManuallyParam
Parameters:#
| Name | Type |
|---|---|
ids | UpdateCacheManuallyParam |
Returns: UpdateCacheManuallyParam
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
Defined in: endpoints/dist/src/Cache.d.ts:20
update#
â–¸ update(opt: Partial<Pick<INotionUser, family_name | given_name | profile_photo>>): void
Update the notion user
Parameters:#
| Name | Type | Description |
|---|---|---|
opt | Partial<Pick<INotionUser, family_name | given_name | profile_photo>> | UpdatableNotionUserParam |
Returns: void
Defined in: core/src/NotionUser.ts:57
updateCacheIfNotPresent#
â–¸ updateCacheIfNotPresent(arg: UpdateCacheManuallyParam): Promise<void>
Parameters:#
| Name | Type |
|---|---|
arg | UpdateCacheManuallyParam |
Returns: Promise<void>
Defined in: endpoints/dist/src/Cache.d.ts:24
updateCacheLocally#
â–¸ updateCacheLocally(arg: Partial<INotionUser>, keys: readonly (id | version | email | family_name | given_name | profile_photo | onboarding_completed)[], appendToStack?: boolean): void
Update the cache of the data using only the passed keys
Parameters:#
| Name | Type | Description |
|---|---|---|
arg | Partial<INotionUser> | |
keys | readonly (id | version | email | family_name | given_name | profile_photo | onboarding_completed)[] | |
appendToStack? | boolean | - |
Returns: void
Defined in: core/src/Data.ts:95
updateCacheManually#
â–¸ updateCacheManually(arg: string | UpdateCacheManuallyParam): Promise<void>
Parameters:#
| Name | Type |
|---|---|
arg | string | UpdateCacheManuallyParam |
Returns: Promise<void>
Defined in: endpoints/dist/src/Cache.d.ts:23
updateCachedData#
â–¸ updateCachedData(): Promise<void>
Returns: Promise<void>
Defined in: core/src/Data.ts:69
updateIterate#
â–¸ ProtectedupdateIterate<TD, RD, C>(args: UpdateTypes<TD, RD>, options: IterateAndUpdateOptions<INotionUser, 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<INotionUser, C> |
transform | (id: string) => undefined | TD |
cb? | (id: string, data: TD, updated\_data: RD, container: C) => any |
Returns: Promise<C>
Defined in: core/src/Data.ts:128
updateLastEditedProps#
â–¸ ProtectedupdateLastEditedProps(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
Defined in: core/src/Data.ts:52
updateSpace#
â–¸ updateSpace(arg: UpdateType<ISpace, Partial<Pick<ISpace, name | icon | disable_public_access | disable_guests | disable_move_to_space | disable_export | domain | invite_link_enabled | beta_enabled>>>): Promise<Space>
Parameters:#
| Name | Type |
|---|---|
arg | UpdateType<ISpace, Partial<Pick<ISpace, name | icon | disable_public_access | disable_guests | disable_move_to_space | disable_export | domain | invite_link_enabled | beta_enabled>>> |
Returns: Promise<Space>
Defined in: core/src/NotionUser.ts:188
updateSpaces#
â–¸ updateSpaces(args: UpdateTypes<ISpace, Partial<Pick<ISpace, name | icon | disable_public_access | disable_guests | disable_move_to_space | disable_export | domain | invite_link_enabled | beta_enabled>>>, multiple?: boolean): Promise<Space[]>
Parameters:#
| Name | Type |
|---|---|
args | UpdateTypes<ISpace, Partial<Pick<ISpace, name | icon | disable_public_access | disable_guests | disable_move_to_space | disable_export | domain | invite_link_enabled | beta_enabled>>> |
multiple? | boolean |
Returns: Promise<Space[]>
Defined in: core/src/NotionUser.ts:192