@im-nobsidian/core 0.1.4 → 0.1.7
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/dist/index.d.ts +174 -3
- package/dist/index.js +1205 -78
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -272,7 +272,11 @@ interface Conflict {
|
|
|
272
272
|
readonly localContent: string;
|
|
273
273
|
readonly remoteContent: string;
|
|
274
274
|
}
|
|
275
|
-
|
|
275
|
+
interface ProgressItem {
|
|
276
|
+
readonly path: string;
|
|
277
|
+
readonly operation: "create" | "update" | "delete";
|
|
278
|
+
}
|
|
279
|
+
type ProgressCallback = (current: number, total: number, item: ProgressItem) => void;
|
|
276
280
|
interface PushOptions {
|
|
277
281
|
readonly paths?: string[];
|
|
278
282
|
readonly force?: boolean;
|
|
@@ -306,6 +310,9 @@ interface PullResult {
|
|
|
306
310
|
readonly writtenPaths: string[];
|
|
307
311
|
readonly failed: FailedOperation[];
|
|
308
312
|
readonly duration: number;
|
|
313
|
+
readonly imageCount: number;
|
|
314
|
+
readonly fileCount: number;
|
|
315
|
+
readonly linkCount: number;
|
|
309
316
|
}
|
|
310
317
|
interface SyncResult {
|
|
311
318
|
readonly push: PushResult;
|
|
@@ -379,6 +386,62 @@ interface WikilinkEntry {
|
|
|
379
386
|
readonly aliases: readonly string[];
|
|
380
387
|
}
|
|
381
388
|
|
|
389
|
+
type ViewType = "table" | "board" | "list" | "calendar" | "timeline" | "gallery" | "form" | "chart" | "map" | "dashboard";
|
|
390
|
+
interface ViewPropertyConfig {
|
|
391
|
+
readonly propertyId: string;
|
|
392
|
+
readonly propertyName?: string;
|
|
393
|
+
readonly visible?: boolean;
|
|
394
|
+
readonly width?: number;
|
|
395
|
+
readonly wrap?: boolean;
|
|
396
|
+
}
|
|
397
|
+
interface CoverConfig {
|
|
398
|
+
readonly type: "page_cover" | "page_content" | "page_content_first" | "property";
|
|
399
|
+
readonly propertyId?: string;
|
|
400
|
+
}
|
|
401
|
+
interface GroupByConfig {
|
|
402
|
+
readonly type: string;
|
|
403
|
+
readonly propertyId: string;
|
|
404
|
+
readonly propertyName?: string;
|
|
405
|
+
readonly sort?: "manual" | "ascending" | "descending";
|
|
406
|
+
readonly hideEmptyGroups?: boolean;
|
|
407
|
+
}
|
|
408
|
+
interface ViewConfig {
|
|
409
|
+
readonly id: string;
|
|
410
|
+
readonly name: string;
|
|
411
|
+
readonly type: ViewType;
|
|
412
|
+
readonly dataSourceId?: string | null;
|
|
413
|
+
readonly filter?: unknown;
|
|
414
|
+
readonly sorts?: Array<{
|
|
415
|
+
readonly property?: string;
|
|
416
|
+
readonly timestamp?: "created_time" | "last_edited_time";
|
|
417
|
+
readonly direction: "ascending" | "descending";
|
|
418
|
+
}>;
|
|
419
|
+
readonly properties?: ViewPropertyConfig[];
|
|
420
|
+
readonly groupBy?: GroupByConfig;
|
|
421
|
+
readonly cover?: CoverConfig;
|
|
422
|
+
readonly coverSize?: "small" | "medium" | "large";
|
|
423
|
+
readonly coverAspect?: "contain" | "cover";
|
|
424
|
+
readonly datePropertyId?: string;
|
|
425
|
+
readonly datePropertyName?: string;
|
|
426
|
+
readonly viewRange?: "week" | "month";
|
|
427
|
+
}
|
|
428
|
+
interface DatabaseViewsConfig {
|
|
429
|
+
readonly databaseId: string;
|
|
430
|
+
readonly databaseName?: string;
|
|
431
|
+
readonly lastSynced: string;
|
|
432
|
+
readonly views: ViewConfig[];
|
|
433
|
+
}
|
|
434
|
+
interface PageCover {
|
|
435
|
+
readonly type: "file" | "external";
|
|
436
|
+
readonly url: string;
|
|
437
|
+
readonly expiryTime?: string;
|
|
438
|
+
}
|
|
439
|
+
interface PageIcon {
|
|
440
|
+
readonly type: "emoji" | "external" | "file" | "icon";
|
|
441
|
+
readonly value: string;
|
|
442
|
+
readonly color?: string;
|
|
443
|
+
}
|
|
444
|
+
|
|
382
445
|
declare class ConfigManager {
|
|
383
446
|
private readonly vaultRoot;
|
|
384
447
|
private config;
|
|
@@ -469,6 +532,7 @@ interface NotionClientOptions {
|
|
|
469
532
|
declare class NotionClient {
|
|
470
533
|
private readonly client;
|
|
471
534
|
private readonly sema;
|
|
535
|
+
private readonly token;
|
|
472
536
|
private readonly propertyMapper;
|
|
473
537
|
constructor(options: NotionClientOptions);
|
|
474
538
|
getInternalClient(): Client;
|
|
@@ -496,6 +560,8 @@ declare class NotionClient {
|
|
|
496
560
|
replaceAll?: boolean;
|
|
497
561
|
}>): Promise<PageMarkdownResponse>;
|
|
498
562
|
movePage(pageId: string, newParentId: string, newParentType: "page" | "database"): Promise<PageObjectResponse>;
|
|
563
|
+
private fetchDatabaseLegacy;
|
|
564
|
+
getDatabaseTitle(databaseId: string): Promise<string>;
|
|
499
565
|
getDatabaseSchema(databaseId: string): Promise<Record<string, {
|
|
500
566
|
id: string;
|
|
501
567
|
type: string;
|
|
@@ -511,6 +577,8 @@ declare class NotionClient {
|
|
|
511
577
|
queryAllDatabasePages(databaseId: string, filter?: unknown): Promise<PageObjectResponse[]>;
|
|
512
578
|
getDataSourceId(databaseId: string): Promise<string>;
|
|
513
579
|
archivePage(pageId: string): Promise<void>;
|
|
580
|
+
getFileBlockUrl(blockId: string): Promise<string | null>;
|
|
581
|
+
getBlock(blockId: string): Promise<BlockObjectResponse>;
|
|
514
582
|
listChildren(blockId: string, options?: {
|
|
515
583
|
startCursor?: string;
|
|
516
584
|
pageSize?: number;
|
|
@@ -519,6 +587,8 @@ declare class NotionClient {
|
|
|
519
587
|
nextCursor: string | null;
|
|
520
588
|
}>;
|
|
521
589
|
fetchAllChildren(blockId: string): Promise<BlockObjectResponse[]>;
|
|
590
|
+
private static readonly CONTAINER_BLOCK_TYPES;
|
|
591
|
+
fetchAllChildrenDeep(blockId: string): Promise<BlockObjectResponse[]>;
|
|
522
592
|
appendChildren(blockId: string, children: unknown[]): Promise<void>;
|
|
523
593
|
deleteBlock(blockId: string): Promise<void>;
|
|
524
594
|
uploadFile(fileData: Blob, filename: string, contentType: string): Promise<string>;
|
|
@@ -535,9 +605,17 @@ declare class NotionClient {
|
|
|
535
605
|
nextCursor: string | null;
|
|
536
606
|
}>;
|
|
537
607
|
getChildPages(parentId: string): Promise<PageObjectResponse[]>;
|
|
608
|
+
getChildDatabaseIds(parentId: string): Promise<string[]>;
|
|
538
609
|
getChildPagesRecursive(parentId: string): Promise<PageObjectResponse[]>;
|
|
610
|
+
listDatabaseViews(databaseId: string): Promise<ViewConfig[]>;
|
|
611
|
+
getView(viewId: string): Promise<ViewConfig | null>;
|
|
612
|
+
getDatabaseViewsConfig(databaseId: string): Promise<DatabaseViewsConfig>;
|
|
613
|
+
extractCover(page: PageObjectResponse): PageCover | null;
|
|
614
|
+
extractIcon(page: PageObjectResponse): PageIcon | null;
|
|
539
615
|
extractTitle(page: PageObjectResponse): string;
|
|
540
616
|
extractProperties(page: PageObjectResponse): Record<string, unknown>;
|
|
617
|
+
private lastRequestTime;
|
|
618
|
+
private readonly minRequestInterval;
|
|
541
619
|
private withRateLimit;
|
|
542
620
|
private executeWithRetry;
|
|
543
621
|
}
|
|
@@ -709,6 +787,8 @@ declare class SyncOrchestrator {
|
|
|
709
787
|
private readonly databaseSyncer;
|
|
710
788
|
private readonly propertyMapper;
|
|
711
789
|
private dbSchemaLoaded;
|
|
790
|
+
private _pullImageCount;
|
|
791
|
+
private _pullFileCount;
|
|
712
792
|
constructor(config: Config, stateDb: StateDB, notionClient: NotionClient, vaultFs: VaultFS);
|
|
713
793
|
push(options?: PushOptions): Promise<PushResult>;
|
|
714
794
|
pull(options?: PullOptions): Promise<PullResult>;
|
|
@@ -716,6 +796,8 @@ declare class SyncOrchestrator {
|
|
|
716
796
|
status(): Promise<StatusResult>;
|
|
717
797
|
private buildConflictsFromRecords;
|
|
718
798
|
private get isDatabaseMode();
|
|
799
|
+
private discoverChildDatabases;
|
|
800
|
+
private resolveNotionLinks;
|
|
719
801
|
private ensureDbSchema;
|
|
720
802
|
private pushCreate;
|
|
721
803
|
private pushUpdate;
|
|
@@ -734,6 +816,7 @@ declare class SyncOrchestrator {
|
|
|
734
816
|
private computePatches;
|
|
735
817
|
private fetchPageMarkdown;
|
|
736
818
|
private extractParentId;
|
|
819
|
+
private resolveBlockToPageId;
|
|
737
820
|
private cleanupInterruptedSync;
|
|
738
821
|
private resolveUniqueFilePath;
|
|
739
822
|
}
|
|
@@ -788,8 +871,16 @@ declare class ImageHandler {
|
|
|
788
871
|
uploadAndAppendImages(pageId: string, images: ImageReference[]): Promise<ImageUploadResult[]>;
|
|
789
872
|
private readImageFromVault;
|
|
790
873
|
private getContentTypeFromPath;
|
|
874
|
+
downloadAllFiles(markdown: string, pageTitle: string): Promise<{
|
|
875
|
+
content: string;
|
|
876
|
+
downloads: ImageDownloadResult[];
|
|
877
|
+
}>;
|
|
878
|
+
private parseNotionFileUrl;
|
|
879
|
+
private downloadFile;
|
|
791
880
|
private isNotionImageUrl;
|
|
881
|
+
private isNotionFileUrl;
|
|
792
882
|
private guessExtension;
|
|
883
|
+
private guessFileExtension;
|
|
793
884
|
}
|
|
794
885
|
|
|
795
886
|
type NotionBlockType = "image" | "pdf" | "video" | "audio" | "file";
|
|
@@ -849,7 +940,8 @@ declare class DatabaseSyncer {
|
|
|
849
940
|
constructor(config: Config, stateDb: StateDB, notionClient: NotionClient, vaultFs: VaultFS, pipeline: ConversionPipeline, imageHandler: ImageHandler);
|
|
850
941
|
pullAll(): Promise<DatabaseSyncResult>;
|
|
851
942
|
pushAll(): Promise<DatabaseSyncResult>;
|
|
852
|
-
|
|
943
|
+
pullDatabase(dbConfig: DatabaseSyncConfig): Promise<DatabaseSyncResult>;
|
|
944
|
+
private pullDatabaseViews;
|
|
853
945
|
private pullDatabasePage;
|
|
854
946
|
private pushDatabase;
|
|
855
947
|
}
|
|
@@ -1121,6 +1213,85 @@ declare class WatchSyncService {
|
|
|
1121
1213
|
private executeSync;
|
|
1122
1214
|
}
|
|
1123
1215
|
|
|
1216
|
+
interface DBEntry {
|
|
1217
|
+
readonly path: string;
|
|
1218
|
+
readonly title: string;
|
|
1219
|
+
readonly icon?: string;
|
|
1220
|
+
readonly cover?: string;
|
|
1221
|
+
readonly properties: Record<string, PropertyValue>;
|
|
1222
|
+
}
|
|
1223
|
+
type PropertyValue = string | number | boolean | null | string[] | {
|
|
1224
|
+
start: string;
|
|
1225
|
+
end?: string;
|
|
1226
|
+
};
|
|
1227
|
+
interface GroupedEntries {
|
|
1228
|
+
readonly groupName: string;
|
|
1229
|
+
readonly groupColor?: NotionColor;
|
|
1230
|
+
readonly entries: DBEntry[];
|
|
1231
|
+
}
|
|
1232
|
+
interface CalendarEntry {
|
|
1233
|
+
readonly entry: DBEntry;
|
|
1234
|
+
readonly date: string;
|
|
1235
|
+
readonly endDate?: string;
|
|
1236
|
+
}
|
|
1237
|
+
type NotionColor = "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red";
|
|
1238
|
+
interface ViewRenderData {
|
|
1239
|
+
readonly databaseId: string;
|
|
1240
|
+
readonly databaseName?: string;
|
|
1241
|
+
readonly viewConfig: ViewConfig;
|
|
1242
|
+
readonly entries: DBEntry[];
|
|
1243
|
+
readonly grouped?: GroupedEntries[];
|
|
1244
|
+
readonly calendarEntries?: CalendarEntry[];
|
|
1245
|
+
readonly propertyNames: string[];
|
|
1246
|
+
readonly schema?: Record<string, PropertySchema>;
|
|
1247
|
+
}
|
|
1248
|
+
interface PropertySchema {
|
|
1249
|
+
readonly name: string;
|
|
1250
|
+
readonly type: string;
|
|
1251
|
+
readonly options?: PropertyOption[];
|
|
1252
|
+
}
|
|
1253
|
+
interface PropertyOption {
|
|
1254
|
+
readonly name: string;
|
|
1255
|
+
readonly color?: NotionColor;
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
declare class ViewDataProvider {
|
|
1259
|
+
private readonly vaultFs;
|
|
1260
|
+
constructor(vaultFs: VaultFS);
|
|
1261
|
+
loadAllViewConfigs(): Promise<Record<string, DatabaseViewsConfig>>;
|
|
1262
|
+
getViewConfigs(databaseId: string): Promise<DatabaseViewsConfig | null>;
|
|
1263
|
+
collectEntries(folderPath: string): Promise<DBEntry[]>;
|
|
1264
|
+
buildViewData(databaseId: string, viewId: string, folderPath: string, schema?: Record<string, PropertySchema>): Promise<ViewRenderData | null>;
|
|
1265
|
+
buildDefaultViewData(databaseId: string, folderPath: string, schema?: Record<string, PropertySchema>): Promise<ViewRenderData | null>;
|
|
1266
|
+
processViewData(entries: DBEntry[], viewConfig: ViewConfig, databaseId: string, databaseName?: string, schema?: Record<string, PropertySchema>): ViewRenderData;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
declare class EntryEditor {
|
|
1270
|
+
private readonly vaultFs;
|
|
1271
|
+
constructor(vaultFs: VaultFS);
|
|
1272
|
+
updateProperty(entryPath: string, propertyName: string, newValue: PropertyValue): Promise<void>;
|
|
1273
|
+
createEntry(folderPath: string, title: string, properties: Record<string, PropertyValue>): Promise<string>;
|
|
1274
|
+
moveEntryToGroup(entry: DBEntry, groupProperty: string, newGroupValue: string): Promise<void>;
|
|
1275
|
+
updateDate(entryPath: string, dateProperty: string, newDate: string): Promise<void>;
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
declare function sortEntries(entries: DBEntry[], sorts: NonNullable<ViewConfig["sorts"]>): DBEntry[];
|
|
1279
|
+
declare function groupEntries(entries: DBEntry[], groupByProperty: string, options?: {
|
|
1280
|
+
sort?: "ascending" | "descending";
|
|
1281
|
+
hideEmptyGroups?: boolean;
|
|
1282
|
+
}): GroupedEntries[];
|
|
1283
|
+
declare function extractCalendarEntries(entries: DBEntry[], dateProperty: string): CalendarEntry[];
|
|
1284
|
+
declare function filterByMonth(calendarEntries: CalendarEntry[], year: number, month: number): CalendarEntry[];
|
|
1285
|
+
declare function getVisibleProperties(viewConfig: ViewConfig): Array<{
|
|
1286
|
+
id: string;
|
|
1287
|
+
name: string;
|
|
1288
|
+
width?: number;
|
|
1289
|
+
}>;
|
|
1290
|
+
|
|
1291
|
+
declare function getNotionColor(color: NotionColor | string): string;
|
|
1292
|
+
declare function getNotionBgColor(color: NotionColor | string): string;
|
|
1293
|
+
declare function generateColorCSS(): string;
|
|
1294
|
+
|
|
1124
1295
|
declare function computeHash(content: string): string;
|
|
1125
1296
|
declare function computeBufferHash(buffer: Buffer): string;
|
|
1126
1297
|
|
|
@@ -1144,4 +1315,4 @@ interface PipelineOptions {
|
|
|
1144
1315
|
}
|
|
1145
1316
|
declare function createDefaultPipeline(options?: PipelineOptions): ConversionPipeline;
|
|
1146
1317
|
|
|
1147
|
-
export { BlockConverter, CalloutRestorer, CalloutTransformer, ChangeDetector, ColorAnnotator, type Config, ConfigManager, ConfigSchema, type Conflict, ConflictResolver, type ConflictStrategy, type ConversionContext, type ConversionPath, ConversionPipeline, type ConversionResult, DEFAULT_CONFIG, type DatabaseSyncConfig, type DatabaseSyncResult, DatabaseSyncer, EmbedResolver, type FailedOperation, type FileDownloadResult, FileHandler, type FileInfo, type FileSystemEntry, type FileType, type FileUploadResult, FileWatcher, FrontmatterExtractor, FrontmatterGenerator, HtmlAnnotationStripper, type ImageDownloadResult, ImageHandler, type ImageReference, InlineDBParser, type LocalChange, LocalImageRestorer, type Logger, type MappingResult, type MappingType, MathNormalizer, MentionToWikilink, type MergeConflictRegion, type MergeResult, NodeVaultFS, type NonMdFileInfo, type NotionBlock, NotionBlockBuilder, NotionClient, type NotionClientOptions, type NotionPageNode, type NotionRichText, type RichTextItem as NotionRichTextItem, type OperationType, type PageCreationPlan, type PathFilterConfig, type PreserveMarker, PreserveMarkerCollector, PreserveMarkerInjector, type Processor, type ProcessorInput, type ProcessorMetadata, type ProcessorOutput, type ProgressCallback, PropertiesTableInjector, PropertiesTableRestorer, PropertyMapper, type PullOptions, type PullResult, type PushOptions, type PushResult, type RemoteChange, type ResolutionChoice, type ResolutionResult, type RichTextSegment, StateDB, type StatusResult, type SyncDirection, type SyncOptions, SyncOrchestrator, type SyncRecord, type SyncResult, type SyncStatus, TreeMapper, UnsupportedBlockStripper, type UpsertSyncRecord, type VaultFS, type WatchSyncOptions, WatchSyncService, type WikilinkEntry, WikilinkResolver, computeBufferHash, computeHash, createDefaultPipeline, generateId, getLogger, normalizeNotionId, notionIdsEqual, sanitizeFileName, setLogger, threeWayMerge };
|
|
1318
|
+
export { BlockConverter, type CalendarEntry, CalloutRestorer, CalloutTransformer, ChangeDetector, ColorAnnotator, type Config, ConfigManager, ConfigSchema, type Conflict, ConflictResolver, type ConflictStrategy, type ConversionContext, type ConversionPath, ConversionPipeline, type ConversionResult, type CoverConfig, type DBEntry, DEFAULT_CONFIG, type DatabaseSyncConfig, type DatabaseSyncResult, DatabaseSyncer, type DatabaseViewsConfig, EmbedResolver, EntryEditor, type FailedOperation, type FileDownloadResult, FileHandler, type FileInfo, type FileSystemEntry, type FileType, type FileUploadResult, FileWatcher, FrontmatterExtractor, FrontmatterGenerator, type GroupByConfig, type GroupedEntries, HtmlAnnotationStripper, type ImageDownloadResult, ImageHandler, type ImageReference, InlineDBParser, type LocalChange, LocalImageRestorer, type Logger, type MappingResult, type MappingType, MathNormalizer, MentionToWikilink, type MergeConflictRegion, type MergeResult, NodeVaultFS, type NonMdFileInfo, type NotionBlock, NotionBlockBuilder, NotionClient, type NotionClientOptions, type NotionColor, type NotionPageNode, type NotionRichText, type RichTextItem as NotionRichTextItem, type OperationType, type PageCover, type PageCreationPlan, type PageIcon, type PathFilterConfig, type PreserveMarker, PreserveMarkerCollector, PreserveMarkerInjector, type Processor, type ProcessorInput, type ProcessorMetadata, type ProcessorOutput, type ProgressCallback, type ProgressItem, PropertiesTableInjector, PropertiesTableRestorer, PropertyMapper, type PropertyOption, type PropertySchema, type PropertyValue, type PullOptions, type PullResult, type PushOptions, type PushResult, type RemoteChange, type ResolutionChoice, type ResolutionResult, type RichTextSegment, StateDB, type StatusResult, type SyncDirection, type SyncOptions, SyncOrchestrator, type SyncRecord, type SyncResult, type SyncStatus, TreeMapper, UnsupportedBlockStripper, type UpsertSyncRecord, type VaultFS, type ViewConfig, ViewDataProvider, type ViewPropertyConfig, type ViewRenderData, type ViewType, type WatchSyncOptions, WatchSyncService, type WikilinkEntry, WikilinkResolver, computeBufferHash, computeHash, createDefaultPipeline, extractCalendarEntries, filterByMonth, generateColorCSS, generateId, getLogger, getNotionBgColor, getNotionColor, getVisibleProperties, groupEntries, normalizeNotionId, notionIdsEqual, sanitizeFileName, setLogger, sortEntries, threeWayMerge };
|