@im-nobsidian/core 0.1.3 → 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 +327 -5
- package/dist/index.js +1898 -126
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,26 @@ import { z } from 'zod';
|
|
|
2
2
|
import { Client } from '@notionhq/client';
|
|
3
3
|
import { PageObjectResponse, BlockObjectResponse, PageMarkdownResponse, PartialBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints.js';
|
|
4
4
|
|
|
5
|
+
declare const DatabaseSyncSchema: z.ZodObject<{
|
|
6
|
+
databaseId: z.ZodString;
|
|
7
|
+
localFolder: z.ZodString;
|
|
8
|
+
propertyMapping: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
9
|
+
pullFilter: z.ZodOptional<z.ZodUnknown>;
|
|
10
|
+
titleProperty: z.ZodDefault<z.ZodString>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
databaseId: string;
|
|
13
|
+
localFolder: string;
|
|
14
|
+
titleProperty: string;
|
|
15
|
+
propertyMapping?: Record<string, string> | undefined;
|
|
16
|
+
pullFilter?: unknown;
|
|
17
|
+
}, {
|
|
18
|
+
databaseId: string;
|
|
19
|
+
localFolder: string;
|
|
20
|
+
propertyMapping?: Record<string, string> | undefined;
|
|
21
|
+
pullFilter?: unknown;
|
|
22
|
+
titleProperty?: string | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
type DatabaseSyncConfig = z.infer<typeof DatabaseSyncSchema>;
|
|
5
25
|
declare const ConfigSchema: z.ZodObject<{
|
|
6
26
|
version: z.ZodLiteral<1>;
|
|
7
27
|
notion: z.ZodObject<{
|
|
@@ -10,18 +30,51 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
10
30
|
workspaceId: z.ZodOptional<z.ZodString>;
|
|
11
31
|
parentMode: z.ZodDefault<z.ZodEnum<["page", "database"]>>;
|
|
12
32
|
databaseId: z.ZodOptional<z.ZodString>;
|
|
33
|
+
databases: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
34
|
+
databaseId: z.ZodString;
|
|
35
|
+
localFolder: z.ZodString;
|
|
36
|
+
propertyMapping: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
37
|
+
pullFilter: z.ZodOptional<z.ZodUnknown>;
|
|
38
|
+
titleProperty: z.ZodDefault<z.ZodString>;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
databaseId: string;
|
|
41
|
+
localFolder: string;
|
|
42
|
+
titleProperty: string;
|
|
43
|
+
propertyMapping?: Record<string, string> | undefined;
|
|
44
|
+
pullFilter?: unknown;
|
|
45
|
+
}, {
|
|
46
|
+
databaseId: string;
|
|
47
|
+
localFolder: string;
|
|
48
|
+
propertyMapping?: Record<string, string> | undefined;
|
|
49
|
+
pullFilter?: unknown;
|
|
50
|
+
titleProperty?: string | undefined;
|
|
51
|
+
}>, "many">>;
|
|
13
52
|
}, "strip", z.ZodTypeAny, {
|
|
14
53
|
token: string;
|
|
15
54
|
rootPageId: string;
|
|
16
55
|
parentMode: "page" | "database";
|
|
17
|
-
|
|
56
|
+
databases: {
|
|
57
|
+
databaseId: string;
|
|
58
|
+
localFolder: string;
|
|
59
|
+
titleProperty: string;
|
|
60
|
+
propertyMapping?: Record<string, string> | undefined;
|
|
61
|
+
pullFilter?: unknown;
|
|
62
|
+
}[];
|
|
18
63
|
databaseId?: string | undefined;
|
|
64
|
+
workspaceId?: string | undefined;
|
|
19
65
|
}, {
|
|
20
66
|
token: string;
|
|
21
67
|
rootPageId: string;
|
|
68
|
+
databaseId?: string | undefined;
|
|
22
69
|
workspaceId?: string | undefined;
|
|
23
70
|
parentMode?: "page" | "database" | undefined;
|
|
24
|
-
|
|
71
|
+
databases?: {
|
|
72
|
+
databaseId: string;
|
|
73
|
+
localFolder: string;
|
|
74
|
+
propertyMapping?: Record<string, string> | undefined;
|
|
75
|
+
pullFilter?: unknown;
|
|
76
|
+
titleProperty?: string | undefined;
|
|
77
|
+
}[] | undefined;
|
|
25
78
|
}>;
|
|
26
79
|
sync: z.ZodObject<{
|
|
27
80
|
direction: z.ZodDefault<z.ZodEnum<["push", "pull", "both"]>>;
|
|
@@ -29,18 +82,21 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
29
82
|
autoSync: z.ZodDefault<z.ZodBoolean>;
|
|
30
83
|
autoSyncInterval: z.ZodDefault<z.ZodNumber>;
|
|
31
84
|
deleteSync: z.ZodDefault<z.ZodBoolean>;
|
|
85
|
+
syncFiles: z.ZodDefault<z.ZodBoolean>;
|
|
32
86
|
}, "strip", z.ZodTypeAny, {
|
|
33
87
|
direction: "push" | "pull" | "both";
|
|
34
88
|
conflictStrategy: "local-first" | "remote-first" | "manual" | "duplicate";
|
|
35
89
|
autoSync: boolean;
|
|
36
90
|
autoSyncInterval: number;
|
|
37
91
|
deleteSync: boolean;
|
|
92
|
+
syncFiles: boolean;
|
|
38
93
|
}, {
|
|
39
94
|
direction?: "push" | "pull" | "both" | undefined;
|
|
40
95
|
conflictStrategy?: "local-first" | "remote-first" | "manual" | "duplicate" | undefined;
|
|
41
96
|
autoSync?: boolean | undefined;
|
|
42
97
|
autoSyncInterval?: number | undefined;
|
|
43
98
|
deleteSync?: boolean | undefined;
|
|
99
|
+
syncFiles?: boolean | undefined;
|
|
44
100
|
}>;
|
|
45
101
|
paths: z.ZodObject<{
|
|
46
102
|
include: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
@@ -93,8 +149,15 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
93
149
|
token: string;
|
|
94
150
|
rootPageId: string;
|
|
95
151
|
parentMode: "page" | "database";
|
|
96
|
-
|
|
152
|
+
databases: {
|
|
153
|
+
databaseId: string;
|
|
154
|
+
localFolder: string;
|
|
155
|
+
titleProperty: string;
|
|
156
|
+
propertyMapping?: Record<string, string> | undefined;
|
|
157
|
+
pullFilter?: unknown;
|
|
158
|
+
}[];
|
|
97
159
|
databaseId?: string | undefined;
|
|
160
|
+
workspaceId?: string | undefined;
|
|
98
161
|
};
|
|
99
162
|
sync: {
|
|
100
163
|
direction: "push" | "pull" | "both";
|
|
@@ -102,6 +165,7 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
102
165
|
autoSync: boolean;
|
|
103
166
|
autoSyncInterval: number;
|
|
104
167
|
deleteSync: boolean;
|
|
168
|
+
syncFiles: boolean;
|
|
105
169
|
};
|
|
106
170
|
paths: {
|
|
107
171
|
include: string[];
|
|
@@ -125,9 +189,16 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
125
189
|
notion: {
|
|
126
190
|
token: string;
|
|
127
191
|
rootPageId: string;
|
|
192
|
+
databaseId?: string | undefined;
|
|
128
193
|
workspaceId?: string | undefined;
|
|
129
194
|
parentMode?: "page" | "database" | undefined;
|
|
130
|
-
|
|
195
|
+
databases?: {
|
|
196
|
+
databaseId: string;
|
|
197
|
+
localFolder: string;
|
|
198
|
+
propertyMapping?: Record<string, string> | undefined;
|
|
199
|
+
pullFilter?: unknown;
|
|
200
|
+
titleProperty?: string | undefined;
|
|
201
|
+
}[] | undefined;
|
|
131
202
|
};
|
|
132
203
|
sync: {
|
|
133
204
|
direction?: "push" | "pull" | "both" | undefined;
|
|
@@ -135,6 +206,7 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
135
206
|
autoSync?: boolean | undefined;
|
|
136
207
|
autoSyncInterval?: number | undefined;
|
|
137
208
|
deleteSync?: boolean | undefined;
|
|
209
|
+
syncFiles?: boolean | undefined;
|
|
138
210
|
};
|
|
139
211
|
paths: {
|
|
140
212
|
include?: string[] | undefined;
|
|
@@ -307,6 +379,62 @@ interface WikilinkEntry {
|
|
|
307
379
|
readonly aliases: readonly string[];
|
|
308
380
|
}
|
|
309
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
|
+
|
|
310
438
|
declare class ConfigManager {
|
|
311
439
|
private readonly vaultRoot;
|
|
312
440
|
private config;
|
|
@@ -347,6 +475,12 @@ declare class StateDB {
|
|
|
347
475
|
upsertWikilink(entry: WikilinkEntry): void;
|
|
348
476
|
getMeta(key: string): string | null;
|
|
349
477
|
setMeta(key: string, value: string): void;
|
|
478
|
+
isFileRegistered(localPath: string): boolean;
|
|
479
|
+
getFileRegistry(localPath: string): FileRegistryEntry | null;
|
|
480
|
+
getFilesByPageId(notionPageId: string): FileRegistryEntry[];
|
|
481
|
+
registerFile(entry: RegisterFileInput): void;
|
|
482
|
+
deleteFileRegistry(localPath: string): void;
|
|
483
|
+
private mapFileRegistryRow;
|
|
350
484
|
storePreserveMarkers(path: string, markers: PreserveMarker[]): void;
|
|
351
485
|
getPreserveMarkers(path: string): PreserveMarker[];
|
|
352
486
|
transaction<T>(fn: () => T): T;
|
|
@@ -365,6 +499,23 @@ interface UpsertSyncRecord {
|
|
|
365
499
|
readonly status: SyncRecord["status"];
|
|
366
500
|
readonly baseSnapshot?: Buffer | null;
|
|
367
501
|
}
|
|
502
|
+
interface FileRegistryEntry {
|
|
503
|
+
readonly id: string;
|
|
504
|
+
readonly localPath: string;
|
|
505
|
+
readonly notionPageId: string;
|
|
506
|
+
readonly fileUploadId: string;
|
|
507
|
+
readonly fileType: string;
|
|
508
|
+
readonly fileHash: string;
|
|
509
|
+
readonly fileSize: number;
|
|
510
|
+
}
|
|
511
|
+
interface RegisterFileInput {
|
|
512
|
+
readonly localPath: string;
|
|
513
|
+
readonly notionPageId: string;
|
|
514
|
+
readonly fileUploadId: string;
|
|
515
|
+
readonly fileType: string;
|
|
516
|
+
readonly fileHash: string;
|
|
517
|
+
readonly fileSize: number;
|
|
518
|
+
}
|
|
368
519
|
|
|
369
520
|
interface NotionClientOptions {
|
|
370
521
|
readonly token: string;
|
|
@@ -374,6 +525,7 @@ interface NotionClientOptions {
|
|
|
374
525
|
declare class NotionClient {
|
|
375
526
|
private readonly client;
|
|
376
527
|
private readonly sema;
|
|
528
|
+
private readonly token;
|
|
377
529
|
private readonly propertyMapper;
|
|
378
530
|
constructor(options: NotionClientOptions);
|
|
379
531
|
getInternalClient(): Client;
|
|
@@ -401,6 +553,8 @@ declare class NotionClient {
|
|
|
401
553
|
replaceAll?: boolean;
|
|
402
554
|
}>): Promise<PageMarkdownResponse>;
|
|
403
555
|
movePage(pageId: string, newParentId: string, newParentType: "page" | "database"): Promise<PageObjectResponse>;
|
|
556
|
+
private fetchDatabaseLegacy;
|
|
557
|
+
getDatabaseTitle(databaseId: string): Promise<string>;
|
|
404
558
|
getDatabaseSchema(databaseId: string): Promise<Record<string, {
|
|
405
559
|
id: string;
|
|
406
560
|
type: string;
|
|
@@ -408,11 +562,16 @@ declare class NotionClient {
|
|
|
408
562
|
queryDatabase(databaseId: string, options?: {
|
|
409
563
|
startCursor?: string;
|
|
410
564
|
pageSize?: number;
|
|
565
|
+
filter?: unknown;
|
|
411
566
|
}): Promise<{
|
|
412
567
|
results: PageObjectResponse[];
|
|
413
568
|
nextCursor: string | null;
|
|
414
569
|
}>;
|
|
570
|
+
queryAllDatabasePages(databaseId: string, filter?: unknown): Promise<PageObjectResponse[]>;
|
|
571
|
+
getDataSourceId(databaseId: string): Promise<string>;
|
|
415
572
|
archivePage(pageId: string): Promise<void>;
|
|
573
|
+
getFileBlockUrl(blockId: string): Promise<string | null>;
|
|
574
|
+
getBlock(blockId: string): Promise<BlockObjectResponse>;
|
|
416
575
|
listChildren(blockId: string, options?: {
|
|
417
576
|
startCursor?: string;
|
|
418
577
|
pageSize?: number;
|
|
@@ -421,6 +580,8 @@ declare class NotionClient {
|
|
|
421
580
|
nextCursor: string | null;
|
|
422
581
|
}>;
|
|
423
582
|
fetchAllChildren(blockId: string): Promise<BlockObjectResponse[]>;
|
|
583
|
+
private static readonly CONTAINER_BLOCK_TYPES;
|
|
584
|
+
fetchAllChildrenDeep(blockId: string): Promise<BlockObjectResponse[]>;
|
|
424
585
|
appendChildren(blockId: string, children: unknown[]): Promise<void>;
|
|
425
586
|
deleteBlock(blockId: string): Promise<void>;
|
|
426
587
|
uploadFile(fileData: Blob, filename: string, contentType: string): Promise<string>;
|
|
@@ -437,9 +598,17 @@ declare class NotionClient {
|
|
|
437
598
|
nextCursor: string | null;
|
|
438
599
|
}>;
|
|
439
600
|
getChildPages(parentId: string): Promise<PageObjectResponse[]>;
|
|
601
|
+
getChildDatabaseIds(parentId: string): Promise<string[]>;
|
|
440
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;
|
|
441
608
|
extractTitle(page: PageObjectResponse): string;
|
|
442
609
|
extractProperties(page: PageObjectResponse): Record<string, unknown>;
|
|
610
|
+
private lastRequestTime;
|
|
611
|
+
private readonly minRequestInterval;
|
|
443
612
|
private withRateLimit;
|
|
444
613
|
private executeWithRetry;
|
|
445
614
|
}
|
|
@@ -580,6 +749,11 @@ declare class ChangeDetector {
|
|
|
580
749
|
private detectMoves;
|
|
581
750
|
}
|
|
582
751
|
|
|
752
|
+
interface NonMdFileInfo {
|
|
753
|
+
readonly path: string;
|
|
754
|
+
readonly size: number;
|
|
755
|
+
readonly mtime: string;
|
|
756
|
+
}
|
|
583
757
|
interface VaultFS {
|
|
584
758
|
readFile(path: string): Promise<string>;
|
|
585
759
|
readBinary(path: string): Promise<Buffer>;
|
|
@@ -590,6 +764,7 @@ interface VaultFS {
|
|
|
590
764
|
exists(path: string): Promise<boolean>;
|
|
591
765
|
ensureFolder(path: string): Promise<void>;
|
|
592
766
|
listMarkdownFiles(): Promise<FileInfo[]>;
|
|
767
|
+
listNonMarkdownFiles(): Promise<NonMdFileInfo[]>;
|
|
593
768
|
}
|
|
594
769
|
|
|
595
770
|
declare class SyncOrchestrator {
|
|
@@ -601,6 +776,8 @@ declare class SyncOrchestrator {
|
|
|
601
776
|
private readonly pipeline;
|
|
602
777
|
private readonly blockConverter;
|
|
603
778
|
private readonly imageHandler;
|
|
779
|
+
private readonly fileHandler;
|
|
780
|
+
private readonly databaseSyncer;
|
|
604
781
|
private readonly propertyMapper;
|
|
605
782
|
private dbSchemaLoaded;
|
|
606
783
|
constructor(config: Config, stateDb: StateDB, notionClient: NotionClient, vaultFs: VaultFS);
|
|
@@ -610,6 +787,8 @@ declare class SyncOrchestrator {
|
|
|
610
787
|
status(): Promise<StatusResult>;
|
|
611
788
|
private buildConflictsFromRecords;
|
|
612
789
|
private get isDatabaseMode();
|
|
790
|
+
private discoverChildDatabases;
|
|
791
|
+
private resolveNotionLinks;
|
|
613
792
|
private ensureDbSchema;
|
|
614
793
|
private pushCreate;
|
|
615
794
|
private pushUpdate;
|
|
@@ -628,6 +807,7 @@ declare class SyncOrchestrator {
|
|
|
628
807
|
private computePatches;
|
|
629
808
|
private fetchPageMarkdown;
|
|
630
809
|
private extractParentId;
|
|
810
|
+
private resolveBlockToPageId;
|
|
631
811
|
private cleanupInterruptedSync;
|
|
632
812
|
private resolveUniqueFilePath;
|
|
633
813
|
}
|
|
@@ -651,8 +831,10 @@ declare class NodeVaultFS implements VaultFS {
|
|
|
651
831
|
exists(path: string): Promise<boolean>;
|
|
652
832
|
ensureFolder(path: string): Promise<void>;
|
|
653
833
|
listMarkdownFiles(): Promise<FileInfo[]>;
|
|
834
|
+
listNonMarkdownFiles(): Promise<NonMdFileInfo[]>;
|
|
654
835
|
private matchesPattern;
|
|
655
836
|
private isExcluded;
|
|
837
|
+
private walkDirNonMd;
|
|
656
838
|
private walkDir;
|
|
657
839
|
}
|
|
658
840
|
|
|
@@ -680,8 +862,47 @@ declare class ImageHandler {
|
|
|
680
862
|
uploadAndAppendImages(pageId: string, images: ImageReference[]): Promise<ImageUploadResult[]>;
|
|
681
863
|
private readImageFromVault;
|
|
682
864
|
private getContentTypeFromPath;
|
|
865
|
+
downloadAllFiles(markdown: string, pageTitle: string): Promise<{
|
|
866
|
+
content: string;
|
|
867
|
+
downloads: ImageDownloadResult[];
|
|
868
|
+
}>;
|
|
869
|
+
private parseNotionFileUrl;
|
|
870
|
+
private downloadFile;
|
|
683
871
|
private isNotionImageUrl;
|
|
872
|
+
private isNotionFileUrl;
|
|
684
873
|
private guessExtension;
|
|
874
|
+
private guessFileExtension;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
type NotionBlockType = "image" | "pdf" | "video" | "audio" | "file";
|
|
878
|
+
interface FileUploadResult {
|
|
879
|
+
readonly localPath: string;
|
|
880
|
+
readonly fileUploadId: string;
|
|
881
|
+
readonly blockType: NotionBlockType;
|
|
882
|
+
}
|
|
883
|
+
interface FileDownloadResult {
|
|
884
|
+
readonly url: string;
|
|
885
|
+
readonly localPath: string;
|
|
886
|
+
readonly hash: string;
|
|
887
|
+
readonly size: number;
|
|
888
|
+
}
|
|
889
|
+
declare class FileHandler {
|
|
890
|
+
private readonly vaultFs;
|
|
891
|
+
private readonly notionClient;
|
|
892
|
+
private readonly stateDb;
|
|
893
|
+
private readonly sema;
|
|
894
|
+
constructor(vaultFs: VaultFS, notionClient: NotionClient, stateDb: StateDB);
|
|
895
|
+
pushFilesForFolder(folderPageId: string, folderPath: string): Promise<FileUploadResult[]>;
|
|
896
|
+
pushAllFiles(): Promise<FileUploadResult[]>;
|
|
897
|
+
downloadFileBlock(url: string, filename: string, targetFolder: string): Promise<FileDownloadResult>;
|
|
898
|
+
downloadFileBlocks(blocks: Array<{
|
|
899
|
+
type: string;
|
|
900
|
+
url: string;
|
|
901
|
+
caption?: string;
|
|
902
|
+
}>, targetFolder: string): Promise<FileDownloadResult[]>;
|
|
903
|
+
private uploadFile;
|
|
904
|
+
private createFileBlock;
|
|
905
|
+
private extractFilename;
|
|
685
906
|
}
|
|
686
907
|
|
|
687
908
|
declare class ConversionPipeline {
|
|
@@ -694,6 +915,28 @@ declare class ConversionPipeline {
|
|
|
694
915
|
convertToMarkdown(content: string, context: ConversionContext, metadata?: ProcessorMetadata): string;
|
|
695
916
|
}
|
|
696
917
|
|
|
918
|
+
interface DatabaseSyncResult {
|
|
919
|
+
created: number;
|
|
920
|
+
updated: number;
|
|
921
|
+
failed: FailedOperation[];
|
|
922
|
+
}
|
|
923
|
+
declare class DatabaseSyncer {
|
|
924
|
+
private readonly config;
|
|
925
|
+
private readonly stateDb;
|
|
926
|
+
private readonly notionClient;
|
|
927
|
+
private readonly vaultFs;
|
|
928
|
+
private readonly pipeline;
|
|
929
|
+
private readonly imageHandler;
|
|
930
|
+
private readonly propertyMapper;
|
|
931
|
+
constructor(config: Config, stateDb: StateDB, notionClient: NotionClient, vaultFs: VaultFS, pipeline: ConversionPipeline, imageHandler: ImageHandler);
|
|
932
|
+
pullAll(): Promise<DatabaseSyncResult>;
|
|
933
|
+
pushAll(): Promise<DatabaseSyncResult>;
|
|
934
|
+
pullDatabase(dbConfig: DatabaseSyncConfig): Promise<DatabaseSyncResult>;
|
|
935
|
+
private pullDatabaseViews;
|
|
936
|
+
private pullDatabasePage;
|
|
937
|
+
private pushDatabase;
|
|
938
|
+
}
|
|
939
|
+
|
|
697
940
|
declare class BlockConverter {
|
|
698
941
|
private n2m;
|
|
699
942
|
private client;
|
|
@@ -961,6 +1204,85 @@ declare class WatchSyncService {
|
|
|
961
1204
|
private executeSync;
|
|
962
1205
|
}
|
|
963
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
|
+
|
|
964
1286
|
declare function computeHash(content: string): string;
|
|
965
1287
|
declare function computeBufferHash(buffer: Buffer): string;
|
|
966
1288
|
|
|
@@ -984,4 +1306,4 @@ interface PipelineOptions {
|
|
|
984
1306
|
}
|
|
985
1307
|
declare function createDefaultPipeline(options?: PipelineOptions): ConversionPipeline;
|
|
986
1308
|
|
|
987
|
-
export { BlockConverter, CalloutRestorer, CalloutTransformer, ChangeDetector, ColorAnnotator, type Config, ConfigManager, ConfigSchema, type Conflict, ConflictResolver, type ConflictStrategy, type ConversionContext, type ConversionPath, ConversionPipeline, type ConversionResult, DEFAULT_CONFIG, EmbedResolver, type FailedOperation, type FileInfo, type FileSystemEntry, type FileType, 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 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 };
|