@im-nobsidian/core 0.1.8 → 0.1.9
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 +50 -8
- package/dist/index.js +87 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -285,18 +285,21 @@ interface PushOptions {
|
|
|
285
285
|
readonly force?: boolean;
|
|
286
286
|
readonly dryRun?: boolean;
|
|
287
287
|
readonly onProgress?: ProgressCallback;
|
|
288
|
+
readonly signal?: AbortSignal;
|
|
288
289
|
}
|
|
289
290
|
interface PullOptions {
|
|
290
291
|
readonly paths?: string[];
|
|
291
292
|
readonly force?: boolean;
|
|
292
293
|
readonly dryRun?: boolean;
|
|
293
294
|
readonly onProgress?: ProgressCallback;
|
|
295
|
+
readonly signal?: AbortSignal;
|
|
294
296
|
}
|
|
295
297
|
interface SyncOptions {
|
|
296
298
|
readonly paths?: string[];
|
|
297
299
|
readonly force?: boolean;
|
|
298
300
|
readonly dryRun?: boolean;
|
|
299
301
|
readonly onProgress?: ProgressCallback;
|
|
302
|
+
readonly signal?: AbortSignal;
|
|
300
303
|
}
|
|
301
304
|
interface PushResult {
|
|
302
305
|
readonly created: number;
|
|
@@ -463,7 +466,35 @@ declare class ConfigManager {
|
|
|
463
466
|
isInitialized(): Promise<boolean>;
|
|
464
467
|
}
|
|
465
468
|
|
|
466
|
-
|
|
469
|
+
interface IStateDB {
|
|
470
|
+
close(): void;
|
|
471
|
+
getByPath(path: string): SyncRecord | null;
|
|
472
|
+
getByNotionId(pageId: string): SyncRecord | null;
|
|
473
|
+
getByStatus(status: SyncStatus): SyncRecord[];
|
|
474
|
+
getAll(): SyncRecord[];
|
|
475
|
+
upsert(record: UpsertSyncRecord): SyncRecord;
|
|
476
|
+
updateStatus(id: string, status: SyncStatus): void;
|
|
477
|
+
updateHash(id: string, hash: string, snapshot?: Buffer | Uint8Array | null): void;
|
|
478
|
+
setNotionLastEdited(id: string, lastEdited: string): void;
|
|
479
|
+
updateStatCache(id: string, mtime: string, fileSize: number): void;
|
|
480
|
+
setNotionParentId(id: string, parentId: string): void;
|
|
481
|
+
delete(id: string): void;
|
|
482
|
+
resolveWikilink(text: string): WikilinkEntry | null;
|
|
483
|
+
resolvePageId(pageId: string): WikilinkEntry | null;
|
|
484
|
+
upsertWikilink(entry: WikilinkEntry): void;
|
|
485
|
+
getMeta(key: string): string | null;
|
|
486
|
+
setMeta(key: string, value: string): void;
|
|
487
|
+
isFileRegistered(localPath: string): boolean;
|
|
488
|
+
getFileRegistry(localPath: string): FileRegistryEntry | null;
|
|
489
|
+
getFilesByPageId(notionPageId: string): FileRegistryEntry[];
|
|
490
|
+
registerFile(entry: RegisterFileInput): void;
|
|
491
|
+
deleteFileRegistry(localPath: string): void;
|
|
492
|
+
storePreserveMarkers(path: string, markers: PreserveMarker[]): void;
|
|
493
|
+
getPreserveMarkers(path: string): PreserveMarker[];
|
|
494
|
+
transaction<T>(fn: () => T): T;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
declare class StateDB implements IStateDB {
|
|
467
498
|
private readonly db;
|
|
468
499
|
private constructor();
|
|
469
500
|
static open(dbPath: string): StateDB;
|
|
@@ -534,12 +565,14 @@ interface NotionClientOptions {
|
|
|
534
565
|
readonly token: string;
|
|
535
566
|
readonly concurrency?: number;
|
|
536
567
|
readonly timeoutMs?: number;
|
|
568
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
537
569
|
}
|
|
538
570
|
declare class NotionClient {
|
|
539
571
|
private readonly client;
|
|
540
572
|
private readonly sema;
|
|
541
573
|
private readonly token;
|
|
542
574
|
private readonly propertyMapper;
|
|
575
|
+
private readonly customFetch?;
|
|
543
576
|
constructor(options: NotionClientOptions);
|
|
544
577
|
getInternalClient(): Client;
|
|
545
578
|
getPage(pageId: string): Promise<PageObjectResponse>;
|
|
@@ -761,7 +794,7 @@ interface FileInfo {
|
|
|
761
794
|
}
|
|
762
795
|
declare class ChangeDetector {
|
|
763
796
|
private readonly stateDb;
|
|
764
|
-
constructor(stateDb:
|
|
797
|
+
constructor(stateDb: IStateDB);
|
|
765
798
|
detectLocalChangesFast(stats: FileStatInfo[], readFile: (path: string) => Promise<string>): Promise<LocalChange[]>;
|
|
766
799
|
detectLocalChanges(currentFiles: FileInfo[]): LocalChange[];
|
|
767
800
|
private detectMoves;
|
|
@@ -807,7 +840,7 @@ declare class SyncOrchestrator {
|
|
|
807
840
|
private dbSchemaLoaded;
|
|
808
841
|
private _pullImageCount;
|
|
809
842
|
private _pullFileCount;
|
|
810
|
-
constructor(config: Config, stateDb:
|
|
843
|
+
constructor(config: Config, stateDb: IStateDB, notionClient: NotionClient, vaultFs: VaultFS, customFetch?: typeof globalThis.fetch);
|
|
811
844
|
push(options?: PushOptions): Promise<PushResult>;
|
|
812
845
|
pull(options?: PullOptions): Promise<PullResult>;
|
|
813
846
|
sync(options?: SyncOptions): Promise<SyncResult>;
|
|
@@ -892,7 +925,9 @@ declare class ImageHandler {
|
|
|
892
925
|
private readonly vaultFs;
|
|
893
926
|
private readonly attachmentFolder;
|
|
894
927
|
private readonly notionClient?;
|
|
895
|
-
|
|
928
|
+
private readonly customFetch?;
|
|
929
|
+
constructor(vaultFs: VaultFS, attachmentFolder?: string, notionClient?: NotionClient | undefined, customFetch?: typeof globalThis.fetch);
|
|
930
|
+
private get fetchFn();
|
|
896
931
|
downloadImage(url: string, pageTitle: string): Promise<ImageDownloadResult>;
|
|
897
932
|
downloadAllImages(markdown: string, pageTitle: string): Promise<{
|
|
898
933
|
content: string;
|
|
@@ -931,7 +966,7 @@ declare class FileHandler {
|
|
|
931
966
|
private readonly notionClient;
|
|
932
967
|
private readonly stateDb;
|
|
933
968
|
private readonly sema;
|
|
934
|
-
constructor(vaultFs: VaultFS, notionClient: NotionClient, stateDb:
|
|
969
|
+
constructor(vaultFs: VaultFS, notionClient: NotionClient, stateDb: IStateDB);
|
|
935
970
|
pushFilesForFolder(folderPageId: string, folderPath: string): Promise<FileUploadResult[]>;
|
|
936
971
|
pushAllFiles(): Promise<FileUploadResult[]>;
|
|
937
972
|
downloadFileBlock(url: string, filename: string, targetFolder: string): Promise<FileDownloadResult>;
|
|
@@ -968,7 +1003,7 @@ declare class DatabaseSyncer {
|
|
|
968
1003
|
private readonly pipeline;
|
|
969
1004
|
private readonly imageHandler;
|
|
970
1005
|
private readonly propertyMapper;
|
|
971
|
-
constructor(config: Config, stateDb:
|
|
1006
|
+
constructor(config: Config, stateDb: IStateDB, notionClient: NotionClient, vaultFs: VaultFS, pipeline: ConversionPipeline, imageHandler: ImageHandler);
|
|
972
1007
|
pullAll(): Promise<DatabaseSyncResult>;
|
|
973
1008
|
pushAll(): Promise<DatabaseSyncResult>;
|
|
974
1009
|
pullDatabase(dbConfig: DatabaseSyncConfig): Promise<DatabaseSyncResult>;
|
|
@@ -1146,7 +1181,7 @@ interface ResolutionResult {
|
|
|
1146
1181
|
declare class ConflictResolver {
|
|
1147
1182
|
private readonly stateDb;
|
|
1148
1183
|
private readonly vaultFs;
|
|
1149
|
-
constructor(stateDb:
|
|
1184
|
+
constructor(stateDb: IStateDB, vaultFs: VaultFS);
|
|
1150
1185
|
resolve(conflict: Conflict, choice: ResolutionChoice): Promise<ResolutionResult>;
|
|
1151
1186
|
resolveByStrategy(conflict: Conflict, strategy: ConflictStrategy): Promise<ResolutionResult>;
|
|
1152
1187
|
resolveAll(conflicts: Conflict[], strategy: ConflictStrategy): Promise<ResolutionResult[]>;
|
|
@@ -1318,6 +1353,13 @@ declare function getVisibleProperties(viewConfig: ViewConfig): Array<{
|
|
|
1318
1353
|
name: string;
|
|
1319
1354
|
width?: number;
|
|
1320
1355
|
}>;
|
|
1356
|
+
interface FilterCondition {
|
|
1357
|
+
property: string;
|
|
1358
|
+
operator: "equals" | "contains" | "startsWith" | "isEmpty" | "isNotEmpty" | "gt" | "lt" | "between";
|
|
1359
|
+
value?: string | number | boolean;
|
|
1360
|
+
valueTo?: string | number;
|
|
1361
|
+
}
|
|
1362
|
+
declare function filterEntries(entries: DBEntry[], searchQuery?: string, filters?: FilterCondition[]): DBEntry[];
|
|
1321
1363
|
|
|
1322
1364
|
declare function getNotionColor(color: NotionColor | string): string;
|
|
1323
1365
|
declare function getNotionBgColor(color: NotionColor | string): string;
|
|
@@ -1346,4 +1388,4 @@ interface PipelineOptions {
|
|
|
1346
1388
|
}
|
|
1347
1389
|
declare function createDefaultPipeline(options?: PipelineOptions): ConversionPipeline;
|
|
1348
1390
|
|
|
1349
|
-
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 FileStatInfo, 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 };
|
|
1391
|
+
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 FileRegistryEntry, type FileStatInfo, type FileSystemEntry, type FileType, type FileUploadResult, FileWatcher, type FilterCondition, FrontmatterExtractor, FrontmatterGenerator, type GroupByConfig, type GroupedEntries, HtmlAnnotationStripper, type IStateDB, 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 RegisterFileInput, 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, filterEntries, generateColorCSS, generateId, getLogger, getNotionBgColor, getNotionColor, getVisibleProperties, groupEntries, normalizeNotionId, notionIdsEqual, sanitizeFileName, setLogger, sortEntries, threeWayMerge };
|
package/dist/index.js
CHANGED
|
@@ -810,13 +810,16 @@ var NotionClient = class _NotionClient {
|
|
|
810
810
|
sema;
|
|
811
811
|
token;
|
|
812
812
|
propertyMapper = new PropertyMapper();
|
|
813
|
+
customFetch;
|
|
813
814
|
constructor(options) {
|
|
814
815
|
this.client = new Client({
|
|
815
816
|
auth: options.token,
|
|
816
817
|
timeoutMs: options.timeoutMs ?? 3e4,
|
|
817
|
-
logLevel: LogLevel.ERROR
|
|
818
|
+
logLevel: LogLevel.ERROR,
|
|
819
|
+
...options.fetch ? { fetch: options.fetch } : {}
|
|
818
820
|
});
|
|
819
821
|
this.token = options.token;
|
|
822
|
+
this.customFetch = options.fetch;
|
|
820
823
|
this.sema = new Sema(options.concurrency ?? 3);
|
|
821
824
|
}
|
|
822
825
|
getInternalClient() {
|
|
@@ -909,7 +912,8 @@ var NotionClient = class _NotionClient {
|
|
|
909
912
|
const cleanId = databaseId.replace(/-/g, "");
|
|
910
913
|
const formatted = `${cleanId.slice(0, 8)}-${cleanId.slice(8, 12)}-${cleanId.slice(12, 16)}-${cleanId.slice(16, 20)}-${cleanId.slice(20)}`;
|
|
911
914
|
const resp = await this.withRateLimit(async () => {
|
|
912
|
-
const
|
|
915
|
+
const doFetch = this.customFetch ?? globalThis.fetch;
|
|
916
|
+
const r = await doFetch(`https://api.notion.com/v1/databases/${formatted}`, {
|
|
913
917
|
headers: {
|
|
914
918
|
Authorization: `Bearer ${this.token}`,
|
|
915
919
|
"Notion-Version": "2022-06-28",
|
|
@@ -3142,14 +3146,19 @@ var EXTENSION_TO_MIME = {
|
|
|
3142
3146
|
".tiff": "image/tiff"
|
|
3143
3147
|
};
|
|
3144
3148
|
var ImageHandler = class {
|
|
3145
|
-
constructor(vaultFs, attachmentFolder = "attachments", notionClient) {
|
|
3149
|
+
constructor(vaultFs, attachmentFolder = "attachments", notionClient, customFetch) {
|
|
3146
3150
|
this.vaultFs = vaultFs;
|
|
3147
3151
|
this.attachmentFolder = attachmentFolder;
|
|
3148
3152
|
this.notionClient = notionClient;
|
|
3153
|
+
this.customFetch = customFetch;
|
|
3149
3154
|
}
|
|
3150
3155
|
vaultFs;
|
|
3151
3156
|
attachmentFolder;
|
|
3152
3157
|
notionClient;
|
|
3158
|
+
customFetch;
|
|
3159
|
+
get fetchFn() {
|
|
3160
|
+
return this.customFetch ?? globalThis.fetch;
|
|
3161
|
+
}
|
|
3153
3162
|
async downloadImage(url, pageTitle) {
|
|
3154
3163
|
const maxRetries = 3;
|
|
3155
3164
|
let lastError = null;
|
|
@@ -3161,7 +3170,7 @@ var ImageHandler = class {
|
|
|
3161
3170
|
`[Im-Nobsidian] \uC774\uBBF8\uC9C0 \uB2E4\uC6B4\uB85C\uB4DC \uC7AC\uC2DC\uB3C4 (${attempt + 1}/${maxRetries}): ${pageTitle}`
|
|
3162
3171
|
);
|
|
3163
3172
|
}
|
|
3164
|
-
const response = await
|
|
3173
|
+
const response = await this.fetchFn(url);
|
|
3165
3174
|
if (!response.ok) {
|
|
3166
3175
|
throw new Error(`\uC774\uBBF8\uC9C0 \uB2E4\uC6B4\uB85C\uB4DC \uC2E4\uD328: ${response.status} ${response.statusText}`);
|
|
3167
3176
|
}
|
|
@@ -3404,7 +3413,7 @@ var ImageHandler = class {
|
|
|
3404
3413
|
`[Im-Nobsidian] \uD30C\uC77C \uB2E4\uC6B4\uB85C\uB4DC \uC7AC\uC2DC\uB3C4 (${attempt + 1}/${maxRetries}): ${caption}`
|
|
3405
3414
|
);
|
|
3406
3415
|
}
|
|
3407
|
-
const response = await
|
|
3416
|
+
const response = await this.fetchFn(url);
|
|
3408
3417
|
if (!response.ok) {
|
|
3409
3418
|
throw new Error(`\uD30C\uC77C \uB2E4\uC6B4\uB85C\uB4DC \uC2E4\uD328: ${response.status} ${response.statusText}`);
|
|
3410
3419
|
}
|
|
@@ -4533,7 +4542,7 @@ function extractTitleFromPath(filePath) {
|
|
|
4533
4542
|
|
|
4534
4543
|
// src/sync/orchestrator.ts
|
|
4535
4544
|
var SyncOrchestrator = class {
|
|
4536
|
-
constructor(config, stateDb, notionClient, vaultFs) {
|
|
4545
|
+
constructor(config, stateDb, notionClient, vaultFs, customFetch) {
|
|
4537
4546
|
this.config = config;
|
|
4538
4547
|
this.stateDb = stateDb;
|
|
4539
4548
|
this.notionClient = notionClient;
|
|
@@ -4543,7 +4552,12 @@ var SyncOrchestrator = class {
|
|
|
4543
4552
|
wikilinkResolver: (text) => stateDb.resolveWikilink(text)
|
|
4544
4553
|
});
|
|
4545
4554
|
this.blockConverter = new BlockConverter();
|
|
4546
|
-
this.imageHandler = new ImageHandler(
|
|
4555
|
+
this.imageHandler = new ImageHandler(
|
|
4556
|
+
vaultFs,
|
|
4557
|
+
config.paths.attachments,
|
|
4558
|
+
notionClient,
|
|
4559
|
+
customFetch
|
|
4560
|
+
);
|
|
4547
4561
|
this.fileHandler = new FileHandler(vaultFs, notionClient, stateDb);
|
|
4548
4562
|
this.propertyMapper = new PropertyMapper();
|
|
4549
4563
|
this.databaseSyncer = new DatabaseSyncer(
|
|
@@ -4642,6 +4656,7 @@ var SyncOrchestrator = class {
|
|
|
4642
4656
|
const tasks = filtered.map((change) => async () => {
|
|
4643
4657
|
await sema.acquire();
|
|
4644
4658
|
try {
|
|
4659
|
+
if (options?.signal?.aborted) return;
|
|
4645
4660
|
const op = change.type === "created" ? "create" : change.type === "deleted" ? "delete" : "update";
|
|
4646
4661
|
options?.onProgress?.(++completed, total, { path: change.path, operation: op });
|
|
4647
4662
|
switch (change.type) {
|
|
@@ -4830,6 +4845,7 @@ var SyncOrchestrator = class {
|
|
|
4830
4845
|
const tasks = filtered.map((change) => async () => {
|
|
4831
4846
|
await sema.acquire();
|
|
4832
4847
|
try {
|
|
4848
|
+
if (options?.signal?.aborted) return;
|
|
4833
4849
|
let resultPath;
|
|
4834
4850
|
switch (change.type) {
|
|
4835
4851
|
case "created": {
|
|
@@ -4980,9 +4996,9 @@ var SyncOrchestrator = class {
|
|
|
4980
4996
|
async status() {
|
|
4981
4997
|
const files = await this.vaultFs.listMarkdownFiles();
|
|
4982
4998
|
const localChanges = this.changeDetector.detectLocalChanges(files);
|
|
4983
|
-
const remoteChanges = await this.detectRemoteChanges();
|
|
4984
|
-
const conflictRecords = this.stateDb.getByStatus("conflict");
|
|
4985
4999
|
const lastSyncAt = this.stateDb.getMeta("last_sync_at");
|
|
5000
|
+
const remoteChanges = lastSyncAt ? await this.detectRemoteChangesIncremental(lastSyncAt) : await this.detectRemoteChanges();
|
|
5001
|
+
const conflictRecords = this.stateDb.getByStatus("conflict");
|
|
4986
5002
|
const conflicts = await this.buildConflictsFromRecords(
|
|
4987
5003
|
conflictRecords,
|
|
4988
5004
|
localChanges,
|
|
@@ -5338,7 +5354,14 @@ var SyncOrchestrator = class {
|
|
|
5338
5354
|
const record = this.stateDb.getByPath(path);
|
|
5339
5355
|
if (!record?.notionPageId) return;
|
|
5340
5356
|
if (this.config.sync.deleteSync) {
|
|
5341
|
-
|
|
5357
|
+
try {
|
|
5358
|
+
await this.notionClient.archivePage(record.notionPageId);
|
|
5359
|
+
} catch (error) {
|
|
5360
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
5361
|
+
if (msg.includes("archived ancestor")) ; else {
|
|
5362
|
+
throw error;
|
|
5363
|
+
}
|
|
5364
|
+
}
|
|
5342
5365
|
this.stateDb.delete(record.id);
|
|
5343
5366
|
} else {
|
|
5344
5367
|
this.stateDb.updateStatus(record.id, "pending");
|
|
@@ -6584,6 +6607,59 @@ function extractGroupName(val) {
|
|
|
6584
6607
|
if (typeof val === "object" && "start" in val) return val.start;
|
|
6585
6608
|
return null;
|
|
6586
6609
|
}
|
|
6610
|
+
function filterEntries(entries, searchQuery, filters) {
|
|
6611
|
+
let result = entries;
|
|
6612
|
+
if (searchQuery && searchQuery.trim()) {
|
|
6613
|
+
const q = searchQuery.trim().toLowerCase();
|
|
6614
|
+
result = result.filter((entry) => {
|
|
6615
|
+
if (entry.title.toLowerCase().includes(q)) return true;
|
|
6616
|
+
return Object.values(entry.properties).some((val) => {
|
|
6617
|
+
if (val === null || val === void 0) return false;
|
|
6618
|
+
if (typeof val === "string") return val.toLowerCase().includes(q);
|
|
6619
|
+
if (Array.isArray(val)) return val.some((v) => v.toLowerCase().includes(q));
|
|
6620
|
+
if (typeof val === "object" && "start" in val) return val.start.includes(q);
|
|
6621
|
+
return String(val).toLowerCase().includes(q);
|
|
6622
|
+
});
|
|
6623
|
+
});
|
|
6624
|
+
}
|
|
6625
|
+
if (filters && filters.length > 0) {
|
|
6626
|
+
for (const filter of filters) {
|
|
6627
|
+
result = result.filter((entry) => matchFilter(entry, filter));
|
|
6628
|
+
}
|
|
6629
|
+
}
|
|
6630
|
+
return result;
|
|
6631
|
+
}
|
|
6632
|
+
function matchFilter(entry, filter) {
|
|
6633
|
+
const val = filter.property === "title" ? entry.title : entry.properties[filter.property] ?? null;
|
|
6634
|
+
switch (filter.operator) {
|
|
6635
|
+
case "isEmpty":
|
|
6636
|
+
return val === null || val === void 0 || val === "" || Array.isArray(val) && val.length === 0;
|
|
6637
|
+
case "isNotEmpty":
|
|
6638
|
+
return val !== null && val !== void 0 && val !== "" && !(Array.isArray(val) && val.length === 0);
|
|
6639
|
+
case "equals":
|
|
6640
|
+
if (typeof val === "boolean") return val === filter.value;
|
|
6641
|
+
return String(val ?? "") === String(filter.value ?? "");
|
|
6642
|
+
case "contains": {
|
|
6643
|
+
const needle = String(filter.value ?? "").toLowerCase();
|
|
6644
|
+
if (typeof val === "string") return val.toLowerCase().includes(needle);
|
|
6645
|
+
if (Array.isArray(val)) return val.some((v) => v.toLowerCase().includes(needle));
|
|
6646
|
+
return String(val ?? "").toLowerCase().includes(needle);
|
|
6647
|
+
}
|
|
6648
|
+
case "startsWith":
|
|
6649
|
+
return String(val ?? "").startsWith(String(filter.value ?? ""));
|
|
6650
|
+
case "gt":
|
|
6651
|
+
return typeof val === "number" && typeof filter.value === "number" && val > filter.value;
|
|
6652
|
+
case "lt":
|
|
6653
|
+
return typeof val === "number" && typeof filter.value === "number" && val < filter.value;
|
|
6654
|
+
case "between": {
|
|
6655
|
+
if (typeof val !== "number" || typeof filter.value !== "number" || typeof filter.valueTo !== "number")
|
|
6656
|
+
return false;
|
|
6657
|
+
return val >= filter.value && val <= filter.valueTo;
|
|
6658
|
+
}
|
|
6659
|
+
default:
|
|
6660
|
+
return true;
|
|
6661
|
+
}
|
|
6662
|
+
}
|
|
6587
6663
|
function parseDate(value) {
|
|
6588
6664
|
const match = /^(\d{4}-\d{2}-\d{2})/.exec(value);
|
|
6589
6665
|
return match?.[1] ?? null;
|
|
@@ -6795,6 +6871,6 @@ ${lines.join("\n")}
|
|
|
6795
6871
|
}`;
|
|
6796
6872
|
}
|
|
6797
6873
|
|
|
6798
|
-
export { BlockConverter, CalloutRestorer, CalloutTransformer, ChangeDetector, ColorAnnotator, ConfigManager, ConfigSchema, ConflictResolver, ConversionPipeline, DEFAULT_CONFIG, DatabaseSyncer, EmbedResolver, EntryEditor, FileHandler, FileWatcher, FrontmatterExtractor, FrontmatterGenerator, HtmlAnnotationStripper, ImageHandler, InlineDBParser, LocalImageRestorer, MathNormalizer, MentionToWikilink, NodeVaultFS, NotionBlockBuilder, NotionClient, PreserveMarkerCollector, PreserveMarkerInjector, PropertiesTableInjector, PropertiesTableRestorer, PropertyMapper, StateDB, SyncOrchestrator, TreeMapper, UnsupportedBlockStripper, ViewDataProvider, WatchSyncService, WikilinkResolver, computeBufferHash, computeHash, createDefaultPipeline, extractCalendarEntries, filterByMonth, generateColorCSS, generateId, getLogger, getNotionBgColor, getNotionColor, getVisibleProperties, groupEntries, normalizeNotionId, notionIdsEqual, sanitizeFileName, setLogger, sortEntries, threeWayMerge };
|
|
6874
|
+
export { BlockConverter, CalloutRestorer, CalloutTransformer, ChangeDetector, ColorAnnotator, ConfigManager, ConfigSchema, ConflictResolver, ConversionPipeline, DEFAULT_CONFIG, DatabaseSyncer, EmbedResolver, EntryEditor, FileHandler, FileWatcher, FrontmatterExtractor, FrontmatterGenerator, HtmlAnnotationStripper, ImageHandler, InlineDBParser, LocalImageRestorer, MathNormalizer, MentionToWikilink, NodeVaultFS, NotionBlockBuilder, NotionClient, PreserveMarkerCollector, PreserveMarkerInjector, PropertiesTableInjector, PropertiesTableRestorer, PropertyMapper, StateDB, SyncOrchestrator, TreeMapper, UnsupportedBlockStripper, ViewDataProvider, WatchSyncService, WikilinkResolver, computeBufferHash, computeHash, createDefaultPipeline, extractCalendarEntries, filterByMonth, filterEntries, generateColorCSS, generateId, getLogger, getNotionBgColor, getNotionColor, getVisibleProperties, groupEntries, normalizeNotionId, notionIdsEqual, sanitizeFileName, setLogger, sortEntries, threeWayMerge };
|
|
6799
6875
|
//# sourceMappingURL=index.js.map
|
|
6800
6876
|
//# sourceMappingURL=index.js.map
|