@texonom/nutils 1.4.7 → 1.5.0

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.
@@ -1,3 +1,3 @@
1
- import type { ExtendedRecordMap, Block, Collection } from '@texonom/ntypes';
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,4 +1,4 @@
1
- import type { ExtendedRecordMap, PageMap, PageChunk } from '@texonom/ntypes';
1
+ import { ExtendedRecordMap, PageMap, PageChunk } from '@texonom/ntypes';
2
2
  export type PageTree = {
3
3
  id: string;
4
4
  type: string;
@@ -1,3 +1,3 @@
1
- import type { Block, ExtendedRecordMap } from '@texonom/ntypes';
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 type { Block, ExtendedRecordMap } from '@texonom/ntypes';
1
+ import { Block, ExtendedRecordMap } from '@texonom/ntypes';
2
2
  export declare function getBlockIcon(block: Block, recordMap: ExtendedRecordMap): string;
3
3
  //# sourceMappingURL=get-block-icon.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { Block, ExtendedRecordMap, PageBlock, Collection, Space } from '@texonom/ntypes';
1
+ import { Block, ExtendedRecordMap, PageBlock, Collection, Space } from '@texonom/ntypes';
2
2
  /**
3
3
  * Returns the parent page block containing a given page.
4
4
  *
@@ -1,3 +1,3 @@
1
- import type { Block, ExtendedRecordMap } from '@texonom/ntypes';
1
+ import { Block, ExtendedRecordMap } from '@texonom/ntypes';
2
2
  export declare function getBlockTitle(block: Block, recordMap: ExtendedRecordMap): string;
3
3
  //# sourceMappingURL=get-block-title.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { ExtendedRecordMap } from '@texonom/ntypes';
1
+ import { ExtendedRecordMap } from '@texonom/ntypes';
2
2
  /**
3
3
  * Gets the canonical, display-friendly version of a page's ID for use in URLs.
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { FormattedDate } from '@texonom/ntypes';
1
+ import { FormattedDate } from '@texonom/ntypes';
2
2
  /**
3
3
  * Attempts to find a valid date from a given property.
4
4
  */
@@ -1,3 +1,3 @@
1
- import type { ExtendedRecordMap } from '@texonom/ntypes';
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
@@ -1,4 +1,4 @@
1
- import type { ExtendedRecordMap } from '@texonom/ntypes';
1
+ import { ExtendedRecordMap } from '@texonom/ntypes';
2
2
  /**
3
3
  * Gets the IDs of all blocks contained on a page starting from a root block ID.
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { Block, ExtendedRecordMap } from '@texonom/ntypes';
1
+ import { Block, ExtendedRecordMap } from '@texonom/ntypes';
2
2
  /**
3
3
  * Gets URLs of all images contained on the given page.
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { ID, BlockType, PageBlock, ExtendedRecordMap } from '@texonom/ntypes';
1
+ import { ID, BlockType, PageBlock, ExtendedRecordMap } from '@texonom/ntypes';
2
2
  export interface TableOfContentsEntry {
3
3
  id: ID;
4
4
  type: BlockType;
@@ -1,3 +1,3 @@
1
- import type { ExtendedRecordMap } from '@texonom/ntypes';
1
+ import { ExtendedRecordMap } from '@texonom/ntypes';
2
2
  export declare function getPageTitle(recordMap: ExtendedRecordMap): string;
3
3
  //# sourceMappingURL=get-page-title.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { Decoration } from '@texonom/ntypes';
1
+ import { Decoration } from '@texonom/ntypes';
2
2
  /**
3
3
  * Gets the raw, unformatted text content of a block's content value.
4
4
  *
package/build/index.d.ts CHANGED
@@ -1,208 +1,28 @@
1
- import { Decoration, Block, ExtendedRecordMap, FormattedDate, PageBlock, Collection, Space, ID, BlockType, PageChunk, PageMap } from '@texonom/ntypes';
2
- export { default as isUrl } from 'is-url-superb';
3
-
4
- /**
5
- * Gets the raw, unformatted text content of a block's content value.
6
- *
7
- * This is useful, for instance, for extracting a block's `title` without any
8
- * rich text formatting.
9
- */
10
- declare const getTextContent: (text?: Decoration[]) => string;
11
-
12
- declare function getBlockTitle(block: Block, recordMap: ExtendedRecordMap): string;
13
-
14
- declare function getBlockIcon(block: Block, recordMap: ExtendedRecordMap): string;
15
-
16
- declare function getBlockCollectionId(block: Block, recordMap: ExtendedRecordMap): string | null;
17
-
18
- declare function getPageTitle(recordMap: ExtendedRecordMap): string;
19
-
20
- /**
21
- * Gets the value of a collection property for a given page (collection item).
22
- *
23
- * @param propertyName property name
24
- * @param block Page block, often be first block in blockMap
25
- * @param recordMap
26
- * @returns - The return value types will follow the following principles:
27
- * 1. if property is date type, it will return `number` or `number[]`(depends on `End Date` switch)
28
- * 2. property is text-like will return `string`
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