@texonom/nutils 1.4.7 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/find-ancestors.d.ts +1 -1
- package/build/get-all-in-space.d.ts +1 -1
- package/build/get-block-collection-id.d.ts +1 -1
- package/build/get-block-icon.d.ts +1 -1
- package/build/get-block-parent-page.d.ts +1 -1
- package/build/get-block-title.d.ts +1 -1
- package/build/get-canonical-page-id.d.ts +1 -1
- package/build/get-date-value.d.ts +1 -1
- package/build/get-page-breadcrumbs.d.ts +1 -1
- package/build/get-page-content-block-ids.d.ts +1 -1
- package/build/get-page-image-urls.d.ts +1 -1
- package/build/get-page-table-of-contents.d.ts +1 -1
- package/build/get-page-title.d.ts +1 -1
- package/build/get-text-content.d.ts +1 -1
- package/build/index.d.ts +28 -208
- package/build/index.js +746 -2
- package/build/index.js.map +1 -1
- package/build/is-url.d.ts +1 -1
- package/build/merge-record-maps.d.ts +1 -1
- package/package.json +10 -7
- package/readme.md +73 -0
- package/LICENSE +0 -21
- package/README.md +0 -32
- package/build/.tsbuildinfo +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ExtendedRecordMap, Block, Collection } from '@texonom/ntypes';
|
|
2
2
|
export declare function findAncestors(recordMap: ExtendedRecordMap, block: Block | Collection, list?: string[]): string[];
|
|
3
3
|
//# sourceMappingURL=find-ancestors.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Block, ExtendedRecordMap } from '@texonom/ntypes';
|
|
2
2
|
export declare function getBlockCollectionId(block: Block, recordMap: ExtendedRecordMap): string | null;
|
|
3
3
|
//# sourceMappingURL=get-block-collection-id.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ExtendedRecordMap } from '@texonom/ntypes';
|
|
2
2
|
export declare const getPageBreadcrumbs: (recordMap: ExtendedRecordMap, activePageId: string) => Array<any> | null;
|
|
3
3
|
//# sourceMappingURL=get-page-breadcrumbs.d.ts.map
|
package/build/index.d.ts
CHANGED
|
@@ -1,208 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
|
|
29
|
-
* 3. multi select property will return `string[]`
|
|
30
|
-
* 4. checkbox property return `boolean`
|
|
31
|
-
* @todo complete all no-text property type
|
|
32
|
-
*/
|
|
33
|
-
declare function getPageProperty<T = string | number | boolean | string[] | number[]>(propertyName: string, block: Block, recordMap: ExtendedRecordMap): T;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Attempts to find a valid date from a given property.
|
|
37
|
-
*/
|
|
38
|
-
declare const getDateValue: (prop: any[]) => FormattedDate | null;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Returns the parent page block containing a given page.
|
|
42
|
-
*
|
|
43
|
-
* Note that many times this will not be the direct parent block since
|
|
44
|
-
* some non-page content blocks can contain sub-blocks.
|
|
45
|
-
*/
|
|
46
|
-
declare const getBlockParentPage: (block: Block, recordMap: ExtendedRecordMap, { inclusive }?: {
|
|
47
|
-
inclusive?: boolean;
|
|
48
|
-
}) => PageBlock | null;
|
|
49
|
-
declare const getBlockParent: (block: Block, recordMap: ExtendedRecordMap, { inclusive }?: {
|
|
50
|
-
inclusive?: boolean;
|
|
51
|
-
}) => PageBlock | Collection | Space;
|
|
52
|
-
|
|
53
|
-
interface TableOfContentsEntry {
|
|
54
|
-
id: ID;
|
|
55
|
-
type: BlockType;
|
|
56
|
-
text: string;
|
|
57
|
-
indentLevel: number;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Gets the metadata for a table of contents block by parsing the page's
|
|
61
|
-
* H1, H2, and H3 elements.
|
|
62
|
-
*/
|
|
63
|
-
declare const getPageTableOfContents: (page: PageBlock, recordMap: ExtendedRecordMap) => Array<TableOfContentsEntry>;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Gets the IDs of all blocks contained on a page starting from a root block ID.
|
|
67
|
-
*/
|
|
68
|
-
declare const getPageContentBlockIds: (recordMap: ExtendedRecordMap, blockId?: string, locust?: boolean) => string[];
|
|
69
|
-
/**
|
|
70
|
-
* Gets the IDs of all blocks contained on a page starting from a root block ID.
|
|
71
|
-
*/
|
|
72
|
-
declare const getPageContentUserIds: (recordMap: ExtendedRecordMap, blockId?: string) => string[];
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Robustly extracts the notion page ID from a notion URL or pathname suffix.
|
|
76
|
-
*
|
|
77
|
-
* Defaults to returning a UUID (with dashes).
|
|
78
|
-
*/
|
|
79
|
-
declare const parsePageId: (id?: string | null, { uuid }?: {
|
|
80
|
-
uuid?: boolean;
|
|
81
|
-
}) => string;
|
|
82
|
-
|
|
83
|
-
declare const idToUuid: (id?: string) => string;
|
|
84
|
-
|
|
85
|
-
declare const uuidToId: (uuid: string) => string;
|
|
86
|
-
|
|
87
|
-
type PageTree = {
|
|
88
|
-
id: string;
|
|
89
|
-
type: string;
|
|
90
|
-
title: string;
|
|
91
|
-
blocks: number;
|
|
92
|
-
pages: number;
|
|
93
|
-
parent?: PageTree;
|
|
94
|
-
children: PageTree[];
|
|
95
|
-
};
|
|
96
|
-
type FetchOption = RequestInit & {
|
|
97
|
-
timeout?: number;
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* Performs a traversal over a given Notion workspace starting from a seed page.
|
|
101
|
-
*
|
|
102
|
-
* Returns a map containing all of the pages that are reachable from the seed
|
|
103
|
-
* page in the space.
|
|
104
|
-
*
|
|
105
|
-
* If `rootSpaceId` is not defined, the space ID of the root page will be used
|
|
106
|
-
* to scope traversal.
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
* @param rootPageId - Page ID to start from.
|
|
110
|
-
* @param rootSpaceId - Space ID to scope traversal.
|
|
111
|
-
* @param getPage - Function used to fetch a single page.
|
|
112
|
-
* @param opts - Optional config
|
|
113
|
-
*/
|
|
114
|
-
declare function getAllInSpace(startPageId: string, getPage: (pageId: string, { fetchOption }?: {
|
|
115
|
-
fetchOption?: FetchOption;
|
|
116
|
-
}) => Promise<ExtendedRecordMap>, getBlocks: (blockIds: string[], fetchOption?: FetchOption) => Promise<PageChunk>, fetchCollections: (contentBlockIds: string[], recordMap: ExtendedRecordMap, pageId?: string, { fetchOption, concurrency, collectionConcurrency }?: {
|
|
117
|
-
fetchOption?: FetchOption;
|
|
118
|
-
concurrency: number;
|
|
119
|
-
collectionConcurrency?: number;
|
|
120
|
-
}) => Promise<ExtendedRecordMap>, { startRecordMap, fetchOption, maxPage, debug, concurrency, collectionConcurrency }?: {
|
|
121
|
-
startRecordMap?: ExtendedRecordMap;
|
|
122
|
-
fetchOption?: FetchOption;
|
|
123
|
-
concurrency?: number;
|
|
124
|
-
maxPage?: number;
|
|
125
|
-
debug?: boolean;
|
|
126
|
-
collectionConcurrency?: number;
|
|
127
|
-
}): Promise<{
|
|
128
|
-
recordMap: ExtendedRecordMap;
|
|
129
|
-
pageMap: PageMap;
|
|
130
|
-
pageTree: PageTree;
|
|
131
|
-
}>;
|
|
132
|
-
declare function recursivePageTree(recordMap: ExtendedRecordMap, pageTree: PageTree): PageTree;
|
|
133
|
-
declare function getPageSync(pageId: string, recordMap: ExtendedRecordMap, getBlocks: (blockIds: string[], fetchOption?: FetchOption) => Promise<PageChunk>): Promise<ExtendedRecordMap>;
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Gets the canonical, display-friendly version of a page's ID for use in URLs.
|
|
137
|
-
*/
|
|
138
|
-
declare const getCanonicalPageId: (pageId: string, recordMap: ExtendedRecordMap, { uuid }?: {
|
|
139
|
-
uuid?: boolean;
|
|
140
|
-
}) => string | null;
|
|
141
|
-
|
|
142
|
-
declare const getPageBreadcrumbs: (recordMap: ExtendedRecordMap, activePageId: string) => Array<any> | null;
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Gets URLs of all images contained on the given page.
|
|
146
|
-
*/
|
|
147
|
-
declare const getPageImageUrls: (recordMap: ExtendedRecordMap, { mapImageUrl }: {
|
|
148
|
-
mapImageUrl: (url: string, block: Block) => string | null;
|
|
149
|
-
}) => string[];
|
|
150
|
-
|
|
151
|
-
declare const normalizeUrl: (url?: string) => string;
|
|
152
|
-
|
|
153
|
-
declare const normalizeTitle: (title?: string | null) => string;
|
|
154
|
-
|
|
155
|
-
declare function mergeRecordMaps(recordMapA: ExtendedRecordMap, recordMapB: ExtendedRecordMap): ExtendedRecordMap;
|
|
156
|
-
|
|
157
|
-
declare const formatDate: (input: string | number, { month }?: {
|
|
158
|
-
month?: "long" | "short";
|
|
159
|
-
}) => string;
|
|
160
|
-
|
|
161
|
-
interface NotionDateTime {
|
|
162
|
-
type: 'datetime';
|
|
163
|
-
start_date: string;
|
|
164
|
-
start_time?: string;
|
|
165
|
-
time_zone?: string;
|
|
166
|
-
}
|
|
167
|
-
declare const formatNotionDateTime: (datetime: NotionDateTime) => string;
|
|
168
|
-
|
|
169
|
-
declare function findAncestors(recordMap: ExtendedRecordMap, block: Block | Collection, list?: string[]): string[];
|
|
170
|
-
|
|
171
|
-
type EstimatePageReadTimeOptions = {
|
|
172
|
-
wordsPerMinute?: number;
|
|
173
|
-
imageReadTimeInSeconds?: number;
|
|
174
|
-
};
|
|
175
|
-
type ContentStats = {
|
|
176
|
-
numWords: number;
|
|
177
|
-
numImages: number;
|
|
178
|
-
};
|
|
179
|
-
type PageReadTimeEstimate = ContentStats & {
|
|
180
|
-
totalWordsReadTimeInMinutes: number;
|
|
181
|
-
totalImageReadTimeInMinutes: number;
|
|
182
|
-
totalReadTimeInMinutes: number;
|
|
183
|
-
};
|
|
184
|
-
/**
|
|
185
|
-
* Returns an estimate for the time it would take for a person to read the content
|
|
186
|
-
* in the given Notion page.
|
|
187
|
-
*
|
|
188
|
-
* Uses Medium for inspiration.
|
|
189
|
-
*
|
|
190
|
-
* @see https://blog.medium.com/read-time-and-you-bc2048ab620c
|
|
191
|
-
* @see https://github.com/ngryman/reading-time
|
|
192
|
-
*
|
|
193
|
-
* TODO: handle non-english content.
|
|
194
|
-
*/
|
|
195
|
-
declare function estimatePageReadTime(block: Block, recordMap: ExtendedRecordMap, { wordsPerMinute, imageReadTimeInSeconds }?: EstimatePageReadTimeOptions): PageReadTimeEstimate;
|
|
196
|
-
/**
|
|
197
|
-
* Same as `estimatePageReadTime`, except it returns the total time estimate as
|
|
198
|
-
* a human-readable string.
|
|
199
|
-
*
|
|
200
|
-
* For example, "9 minutes" or "less than a minute".
|
|
201
|
-
*/
|
|
202
|
-
declare function estimatePageReadTimeAsHumanizedString(block: Block, recordMap: ExtendedRecordMap, opts: EstimatePageReadTimeOptions): string;
|
|
203
|
-
|
|
204
|
-
declare const defaultMapImageUrl: (url: string, block: Block) => string | null;
|
|
205
|
-
|
|
206
|
-
declare const defaultMapPageUrl: (rootPageId?: string) => (pageId: string) => string;
|
|
207
|
-
|
|
208
|
-
export { type NotionDateTime, type PageTree, type TableOfContentsEntry, defaultMapImageUrl, defaultMapPageUrl, estimatePageReadTime, estimatePageReadTimeAsHumanizedString, findAncestors, formatDate, formatNotionDateTime, getAllInSpace, getBlockCollectionId, getBlockIcon, getBlockParent, getBlockParentPage, getBlockTitle, getCanonicalPageId, getDateValue, getPageBreadcrumbs, getPageContentBlockIds, getPageContentUserIds, getPageImageUrls, getPageProperty, getPageSync, getPageTableOfContents, getPageTitle, getTextContent, idToUuid, mergeRecordMaps, normalizeTitle, normalizeUrl, parsePageId, recursivePageTree, uuidToId };
|
|
1
|
+
export * from './get-text-content';
|
|
2
|
+
export * from './get-block-title';
|
|
3
|
+
export * from './get-block-icon';
|
|
4
|
+
export * from './get-block-collection-id';
|
|
5
|
+
export * from './get-page-title';
|
|
6
|
+
export * from './get-page-property';
|
|
7
|
+
export * from './get-date-value';
|
|
8
|
+
export * from './get-block-parent-page';
|
|
9
|
+
export * from './get-page-table-of-contents';
|
|
10
|
+
export * from './get-page-content-block-ids';
|
|
11
|
+
export * from './parse-page-id';
|
|
12
|
+
export * from './id-to-uuid';
|
|
13
|
+
export * from './uuid-to-id';
|
|
14
|
+
export * from './get-all-in-space';
|
|
15
|
+
export * from './get-canonical-page-id';
|
|
16
|
+
export * from './get-page-breadcrumbs';
|
|
17
|
+
export * from './get-page-image-urls';
|
|
18
|
+
export * from './is-url';
|
|
19
|
+
export * from './normalize-url';
|
|
20
|
+
export * from './normalize-title';
|
|
21
|
+
export * from './merge-record-maps';
|
|
22
|
+
export * from './format-date';
|
|
23
|
+
export * from './format-notion-date-time';
|
|
24
|
+
export * from './find-ancestors';
|
|
25
|
+
export * from './estimate-page-read-time';
|
|
26
|
+
export * from './map-image-url';
|
|
27
|
+
export * from './map-page-url';
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|