@im-nobsidian/core 0.1.9 → 0.1.10
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 -1
- package/dist/index.js +227 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -605,6 +605,19 @@ declare class NotionClient {
|
|
|
605
605
|
id: string;
|
|
606
606
|
type: string;
|
|
607
607
|
}>>;
|
|
608
|
+
getDatabaseSchemaFull(databaseId: string): Promise<Record<string, {
|
|
609
|
+
id: string;
|
|
610
|
+
type: string;
|
|
611
|
+
options?: Array<{
|
|
612
|
+
name: string;
|
|
613
|
+
color?: string;
|
|
614
|
+
}>;
|
|
615
|
+
groups?: Array<{
|
|
616
|
+
name: string;
|
|
617
|
+
color?: string;
|
|
618
|
+
optionIds?: string[];
|
|
619
|
+
}>;
|
|
620
|
+
}>>;
|
|
608
621
|
queryDatabase(databaseId: string, options?: {
|
|
609
622
|
startCursor?: string;
|
|
610
623
|
pageSize?: number;
|
|
@@ -1003,11 +1016,13 @@ declare class DatabaseSyncer {
|
|
|
1003
1016
|
private readonly pipeline;
|
|
1004
1017
|
private readonly imageHandler;
|
|
1005
1018
|
private readonly propertyMapper;
|
|
1019
|
+
private readonly baseFileGenerator;
|
|
1006
1020
|
constructor(config: Config, stateDb: IStateDB, notionClient: NotionClient, vaultFs: VaultFS, pipeline: ConversionPipeline, imageHandler: ImageHandler);
|
|
1007
1021
|
pullAll(): Promise<DatabaseSyncResult>;
|
|
1008
1022
|
pushAll(): Promise<DatabaseSyncResult>;
|
|
1009
1023
|
pullDatabase(dbConfig: DatabaseSyncConfig): Promise<DatabaseSyncResult>;
|
|
1010
1024
|
private pullDatabaseViews;
|
|
1025
|
+
private generateBaseFile;
|
|
1011
1026
|
private pullDatabasePage;
|
|
1012
1027
|
private pushDatabase;
|
|
1013
1028
|
}
|
|
@@ -1341,6 +1356,40 @@ declare class EntryEditor {
|
|
|
1341
1356
|
updateDate(entryPath: string, dateProperty: string, newDate: string): Promise<void>;
|
|
1342
1357
|
}
|
|
1343
1358
|
|
|
1359
|
+
interface BasePropertySchema {
|
|
1360
|
+
readonly id: string;
|
|
1361
|
+
readonly type: string;
|
|
1362
|
+
readonly options?: Array<{
|
|
1363
|
+
name: string;
|
|
1364
|
+
color?: string;
|
|
1365
|
+
}>;
|
|
1366
|
+
readonly groups?: Array<{
|
|
1367
|
+
name: string;
|
|
1368
|
+
color?: string;
|
|
1369
|
+
optionIds?: string[];
|
|
1370
|
+
}>;
|
|
1371
|
+
}
|
|
1372
|
+
interface BaseFileOptions {
|
|
1373
|
+
readonly databaseId: string;
|
|
1374
|
+
readonly databaseName: string;
|
|
1375
|
+
readonly schema: Record<string, BasePropertySchema>;
|
|
1376
|
+
readonly viewsConfig: DatabaseViewsConfig;
|
|
1377
|
+
readonly folderPath: string;
|
|
1378
|
+
}
|
|
1379
|
+
declare class BaseFileGenerator {
|
|
1380
|
+
generate(options: BaseFileOptions): string;
|
|
1381
|
+
private writeFilters;
|
|
1382
|
+
private needsContentCoverFormula;
|
|
1383
|
+
private writeFormulas;
|
|
1384
|
+
private writePropertyDisplayNames;
|
|
1385
|
+
private writeViews;
|
|
1386
|
+
private convertView;
|
|
1387
|
+
private toNoteRef;
|
|
1388
|
+
private resolvePropertyName;
|
|
1389
|
+
private yamlKey;
|
|
1390
|
+
private yamlValue;
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1344
1393
|
declare function sortEntries(entries: DBEntry[], sorts: NonNullable<ViewConfig["sorts"]>): DBEntry[];
|
|
1345
1394
|
declare function groupEntries(entries: DBEntry[], groupByProperty: string, options?: {
|
|
1346
1395
|
sort?: "ascending" | "descending";
|
|
@@ -1388,4 +1437,4 @@ interface PipelineOptions {
|
|
|
1388
1437
|
}
|
|
1389
1438
|
declare function createDefaultPipeline(options?: PipelineOptions): ConversionPipeline;
|
|
1390
1439
|
|
|
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 };
|
|
1440
|
+
export { BaseFileGenerator, type BaseFileOptions, type BasePropertySchema, 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
|
@@ -940,6 +940,39 @@ var NotionClient = class _NotionClient {
|
|
|
940
940
|
}
|
|
941
941
|
return schema;
|
|
942
942
|
}
|
|
943
|
+
async getDatabaseSchemaFull(databaseId) {
|
|
944
|
+
const db = await this.fetchDatabaseLegacy(databaseId);
|
|
945
|
+
const properties = db.properties;
|
|
946
|
+
if (!properties) return {};
|
|
947
|
+
const schema = {};
|
|
948
|
+
for (const [name, prop] of Object.entries(properties)) {
|
|
949
|
+
const entry = {
|
|
950
|
+
id: prop.id,
|
|
951
|
+
type: prop.type
|
|
952
|
+
};
|
|
953
|
+
if (prop.type === "select" || prop.type === "multi_select") {
|
|
954
|
+
const typeData = prop[prop.type];
|
|
955
|
+
if (typeData?.options) {
|
|
956
|
+
entry.options = typeData.options.map((o) => ({ name: o.name, color: o.color }));
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
if (prop.type === "status") {
|
|
960
|
+
const statusData = prop.status;
|
|
961
|
+
if (statusData?.options) {
|
|
962
|
+
entry.options = statusData.options.map((o) => ({ name: o.name, color: o.color }));
|
|
963
|
+
}
|
|
964
|
+
if (statusData?.groups) {
|
|
965
|
+
entry.groups = statusData.groups.map((g) => ({
|
|
966
|
+
name: g.name,
|
|
967
|
+
color: g.color,
|
|
968
|
+
optionIds: g.option_ids
|
|
969
|
+
}));
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
schema[name] = entry;
|
|
973
|
+
}
|
|
974
|
+
return schema;
|
|
975
|
+
}
|
|
943
976
|
async queryDatabase(databaseId, options) {
|
|
944
977
|
const dsId = await this.getDataSourceId(databaseId);
|
|
945
978
|
const response = await this.withRateLimit(
|
|
@@ -3768,6 +3801,168 @@ function sanitizeFileName(name) {
|
|
|
3768
3801
|
return sanitized;
|
|
3769
3802
|
}
|
|
3770
3803
|
|
|
3804
|
+
// src/view/base-file-generator.ts
|
|
3805
|
+
var NOTION_TO_BASES_VIEW = {
|
|
3806
|
+
table: "table",
|
|
3807
|
+
gallery: "cards",
|
|
3808
|
+
list: "list",
|
|
3809
|
+
board: "cards",
|
|
3810
|
+
calendar: null,
|
|
3811
|
+
timeline: null,
|
|
3812
|
+
form: null,
|
|
3813
|
+
chart: null,
|
|
3814
|
+
map: null,
|
|
3815
|
+
dashboard: null
|
|
3816
|
+
};
|
|
3817
|
+
var BaseFileGenerator = class {
|
|
3818
|
+
generate(options) {
|
|
3819
|
+
const lines = [];
|
|
3820
|
+
lines.push(`# Auto-generated by Im-Nobsidian from Notion DB: ${options.databaseName}`);
|
|
3821
|
+
lines.push(`# Database ID: ${options.databaseId}`);
|
|
3822
|
+
lines.push("");
|
|
3823
|
+
this.writeFilters(lines, options.folderPath);
|
|
3824
|
+
this.writeFormulas(lines, options.viewsConfig.views);
|
|
3825
|
+
this.writePropertyDisplayNames(lines, options.schema);
|
|
3826
|
+
this.writeViews(lines, options.viewsConfig.views, options.schema);
|
|
3827
|
+
return lines.join("\n");
|
|
3828
|
+
}
|
|
3829
|
+
writeFilters(lines, folderPath) {
|
|
3830
|
+
lines.push("filters:");
|
|
3831
|
+
lines.push(" and:");
|
|
3832
|
+
lines.push(` - file.inFolder("${folderPath}")`);
|
|
3833
|
+
lines.push("");
|
|
3834
|
+
}
|
|
3835
|
+
needsContentCoverFormula(views) {
|
|
3836
|
+
return views.some(
|
|
3837
|
+
(v) => v.type === "gallery" && v.cover && (v.cover.type === "page_content" || v.cover.type === "page_content_first")
|
|
3838
|
+
);
|
|
3839
|
+
}
|
|
3840
|
+
writeFormulas(lines, views) {
|
|
3841
|
+
if (!this.needsContentCoverFormula(views)) return;
|
|
3842
|
+
lines.push("formulas:");
|
|
3843
|
+
lines.push(" coverImage: file.embeds[0]");
|
|
3844
|
+
lines.push("");
|
|
3845
|
+
}
|
|
3846
|
+
writePropertyDisplayNames(lines, schema) {
|
|
3847
|
+
const entries = Object.entries(schema).filter(([, prop]) => prop.type !== "title");
|
|
3848
|
+
if (entries.length === 0) return;
|
|
3849
|
+
lines.push("properties:");
|
|
3850
|
+
for (const [name] of entries) {
|
|
3851
|
+
lines.push(` ${this.yamlKey(name)}:`);
|
|
3852
|
+
lines.push(` displayName: ${this.yamlValue(name)}`);
|
|
3853
|
+
}
|
|
3854
|
+
lines.push("");
|
|
3855
|
+
}
|
|
3856
|
+
writeViews(lines, views, schema) {
|
|
3857
|
+
const basesViews = views.map((v) => this.convertView(v, schema)).filter((v) => v !== null);
|
|
3858
|
+
if (basesViews.length === 0) {
|
|
3859
|
+
lines.push("views:");
|
|
3860
|
+
lines.push(" - type: table");
|
|
3861
|
+
lines.push(" name: Table");
|
|
3862
|
+
return;
|
|
3863
|
+
}
|
|
3864
|
+
lines.push("views:");
|
|
3865
|
+
for (const view of basesViews) {
|
|
3866
|
+
lines.push(` - type: ${view.type}`);
|
|
3867
|
+
lines.push(` name: ${this.yamlValue(view.name)}`);
|
|
3868
|
+
if (view.order && view.order.length > 0) {
|
|
3869
|
+
lines.push(" order:");
|
|
3870
|
+
for (const col of view.order) {
|
|
3871
|
+
lines.push(` - ${col}`);
|
|
3872
|
+
}
|
|
3873
|
+
}
|
|
3874
|
+
if (view.sort && view.sort.length > 0) {
|
|
3875
|
+
lines.push(" sort:");
|
|
3876
|
+
for (const s of view.sort) {
|
|
3877
|
+
lines.push(` - column: ${s.column}`);
|
|
3878
|
+
lines.push(` direction: ${s.direction}`);
|
|
3879
|
+
}
|
|
3880
|
+
}
|
|
3881
|
+
if (view.groupBy) {
|
|
3882
|
+
lines.push(" groupBy:");
|
|
3883
|
+
lines.push(` property: ${view.groupBy.property}`);
|
|
3884
|
+
if (view.groupBy.direction) {
|
|
3885
|
+
lines.push(` direction: ${view.groupBy.direction}`);
|
|
3886
|
+
}
|
|
3887
|
+
}
|
|
3888
|
+
if (view.image) {
|
|
3889
|
+
lines.push(` image: ${view.image}`);
|
|
3890
|
+
}
|
|
3891
|
+
}
|
|
3892
|
+
}
|
|
3893
|
+
convertView(view, schema) {
|
|
3894
|
+
const basesType = NOTION_TO_BASES_VIEW[view.type];
|
|
3895
|
+
if (!basesType) return null;
|
|
3896
|
+
const result = {
|
|
3897
|
+
type: basesType,
|
|
3898
|
+
name: view.name || view.type
|
|
3899
|
+
};
|
|
3900
|
+
if (view.properties && view.properties.length > 0) {
|
|
3901
|
+
const visible = view.properties.filter((p) => p.visible !== false).map((p) => {
|
|
3902
|
+
const name = p.propertyName ?? this.resolvePropertyName(p.propertyId, schema);
|
|
3903
|
+
return name ? this.toNoteRef(name) : null;
|
|
3904
|
+
}).filter((name) => !!name);
|
|
3905
|
+
if (visible.length > 0) {
|
|
3906
|
+
result.order = ["file.name", ...visible];
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3909
|
+
if (view.sorts && view.sorts.length > 0) {
|
|
3910
|
+
result.sort = view.sorts.map((s) => {
|
|
3911
|
+
let column;
|
|
3912
|
+
if (s.property) {
|
|
3913
|
+
const propName = this.resolvePropertyName(s.property, schema) ?? s.property;
|
|
3914
|
+
column = this.toNoteRef(propName);
|
|
3915
|
+
} else if (s.timestamp) {
|
|
3916
|
+
column = s.timestamp === "created_time" ? "file.ctime" : "file.mtime";
|
|
3917
|
+
} else {
|
|
3918
|
+
return null;
|
|
3919
|
+
}
|
|
3920
|
+
return {
|
|
3921
|
+
column,
|
|
3922
|
+
direction: s.direction === "ascending" ? "ASC" : "DESC"
|
|
3923
|
+
};
|
|
3924
|
+
}).filter((s) => s !== null);
|
|
3925
|
+
}
|
|
3926
|
+
if (view.groupBy) {
|
|
3927
|
+
const propName = view.groupBy.propertyName ?? this.resolvePropertyName(view.groupBy.propertyId, schema);
|
|
3928
|
+
if (propName) {
|
|
3929
|
+
result.groupBy = {
|
|
3930
|
+
property: this.toNoteRef(propName),
|
|
3931
|
+
direction: view.groupBy.sort === "ascending" ? "ASC" : view.groupBy.sort === "descending" ? "DESC" : void 0
|
|
3932
|
+
};
|
|
3933
|
+
}
|
|
3934
|
+
}
|
|
3935
|
+
if (view.type === "gallery" && view.cover) {
|
|
3936
|
+
if (view.cover.type === "property" && view.cover.propertyId) {
|
|
3937
|
+
const propName = this.resolvePropertyName(view.cover.propertyId, schema);
|
|
3938
|
+
if (propName) result.image = this.toNoteRef(propName);
|
|
3939
|
+
} else if (view.cover.type === "page_cover") {
|
|
3940
|
+
result.image = "note.cover";
|
|
3941
|
+
} else if (view.cover.type === "page_content" || view.cover.type === "page_content_first") {
|
|
3942
|
+
result.image = "formula.coverImage";
|
|
3943
|
+
}
|
|
3944
|
+
}
|
|
3945
|
+
return result;
|
|
3946
|
+
}
|
|
3947
|
+
toNoteRef(propertyName) {
|
|
3948
|
+
return propertyName;
|
|
3949
|
+
}
|
|
3950
|
+
resolvePropertyName(propertyId, schema) {
|
|
3951
|
+
for (const [name, prop] of Object.entries(schema)) {
|
|
3952
|
+
if (prop.id === propertyId) return name;
|
|
3953
|
+
}
|
|
3954
|
+
return void 0;
|
|
3955
|
+
}
|
|
3956
|
+
yamlKey(key) {
|
|
3957
|
+
if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(key)) return key;
|
|
3958
|
+
return `"${key.replace(/"/g, '\\"')}"`;
|
|
3959
|
+
}
|
|
3960
|
+
yamlValue(value) {
|
|
3961
|
+
if (/^[a-zA-Z0-9_-]+$/.test(value)) return value;
|
|
3962
|
+
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
3963
|
+
}
|
|
3964
|
+
};
|
|
3965
|
+
|
|
3771
3966
|
// src/converter/enhanced-md-converter.ts
|
|
3772
3967
|
var NOTION_CALLOUT_RE = /^::: callout\n([\s\S]*?)\n:::/gm;
|
|
3773
3968
|
var NOTION_CALLOUT_TAG_RE = /<callout[^>]*>\n?([\s\S]*?)<\/callout>/g;
|
|
@@ -4241,6 +4436,7 @@ var DatabaseSyncer = class {
|
|
|
4241
4436
|
pipeline;
|
|
4242
4437
|
imageHandler;
|
|
4243
4438
|
propertyMapper = new PropertyMapper();
|
|
4439
|
+
baseFileGenerator = new BaseFileGenerator();
|
|
4244
4440
|
async pullAll() {
|
|
4245
4441
|
const databases = this.config.notion.databases;
|
|
4246
4442
|
if (!databases || databases.length === 0) {
|
|
@@ -4295,7 +4491,8 @@ var DatabaseSyncer = class {
|
|
|
4295
4491
|
const schema = await this.notionClient.getDatabaseSchema(dbConfig.databaseId);
|
|
4296
4492
|
this.propertyMapper.loadSchema(schema);
|
|
4297
4493
|
await this.vaultFs.ensureFolder(dbConfig.localFolder);
|
|
4298
|
-
await this.pullDatabaseViews(dbConfig);
|
|
4494
|
+
const viewsConfig = await this.pullDatabaseViews(dbConfig);
|
|
4495
|
+
await this.generateBaseFile(dbConfig, viewsConfig);
|
|
4299
4496
|
const pages = await this.notionClient.queryAllDatabasePages(
|
|
4300
4497
|
dbConfig.databaseId,
|
|
4301
4498
|
dbConfig.pullFilter
|
|
@@ -4332,7 +4529,7 @@ var DatabaseSyncer = class {
|
|
|
4332
4529
|
try {
|
|
4333
4530
|
const existing = await this.vaultFs.readFile(configPath);
|
|
4334
4531
|
const parsed = JSON.parse(existing);
|
|
4335
|
-
if (parsed[dbConfig.databaseId]) return;
|
|
4532
|
+
if (parsed[dbConfig.databaseId]) return parsed[dbConfig.databaseId];
|
|
4336
4533
|
} catch {
|
|
4337
4534
|
}
|
|
4338
4535
|
}
|
|
@@ -4349,8 +4546,33 @@ var DatabaseSyncer = class {
|
|
|
4349
4546
|
getLogger().debug(
|
|
4350
4547
|
`[DB Sync] \uBDF0 \uC124\uC815 ${viewsConfig.views.length}\uAC1C \uC800\uC7A5: ${dbConfig.databaseId}`
|
|
4351
4548
|
);
|
|
4549
|
+
return viewsConfig;
|
|
4352
4550
|
} catch (error) {
|
|
4353
4551
|
getLogger().warn(`[DB Sync] \uBDF0 \uC124\uC815 Pull \uC2E4\uD328 (\uACC4\uC18D \uC9C4\uD589):`, error);
|
|
4552
|
+
return null;
|
|
4553
|
+
}
|
|
4554
|
+
}
|
|
4555
|
+
async generateBaseFile(dbConfig, viewsConfig) {
|
|
4556
|
+
try {
|
|
4557
|
+
const schemaFull = await this.notionClient.getDatabaseSchemaFull(dbConfig.databaseId);
|
|
4558
|
+
const dbName = viewsConfig?.databaseName || await this.notionClient.getDatabaseTitle(dbConfig.databaseId) || dbConfig.localFolder.split("/").pop() || "Database";
|
|
4559
|
+
const baseContent = this.baseFileGenerator.generate({
|
|
4560
|
+
databaseId: dbConfig.databaseId,
|
|
4561
|
+
databaseName: dbName,
|
|
4562
|
+
schema: schemaFull,
|
|
4563
|
+
viewsConfig: viewsConfig ?? {
|
|
4564
|
+
databaseId: dbConfig.databaseId,
|
|
4565
|
+
databaseName: dbName,
|
|
4566
|
+
lastSynced: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4567
|
+
views: [{ id: "default", name: "Table", type: "table" }]
|
|
4568
|
+
},
|
|
4569
|
+
folderPath: dbConfig.localFolder
|
|
4570
|
+
});
|
|
4571
|
+
const basePath = `${dbConfig.localFolder}/${sanitizeFileName(dbName)}.base`;
|
|
4572
|
+
await this.vaultFs.writeFile(basePath, baseContent);
|
|
4573
|
+
getLogger().debug(`[DB Sync] .base \uD30C\uC77C \uC0DD\uC131: ${basePath}`);
|
|
4574
|
+
} catch (error) {
|
|
4575
|
+
getLogger().warn(`[DB Sync] .base \uD30C\uC77C \uC0DD\uC131 \uC2E4\uD328 (\uACC4\uC18D \uC9C4\uD589):`, error);
|
|
4354
4576
|
}
|
|
4355
4577
|
}
|
|
4356
4578
|
async pullDatabasePage(page, dbConfig) {
|
|
@@ -4370,7 +4592,7 @@ var DatabaseSyncer = class {
|
|
|
4370
4592
|
);
|
|
4371
4593
|
const localUrlMatch = coverResult.content.match(/!\[cover\]\((.+?)\)/);
|
|
4372
4594
|
if (localUrlMatch?.[1]) {
|
|
4373
|
-
properties.cover = localUrlMatch[1]
|
|
4595
|
+
properties.cover = `[[${localUrlMatch[1]}]]`;
|
|
4374
4596
|
} else {
|
|
4375
4597
|
properties.cover = cover.url;
|
|
4376
4598
|
}
|
|
@@ -5990,7 +6212,7 @@ var NodeVaultFS = class {
|
|
|
5990
6212
|
if (this.isExcluded(relativePath)) continue;
|
|
5991
6213
|
if (entry.isDirectory()) {
|
|
5992
6214
|
await this.walkDirNonMd(fullPath, result);
|
|
5993
|
-
} else if (entry.isFile() && !entry.name.endsWith(".md")) {
|
|
6215
|
+
} else if (entry.isFile() && !entry.name.endsWith(".md") && !entry.name.endsWith(".base")) {
|
|
5994
6216
|
const fileStat = await stat(fullPath);
|
|
5995
6217
|
result.push({
|
|
5996
6218
|
path: relativePath,
|
|
@@ -6871,6 +7093,6 @@ ${lines.join("\n")}
|
|
|
6871
7093
|
}`;
|
|
6872
7094
|
}
|
|
6873
7095
|
|
|
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 };
|
|
7096
|
+
export { BaseFileGenerator, 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 };
|
|
6875
7097
|
//# sourceMappingURL=index.js.map
|
|
6876
7098
|
//# sourceMappingURL=index.js.map
|