@im-nobsidian/core 0.1.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.
- package/LICENSE +21 -0
- package/dist/index.d.ts +935 -0
- package/dist/index.js +3683 -0
- package/dist/index.js.map +1 -0
- package/package.json +61 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,935 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Client } from '@notionhq/client';
|
|
3
|
+
import { PageObjectResponse, BlockObjectResponse, PartialBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints.js';
|
|
4
|
+
|
|
5
|
+
declare const ConfigSchema: z.ZodObject<{
|
|
6
|
+
version: z.ZodLiteral<1>;
|
|
7
|
+
notion: z.ZodObject<{
|
|
8
|
+
token: z.ZodString;
|
|
9
|
+
rootPageId: z.ZodString;
|
|
10
|
+
workspaceId: z.ZodOptional<z.ZodString>;
|
|
11
|
+
parentMode: z.ZodDefault<z.ZodEnum<["page", "database"]>>;
|
|
12
|
+
databaseId: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
token: string;
|
|
15
|
+
rootPageId: string;
|
|
16
|
+
parentMode: "page" | "database";
|
|
17
|
+
workspaceId?: string | undefined;
|
|
18
|
+
databaseId?: string | undefined;
|
|
19
|
+
}, {
|
|
20
|
+
token: string;
|
|
21
|
+
rootPageId: string;
|
|
22
|
+
workspaceId?: string | undefined;
|
|
23
|
+
parentMode?: "page" | "database" | undefined;
|
|
24
|
+
databaseId?: string | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
sync: z.ZodObject<{
|
|
27
|
+
direction: z.ZodDefault<z.ZodEnum<["push", "pull", "both"]>>;
|
|
28
|
+
conflictStrategy: z.ZodDefault<z.ZodEnum<["local-first", "remote-first", "manual", "duplicate"]>>;
|
|
29
|
+
autoSync: z.ZodDefault<z.ZodBoolean>;
|
|
30
|
+
autoSyncInterval: z.ZodDefault<z.ZodNumber>;
|
|
31
|
+
deleteSync: z.ZodDefault<z.ZodBoolean>;
|
|
32
|
+
}, "strip", z.ZodTypeAny, {
|
|
33
|
+
direction: "push" | "pull" | "both";
|
|
34
|
+
conflictStrategy: "local-first" | "remote-first" | "manual" | "duplicate";
|
|
35
|
+
autoSync: boolean;
|
|
36
|
+
autoSyncInterval: number;
|
|
37
|
+
deleteSync: boolean;
|
|
38
|
+
}, {
|
|
39
|
+
direction?: "push" | "pull" | "both" | undefined;
|
|
40
|
+
conflictStrategy?: "local-first" | "remote-first" | "manual" | "duplicate" | undefined;
|
|
41
|
+
autoSync?: boolean | undefined;
|
|
42
|
+
autoSyncInterval?: number | undefined;
|
|
43
|
+
deleteSync?: boolean | undefined;
|
|
44
|
+
}>;
|
|
45
|
+
paths: z.ZodObject<{
|
|
46
|
+
include: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
47
|
+
exclude: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
48
|
+
attachments: z.ZodDefault<z.ZodString>;
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
include: string[];
|
|
51
|
+
exclude: string[];
|
|
52
|
+
attachments: string;
|
|
53
|
+
}, {
|
|
54
|
+
include?: string[] | undefined;
|
|
55
|
+
exclude?: string[] | undefined;
|
|
56
|
+
attachments?: string | undefined;
|
|
57
|
+
}>;
|
|
58
|
+
conversion: z.ZodObject<{
|
|
59
|
+
preferMarkdownApi: z.ZodDefault<z.ZodBoolean>;
|
|
60
|
+
preserveMarkers: z.ZodDefault<z.ZodBoolean>;
|
|
61
|
+
frontmatterMapping: z.ZodDefault<z.ZodBoolean>;
|
|
62
|
+
imageDownload: z.ZodDefault<z.ZodEnum<["immediate", "lazy", "skip"]>>;
|
|
63
|
+
}, "strip", z.ZodTypeAny, {
|
|
64
|
+
preferMarkdownApi: boolean;
|
|
65
|
+
preserveMarkers: boolean;
|
|
66
|
+
frontmatterMapping: boolean;
|
|
67
|
+
imageDownload: "immediate" | "lazy" | "skip";
|
|
68
|
+
}, {
|
|
69
|
+
preferMarkdownApi?: boolean | undefined;
|
|
70
|
+
preserveMarkers?: boolean | undefined;
|
|
71
|
+
frontmatterMapping?: boolean | undefined;
|
|
72
|
+
imageDownload?: "immediate" | "lazy" | "skip" | undefined;
|
|
73
|
+
}>;
|
|
74
|
+
advanced: z.ZodObject<{
|
|
75
|
+
concurrency: z.ZodDefault<z.ZodNumber>;
|
|
76
|
+
maxRetries: z.ZodDefault<z.ZodNumber>;
|
|
77
|
+
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
78
|
+
batchSize: z.ZodDefault<z.ZodNumber>;
|
|
79
|
+
}, "strip", z.ZodTypeAny, {
|
|
80
|
+
concurrency: number;
|
|
81
|
+
maxRetries: number;
|
|
82
|
+
timeoutMs: number;
|
|
83
|
+
batchSize: number;
|
|
84
|
+
}, {
|
|
85
|
+
concurrency?: number | undefined;
|
|
86
|
+
maxRetries?: number | undefined;
|
|
87
|
+
timeoutMs?: number | undefined;
|
|
88
|
+
batchSize?: number | undefined;
|
|
89
|
+
}>;
|
|
90
|
+
}, "strip", z.ZodTypeAny, {
|
|
91
|
+
version: 1;
|
|
92
|
+
notion: {
|
|
93
|
+
token: string;
|
|
94
|
+
rootPageId: string;
|
|
95
|
+
parentMode: "page" | "database";
|
|
96
|
+
workspaceId?: string | undefined;
|
|
97
|
+
databaseId?: string | undefined;
|
|
98
|
+
};
|
|
99
|
+
sync: {
|
|
100
|
+
direction: "push" | "pull" | "both";
|
|
101
|
+
conflictStrategy: "local-first" | "remote-first" | "manual" | "duplicate";
|
|
102
|
+
autoSync: boolean;
|
|
103
|
+
autoSyncInterval: number;
|
|
104
|
+
deleteSync: boolean;
|
|
105
|
+
};
|
|
106
|
+
paths: {
|
|
107
|
+
include: string[];
|
|
108
|
+
exclude: string[];
|
|
109
|
+
attachments: string;
|
|
110
|
+
};
|
|
111
|
+
conversion: {
|
|
112
|
+
preferMarkdownApi: boolean;
|
|
113
|
+
preserveMarkers: boolean;
|
|
114
|
+
frontmatterMapping: boolean;
|
|
115
|
+
imageDownload: "immediate" | "lazy" | "skip";
|
|
116
|
+
};
|
|
117
|
+
advanced: {
|
|
118
|
+
concurrency: number;
|
|
119
|
+
maxRetries: number;
|
|
120
|
+
timeoutMs: number;
|
|
121
|
+
batchSize: number;
|
|
122
|
+
};
|
|
123
|
+
}, {
|
|
124
|
+
version: 1;
|
|
125
|
+
notion: {
|
|
126
|
+
token: string;
|
|
127
|
+
rootPageId: string;
|
|
128
|
+
workspaceId?: string | undefined;
|
|
129
|
+
parentMode?: "page" | "database" | undefined;
|
|
130
|
+
databaseId?: string | undefined;
|
|
131
|
+
};
|
|
132
|
+
sync: {
|
|
133
|
+
direction?: "push" | "pull" | "both" | undefined;
|
|
134
|
+
conflictStrategy?: "local-first" | "remote-first" | "manual" | "duplicate" | undefined;
|
|
135
|
+
autoSync?: boolean | undefined;
|
|
136
|
+
autoSyncInterval?: number | undefined;
|
|
137
|
+
deleteSync?: boolean | undefined;
|
|
138
|
+
};
|
|
139
|
+
paths: {
|
|
140
|
+
include?: string[] | undefined;
|
|
141
|
+
exclude?: string[] | undefined;
|
|
142
|
+
attachments?: string | undefined;
|
|
143
|
+
};
|
|
144
|
+
conversion: {
|
|
145
|
+
preferMarkdownApi?: boolean | undefined;
|
|
146
|
+
preserveMarkers?: boolean | undefined;
|
|
147
|
+
frontmatterMapping?: boolean | undefined;
|
|
148
|
+
imageDownload?: "immediate" | "lazy" | "skip" | undefined;
|
|
149
|
+
};
|
|
150
|
+
advanced: {
|
|
151
|
+
concurrency?: number | undefined;
|
|
152
|
+
maxRetries?: number | undefined;
|
|
153
|
+
timeoutMs?: number | undefined;
|
|
154
|
+
batchSize?: number | undefined;
|
|
155
|
+
};
|
|
156
|
+
}>;
|
|
157
|
+
type Config = z.infer<typeof ConfigSchema>;
|
|
158
|
+
declare const DEFAULT_CONFIG: Config;
|
|
159
|
+
|
|
160
|
+
type SyncDirection = "push" | "pull" | "both";
|
|
161
|
+
type FileType = "file" | "folder-note" | "folder-only" | "db-row";
|
|
162
|
+
type SyncStatus = "synced" | "pending" | "conflict" | "error";
|
|
163
|
+
type OperationType = "create" | "update" | "delete" | "move";
|
|
164
|
+
type ConflictStrategy = "local-first" | "remote-first" | "manual" | "duplicate";
|
|
165
|
+
interface SyncRecord {
|
|
166
|
+
readonly id: string;
|
|
167
|
+
readonly obsidianPath: string;
|
|
168
|
+
readonly notionPageId: string | null;
|
|
169
|
+
readonly notionParentId: string | null;
|
|
170
|
+
readonly contentHash: string;
|
|
171
|
+
readonly notionLastEdited: string | null;
|
|
172
|
+
readonly localLastModified: string;
|
|
173
|
+
readonly syncDirection: SyncDirection;
|
|
174
|
+
readonly fileType: FileType;
|
|
175
|
+
readonly status: SyncStatus;
|
|
176
|
+
readonly baseSnapshot: Buffer | null;
|
|
177
|
+
readonly version: number;
|
|
178
|
+
readonly createdAt: string;
|
|
179
|
+
readonly updatedAt: string;
|
|
180
|
+
}
|
|
181
|
+
interface LocalChange {
|
|
182
|
+
readonly path: string;
|
|
183
|
+
readonly type: "created" | "modified" | "deleted" | "moved";
|
|
184
|
+
readonly currentHash: string;
|
|
185
|
+
readonly previousHash: string | null;
|
|
186
|
+
readonly movedFrom?: string;
|
|
187
|
+
}
|
|
188
|
+
interface RemoteChange {
|
|
189
|
+
readonly pageId: string;
|
|
190
|
+
readonly type: "created" | "modified" | "deleted" | "moved";
|
|
191
|
+
readonly lastEdited: string;
|
|
192
|
+
readonly previousEdited: string | null;
|
|
193
|
+
readonly movedFromParent?: string;
|
|
194
|
+
}
|
|
195
|
+
interface Conflict {
|
|
196
|
+
readonly syncRecord: SyncRecord;
|
|
197
|
+
readonly localChange: LocalChange;
|
|
198
|
+
readonly remoteChange: RemoteChange;
|
|
199
|
+
readonly baseContent: string | null;
|
|
200
|
+
readonly localContent: string;
|
|
201
|
+
readonly remoteContent: string;
|
|
202
|
+
}
|
|
203
|
+
type ProgressCallback = (current: number, total: number, path: string) => void;
|
|
204
|
+
interface PushOptions {
|
|
205
|
+
readonly paths?: string[];
|
|
206
|
+
readonly force?: boolean;
|
|
207
|
+
readonly dryRun?: boolean;
|
|
208
|
+
readonly onProgress?: ProgressCallback;
|
|
209
|
+
}
|
|
210
|
+
interface PullOptions {
|
|
211
|
+
readonly paths?: string[];
|
|
212
|
+
readonly force?: boolean;
|
|
213
|
+
readonly dryRun?: boolean;
|
|
214
|
+
readonly onProgress?: ProgressCallback;
|
|
215
|
+
}
|
|
216
|
+
interface SyncOptions {
|
|
217
|
+
readonly paths?: string[];
|
|
218
|
+
readonly force?: boolean;
|
|
219
|
+
readonly dryRun?: boolean;
|
|
220
|
+
readonly onProgress?: ProgressCallback;
|
|
221
|
+
}
|
|
222
|
+
interface PushResult {
|
|
223
|
+
readonly created: number;
|
|
224
|
+
readonly updated: number;
|
|
225
|
+
readonly deleted: number;
|
|
226
|
+
readonly failed: FailedOperation[];
|
|
227
|
+
readonly duration: number;
|
|
228
|
+
}
|
|
229
|
+
interface PullResult {
|
|
230
|
+
readonly created: number;
|
|
231
|
+
readonly updated: number;
|
|
232
|
+
readonly deleted: number;
|
|
233
|
+
readonly conflicts: Conflict[];
|
|
234
|
+
readonly writtenPaths: string[];
|
|
235
|
+
readonly failed: FailedOperation[];
|
|
236
|
+
readonly duration: number;
|
|
237
|
+
}
|
|
238
|
+
interface SyncResult {
|
|
239
|
+
readonly push: PushResult;
|
|
240
|
+
readonly pull: PullResult;
|
|
241
|
+
readonly conflicts: Conflict[];
|
|
242
|
+
readonly duration: number;
|
|
243
|
+
}
|
|
244
|
+
interface StatusResult {
|
|
245
|
+
readonly localChanges: LocalChange[];
|
|
246
|
+
readonly remoteChanges: RemoteChange[];
|
|
247
|
+
readonly conflicts: Conflict[];
|
|
248
|
+
readonly conflictRecords: SyncRecord[];
|
|
249
|
+
readonly pendingOperations: number;
|
|
250
|
+
readonly lastSyncAt: string | null;
|
|
251
|
+
}
|
|
252
|
+
interface FailedOperation {
|
|
253
|
+
readonly path: string;
|
|
254
|
+
readonly operation: OperationType;
|
|
255
|
+
readonly error: string;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
type ConversionPath = "markdown-api" | "block-api";
|
|
259
|
+
interface ProcessorInput {
|
|
260
|
+
readonly content: string;
|
|
261
|
+
readonly metadata: ProcessorMetadata;
|
|
262
|
+
readonly context: ConversionContext;
|
|
263
|
+
}
|
|
264
|
+
interface ProcessorOutput {
|
|
265
|
+
readonly content: string;
|
|
266
|
+
readonly metadata: ProcessorMetadata;
|
|
267
|
+
}
|
|
268
|
+
interface ProcessorMetadata {
|
|
269
|
+
readonly properties?: Record<string, unknown>;
|
|
270
|
+
readonly preserveMarkers?: PreserveMarker[];
|
|
271
|
+
readonly images?: ImageReference[];
|
|
272
|
+
readonly [key: string]: unknown;
|
|
273
|
+
}
|
|
274
|
+
interface ConversionContext {
|
|
275
|
+
readonly direction: "push" | "pull";
|
|
276
|
+
readonly path: ConversionPath;
|
|
277
|
+
readonly filePath: string;
|
|
278
|
+
readonly parentMode?: "page" | "database";
|
|
279
|
+
}
|
|
280
|
+
interface Processor {
|
|
281
|
+
readonly name: string;
|
|
282
|
+
readonly order: number;
|
|
283
|
+
process(input: ProcessorInput): ProcessorOutput;
|
|
284
|
+
}
|
|
285
|
+
interface ConversionResult {
|
|
286
|
+
readonly content: string;
|
|
287
|
+
readonly properties: Record<string, unknown>;
|
|
288
|
+
readonly images: ImageReference[];
|
|
289
|
+
readonly preserveMarkers: PreserveMarker[];
|
|
290
|
+
}
|
|
291
|
+
interface PreserveMarker {
|
|
292
|
+
readonly type: string;
|
|
293
|
+
readonly params: Record<string, string>;
|
|
294
|
+
readonly startIndex: number;
|
|
295
|
+
readonly endIndex?: number;
|
|
296
|
+
}
|
|
297
|
+
interface ImageReference {
|
|
298
|
+
readonly url: string;
|
|
299
|
+
readonly localPath?: string;
|
|
300
|
+
readonly hash?: string;
|
|
301
|
+
readonly isExternal: boolean;
|
|
302
|
+
}
|
|
303
|
+
interface WikilinkEntry {
|
|
304
|
+
readonly obsidianPath: string;
|
|
305
|
+
readonly notionPageId: string;
|
|
306
|
+
readonly title: string;
|
|
307
|
+
readonly aliases: readonly string[];
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
declare class ConfigManager {
|
|
311
|
+
private readonly vaultRoot;
|
|
312
|
+
private config;
|
|
313
|
+
constructor(vaultRoot: string);
|
|
314
|
+
get configDir(): string;
|
|
315
|
+
get configPath(): string;
|
|
316
|
+
get dbPath(): string;
|
|
317
|
+
load(): Promise<Config>;
|
|
318
|
+
save(config: Config): Promise<void>;
|
|
319
|
+
init(params: {
|
|
320
|
+
token: string;
|
|
321
|
+
rootPageId: string;
|
|
322
|
+
}): Promise<Config>;
|
|
323
|
+
getConfig(): Config;
|
|
324
|
+
private ensureGitignore;
|
|
325
|
+
isInitialized(): Promise<boolean>;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
declare class StateDB {
|
|
329
|
+
private readonly db;
|
|
330
|
+
private constructor();
|
|
331
|
+
static open(dbPath: string): StateDB;
|
|
332
|
+
private migrate;
|
|
333
|
+
private getSchemaVersion;
|
|
334
|
+
close(): void;
|
|
335
|
+
getByPath(path: string): SyncRecord | null;
|
|
336
|
+
getByNotionId(pageId: string): SyncRecord | null;
|
|
337
|
+
getByStatus(status: SyncStatus): SyncRecord[];
|
|
338
|
+
getAll(): SyncRecord[];
|
|
339
|
+
upsert(record: UpsertSyncRecord): SyncRecord;
|
|
340
|
+
updateStatus(id: string, status: SyncStatus): void;
|
|
341
|
+
updateHash(id: string, hash: string, snapshot?: Buffer | null): void;
|
|
342
|
+
delete(id: string): void;
|
|
343
|
+
resolveWikilink(text: string): WikilinkEntry | null;
|
|
344
|
+
resolvePageId(pageId: string): WikilinkEntry | null;
|
|
345
|
+
upsertWikilink(entry: WikilinkEntry): void;
|
|
346
|
+
getMeta(key: string): string | null;
|
|
347
|
+
setMeta(key: string, value: string): void;
|
|
348
|
+
storePreserveMarkers(path: string, markers: PreserveMarker[]): void;
|
|
349
|
+
getPreserveMarkers(path: string): PreserveMarker[];
|
|
350
|
+
transaction<T>(fn: () => T): T;
|
|
351
|
+
private mapRow;
|
|
352
|
+
private mapWikilinkRow;
|
|
353
|
+
}
|
|
354
|
+
interface UpsertSyncRecord {
|
|
355
|
+
readonly obsidianPath: string;
|
|
356
|
+
readonly notionPageId?: string | null;
|
|
357
|
+
readonly notionParentId?: string | null;
|
|
358
|
+
readonly contentHash: string;
|
|
359
|
+
readonly notionLastEdited?: string | null;
|
|
360
|
+
readonly localLastModified: string;
|
|
361
|
+
readonly syncDirection: SyncRecord["syncDirection"];
|
|
362
|
+
readonly fileType: SyncRecord["fileType"];
|
|
363
|
+
readonly status: SyncRecord["status"];
|
|
364
|
+
readonly baseSnapshot?: Buffer | null;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
interface NotionClientOptions {
|
|
368
|
+
readonly token: string;
|
|
369
|
+
readonly concurrency?: number;
|
|
370
|
+
readonly timeoutMs?: number;
|
|
371
|
+
}
|
|
372
|
+
declare class NotionClient {
|
|
373
|
+
private readonly client;
|
|
374
|
+
private readonly sema;
|
|
375
|
+
private readonly propertyMapper;
|
|
376
|
+
constructor(options: NotionClientOptions);
|
|
377
|
+
getInternalClient(): Client;
|
|
378
|
+
getPage(pageId: string): Promise<PageObjectResponse>;
|
|
379
|
+
createPage(params: {
|
|
380
|
+
parentId: string;
|
|
381
|
+
parentType: "page" | "database";
|
|
382
|
+
title: string;
|
|
383
|
+
properties?: Record<string, unknown>;
|
|
384
|
+
children?: BlockObjectResponse[];
|
|
385
|
+
}): Promise<PageObjectResponse>;
|
|
386
|
+
updatePageProperties(pageId: string, properties: Record<string, unknown>): Promise<PageObjectResponse>;
|
|
387
|
+
getDatabaseSchema(databaseId: string): Promise<Record<string, {
|
|
388
|
+
id: string;
|
|
389
|
+
type: string;
|
|
390
|
+
}>>;
|
|
391
|
+
queryDatabase(databaseId: string, options?: {
|
|
392
|
+
startCursor?: string;
|
|
393
|
+
pageSize?: number;
|
|
394
|
+
}): Promise<{
|
|
395
|
+
results: PageObjectResponse[];
|
|
396
|
+
nextCursor: string | null;
|
|
397
|
+
}>;
|
|
398
|
+
archivePage(pageId: string): Promise<void>;
|
|
399
|
+
listChildren(blockId: string, options?: {
|
|
400
|
+
startCursor?: string;
|
|
401
|
+
pageSize?: number;
|
|
402
|
+
}): Promise<{
|
|
403
|
+
results: (BlockObjectResponse | PartialBlockObjectResponse)[];
|
|
404
|
+
nextCursor: string | null;
|
|
405
|
+
}>;
|
|
406
|
+
fetchAllChildren(blockId: string): Promise<BlockObjectResponse[]>;
|
|
407
|
+
appendChildren(blockId: string, children: unknown[]): Promise<void>;
|
|
408
|
+
deleteBlock(blockId: string): Promise<void>;
|
|
409
|
+
search(params: {
|
|
410
|
+
query?: string;
|
|
411
|
+
filter?: {
|
|
412
|
+
property: "object";
|
|
413
|
+
value: "page" | "database";
|
|
414
|
+
};
|
|
415
|
+
startCursor?: string;
|
|
416
|
+
pageSize?: number;
|
|
417
|
+
}): Promise<{
|
|
418
|
+
results: PageObjectResponse[];
|
|
419
|
+
nextCursor: string | null;
|
|
420
|
+
}>;
|
|
421
|
+
getChildPages(parentId: string): Promise<PageObjectResponse[]>;
|
|
422
|
+
getChildPagesRecursive(parentId: string): Promise<PageObjectResponse[]>;
|
|
423
|
+
extractTitle(page: PageObjectResponse): string;
|
|
424
|
+
extractProperties(page: PageObjectResponse): Record<string, unknown>;
|
|
425
|
+
private withRateLimit;
|
|
426
|
+
private executeWithRetry;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
interface RichTextSegment {
|
|
430
|
+
content: string;
|
|
431
|
+
bold?: boolean;
|
|
432
|
+
italic?: boolean;
|
|
433
|
+
underline?: boolean;
|
|
434
|
+
strikethrough?: boolean;
|
|
435
|
+
code?: boolean;
|
|
436
|
+
color?: string;
|
|
437
|
+
link?: string;
|
|
438
|
+
}
|
|
439
|
+
interface NotionRichText {
|
|
440
|
+
type: "text";
|
|
441
|
+
text: {
|
|
442
|
+
content: string;
|
|
443
|
+
link?: {
|
|
444
|
+
url: string;
|
|
445
|
+
} | null;
|
|
446
|
+
};
|
|
447
|
+
annotations: {
|
|
448
|
+
bold: boolean;
|
|
449
|
+
italic: boolean;
|
|
450
|
+
underline: boolean;
|
|
451
|
+
strikethrough: boolean;
|
|
452
|
+
code: boolean;
|
|
453
|
+
color: string;
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
interface NotionEquationRichText {
|
|
457
|
+
type: "equation";
|
|
458
|
+
equation: {
|
|
459
|
+
expression: string;
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
interface NotionMentionRichText {
|
|
463
|
+
type: "mention";
|
|
464
|
+
mention: {
|
|
465
|
+
type: "page";
|
|
466
|
+
page: {
|
|
467
|
+
id: string;
|
|
468
|
+
};
|
|
469
|
+
} | {
|
|
470
|
+
type: "date";
|
|
471
|
+
date: {
|
|
472
|
+
start: string;
|
|
473
|
+
end?: string;
|
|
474
|
+
};
|
|
475
|
+
} | {
|
|
476
|
+
type: "user";
|
|
477
|
+
user: {
|
|
478
|
+
id: string;
|
|
479
|
+
};
|
|
480
|
+
} | {
|
|
481
|
+
type: "database";
|
|
482
|
+
database: {
|
|
483
|
+
id: string;
|
|
484
|
+
};
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
type RichTextItem = NotionRichText | NotionEquationRichText | NotionMentionRichText;
|
|
488
|
+
interface NotionBlock {
|
|
489
|
+
object?: "block";
|
|
490
|
+
type: string;
|
|
491
|
+
[key: string]: unknown;
|
|
492
|
+
}
|
|
493
|
+
declare class NotionBlockBuilder {
|
|
494
|
+
static richText(content: string, options?: Partial<RichTextSegment>): NotionRichText[];
|
|
495
|
+
static richTextArray(segments: RichTextSegment[]): NotionRichText[];
|
|
496
|
+
static richTextEquation(expression: string): NotionEquationRichText[];
|
|
497
|
+
static richTextMentionPage(pageId: string): NotionMentionRichText[];
|
|
498
|
+
static richTextMentionDate(start: string, end?: string): NotionMentionRichText[];
|
|
499
|
+
static paragraph(richText: RichTextItem[], color?: string): NotionBlock;
|
|
500
|
+
static heading(level: 1 | 2 | 3, richText: RichTextItem[], options?: {
|
|
501
|
+
color?: string;
|
|
502
|
+
isToggleable?: boolean;
|
|
503
|
+
children?: NotionBlock[];
|
|
504
|
+
}): NotionBlock;
|
|
505
|
+
static callout(richText: RichTextItem[], icon?: string, options?: {
|
|
506
|
+
color?: string;
|
|
507
|
+
children?: NotionBlock[];
|
|
508
|
+
}): NotionBlock;
|
|
509
|
+
static toggle(richText: RichTextItem[], children?: NotionBlock[], color?: string): NotionBlock;
|
|
510
|
+
static bulletedListItem(richText: RichTextItem[], children?: NotionBlock[], color?: string): NotionBlock;
|
|
511
|
+
static numberedListItem(richText: RichTextItem[], children?: NotionBlock[], color?: string): NotionBlock;
|
|
512
|
+
static toDo(richText: RichTextItem[], checked?: boolean, color?: string): NotionBlock;
|
|
513
|
+
static quote(richText: RichTextItem[], children?: NotionBlock[], color?: string): NotionBlock;
|
|
514
|
+
static divider(): NotionBlock;
|
|
515
|
+
static code(code: string, language?: string, caption?: string): NotionBlock;
|
|
516
|
+
static equationBlock(expression: string): NotionBlock;
|
|
517
|
+
static image(url: string, caption?: string): NotionBlock;
|
|
518
|
+
static bookmark(url: string, caption?: string): NotionBlock;
|
|
519
|
+
static video(url: string, caption?: string): NotionBlock;
|
|
520
|
+
static audio(url: string, caption?: string): NotionBlock;
|
|
521
|
+
static fileBlock(url: string, name?: string, caption?: string): NotionBlock;
|
|
522
|
+
static pdf(url: string, caption?: string): NotionBlock;
|
|
523
|
+
static embed(url: string, caption?: string): NotionBlock;
|
|
524
|
+
static tableOfContents(color?: string): NotionBlock;
|
|
525
|
+
static breadcrumb(): NotionBlock;
|
|
526
|
+
static columnList(columns: NotionBlock[][]): NotionBlock;
|
|
527
|
+
static syncedBlockOriginal(children: NotionBlock[]): NotionBlock;
|
|
528
|
+
static syncedBlockDuplicate(originalBlockId: string): NotionBlock;
|
|
529
|
+
static linkToPage(pageId: string): NotionBlock;
|
|
530
|
+
static table(rows: string[][], hasColumnHeader?: boolean, hasRowHeader?: boolean): NotionBlock;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
type NotionPropertyValue = Record<string, unknown>;
|
|
534
|
+
declare class PropertyMapper {
|
|
535
|
+
private schema;
|
|
536
|
+
loadSchema(properties: Record<string, {
|
|
537
|
+
id: string;
|
|
538
|
+
type: string;
|
|
539
|
+
}>): void;
|
|
540
|
+
toNotionProperties(frontmatter: Record<string, unknown>, title: string): Record<string, NotionPropertyValue>;
|
|
541
|
+
fromNotionProperties(notionProps: Record<string, unknown>): Record<string, unknown>;
|
|
542
|
+
private convertBySchema;
|
|
543
|
+
private inferAndConvert;
|
|
544
|
+
private extractValue;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
interface FileInfo {
|
|
548
|
+
readonly path: string;
|
|
549
|
+
readonly content: string;
|
|
550
|
+
readonly mtime: string;
|
|
551
|
+
}
|
|
552
|
+
declare class ChangeDetector {
|
|
553
|
+
private readonly stateDb;
|
|
554
|
+
constructor(stateDb: StateDB);
|
|
555
|
+
detectLocalChanges(currentFiles: FileInfo[]): LocalChange[];
|
|
556
|
+
private detectMoves;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
interface VaultFS {
|
|
560
|
+
readFile(path: string): Promise<string>;
|
|
561
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
562
|
+
writeBinary(path: string, data: Buffer): Promise<void>;
|
|
563
|
+
deleteFile(path: string): Promise<void>;
|
|
564
|
+
moveFile(from: string, to: string): Promise<void>;
|
|
565
|
+
exists(path: string): Promise<boolean>;
|
|
566
|
+
ensureFolder(path: string): Promise<void>;
|
|
567
|
+
listMarkdownFiles(): Promise<FileInfo[]>;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
declare class SyncOrchestrator {
|
|
571
|
+
private readonly config;
|
|
572
|
+
private readonly stateDb;
|
|
573
|
+
private readonly notionClient;
|
|
574
|
+
private readonly vaultFs;
|
|
575
|
+
private readonly changeDetector;
|
|
576
|
+
private readonly pipeline;
|
|
577
|
+
private readonly blockConverter;
|
|
578
|
+
private readonly imageHandler;
|
|
579
|
+
private readonly propertyMapper;
|
|
580
|
+
private dbSchemaLoaded;
|
|
581
|
+
constructor(config: Config, stateDb: StateDB, notionClient: NotionClient, vaultFs: VaultFS);
|
|
582
|
+
push(options?: PushOptions): Promise<PushResult>;
|
|
583
|
+
pull(options?: PullOptions): Promise<PullResult>;
|
|
584
|
+
sync(options?: SyncOptions): Promise<SyncResult>;
|
|
585
|
+
status(): Promise<StatusResult>;
|
|
586
|
+
private buildConflictsFromRecords;
|
|
587
|
+
private get isDatabaseMode();
|
|
588
|
+
private ensureDbSchema;
|
|
589
|
+
private pushCreate;
|
|
590
|
+
private pushUpdate;
|
|
591
|
+
private pushDelete;
|
|
592
|
+
private detectRemoteChanges;
|
|
593
|
+
private pullCreate;
|
|
594
|
+
private pullUpdate;
|
|
595
|
+
private pullDelete;
|
|
596
|
+
private ensureFolderPage;
|
|
597
|
+
private resolveNotionParent;
|
|
598
|
+
private isFolderNote;
|
|
599
|
+
private resolveParentPath;
|
|
600
|
+
private extractParentId;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
interface PathFilterConfig {
|
|
604
|
+
readonly include?: string[];
|
|
605
|
+
readonly exclude?: string[];
|
|
606
|
+
}
|
|
607
|
+
declare class NodeVaultFS implements VaultFS {
|
|
608
|
+
private readonly rootPath;
|
|
609
|
+
private readonly includePatterns;
|
|
610
|
+
private readonly excludePatterns;
|
|
611
|
+
constructor(rootPath: string, pathConfig?: PathFilterConfig);
|
|
612
|
+
private loadImNobsidianIgnore;
|
|
613
|
+
readFile(path: string): Promise<string>;
|
|
614
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
615
|
+
writeBinary(path: string, data: Buffer): Promise<void>;
|
|
616
|
+
deleteFile(path: string): Promise<void>;
|
|
617
|
+
moveFile(from: string, to: string): Promise<void>;
|
|
618
|
+
exists(path: string): Promise<boolean>;
|
|
619
|
+
ensureFolder(path: string): Promise<void>;
|
|
620
|
+
listMarkdownFiles(): Promise<FileInfo[]>;
|
|
621
|
+
private matchesPattern;
|
|
622
|
+
private isExcluded;
|
|
623
|
+
private walkDir;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
interface ImageDownloadResult {
|
|
627
|
+
readonly originalUrl: string;
|
|
628
|
+
readonly localPath: string;
|
|
629
|
+
readonly hash: string;
|
|
630
|
+
readonly size: number;
|
|
631
|
+
}
|
|
632
|
+
declare class ImageHandler {
|
|
633
|
+
private readonly vaultFs;
|
|
634
|
+
private readonly attachmentFolder;
|
|
635
|
+
constructor(vaultFs: VaultFS, attachmentFolder?: string);
|
|
636
|
+
downloadImage(url: string, pageTitle: string): Promise<ImageDownloadResult>;
|
|
637
|
+
downloadAllImages(markdown: string, pageTitle: string): Promise<{
|
|
638
|
+
content: string;
|
|
639
|
+
downloads: ImageDownloadResult[];
|
|
640
|
+
}>;
|
|
641
|
+
private isNotionImageUrl;
|
|
642
|
+
private guessExtension;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
declare class ConversionPipeline {
|
|
646
|
+
private readonly preProcessors;
|
|
647
|
+
private readonly postProcessors;
|
|
648
|
+
registerPreProcessor(processor: Processor): void;
|
|
649
|
+
registerPostProcessor(processor: Processor): void;
|
|
650
|
+
selectPath(content: string): ConversionPath;
|
|
651
|
+
convertToNotion(markdown: string, context: ConversionContext): ConversionResult;
|
|
652
|
+
convertToMarkdown(content: string, context: ConversionContext, metadata?: ProcessorMetadata): string;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
declare class BlockConverter {
|
|
656
|
+
private n2m;
|
|
657
|
+
private client;
|
|
658
|
+
initNotionToMd(client: Client): void;
|
|
659
|
+
private registerCustomTransformers;
|
|
660
|
+
private registerToggleTransformer;
|
|
661
|
+
private registerToggleHeadingTransformers;
|
|
662
|
+
private registerColumnTransformer;
|
|
663
|
+
private registerSyncedBlockTransformer;
|
|
664
|
+
private registerBookmarkTransformer;
|
|
665
|
+
private registerVideoTransformer;
|
|
666
|
+
private registerAudioTransformer;
|
|
667
|
+
private registerFileTransformer;
|
|
668
|
+
private registerChildPageTransformer;
|
|
669
|
+
private registerChildDatabaseTransformer;
|
|
670
|
+
private registerLinkToPageTransformer;
|
|
671
|
+
private registerTocTransformer;
|
|
672
|
+
private registerBreadcrumbTransformer;
|
|
673
|
+
private registerLinkPreviewTransformer;
|
|
674
|
+
private registerCalloutTransformer;
|
|
675
|
+
markdownToNotionBlocks(markdown: string): unknown[];
|
|
676
|
+
private toggleContents;
|
|
677
|
+
private columnContents;
|
|
678
|
+
private toggleCounter;
|
|
679
|
+
private columnCounter;
|
|
680
|
+
private preProcessMarkdown;
|
|
681
|
+
private replaceDividers;
|
|
682
|
+
private extractToggleBlocks;
|
|
683
|
+
private extractColumnBlocks;
|
|
684
|
+
private postProcessBlocks;
|
|
685
|
+
private convertTogglePlaceholder;
|
|
686
|
+
private convertColumnPlaceholder;
|
|
687
|
+
private convertDividerPlaceholder;
|
|
688
|
+
private convertImageToVideoOrEmbed;
|
|
689
|
+
private convertQuoteToCallout;
|
|
690
|
+
notionBlocksToMarkdown(pageId: string): Promise<string>;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
declare class FrontmatterExtractor implements Processor {
|
|
694
|
+
readonly name = "FrontmatterExtractor";
|
|
695
|
+
readonly order = 10;
|
|
696
|
+
process(input: ProcessorInput): ProcessorOutput;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
declare class WikilinkResolver implements Processor {
|
|
700
|
+
readonly name = "WikilinkResolver";
|
|
701
|
+
readonly order = 20;
|
|
702
|
+
process(input: ProcessorInput): ProcessorOutput;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
declare class CalloutTransformer implements Processor {
|
|
706
|
+
readonly name = "CalloutTransformer";
|
|
707
|
+
readonly order = 30;
|
|
708
|
+
process(input: ProcessorInput): ProcessorOutput;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
declare class InlineDBParser implements Processor {
|
|
712
|
+
readonly name = "InlineDBParser";
|
|
713
|
+
readonly order = 40;
|
|
714
|
+
process(input: ProcessorInput): ProcessorOutput;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
declare class MathNormalizer implements Processor {
|
|
718
|
+
readonly name = "MathNormalizer";
|
|
719
|
+
readonly order = 50;
|
|
720
|
+
process(input: ProcessorInput): ProcessorOutput;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
declare class EmbedResolver implements Processor {
|
|
724
|
+
readonly name = "EmbedResolver";
|
|
725
|
+
readonly order = 60;
|
|
726
|
+
process(input: ProcessorInput): ProcessorOutput;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
declare class PreserveMarkerCollector implements Processor {
|
|
730
|
+
readonly name = "PreserveMarkerCollector";
|
|
731
|
+
readonly order = 70;
|
|
732
|
+
process(input: ProcessorInput): ProcessorOutput;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
declare class UnsupportedBlockStripper implements Processor {
|
|
736
|
+
readonly name = "UnsupportedBlockStripper";
|
|
737
|
+
readonly order = 5;
|
|
738
|
+
process(input: ProcessorInput): ProcessorOutput;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
declare class PropertiesTableInjector implements Processor {
|
|
742
|
+
readonly name = "PropertiesTableInjector";
|
|
743
|
+
readonly order = 15;
|
|
744
|
+
process(input: ProcessorInput): ProcessorOutput;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
declare class HtmlAnnotationStripper implements Processor {
|
|
748
|
+
readonly name = "HtmlAnnotationStripper";
|
|
749
|
+
readonly order = 5;
|
|
750
|
+
process(input: ProcessorInput): ProcessorOutput;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
declare class MentionToWikilink implements Processor {
|
|
754
|
+
readonly name = "MentionToWikilink";
|
|
755
|
+
readonly order = 10;
|
|
756
|
+
process(input: ProcessorInput): ProcessorOutput;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
declare class CalloutRestorer implements Processor {
|
|
760
|
+
readonly name = "CalloutRestorer";
|
|
761
|
+
readonly order = 20;
|
|
762
|
+
process(input: ProcessorInput): ProcessorOutput;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
declare class ColorAnnotator implements Processor {
|
|
766
|
+
readonly name = "ColorAnnotator";
|
|
767
|
+
readonly order = 30;
|
|
768
|
+
process(input: ProcessorInput): ProcessorOutput;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
declare class FrontmatterGenerator implements Processor {
|
|
772
|
+
readonly name = "FrontmatterGenerator";
|
|
773
|
+
readonly order = 90;
|
|
774
|
+
process(input: ProcessorInput): ProcessorOutput;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
declare class PreserveMarkerInjector implements Processor {
|
|
778
|
+
readonly name = "PreserveMarkerInjector";
|
|
779
|
+
readonly order = 100;
|
|
780
|
+
process(input: ProcessorInput): ProcessorOutput;
|
|
781
|
+
private formatMarker;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
declare class LocalImageRestorer implements Processor {
|
|
785
|
+
readonly name = "LocalImageRestorer";
|
|
786
|
+
readonly order = 15;
|
|
787
|
+
process(input: ProcessorInput): ProcessorOutput;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
declare class PropertiesTableRestorer implements Processor {
|
|
791
|
+
readonly name = "PropertiesTableRestorer";
|
|
792
|
+
readonly order = 5;
|
|
793
|
+
process(input: ProcessorInput): ProcessorOutput;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
interface MergeResult {
|
|
797
|
+
readonly success: boolean;
|
|
798
|
+
readonly merged: string;
|
|
799
|
+
readonly conflicts: MergeConflictRegion[];
|
|
800
|
+
}
|
|
801
|
+
interface MergeConflictRegion {
|
|
802
|
+
readonly localLines: string[];
|
|
803
|
+
readonly remoteLines: string[];
|
|
804
|
+
}
|
|
805
|
+
declare function threeWayMerge(base: string, local: string, remote: string): MergeResult;
|
|
806
|
+
|
|
807
|
+
type ResolutionChoice = "local" | "remote" | "merge" | "duplicate";
|
|
808
|
+
interface ResolutionResult {
|
|
809
|
+
readonly path: string;
|
|
810
|
+
readonly choice: ResolutionChoice;
|
|
811
|
+
readonly success: boolean;
|
|
812
|
+
readonly mergeHadConflicts?: boolean;
|
|
813
|
+
}
|
|
814
|
+
declare class ConflictResolver {
|
|
815
|
+
private readonly stateDb;
|
|
816
|
+
private readonly vaultFs;
|
|
817
|
+
constructor(stateDb: StateDB, vaultFs: VaultFS);
|
|
818
|
+
resolve(conflict: Conflict, choice: ResolutionChoice): Promise<ResolutionResult>;
|
|
819
|
+
resolveByStrategy(conflict: Conflict, strategy: ConflictStrategy): Promise<ResolutionResult>;
|
|
820
|
+
resolveAll(conflicts: Conflict[], strategy: ConflictStrategy): Promise<ResolutionResult[]>;
|
|
821
|
+
private resolveLocal;
|
|
822
|
+
private resolveRemote;
|
|
823
|
+
private resolveMerge;
|
|
824
|
+
private resolveDuplicate;
|
|
825
|
+
generateDiff(conflict: Conflict): string;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
interface NotionPageNode {
|
|
829
|
+
readonly id: string;
|
|
830
|
+
readonly title: string;
|
|
831
|
+
readonly hasContent: boolean;
|
|
832
|
+
readonly hasChildren: boolean;
|
|
833
|
+
readonly isDatabase: boolean;
|
|
834
|
+
readonly parentId: string | null;
|
|
835
|
+
readonly children: NotionPageNode[];
|
|
836
|
+
}
|
|
837
|
+
type MappingType = "file" | "folder-note" | "folder-only" | "database-folder";
|
|
838
|
+
interface MappingResult {
|
|
839
|
+
readonly type: MappingType;
|
|
840
|
+
readonly obsidianPath: string;
|
|
841
|
+
readonly folderPath?: string;
|
|
842
|
+
readonly notePath?: string;
|
|
843
|
+
readonly schemaPath?: string;
|
|
844
|
+
}
|
|
845
|
+
declare class TreeMapper {
|
|
846
|
+
mapNotionToObsidian(root: NotionPageNode, basePath?: string): MappingResult[];
|
|
847
|
+
private mapRecursive;
|
|
848
|
+
mapObsidianToNotion(entries: FileSystemEntry[], parentPageId: string): PageCreationPlan[];
|
|
849
|
+
private planRecursive;
|
|
850
|
+
private findFolderNote;
|
|
851
|
+
determineFileType(page: {
|
|
852
|
+
hasContent: boolean;
|
|
853
|
+
hasChildren: boolean;
|
|
854
|
+
isDatabase: boolean;
|
|
855
|
+
}): MappingType;
|
|
856
|
+
}
|
|
857
|
+
interface FileSystemEntry {
|
|
858
|
+
readonly name: string;
|
|
859
|
+
readonly path: string;
|
|
860
|
+
readonly isDirectory: boolean;
|
|
861
|
+
readonly children: FileSystemEntry[];
|
|
862
|
+
}
|
|
863
|
+
interface PageCreationPlan {
|
|
864
|
+
readonly type: "page-with-children" | "empty-page-with-children" | "leaf-page";
|
|
865
|
+
readonly title: string;
|
|
866
|
+
readonly parentPageId: string;
|
|
867
|
+
readonly contentSource?: string;
|
|
868
|
+
readonly hasContent: boolean;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
type WatchEvent = "add" | "change" | "unlink";
|
|
872
|
+
interface WatchCallback {
|
|
873
|
+
(event: WatchEvent, path: string): void;
|
|
874
|
+
}
|
|
875
|
+
declare class FileWatcher {
|
|
876
|
+
private readonly rootPath;
|
|
877
|
+
private readonly callback;
|
|
878
|
+
private watcher;
|
|
879
|
+
constructor(rootPath: string, callback: WatchCallback);
|
|
880
|
+
start(): void;
|
|
881
|
+
stop(): Promise<void>;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
interface WatchSyncOptions {
|
|
885
|
+
readonly debounceMs?: number;
|
|
886
|
+
readonly syncDirection?: "push" | "pull" | "both";
|
|
887
|
+
readonly onSyncStart?: () => void;
|
|
888
|
+
readonly onSyncComplete?: (result: SyncResult) => void;
|
|
889
|
+
readonly onSyncError?: (error: Error) => void;
|
|
890
|
+
readonly onFileChange?: (event: WatchEvent, path: string) => void;
|
|
891
|
+
}
|
|
892
|
+
declare class WatchSyncService {
|
|
893
|
+
private readonly rootPath;
|
|
894
|
+
private readonly orchestrator;
|
|
895
|
+
private readonly debounceMs;
|
|
896
|
+
private readonly options;
|
|
897
|
+
private watcher;
|
|
898
|
+
private debounceTimer;
|
|
899
|
+
private pendingChanges;
|
|
900
|
+
private syncing;
|
|
901
|
+
private syncQueued;
|
|
902
|
+
private running;
|
|
903
|
+
constructor(rootPath: string, orchestrator: SyncOrchestrator, options?: WatchSyncOptions);
|
|
904
|
+
start(): void;
|
|
905
|
+
stop(): Promise<void>;
|
|
906
|
+
isRunning(): boolean;
|
|
907
|
+
isSyncing(): boolean;
|
|
908
|
+
getPendingCount(): number;
|
|
909
|
+
private handleFileChange;
|
|
910
|
+
private scheduleSync;
|
|
911
|
+
private clearDebounce;
|
|
912
|
+
private executeSync;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
declare function computeHash(content: string): string;
|
|
916
|
+
declare function computeBufferHash(buffer: Buffer): string;
|
|
917
|
+
|
|
918
|
+
declare function generateId(): string;
|
|
919
|
+
declare function normalizeNotionId(id: string): string;
|
|
920
|
+
declare function notionIdsEqual(a: string, b: string): boolean;
|
|
921
|
+
|
|
922
|
+
declare function sanitizeFileName(name: string): string;
|
|
923
|
+
|
|
924
|
+
interface Logger {
|
|
925
|
+
warn(message: string, ...args: unknown[]): void;
|
|
926
|
+
error(message: string, ...args: unknown[]): void;
|
|
927
|
+
info(message: string, ...args: unknown[]): void;
|
|
928
|
+
debug(message: string, ...args: unknown[]): void;
|
|
929
|
+
}
|
|
930
|
+
declare function setLogger(logger: Logger): void;
|
|
931
|
+
declare function getLogger(): Logger;
|
|
932
|
+
|
|
933
|
+
declare function createDefaultPipeline(): ConversionPipeline;
|
|
934
|
+
|
|
935
|
+
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 };
|