collection
@nishans/core / Exports / Collection
Class: Collection#
A class to represent collection of Notion
noinheritdoc
Hierarchy#
Data<ICollection>
↳ Collection
Index#
Constructors#
Properties#
Methods#
- #getRowPages
- addToChildArray
- createPages
- createSchemaUnits
- createTemplates
- deleteCachedData
- deleteIterate
- deletePage
- deletePages
- deleteSchemaUnit
- deleteSchemaUnits
- deleteTemplate
- deleteTemplates
- emptyStack
- executeOperation
- getCachedData
- getCachedParentData
- getIterate
- getLastEditedProps
- getPage
- getPages
- getProps
- getSchemaUnit
- getSchemaUnits
- getTemplate
- getTemplates
- initializeCache
- initializeCacheForSpecificData
- initializeCacheForThisData
- printStack
- returnNonCachedData
- saveToCache
- update
- updateCacheIfNotPresent
- updateCacheLocally
- updateCacheManually
- updateCachedData
- updateIterate
- updateLastEditedProps
- updatePage
- updatePages
- updateSchemaUnit
- updateSchemaUnits
- updateTemplate
- updateTemplates
Constructors#
constructor#
+ new Collection(args: NishanArg): Collection
Parameters:#
| Name | Type |
|---|---|
args | NishanArg |
Returns: Collection
Defined in: core/src/Collection.ts:14
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#
#getRowPages#
â–¸ #getRowPages(): Promise<string[]>
Returns: Promise<string[]>
Defined in: core/src/Collection.ts:20
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
createPages#
â–¸ createPages(rows: Pick<IPageCreateInput, id | properties | format | isPrivate | contents>[]): Promise<ITBlock>
Add rows of data to the collection block
Parameters:#
| Name | Type |
|---|---|
rows | Pick<IPageCreateInput, id | properties | format | isPrivate | contents>[] |
Returns: Promise<ITBlock>
An array of newly created page objects
Defined in: core/src/Collection.ts:108
createSchemaUnits#
â–¸ createSchemaUnits(args: TSchemaUnitInput[]): ITSchemaUnit
Create multiple new columns in the collection schema
Parameters:#
| Name | Type | Description |
|---|---|---|
args | TSchemaUnitInput[] | array of Schema creation properties |
Returns: ITSchemaUnit
An array of SchemaUnit objects representing the columns
Defined in: core/src/Collection.ts:160
createTemplates#
â–¸ createTemplates(rows: Pick<IPageCreateInput, id | properties | format | isPrivate | contents>[]): Promise<ITBlock>
Create multiple templates for the collection
Parameters:#
| Name | Type |
|---|---|
rows | Pick<IPageCreateInput, id | properties | format | isPrivate | contents>[] |
Returns: Promise<ITBlock>
Defined in: core/src/Collection.ts:44
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<ICollection>, 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<ICollection> |
transform | (id: string) => undefined | TD |
cb? | (id: string, data: TD) => void | Promise<any> |
Returns: Promise<TD[]>
Defined in: core/src/Data.ts:118
deletePage#
â–¸ deletePage(args?: FilterType<IPage>): Promise<void>
Parameters:#
| Name | Type |
|---|---|
args? | FilterType<IPage> |
Returns: Promise<void>
Defined in: core/src/Collection.ts:138
deletePages#
â–¸ deletePages(args?: FilterTypes<IPage>, multiple?: boolean): Promise<void>
Delete multiple template pages from the collection
Parameters:#
| Name | Type | Description |
|---|---|---|
args? | FilterTypes<IPage> | string of ids or a predicate function |
multiple? | boolean | whether multiple or single item is targeted |
Returns: Promise<void>
Defined in: core/src/Collection.ts:147
deleteSchemaUnit#
â–¸ deleteSchemaUnit(args?: FilterType<ISchemaMapValue>): Promise<void>
Delete a single column from the collection schema
Parameters:#
| Name | Type | Description |
|---|---|---|
args? | FilterType<ISchemaMapValue> | schema_id string or predicate function |
Returns: Promise<void>
A SchemaUnit object representing the column
Defined in: core/src/Collection.ts:240
deleteSchemaUnits#
â–¸ deleteSchemaUnits(args?: FilterTypes<ISchemaMapValue>, multiple?: boolean): Promise<void>
Delete multiple columns from the collection schema
Parameters:#
| Name | Type | Description |
|---|---|---|
args? | FilterTypes<ISchemaMapValue> | schema_id string array or predicate function |
multiple? | boolean | - |
Returns: Promise<void>
An array of SchemaUnit objects representing the columns
Defined in: core/src/Collection.ts:249
deleteTemplate#
â–¸ deleteTemplate(args?: FilterType<IPage>): Promise<void>
Delete a single template page from the collection
Parameters:#
| Name | Type | Description |
|---|---|---|
args? | FilterType<IPage> | string id or a predicate function |
Returns: Promise<void>
Defined in: core/src/Collection.ts:85
deleteTemplates#
â–¸ deleteTemplates(args?: FilterTypes<IPage>, multiple?: boolean): Promise<void>
Delete multiple template pages from the collection
Parameters:#
| Name | Type | Description |
|---|---|---|
args? | FilterTypes<IPage> | string of ids or a predicate function |
multiple? | boolean | whether multiple or single item is targeted |
Returns: Promise<void>
Defined in: core/src/Collection.ts:94
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(): ICollection
Get the cached data using the current data id
Returns: ICollection
Defined in: core/src/Data.ts:62
getCachedParentData#
â–¸ getCachedParentData(): TCollectionBlock
Returns: TCollectionBlock
Defined in: core/src/Collection.ts:28
getIterate#
â–¸ ProtectedgetIterate<RD, C>(args: FilterTypes<RD>, options: IterateAndGetOptions<ICollection, 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<ICollection, 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
getPage#
â–¸ getPage(arg?: FilterType<IPage>): Promise<Page>
Parameters:#
| Name | Type |
|---|---|
arg? | FilterType<IPage> |
Returns: Promise<Page>
Defined in: core/src/Collection.ts:112
getPages#
â–¸ getPages(args?: FilterTypes<IPage>, multiple?: boolean): Promise<Page[]>
Parameters:#
| Name | Type |
|---|---|
args? | FilterTypes<IPage> |
multiple? | boolean |
Returns: Promise<Page[]>
Defined in: core/src/Collection.ts:116
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
getSchemaUnit#
â–¸ getSchemaUnit(arg?: FilterType<ISchemaMapValue>): Promise<ITSchemaUnit>
Parameters:#
| Name | Type |
|---|---|
arg? | FilterType<ISchemaMapValue> |
Returns: Promise<ITSchemaUnit>
Defined in: core/src/Collection.ts:181
getSchemaUnits#
â–¸ getSchemaUnits(args?: FilterTypes<ISchemaMapValue>, multiple?: boolean): Promise<ITSchemaUnit>
Return multiple columns from the collection schema
Parameters:#
| Name | Type | Description |
|---|---|---|
args? | FilterTypes<ISchemaMapValue> | schema_id string array or predicate function |
multiple? | boolean | - |
Returns: Promise<ITSchemaUnit>
An array of SchemaUnit objects representing the columns
Defined in: core/src/Collection.ts:190
getTemplate#
â–¸ getTemplate(args?: FilterType<IPage>): Promise<Page>
Get a single template page of the collection
Parameters:#
| Name | Type | Description |
|---|---|---|
args? | FilterType<IPage> | string id or a predicate function |
Returns: Promise<Page>
Template page object
Defined in: core/src/Collection.ts:53
getTemplates#
â–¸ getTemplates(args?: FilterTypes<IPage>, multiple?: boolean): Promise<Page[]>
Parameters:#
| Name | Type |
|---|---|
args? | FilterTypes<IPage> |
multiple? | boolean |
Returns: Promise<Page[]>
Defined in: core/src/Collection.ts:57
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<ICollection, name | icon | description>>): void
Update the collection
Parameters:#
| Name | Type | Description |
|---|---|---|
opt | Partial<Pick<ICollection, name | icon | description>> | CollectionUpdateParam |
Returns: void
Defined in: core/src/Collection.ts:36
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<ICollection>, keys: readonly (id | name | icon | description | template_pages | cover | migrated | schema | alive | version | parent_id | parent_table)[], appendToStack?: boolean): void
Update the cache of the data using only the passed keys
Parameters:#
| Name | Type | Description |
|---|---|---|
arg | Partial<ICollection> | |
keys | readonly (id | name | icon | description | template_pages | cover | migrated | schema | alive | version | parent_id | parent_table)[] | |
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<ICollection, 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<ICollection, 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
updatePage#
â–¸ updatePage(args: UpdateType<IPage, IPageUpdateInput>): Promise<Page>
Parameters:#
| Name | Type |
|---|---|
args | UpdateType<IPage, IPageUpdateInput> |
Returns: Promise<Page>
Defined in: core/src/Collection.ts:125
updatePages#
â–¸ updatePages(args: UpdateTypes<IPage, IPageUpdateInput>, multiple?: boolean): Promise<Page[]>
Parameters:#
| Name | Type |
|---|---|
args | UpdateTypes<IPage, IPageUpdateInput> |
multiple? | boolean |
Returns: Promise<Page[]>
Defined in: core/src/Collection.ts:129
updateSchemaUnit#
â–¸ updateSchemaUnit(arg: UpdateType<ISchemaMapValue, Partial<TextSchemaUnit> | Partial<NumberSchemaUnit> | Partial<SelectSchemaUnit> | Partial<MultiSelectSchemaUnit> | Partial<TitleSchemaUnit> | Partial<DateSchemaUnit> | Partial<PersonSchemaUnit> | Partial<FileSchemaUnit> | Partial<CheckboxSchemaUnit> | Partial<UrlSchemaUnit> | Partial<EmailSchemaUnit> | Partial<PhoneNumberSchemaUnit> | Partial<RelationSchemaUnit> | Partial<RollupSchemaUnit> | Partial<CreatedTimeSchemaUnit> | Partial<CreatedBySchemaUnit> | Partial<LastEditedTimeSchemaUnit> | Partial<LastEditedBySchemaUnit> | Partial<FormulaSchemaUnit>>): Promise<ITSchemaUnit>
Update and return a single column from the collection schema
Parameters:#
| Name | Type |
|---|---|
arg | UpdateType<ISchemaMapValue, Partial<TextSchemaUnit> | Partial<NumberSchemaUnit> | Partial<SelectSchemaUnit> | Partial<MultiSelectSchemaUnit> | Partial<TitleSchemaUnit> | Partial<DateSchemaUnit> | Partial<PersonSchemaUnit> | Partial<FileSchemaUnit> | Partial<CheckboxSchemaUnit> | Partial<UrlSchemaUnit> | Partial<EmailSchemaUnit> | Partial<PhoneNumberSchemaUnit> | Partial<RelationSchemaUnit> | Partial<RollupSchemaUnit> | Partial<CreatedTimeSchemaUnit> | Partial<CreatedBySchemaUnit> | Partial<LastEditedTimeSchemaUnit> | Partial<LastEditedBySchemaUnit> | Partial<FormulaSchemaUnit>> |
Returns: Promise<ITSchemaUnit>
A SchemaUnit object representing the column
Defined in: core/src/Collection.ts:205
updateSchemaUnits#
â–¸ updateSchemaUnits(args: UpdateTypes<ISchemaMapValue, Partial<TextSchemaUnit> | Partial<NumberSchemaUnit> | Partial<SelectSchemaUnit> | Partial<MultiSelectSchemaUnit> | Partial<TitleSchemaUnit> | Partial<DateSchemaUnit> | Partial<PersonSchemaUnit> | Partial<FileSchemaUnit> | Partial<CheckboxSchemaUnit> | Partial<UrlSchemaUnit> | Partial<EmailSchemaUnit> | Partial<PhoneNumberSchemaUnit> | Partial<RelationSchemaUnit> | Partial<RollupSchemaUnit> | Partial<CreatedTimeSchemaUnit> | Partial<CreatedBySchemaUnit> | Partial<LastEditedTimeSchemaUnit> | Partial<LastEditedBySchemaUnit> | Partial<FormulaSchemaUnit>>, multiple?: boolean): Promise<ITSchemaUnit>
Update and return multiple columns from the collection schema
Parameters:#
| Name | Type | Description |
|---|---|---|
args | UpdateTypes<ISchemaMapValue, Partial<TextSchemaUnit> | Partial<NumberSchemaUnit> | Partial<SelectSchemaUnit> | Partial<MultiSelectSchemaUnit> | Partial<TitleSchemaUnit> | Partial<DateSchemaUnit> | Partial<PersonSchemaUnit> | Partial<FileSchemaUnit> | Partial<CheckboxSchemaUnit> | Partial<UrlSchemaUnit> | Partial<EmailSchemaUnit> | Partial<PhoneNumberSchemaUnit> | Partial<RelationSchemaUnit> | Partial<RollupSchemaUnit> | Partial<CreatedTimeSchemaUnit> | Partial<CreatedBySchemaUnit> | Partial<LastEditedTimeSchemaUnit> | Partial<LastEditedBySchemaUnit> | Partial<FormulaSchemaUnit>> | schema_id string and schema properties array of tuples |
multiple? | boolean | - |
Returns: Promise<ITSchemaUnit>
An array of SchemaUnit objects representing the columns
Defined in: core/src/Collection.ts:214
updateTemplate#
â–¸ updateTemplate(args: UpdateType<IPage, IPageUpdateInput>): Promise<Page>
Parameters:#
| Name | Type |
|---|---|
args | UpdateType<IPage, IPageUpdateInput> |
Returns: Promise<Page>
Defined in: core/src/Collection.ts:66
updateTemplates#
â–¸ updateTemplates(args: UpdateTypes<IPage, IPageUpdateInput>, multiple?: boolean): Promise<Page[]>
Parameters:#
| Name | Type |
|---|---|
args | UpdateTypes<IPage, IPageUpdateInput> |
multiple? | boolean |
Returns: Promise<Page[]>
Defined in: core/src/Collection.ts:71