@im-nobsidian/core 0.1.4 → 0.1.6

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 CHANGED
@@ -379,6 +379,62 @@ interface WikilinkEntry {
379
379
  readonly aliases: readonly string[];
380
380
  }
381
381
 
382
+ type ViewType = "table" | "board" | "list" | "calendar" | "timeline" | "gallery" | "form" | "chart" | "map" | "dashboard";
383
+ interface ViewPropertyConfig {
384
+ readonly propertyId: string;
385
+ readonly propertyName?: string;
386
+ readonly visible?: boolean;
387
+ readonly width?: number;
388
+ readonly wrap?: boolean;
389
+ }
390
+ interface CoverConfig {
391
+ readonly type: "page_cover" | "page_content" | "page_content_first" | "property";
392
+ readonly propertyId?: string;
393
+ }
394
+ interface GroupByConfig {
395
+ readonly type: string;
396
+ readonly propertyId: string;
397
+ readonly propertyName?: string;
398
+ readonly sort?: "manual" | "ascending" | "descending";
399
+ readonly hideEmptyGroups?: boolean;
400
+ }
401
+ interface ViewConfig {
402
+ readonly id: string;
403
+ readonly name: string;
404
+ readonly type: ViewType;
405
+ readonly dataSourceId?: string | null;
406
+ readonly filter?: unknown;
407
+ readonly sorts?: Array<{
408
+ readonly property?: string;
409
+ readonly timestamp?: "created_time" | "last_edited_time";
410
+ readonly direction: "ascending" | "descending";
411
+ }>;
412
+ readonly properties?: ViewPropertyConfig[];
413
+ readonly groupBy?: GroupByConfig;
414
+ readonly cover?: CoverConfig;
415
+ readonly coverSize?: "small" | "medium" | "large";
416
+ readonly coverAspect?: "contain" | "cover";
417
+ readonly datePropertyId?: string;
418
+ readonly datePropertyName?: string;
419
+ readonly viewRange?: "week" | "month";
420
+ }
421
+ interface DatabaseViewsConfig {
422
+ readonly databaseId: string;
423
+ readonly databaseName?: string;
424
+ readonly lastSynced: string;
425
+ readonly views: ViewConfig[];
426
+ }
427
+ interface PageCover {
428
+ readonly type: "file" | "external";
429
+ readonly url: string;
430
+ readonly expiryTime?: string;
431
+ }
432
+ interface PageIcon {
433
+ readonly type: "emoji" | "external" | "file" | "icon";
434
+ readonly value: string;
435
+ readonly color?: string;
436
+ }
437
+
382
438
  declare class ConfigManager {
383
439
  private readonly vaultRoot;
384
440
  private config;
@@ -469,6 +525,7 @@ interface NotionClientOptions {
469
525
  declare class NotionClient {
470
526
  private readonly client;
471
527
  private readonly sema;
528
+ private readonly token;
472
529
  private readonly propertyMapper;
473
530
  constructor(options: NotionClientOptions);
474
531
  getInternalClient(): Client;
@@ -496,6 +553,8 @@ declare class NotionClient {
496
553
  replaceAll?: boolean;
497
554
  }>): Promise<PageMarkdownResponse>;
498
555
  movePage(pageId: string, newParentId: string, newParentType: "page" | "database"): Promise<PageObjectResponse>;
556
+ private fetchDatabaseLegacy;
557
+ getDatabaseTitle(databaseId: string): Promise<string>;
499
558
  getDatabaseSchema(databaseId: string): Promise<Record<string, {
500
559
  id: string;
501
560
  type: string;
@@ -511,6 +570,8 @@ declare class NotionClient {
511
570
  queryAllDatabasePages(databaseId: string, filter?: unknown): Promise<PageObjectResponse[]>;
512
571
  getDataSourceId(databaseId: string): Promise<string>;
513
572
  archivePage(pageId: string): Promise<void>;
573
+ getFileBlockUrl(blockId: string): Promise<string | null>;
574
+ getBlock(blockId: string): Promise<BlockObjectResponse>;
514
575
  listChildren(blockId: string, options?: {
515
576
  startCursor?: string;
516
577
  pageSize?: number;
@@ -519,6 +580,8 @@ declare class NotionClient {
519
580
  nextCursor: string | null;
520
581
  }>;
521
582
  fetchAllChildren(blockId: string): Promise<BlockObjectResponse[]>;
583
+ private static readonly CONTAINER_BLOCK_TYPES;
584
+ fetchAllChildrenDeep(blockId: string): Promise<BlockObjectResponse[]>;
522
585
  appendChildren(blockId: string, children: unknown[]): Promise<void>;
523
586
  deleteBlock(blockId: string): Promise<void>;
524
587
  uploadFile(fileData: Blob, filename: string, contentType: string): Promise<string>;
@@ -535,9 +598,17 @@ declare class NotionClient {
535
598
  nextCursor: string | null;
536
599
  }>;
537
600
  getChildPages(parentId: string): Promise<PageObjectResponse[]>;
601
+ getChildDatabaseIds(parentId: string): Promise<string[]>;
538
602
  getChildPagesRecursive(parentId: string): Promise<PageObjectResponse[]>;
603
+ listDatabaseViews(databaseId: string): Promise<ViewConfig[]>;
604
+ getView(viewId: string): Promise<ViewConfig | null>;
605
+ getDatabaseViewsConfig(databaseId: string): Promise<DatabaseViewsConfig>;
606
+ extractCover(page: PageObjectResponse): PageCover | null;
607
+ extractIcon(page: PageObjectResponse): PageIcon | null;
539
608
  extractTitle(page: PageObjectResponse): string;
540
609
  extractProperties(page: PageObjectResponse): Record<string, unknown>;
610
+ private lastRequestTime;
611
+ private readonly minRequestInterval;
541
612
  private withRateLimit;
542
613
  private executeWithRetry;
543
614
  }
@@ -716,6 +787,8 @@ declare class SyncOrchestrator {
716
787
  status(): Promise<StatusResult>;
717
788
  private buildConflictsFromRecords;
718
789
  private get isDatabaseMode();
790
+ private discoverChildDatabases;
791
+ private resolveNotionLinks;
719
792
  private ensureDbSchema;
720
793
  private pushCreate;
721
794
  private pushUpdate;
@@ -734,6 +807,7 @@ declare class SyncOrchestrator {
734
807
  private computePatches;
735
808
  private fetchPageMarkdown;
736
809
  private extractParentId;
810
+ private resolveBlockToPageId;
737
811
  private cleanupInterruptedSync;
738
812
  private resolveUniqueFilePath;
739
813
  }
@@ -788,8 +862,16 @@ declare class ImageHandler {
788
862
  uploadAndAppendImages(pageId: string, images: ImageReference[]): Promise<ImageUploadResult[]>;
789
863
  private readImageFromVault;
790
864
  private getContentTypeFromPath;
865
+ downloadAllFiles(markdown: string, pageTitle: string): Promise<{
866
+ content: string;
867
+ downloads: ImageDownloadResult[];
868
+ }>;
869
+ private parseNotionFileUrl;
870
+ private downloadFile;
791
871
  private isNotionImageUrl;
872
+ private isNotionFileUrl;
792
873
  private guessExtension;
874
+ private guessFileExtension;
793
875
  }
794
876
 
795
877
  type NotionBlockType = "image" | "pdf" | "video" | "audio" | "file";
@@ -849,7 +931,8 @@ declare class DatabaseSyncer {
849
931
  constructor(config: Config, stateDb: StateDB, notionClient: NotionClient, vaultFs: VaultFS, pipeline: ConversionPipeline, imageHandler: ImageHandler);
850
932
  pullAll(): Promise<DatabaseSyncResult>;
851
933
  pushAll(): Promise<DatabaseSyncResult>;
852
- private pullDatabase;
934
+ pullDatabase(dbConfig: DatabaseSyncConfig): Promise<DatabaseSyncResult>;
935
+ private pullDatabaseViews;
853
936
  private pullDatabasePage;
854
937
  private pushDatabase;
855
938
  }
@@ -1121,6 +1204,85 @@ declare class WatchSyncService {
1121
1204
  private executeSync;
1122
1205
  }
1123
1206
 
1207
+ interface DBEntry {
1208
+ readonly path: string;
1209
+ readonly title: string;
1210
+ readonly icon?: string;
1211
+ readonly cover?: string;
1212
+ readonly properties: Record<string, PropertyValue>;
1213
+ }
1214
+ type PropertyValue = string | number | boolean | null | string[] | {
1215
+ start: string;
1216
+ end?: string;
1217
+ };
1218
+ interface GroupedEntries {
1219
+ readonly groupName: string;
1220
+ readonly groupColor?: NotionColor;
1221
+ readonly entries: DBEntry[];
1222
+ }
1223
+ interface CalendarEntry {
1224
+ readonly entry: DBEntry;
1225
+ readonly date: string;
1226
+ readonly endDate?: string;
1227
+ }
1228
+ type NotionColor = "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red";
1229
+ interface ViewRenderData {
1230
+ readonly databaseId: string;
1231
+ readonly databaseName?: string;
1232
+ readonly viewConfig: ViewConfig;
1233
+ readonly entries: DBEntry[];
1234
+ readonly grouped?: GroupedEntries[];
1235
+ readonly calendarEntries?: CalendarEntry[];
1236
+ readonly propertyNames: string[];
1237
+ readonly schema?: Record<string, PropertySchema>;
1238
+ }
1239
+ interface PropertySchema {
1240
+ readonly name: string;
1241
+ readonly type: string;
1242
+ readonly options?: PropertyOption[];
1243
+ }
1244
+ interface PropertyOption {
1245
+ readonly name: string;
1246
+ readonly color?: NotionColor;
1247
+ }
1248
+
1249
+ declare class ViewDataProvider {
1250
+ private readonly vaultFs;
1251
+ constructor(vaultFs: VaultFS);
1252
+ loadAllViewConfigs(): Promise<Record<string, DatabaseViewsConfig>>;
1253
+ getViewConfigs(databaseId: string): Promise<DatabaseViewsConfig | null>;
1254
+ collectEntries(folderPath: string): Promise<DBEntry[]>;
1255
+ buildViewData(databaseId: string, viewId: string, folderPath: string, schema?: Record<string, PropertySchema>): Promise<ViewRenderData | null>;
1256
+ buildDefaultViewData(databaseId: string, folderPath: string, schema?: Record<string, PropertySchema>): Promise<ViewRenderData | null>;
1257
+ processViewData(entries: DBEntry[], viewConfig: ViewConfig, databaseId: string, databaseName?: string, schema?: Record<string, PropertySchema>): ViewRenderData;
1258
+ }
1259
+
1260
+ declare class EntryEditor {
1261
+ private readonly vaultFs;
1262
+ constructor(vaultFs: VaultFS);
1263
+ updateProperty(entryPath: string, propertyName: string, newValue: PropertyValue): Promise<void>;
1264
+ createEntry(folderPath: string, title: string, properties: Record<string, PropertyValue>): Promise<string>;
1265
+ moveEntryToGroup(entry: DBEntry, groupProperty: string, newGroupValue: string): Promise<void>;
1266
+ updateDate(entryPath: string, dateProperty: string, newDate: string): Promise<void>;
1267
+ }
1268
+
1269
+ declare function sortEntries(entries: DBEntry[], sorts: NonNullable<ViewConfig["sorts"]>): DBEntry[];
1270
+ declare function groupEntries(entries: DBEntry[], groupByProperty: string, options?: {
1271
+ sort?: "ascending" | "descending";
1272
+ hideEmptyGroups?: boolean;
1273
+ }): GroupedEntries[];
1274
+ declare function extractCalendarEntries(entries: DBEntry[], dateProperty: string): CalendarEntry[];
1275
+ declare function filterByMonth(calendarEntries: CalendarEntry[], year: number, month: number): CalendarEntry[];
1276
+ declare function getVisibleProperties(viewConfig: ViewConfig): Array<{
1277
+ id: string;
1278
+ name: string;
1279
+ width?: number;
1280
+ }>;
1281
+
1282
+ declare function getNotionColor(color: NotionColor | string): string;
1283
+ declare function getNotionBgColor(color: NotionColor | string): string;
1284
+ declare function generateColorCSS(): string;
1285
+
1124
1286
  declare function computeHash(content: string): string;
1125
1287
  declare function computeBufferHash(buffer: Buffer): string;
1126
1288
 
@@ -1144,4 +1306,4 @@ interface PipelineOptions {
1144
1306
  }
1145
1307
  declare function createDefaultPipeline(options?: PipelineOptions): ConversionPipeline;
1146
1308
 
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 };
1309
+ 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, 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 };