@im-nobsidian/core 0.1.6 → 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 +11 -2
- package/dist/index.js +46 -7
- 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;
|
|
@@ -780,6 +787,8 @@ declare class SyncOrchestrator {
|
|
|
780
787
|
private readonly databaseSyncer;
|
|
781
788
|
private readonly propertyMapper;
|
|
782
789
|
private dbSchemaLoaded;
|
|
790
|
+
private _pullImageCount;
|
|
791
|
+
private _pullFileCount;
|
|
783
792
|
constructor(config: Config, stateDb: StateDB, notionClient: NotionClient, vaultFs: VaultFS);
|
|
784
793
|
push(options?: PushOptions): Promise<PushResult>;
|
|
785
794
|
pull(options?: PullOptions): Promise<PullResult>;
|
|
@@ -1306,4 +1315,4 @@ interface PipelineOptions {
|
|
|
1306
1315
|
}
|
|
1307
1316
|
declare function createDefaultPipeline(options?: PipelineOptions): ConversionPipeline;
|
|
1308
1317
|
|
|
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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -4443,6 +4443,8 @@ var SyncOrchestrator = class {
|
|
|
4443
4443
|
databaseSyncer;
|
|
4444
4444
|
propertyMapper;
|
|
4445
4445
|
dbSchemaLoaded = false;
|
|
4446
|
+
_pullImageCount = 0;
|
|
4447
|
+
_pullFileCount = 0;
|
|
4446
4448
|
async push(options) {
|
|
4447
4449
|
const startTime = Date.now();
|
|
4448
4450
|
if (this.config.sync.direction === "pull") {
|
|
@@ -4466,6 +4468,12 @@ var SyncOrchestrator = class {
|
|
|
4466
4468
|
const dryCreated = filtered.filter((c) => c.type === "created").length;
|
|
4467
4469
|
const dryUpdated = filtered.filter((c) => c.type === "modified" || c.type === "moved").length;
|
|
4468
4470
|
const dryDeleted = filtered.filter((c) => c.type === "deleted").length;
|
|
4471
|
+
let dryProgress = 0;
|
|
4472
|
+
const dryTotal = filtered.length;
|
|
4473
|
+
for (const change of filtered) {
|
|
4474
|
+
const op = change.type === "created" ? "create" : change.type === "deleted" ? "delete" : "update";
|
|
4475
|
+
options?.onProgress?.(++dryProgress, dryTotal, { path: change.path, operation: op });
|
|
4476
|
+
}
|
|
4469
4477
|
return {
|
|
4470
4478
|
created: dryCreated,
|
|
4471
4479
|
updated: dryUpdated,
|
|
@@ -4500,7 +4508,8 @@ var SyncOrchestrator = class {
|
|
|
4500
4508
|
const tasks = filtered.map((change) => async () => {
|
|
4501
4509
|
await sema.acquire();
|
|
4502
4510
|
try {
|
|
4503
|
-
|
|
4511
|
+
const op = change.type === "created" ? "create" : change.type === "deleted" ? "delete" : "update";
|
|
4512
|
+
options?.onProgress?.(++completed, total, { path: change.path, operation: op });
|
|
4504
4513
|
switch (change.type) {
|
|
4505
4514
|
case "created":
|
|
4506
4515
|
await this.pushCreate(change.path);
|
|
@@ -4604,7 +4613,10 @@ var SyncOrchestrator = class {
|
|
|
4604
4613
|
conflicts: [],
|
|
4605
4614
|
writtenPaths: [],
|
|
4606
4615
|
failed: [],
|
|
4607
|
-
duration: Date.now() - startTime
|
|
4616
|
+
duration: Date.now() - startTime,
|
|
4617
|
+
imageCount: 0,
|
|
4618
|
+
fileCount: 0,
|
|
4619
|
+
linkCount: 0
|
|
4608
4620
|
};
|
|
4609
4621
|
if (this.config.sync.direction === "push") {
|
|
4610
4622
|
return emptyResult;
|
|
@@ -4613,6 +4625,8 @@ var SyncOrchestrator = class {
|
|
|
4613
4625
|
let created = 0;
|
|
4614
4626
|
let updated = 0;
|
|
4615
4627
|
let deleted = 0;
|
|
4628
|
+
this._pullImageCount = 0;
|
|
4629
|
+
this._pullFileCount = 0;
|
|
4616
4630
|
const conflicts = [];
|
|
4617
4631
|
const writtenPaths = [];
|
|
4618
4632
|
const failed = [];
|
|
@@ -4628,6 +4642,14 @@ var SyncOrchestrator = class {
|
|
|
4628
4642
|
const dryCreated = filtered.filter((c) => c.type === "created").length;
|
|
4629
4643
|
const dryUpdated = filtered.filter((c) => c.type === "modified").length;
|
|
4630
4644
|
const dryDeleted = filtered.filter((c) => c.type === "deleted").length;
|
|
4645
|
+
let dryProgress = 0;
|
|
4646
|
+
const dryTotal = filtered.length;
|
|
4647
|
+
for (const change of filtered) {
|
|
4648
|
+
const op = change.type === "created" ? "create" : change.type === "deleted" ? "delete" : "update";
|
|
4649
|
+
const record = this.stateDb.getByNotionId(change.pageId);
|
|
4650
|
+
const displayPath = record?.obsidianPath ?? change.pageId;
|
|
4651
|
+
options?.onProgress?.(++dryProgress, dryTotal, { path: displayPath, operation: op });
|
|
4652
|
+
}
|
|
4631
4653
|
return {
|
|
4632
4654
|
created: dryCreated,
|
|
4633
4655
|
updated: dryUpdated,
|
|
@@ -4635,7 +4657,10 @@ var SyncOrchestrator = class {
|
|
|
4635
4657
|
conflicts: [],
|
|
4636
4658
|
writtenPaths: [],
|
|
4637
4659
|
failed: [],
|
|
4638
|
-
duration: Date.now() - startTime
|
|
4660
|
+
duration: Date.now() - startTime,
|
|
4661
|
+
imageCount: 0,
|
|
4662
|
+
fileCount: 0,
|
|
4663
|
+
linkCount: 0
|
|
4639
4664
|
};
|
|
4640
4665
|
}
|
|
4641
4666
|
this.stateDb.setMeta("pull_in_progress", "true");
|
|
@@ -4645,7 +4670,10 @@ var SyncOrchestrator = class {
|
|
|
4645
4670
|
const tasks = filtered.map((change) => async () => {
|
|
4646
4671
|
await sema.acquire();
|
|
4647
4672
|
try {
|
|
4648
|
-
|
|
4673
|
+
const record = this.stateDb.getByNotionId(change.pageId);
|
|
4674
|
+
const displayPath = record?.obsidianPath ?? change.pageId;
|
|
4675
|
+
const op = change.type === "created" ? "create" : change.type === "deleted" ? "delete" : "update";
|
|
4676
|
+
options?.onProgress?.(++pullCompleted, pullTotal, { path: displayPath, operation: op });
|
|
4649
4677
|
switch (change.type) {
|
|
4650
4678
|
case "created": {
|
|
4651
4679
|
const path = await this.pullCreate(change.pageId);
|
|
@@ -4782,7 +4810,7 @@ var SyncOrchestrator = class {
|
|
|
4782
4810
|
}
|
|
4783
4811
|
}
|
|
4784
4812
|
const allSyncedMdPaths = this.stateDb.getAll().filter((r) => r.obsidianPath?.endsWith(".md")).map((r) => r.obsidianPath);
|
|
4785
|
-
await this.resolveNotionLinks(allSyncedMdPaths);
|
|
4813
|
+
const linkCount = await this.resolveNotionLinks(allSyncedMdPaths);
|
|
4786
4814
|
this.stateDb.setMeta("last_pull_at", (/* @__PURE__ */ new Date()).toISOString());
|
|
4787
4815
|
this.stateDb.setMeta("last_sync_at", (/* @__PURE__ */ new Date()).toISOString());
|
|
4788
4816
|
this.stateDb.setMeta("pull_in_progress", "");
|
|
@@ -4793,7 +4821,10 @@ var SyncOrchestrator = class {
|
|
|
4793
4821
|
conflicts,
|
|
4794
4822
|
writtenPaths,
|
|
4795
4823
|
failed,
|
|
4796
|
-
duration: Date.now() - startTime
|
|
4824
|
+
duration: Date.now() - startTime,
|
|
4825
|
+
imageCount: this._pullImageCount,
|
|
4826
|
+
fileCount: this._pullFileCount,
|
|
4827
|
+
linkCount
|
|
4797
4828
|
};
|
|
4798
4829
|
}
|
|
4799
4830
|
async sync(options) {
|
|
@@ -4893,6 +4924,7 @@ var SyncOrchestrator = class {
|
|
|
4893
4924
|
return allDbs;
|
|
4894
4925
|
}
|
|
4895
4926
|
async resolveNotionLinks(paths) {
|
|
4927
|
+
let totalResolved = 0;
|
|
4896
4928
|
const allRecords = this.stateDb.getAll();
|
|
4897
4929
|
const idToTitle = /* @__PURE__ */ new Map();
|
|
4898
4930
|
for (const r of allRecords) {
|
|
@@ -4903,7 +4935,7 @@ var SyncOrchestrator = class {
|
|
|
4903
4935
|
idToTitle.set(r.notionPageId, title);
|
|
4904
4936
|
}
|
|
4905
4937
|
}
|
|
4906
|
-
if (idToTitle.size === 0) return;
|
|
4938
|
+
if (idToTitle.size === 0) return 0;
|
|
4907
4939
|
for (const filePath of paths) {
|
|
4908
4940
|
if (!filePath.endsWith(".md")) continue;
|
|
4909
4941
|
try {
|
|
@@ -4912,6 +4944,7 @@ var SyncOrchestrator = class {
|
|
|
4912
4944
|
const resolved = content.replace(/\[\[notion:([a-f0-9-]+)\]\]/g, (_match, id) => {
|
|
4913
4945
|
const title = idToTitle.get(id.replace(/-/g, ""));
|
|
4914
4946
|
if (title) {
|
|
4947
|
+
totalResolved++;
|
|
4915
4948
|
changed = true;
|
|
4916
4949
|
return `[[${title}]]`;
|
|
4917
4950
|
}
|
|
@@ -4923,6 +4956,7 @@ var SyncOrchestrator = class {
|
|
|
4923
4956
|
(_match, text, id) => {
|
|
4924
4957
|
const title = idToTitle.get(id);
|
|
4925
4958
|
if (title) {
|
|
4959
|
+
totalResolved++;
|
|
4926
4960
|
changed = true;
|
|
4927
4961
|
return `[[${title}|${text}]]`;
|
|
4928
4962
|
}
|
|
@@ -4936,6 +4970,7 @@ var SyncOrchestrator = class {
|
|
|
4936
4970
|
} catch {
|
|
4937
4971
|
}
|
|
4938
4972
|
}
|
|
4973
|
+
return totalResolved;
|
|
4939
4974
|
}
|
|
4940
4975
|
async ensureDbSchema() {
|
|
4941
4976
|
if (this.dbSchemaLoaded || !this.isDatabaseMode) return;
|
|
@@ -5171,9 +5206,11 @@ var SyncOrchestrator = class {
|
|
|
5171
5206
|
if (this.config.conversion.imageDownload === "immediate") {
|
|
5172
5207
|
const imageResult = await this.imageHandler.downloadAllImages(markdown, title);
|
|
5173
5208
|
processedMarkdown = imageResult.content;
|
|
5209
|
+
this._pullImageCount += imageResult.downloads.length;
|
|
5174
5210
|
}
|
|
5175
5211
|
const fileResult = await this.imageHandler.downloadAllFiles(processedMarkdown, title);
|
|
5176
5212
|
processedMarkdown = fileResult.content;
|
|
5213
|
+
this._pullFileCount += fileResult.downloads.length;
|
|
5177
5214
|
const finalContent = this.pipeline.convertToMarkdown(
|
|
5178
5215
|
processedMarkdown,
|
|
5179
5216
|
{
|
|
@@ -5229,9 +5266,11 @@ var SyncOrchestrator = class {
|
|
|
5229
5266
|
if (this.config.conversion.imageDownload === "immediate") {
|
|
5230
5267
|
const imageResult = await this.imageHandler.downloadAllImages(markdown, title);
|
|
5231
5268
|
markdown = imageResult.content;
|
|
5269
|
+
this._pullImageCount += imageResult.downloads.length;
|
|
5232
5270
|
}
|
|
5233
5271
|
const fileResult = await this.imageHandler.downloadAllFiles(markdown, title);
|
|
5234
5272
|
markdown = fileResult.content;
|
|
5273
|
+
this._pullFileCount += fileResult.downloads.length;
|
|
5235
5274
|
const savedMarkers = this.stateDb.getPreserveMarkers(record.obsidianPath);
|
|
5236
5275
|
const remoteContent = this.pipeline.convertToMarkdown(
|
|
5237
5276
|
markdown,
|