@im-nobsidian/core 0.17.0 → 0.18.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/dist/index.d.ts +89 -30
- package/dist/index.js +558 -106
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -9,21 +9,15 @@ declare const DEFAULT_TITLE_PROPERTY = "Name";
|
|
|
9
9
|
declare const DatabaseSyncSchema: z.ZodObject<{
|
|
10
10
|
databaseId: z.ZodString;
|
|
11
11
|
localFolder: z.ZodString;
|
|
12
|
-
propertyMapping: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
13
12
|
pullFilter: z.ZodOptional<z.ZodUnknown>;
|
|
14
|
-
titleProperty: z.ZodDefault<z.ZodString>;
|
|
15
13
|
}, "strip", z.ZodTypeAny, {
|
|
16
14
|
databaseId: string;
|
|
17
15
|
localFolder: string;
|
|
18
|
-
titleProperty: string;
|
|
19
|
-
propertyMapping?: Record<string, string> | undefined;
|
|
20
16
|
pullFilter?: unknown;
|
|
21
17
|
}, {
|
|
22
18
|
databaseId: string;
|
|
23
19
|
localFolder: string;
|
|
24
|
-
propertyMapping?: Record<string, string> | undefined;
|
|
25
20
|
pullFilter?: unknown;
|
|
26
|
-
titleProperty?: string | undefined;
|
|
27
21
|
}>;
|
|
28
22
|
type DatabaseSyncConfig = z.infer<typeof DatabaseSyncSchema>;
|
|
29
23
|
declare const ConfigSchema: z.ZodObject<{
|
|
@@ -36,46 +30,36 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
36
30
|
databases: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
37
31
|
databaseId: z.ZodString;
|
|
38
32
|
localFolder: z.ZodString;
|
|
39
|
-
propertyMapping: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
40
33
|
pullFilter: z.ZodOptional<z.ZodUnknown>;
|
|
41
|
-
titleProperty: z.ZodDefault<z.ZodString>;
|
|
42
34
|
}, "strip", z.ZodTypeAny, {
|
|
43
35
|
databaseId: string;
|
|
44
36
|
localFolder: string;
|
|
45
|
-
titleProperty: string;
|
|
46
|
-
propertyMapping?: Record<string, string> | undefined;
|
|
47
37
|
pullFilter?: unknown;
|
|
48
38
|
}, {
|
|
49
39
|
databaseId: string;
|
|
50
40
|
localFolder: string;
|
|
51
|
-
propertyMapping?: Record<string, string> | undefined;
|
|
52
41
|
pullFilter?: unknown;
|
|
53
|
-
titleProperty?: string | undefined;
|
|
54
42
|
}>, "many">>;
|
|
55
43
|
}, "strip", z.ZodTypeAny, {
|
|
56
|
-
token: string;
|
|
57
|
-
rootPageId: string;
|
|
58
|
-
parentMode: "page" | "database";
|
|
59
44
|
databases: {
|
|
60
45
|
databaseId: string;
|
|
61
46
|
localFolder: string;
|
|
62
|
-
titleProperty: string;
|
|
63
|
-
propertyMapping?: Record<string, string> | undefined;
|
|
64
47
|
pullFilter?: unknown;
|
|
65
48
|
}[];
|
|
49
|
+
token: string;
|
|
50
|
+
rootPageId: string;
|
|
51
|
+
parentMode: "page" | "database";
|
|
66
52
|
databaseId?: string | undefined;
|
|
67
53
|
}, {
|
|
68
54
|
token: string;
|
|
69
55
|
rootPageId: string;
|
|
70
56
|
databaseId?: string | undefined;
|
|
71
|
-
parentMode?: "page" | "database" | undefined;
|
|
72
57
|
databases?: {
|
|
73
58
|
databaseId: string;
|
|
74
59
|
localFolder: string;
|
|
75
|
-
propertyMapping?: Record<string, string> | undefined;
|
|
76
60
|
pullFilter?: unknown;
|
|
77
|
-
titleProperty?: string | undefined;
|
|
78
61
|
}[] | undefined;
|
|
62
|
+
parentMode?: "page" | "database" | undefined;
|
|
79
63
|
}>;
|
|
80
64
|
sync: z.ZodObject<{
|
|
81
65
|
direction: z.ZodDefault<z.ZodEnum<["push", "pull", "both"]>>;
|
|
@@ -197,16 +181,14 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
197
181
|
}>;
|
|
198
182
|
}, "strip", z.ZodTypeAny, {
|
|
199
183
|
notion: {
|
|
200
|
-
token: string;
|
|
201
|
-
rootPageId: string;
|
|
202
|
-
parentMode: "page" | "database";
|
|
203
184
|
databases: {
|
|
204
185
|
databaseId: string;
|
|
205
186
|
localFolder: string;
|
|
206
|
-
titleProperty: string;
|
|
207
|
-
propertyMapping?: Record<string, string> | undefined;
|
|
208
187
|
pullFilter?: unknown;
|
|
209
188
|
}[];
|
|
189
|
+
token: string;
|
|
190
|
+
rootPageId: string;
|
|
191
|
+
parentMode: "page" | "database";
|
|
210
192
|
databaseId?: string | undefined;
|
|
211
193
|
};
|
|
212
194
|
conversion: {
|
|
@@ -257,14 +239,12 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
257
239
|
token: string;
|
|
258
240
|
rootPageId: string;
|
|
259
241
|
databaseId?: string | undefined;
|
|
260
|
-
parentMode?: "page" | "database" | undefined;
|
|
261
242
|
databases?: {
|
|
262
243
|
databaseId: string;
|
|
263
244
|
localFolder: string;
|
|
264
|
-
propertyMapping?: Record<string, string> | undefined;
|
|
265
245
|
pullFilter?: unknown;
|
|
266
|
-
titleProperty?: string | undefined;
|
|
267
246
|
}[] | undefined;
|
|
247
|
+
parentMode?: "page" | "database" | undefined;
|
|
268
248
|
};
|
|
269
249
|
conversion: {
|
|
270
250
|
timeZone?: string | undefined;
|
|
@@ -455,6 +435,8 @@ interface PushResult {
|
|
|
455
435
|
* 겹치지 않는다. 예전에는 updated 에 섞여, 이름만 바꾼 노트도 「수정」 으로 보였다.
|
|
456
436
|
*/
|
|
457
437
|
readonly moved: number;
|
|
438
|
+
/** 폴더 첨부로 올린 파일 수(ADR-054) — 노트 임베드는 노트와 함께 가 여기 들지 않는다. 없으면 0. */
|
|
439
|
+
readonly uploadedFiles?: number;
|
|
458
440
|
readonly failed: FailedOperation[];
|
|
459
441
|
readonly duration: number;
|
|
460
442
|
/**
|
|
@@ -3256,7 +3238,7 @@ declare class ImageHandler {
|
|
|
3256
3238
|
/**
|
|
3257
3239
|
* 임베드 경로가 가리킬 수 있는 볼트 실제 파일 후보를 우선순위대로 만든다(F23).
|
|
3258
3240
|
* Obsidian 위키링크 임베드는 노트 옆 파일을 파일명만으로 참조하는 게 관례라
|
|
3259
|
-
* 노트 폴더 → 볼트 루트 → attachments/ 순.
|
|
3241
|
+
* 노트 폴더 → 볼트 루트 → attachments/ 순. 세 곳에 없으면 볼트 어디서든 이름으로 찾는다({@link VaultFileIndex}).
|
|
3260
3242
|
*
|
|
3261
3243
|
* push(업로드)와 pull(원본 복원)이 **같은 사다리**를 봐야 왕복이 닫힌다. 예전에는
|
|
3262
3244
|
* pull 쪽이 볼트 루트만 확인해서, `__e2e_probe__/노트.md` 안의 `![[t-img.png]]` 는
|
|
@@ -3264,6 +3246,9 @@ declare class ImageHandler {
|
|
|
3264
3246
|
* 새로 받았다(실측) — 왕복할 때마다 첨부가 한 벌씩 늘어난다.
|
|
3265
3247
|
*/
|
|
3266
3248
|
private vaultCandidates;
|
|
3249
|
+
private indexOfFiles;
|
|
3250
|
+
/** 볼트의 첨부 이름표 — 처음 쓸 때 만든다. */
|
|
3251
|
+
private get fileIndex();
|
|
3267
3252
|
/**
|
|
3268
3253
|
* 임베드 경로를 볼트 실제 파일로 해석해 읽는다(F23).
|
|
3269
3254
|
* 폴백은 조용히 진행하고, 전부 실패했을 때만 마지막 오류를 던진다.
|
|
@@ -3275,6 +3260,8 @@ declare class ImageHandler {
|
|
|
3275
3260
|
}>;
|
|
3276
3261
|
private parseNotionFileUrl;
|
|
3277
3262
|
private downloadFile;
|
|
3263
|
+
/** 받은 파일의 이름 — `<줄기>-<해시><확장자>`. */
|
|
3264
|
+
private fileNameOf;
|
|
3278
3265
|
private isNotionImageUrl;
|
|
3279
3266
|
private isNotionFileUrl;
|
|
3280
3267
|
/**
|
|
@@ -3301,6 +3288,13 @@ declare class ImageHandler {
|
|
|
3301
3288
|
*/
|
|
3302
3289
|
type NotionBlockType = "image" | "pdf" | "video" | "audio" | "file";
|
|
3303
3290
|
|
|
3291
|
+
/** 폴더 페이지에 실린 폴더 첨부 하나. */
|
|
3292
|
+
interface FolderFileRef {
|
|
3293
|
+
readonly url: string;
|
|
3294
|
+
/** 올린 파일 이름 — Notion 이 주소 끝에 싣는다. 받을 때 이 이름으로 쓴다. */
|
|
3295
|
+
readonly name: string;
|
|
3296
|
+
}
|
|
3297
|
+
|
|
3304
3298
|
/** 첨부 다운로드 운영 튜닝값. 미지정 시 기존 동작과 동일한 기본값 사용. */
|
|
3305
3299
|
interface FileHandlerOptions {
|
|
3306
3300
|
/** 다운로드에 쓸 fetch 구현(테스트 주입용). 기본 전역 fetch. */
|
|
@@ -3309,6 +3303,21 @@ interface FileHandlerOptions {
|
|
|
3309
3303
|
readonly downloadTimeoutMs?: number;
|
|
3310
3304
|
/** 첨부 1건 업로드 전체의 시간 상한(ms). 기본 30분. 0 이하면 상한 없음. */
|
|
3311
3305
|
readonly itemTimeoutMs?: number;
|
|
3306
|
+
/**
|
|
3307
|
+
* pull 이 받은 그림 · 파일을 두는 폴더(`paths.attachments`). 그 안의 파일은 폴더 첨부로 올리지 않는다 — 받은 것을
|
|
3308
|
+
* 다시 올리면 Notion 에 사본이 생긴다.
|
|
3309
|
+
*/
|
|
3310
|
+
readonly attachmentsFolder?: string;
|
|
3311
|
+
/**
|
|
3312
|
+
* 지운 폴더 첨부를 다른 쪽에서도 지우나(`sync.deleteSync`) — 볼트에서 지우면 Notion 의 블록을, Notion 에서 지우면 볼트의
|
|
3313
|
+
* 파일을. 기본 false.
|
|
3314
|
+
*/
|
|
3315
|
+
readonly deleteSync?: boolean;
|
|
3316
|
+
}
|
|
3317
|
+
/** 노트 없는 폴더의 Notion 페이지를 마련하는 쪽 — push 의 폴더 배치(`FolderPlacement`). */
|
|
3318
|
+
interface FolderPageProvider {
|
|
3319
|
+
/** 폴더의 페이지를 마련한다. 이미 있으면 그대로 둔다. 마련할 수 없으면 까닭과 함께 던진다. */
|
|
3320
|
+
ensureFolderPage(folder: string): Promise<void>;
|
|
3312
3321
|
}
|
|
3313
3322
|
interface FileUploadResult {
|
|
3314
3323
|
readonly localPath: string;
|
|
@@ -3329,6 +3338,8 @@ declare class FileHandler {
|
|
|
3329
3338
|
private readonly customFetch?;
|
|
3330
3339
|
private readonly downloadTimeoutMs;
|
|
3331
3340
|
private readonly itemTimeoutMs;
|
|
3341
|
+
private readonly attachmentsFolder;
|
|
3342
|
+
private readonly deleteSync;
|
|
3332
3343
|
constructor(vaultFs: VaultFS, notionClient: NotionClient, stateDb: IStateDB, concurrency?: number, options?: FileHandlerOptions);
|
|
3333
3344
|
private get fetchFn();
|
|
3334
3345
|
pushFilesForFolder(folderPageId: string, folderPath: string): Promise<FileUploadResult[]>;
|
|
@@ -3349,6 +3360,12 @@ declare class FileHandler {
|
|
|
3349
3360
|
* @returns 업로드 결과. 변경 없음(스킵)이거나 실패했으면 null.
|
|
3350
3361
|
*/
|
|
3351
3362
|
private pushSingleFile;
|
|
3363
|
+
/** 올린 뒤 바뀌지 않았나 — 크기가 같으면 읽지 않는다. */
|
|
3364
|
+
private isUnchanged;
|
|
3365
|
+
/** pull 이 받은 것을 두는 폴더 안인가. */
|
|
3366
|
+
private inAttachmentsFolder;
|
|
3367
|
+
/** 폴더 첨부를 둘 Notion 페이지 — 폴더 노트 없는 폴더의 페이지(폴더 레코드)만. 맨 위는 루트 기록이 있을 때만. */
|
|
3368
|
+
private folderPageOf;
|
|
3352
3369
|
/**
|
|
3353
3370
|
* 업로드 후보 목록 — 도구 내부 산출물(`.base`/`.notion.json`)은 아예 빼고, Notion 이 받지 않는
|
|
3354
3371
|
* 형식은 따로 모은다.
|
|
@@ -3367,7 +3384,43 @@ declare class FileHandler {
|
|
|
3367
3384
|
* @param failed 올리지 못한 첨부를 담을 곳 — push 결과의 `failed` 를 넘기면 CLI · 플러그인이 처리하지 못한 것으로
|
|
3368
3385
|
* 보인다. 예전엔 경고 로그로만 남아 push 가 「실패 0」 으로 끝났다.
|
|
3369
3386
|
*/
|
|
3370
|
-
pushAllFiles(failed?: FailedOperation[]): Promise<FileUploadResult[]>;
|
|
3387
|
+
pushAllFiles(failed?: FailedOperation[], folders?: FolderPageProvider): Promise<FileUploadResult[]>;
|
|
3388
|
+
/**
|
|
3389
|
+
* 볼트에서 지운 폴더 첨부를 Notion 에서도 지운다(deleteSync) — 폴더 페이지에 적힌 파일 가운데 볼트에 없는 것의 블록과 기록.
|
|
3390
|
+
* 포함 · 제외 패턴으로 빠진 파일은 볼트에 있어 지우지 않는다.
|
|
3391
|
+
*/
|
|
3392
|
+
private removeDeletedFolderFiles;
|
|
3393
|
+
/** 폴더 첨부를 둘 페이지 — 노트 없는 폴더면 마련한다. 둘 곳이 없으면 그 파일들을 `stranded` 에 담고 null. */
|
|
3394
|
+
private provideFolderPage;
|
|
3395
|
+
/**
|
|
3396
|
+
* 둘 곳이 없어 올리지 않은 폴더 첨부 — 경고로 알린다. 예전에는 디버그 로그로만 남아 파일이 Notion 에 가지 않은 것을 알 수
|
|
3397
|
+
* 없었다. 노트에 붙이면 그 노트와 함께 올라간다.
|
|
3398
|
+
*/
|
|
3399
|
+
private reportStranded;
|
|
3400
|
+
/** 볼트의 노트가 붙인 파일 이름 — {@link embeddedNamesOf}. 읽지 못한 노트는 건너뛴다. */
|
|
3401
|
+
private embeddedNames;
|
|
3402
|
+
/**
|
|
3403
|
+
* 폴더 페이지의 폴더 첨부를 그 폴더에 받는다 — 올린 이름 그대로. Notion 파일 id 가 적어 둔 것과 같으면(올린 볼트 · 앞서
|
|
3404
|
+
* 받은 볼트) 받지 않는다. Notion 에서 바뀐 파일은 볼트 쪽이 그대로일 때만 덮는다 — 볼트에서도 고쳤으면 두고 알린다(다음
|
|
3405
|
+
* push 가 볼트의 것을 올린다).
|
|
3406
|
+
*
|
|
3407
|
+
* @param complete 본문을 끝까지 받았나 — 그럴 때만 Notion 에서 지운 파일을 볼트에서 지운다(deleteSync). 잘린 본문에 없는
|
|
3408
|
+
* 파일은 지운 것이 아니다.
|
|
3409
|
+
* @returns 새로 받거나 바꾼 파일 수
|
|
3410
|
+
*/
|
|
3411
|
+
receiveFolderFiles(folder: string, pageId: string, files: readonly FolderFileRef[], complete?: boolean): Promise<number>;
|
|
3412
|
+
/**
|
|
3413
|
+
* Notion 에서 지운 폴더 첨부를 볼트에서 지운다 — 지난 동기화 그대로일 때만. 볼트에서 고쳤으면 두고 기록만 놓는다 — 다음 push
|
|
3414
|
+
* 가 다시 올린다(노트의 원격 삭제와 같은 규칙).
|
|
3415
|
+
*/
|
|
3416
|
+
private removeLocalFolderFile;
|
|
3417
|
+
/**
|
|
3418
|
+
* 폴더 첨부 하나를 받는다. 볼트에 같은 경로가 있으면: 같은 내용이면 적기만 하고, 지난 동기화 뒤 볼트에서 그대로인 파일은
|
|
3419
|
+
* 덮고(`entry`), 그 밖(볼트에서 고친 것 · 처음 보는 다른 파일)은 두고 알린다.
|
|
3420
|
+
*
|
|
3421
|
+
* @returns 볼트에 썼는가
|
|
3422
|
+
*/
|
|
3423
|
+
private receiveOne;
|
|
3371
3424
|
downloadFileBlock(url: string, filename: string, targetFolder: string): Promise<FileDownloadResult>;
|
|
3372
3425
|
downloadFileBlocks(blocks: Array<{
|
|
3373
3426
|
type: string;
|
|
@@ -3375,6 +3428,12 @@ declare class FileHandler {
|
|
|
3375
3428
|
caption?: string;
|
|
3376
3429
|
}>, targetFolder: string): Promise<FileDownloadResult[]>;
|
|
3377
3430
|
private uploadFile;
|
|
3431
|
+
/** 이 페이지에서 같은 이름의 파일 블록 중 방금 붙인 것 말고를 지운다. */
|
|
3432
|
+
private removeOlderBlocks;
|
|
3433
|
+
/**
|
|
3434
|
+
* 폴더 첨부의 파일 블록 — 캡션에 파일 이름을 적는다. 받는 쪽이 그 표시로 폴더 첨부를 알아본다({@link folderFilesOf}) —
|
|
3435
|
+
* 자식 페이지가 없는 폴더 페이지는 PDF 하나만 붙인 노트와 모양이 같다.
|
|
3436
|
+
*/
|
|
3378
3437
|
private createFileBlock;
|
|
3379
3438
|
private extractFilename;
|
|
3380
3439
|
}
|