@interactive-inc/docs-client 1.1.1 → 2.0.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/README.md +448 -0
- package/build/{doc-file-system-DEmPPJPE.d.ts → doc-file-system-z2sEMkq0.d.ts} +5 -5
- package/build/{doc-file-system.interface-C5vpYrOL.d.ts → doc-file-system.interface-CmQywbuP.d.ts} +3 -2
- package/build/file-system-json.d.ts +52 -10
- package/build/file-system-json.js +122 -68
- package/build/file-system-mock.d.ts +1 -1
- package/build/file-system-mock.js +8 -3
- package/build/file-system-node.d.ts +2 -2
- package/build/file-system-node.js +14 -12
- package/build/file-system-octokit.d.ts +7 -2
- package/build/file-system-octokit.js +42 -34
- package/build/file-system.d.ts +4 -4
- package/build/file-system.js +13 -12
- package/build/index.d.ts +101 -233
- package/build/index.js +552 -778
- package/build/models.d.ts +81 -1
- package/build/models.js +14 -15
- package/package.json +46 -17
- package/.env.local +0 -3
- package/tmp/docs-studio/files/a.md +0 -9
- package/tmp/docs-studio/pages/delete-document.md +0 -7
- package/tmp/docs-studio/pages/document-editor.md +0 -9
- package/tmp/docs-studio/pages/edit-document-content.md +0 -7
- package/tmp/docs-studio/pages/index.md +0 -14
package/build/file-system.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import * as fs from 'fs/promises';
|
|
2
2
|
|
|
3
3
|
// lib/modules/path-system/doc-path-system.ts
|
|
4
|
-
var DocPathSystem = class {
|
|
4
|
+
var DocPathSystem = class _DocPathSystem {
|
|
5
5
|
separator = "/";
|
|
6
|
+
constructor() {
|
|
7
|
+
if (new.target === _DocPathSystem) {
|
|
8
|
+
Object.freeze(this);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
6
11
|
/**
|
|
7
12
|
* Join paths
|
|
8
13
|
*/
|
|
@@ -58,8 +63,8 @@ var DocPathSystem = class {
|
|
|
58
63
|
* Calculate relative path
|
|
59
64
|
*/
|
|
60
65
|
relative(from, to) {
|
|
61
|
-
const fromSegments = from.split(this.separator).filter(
|
|
62
|
-
const toSegments = to.split(this.separator).filter(
|
|
66
|
+
const fromSegments = from.split(this.separator).filter((s) => s !== "" && s !== ".");
|
|
67
|
+
const toSegments = to.split(this.separator).filter((s) => s !== "" && s !== ".");
|
|
63
68
|
let commonLength = 0;
|
|
64
69
|
for (let i = 0; i < Math.min(fromSegments.length, toSegments.length); i++) {
|
|
65
70
|
if (fromSegments[i] === toSegments[i]) {
|
|
@@ -268,6 +273,7 @@ var DocFileSystemNodeRead = class {
|
|
|
268
273
|
constructor(props) {
|
|
269
274
|
this.basePath = props.basePath;
|
|
270
275
|
this.pathSystem = props.pathSystem ?? new DocPathSystem();
|
|
276
|
+
Object.freeze(this);
|
|
271
277
|
}
|
|
272
278
|
/**
|
|
273
279
|
* Read file content at the specified path
|
|
@@ -317,9 +323,7 @@ var DocFileSystemNodeRead = class {
|
|
|
317
323
|
if (fileNames instanceof Error) {
|
|
318
324
|
return fileNames;
|
|
319
325
|
}
|
|
320
|
-
return fileNames.map(
|
|
321
|
-
(fileName) => this.pathSystem.join(relativePath, fileName)
|
|
322
|
-
);
|
|
326
|
+
return fileNames.map((fileName) => this.pathSystem.join(relativePath, fileName));
|
|
323
327
|
} catch (error) {
|
|
324
328
|
return error instanceof Error ? error : new Error(`Failed to read directory file paths at ${relativePath}`);
|
|
325
329
|
}
|
|
@@ -429,6 +433,7 @@ var DocFileSystemNodeWrite = class {
|
|
|
429
433
|
this.basePath = props.basePath;
|
|
430
434
|
this.pathSystem = props.pathSystem ?? new DocPathSystem();
|
|
431
435
|
this.reader = props.reader;
|
|
436
|
+
Object.freeze(this);
|
|
432
437
|
}
|
|
433
438
|
/**
|
|
434
439
|
* Write content to file at the specified path (creates directory if needed)
|
|
@@ -498,9 +503,7 @@ var DocFileSystemNodeWrite = class {
|
|
|
498
503
|
await fs.copyFile(sourceFullPath, destFullPath);
|
|
499
504
|
return null;
|
|
500
505
|
} catch (error) {
|
|
501
|
-
return error instanceof Error ? error : new Error(
|
|
502
|
-
`Failed to copy file from ${sourcePath} to ${destinationPath}`
|
|
503
|
-
);
|
|
506
|
+
return error instanceof Error ? error : new Error(`Failed to copy file from ${sourcePath} to ${destinationPath}`);
|
|
504
507
|
}
|
|
505
508
|
}
|
|
506
509
|
/**
|
|
@@ -513,9 +516,7 @@ var DocFileSystemNodeWrite = class {
|
|
|
513
516
|
await fs.rename(sourceFullPath, destFullPath);
|
|
514
517
|
return null;
|
|
515
518
|
} catch (error) {
|
|
516
|
-
return error instanceof Error ? error : new Error(
|
|
517
|
-
`Failed to move file from ${sourcePath} to ${destinationPath}`
|
|
518
|
-
);
|
|
519
|
+
return error instanceof Error ? error : new Error(`Failed to move file from ${sourcePath} to ${destinationPath}`);
|
|
519
520
|
}
|
|
520
521
|
}
|
|
521
522
|
};
|
package/build/index.d.ts
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
|
-
import { D as DocFileSystemInterface, a as DocPathSystem } from './doc-file-system.interface-
|
|
1
|
+
import { D as DocFileSystemInterface, a as DocPathSystem } from './doc-file-system.interface-CmQywbuP.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { zDocFileMd, zDocFileUnknown, zDocClientConfig, zDocFilePath, zDocFileIndexSchemaField, zDocSchemaFieldText, zDocSchemaFieldNumber, zDocSchemaFieldBoolean, zDocSchemaFieldRelation, zDocSchemaFieldSelectText, zDocSchemaFieldSelectNumber, zDocSchemaFieldMultiText, zDocSchemaFieldMultiNumber, zDocSchemaFieldMultiRelation, zDocSchemaFieldMultiSelectText, zDocSchemaFieldMultiSelectNumber, zDocFileIndex, zDocRelation, zDocRelationFile, zDocMetaFieldRelation, zDocMetaFieldMultiRelation, zDocMetaFieldText, zDocMetaFieldNumber, zDocMetaFieldBoolean, zDocMetaFieldMultiText, zDocMetaFieldMultiNumber, zDocRelationField, zDocMetaField, zDocMetaFieldSelectText, zDocMetaFieldSelectNumber, zDocMetaFieldMultiSelectText, zDocMetaFieldMultiSelectNumber, zDocMetaFieldTypeText, zDocMetaFieldTypeNumber, zDocMetaFieldTypeBoolean, zDocMetaFieldTypeSelectText, zDocMetaFieldTypeSelectNumber, zDocMetaFieldTypeRelation, zDocMetaFieldType } from './models.js';
|
|
3
|
+
import { zDocFileMd, zDocFileUnknown, zDocClientConfig, zDocFilePath, zDocFileIndexSchemaField, zDocSchemaFieldText, zDocSchemaFieldNumber, zDocSchemaFieldBoolean, zDocSchemaFieldRelation, zDocSchemaFieldSelectText, zDocSchemaFieldSelectNumber, zDocSchemaFieldMultiText, zDocSchemaFieldMultiNumber, zDocSchemaFieldMultiRelation, zDocSchemaFieldMultiSelectText, zDocSchemaFieldMultiSelectNumber, zDocDirectoryMeta, zDocFileIndex, zDocRelation, zDocRelationFile, zDocMetaFieldRelation, zDocMetaFieldMultiRelation, zDocMetaFieldText, zDocMetaFieldNumber, zDocMetaFieldBoolean, zDocMetaFieldMultiText, zDocMetaFieldMultiNumber, zDocRelationField, zDocMetaField, zDocMetaFieldSelectText, zDocMetaFieldSelectNumber, zDocMetaFieldMultiSelectText, zDocMetaFieldMultiSelectNumber, zDocMetaFieldTypeText, zDocMetaFieldTypeNumber, zDocMetaFieldTypeBoolean, zDocMetaFieldTypeSelectText, zDocMetaFieldTypeSelectNumber, zDocMetaFieldTypeRelation, zDocMetaFieldType } from './models.js';
|
|
4
|
+
|
|
5
|
+
type SafeMethod<F> = F extends (...args: infer A) => Promise<infer R> ? (...args: A) => Promise<R | Error> : F;
|
|
6
|
+
/**
|
|
7
|
+
* All async methods return T | Error instead of throwing.
|
|
8
|
+
*
|
|
9
|
+
* Promise を返すメソッドのみ T | Error に変換される。AsyncGenerator を返すメソッド
|
|
10
|
+
* (filesGenerator など)は変換されないため、安全に列挙したい場合は配列を返す
|
|
11
|
+
* files()/mdFiles() を .safe 経由で使うこと
|
|
12
|
+
*/
|
|
13
|
+
type Safe<T> = {
|
|
14
|
+
[K in keyof T as K extends "safe" ? never : K]: SafeMethod<T[K]>;
|
|
15
|
+
};
|
|
16
|
+
declare function createSafeProxy<T extends object>(target: T): Safe<T>;
|
|
4
17
|
|
|
5
18
|
/**
|
|
6
19
|
* Single boolean type schema field
|
|
@@ -298,7 +311,6 @@ declare class DocFileIndexSchemaValue<T extends DocCustomSchema> {
|
|
|
298
311
|
toJson(): DocFileIndexSchema<keyof T>;
|
|
299
312
|
/**
|
|
300
313
|
* Create empty schema entity
|
|
301
|
-
* biome-ignore lint/complexity/noBannedTypes: {} as DocCustomSchema
|
|
302
314
|
*/
|
|
303
315
|
static empty(): DocFileIndexSchemaValue<{}>;
|
|
304
316
|
}
|
|
@@ -357,19 +369,9 @@ declare class DocFileIndexMetaValue<T extends DocCustomSchema> {
|
|
|
357
369
|
* Generate empty FrontMatter
|
|
358
370
|
*/
|
|
359
371
|
static empty<T extends DocCustomSchema>(customSchema: T, config: DocClientConfig): DocFileIndexMetaValue<T>;
|
|
360
|
-
|
|
361
|
-
* Extract icon
|
|
362
|
-
*/
|
|
372
|
+
static emptySchema<T extends DocCustomSchema>(customSchema: T): DocFileIndexSchema<keyof T>;
|
|
363
373
|
private static extractIcon;
|
|
364
|
-
/**
|
|
365
|
-
* Extract schema part
|
|
366
|
-
*/
|
|
367
374
|
private static extractSchema;
|
|
368
|
-
/**
|
|
369
|
-
* Normalize entire schema
|
|
370
|
-
*/
|
|
371
|
-
private static normalizeSchema;
|
|
372
|
-
static emptySchema<T extends DocCustomSchema>(customSchema: T): DocFileIndexSchema<keyof T>;
|
|
373
375
|
}
|
|
374
376
|
|
|
375
377
|
/**
|
|
@@ -408,6 +410,11 @@ declare class DocFileIndexContentValue<T extends DocCustomSchema> {
|
|
|
408
410
|
* Generate from Markdown text
|
|
409
411
|
*/
|
|
410
412
|
static fromMarkdown<T extends DocCustomSchema>(markdown: string, customSchema: T, config: DocClientConfig): DocFileIndexContentValue<T>;
|
|
413
|
+
/**
|
|
414
|
+
* Generate from Markdown text with .meta.json
|
|
415
|
+
* FrontMatter is ignored, only body/title/description are extracted
|
|
416
|
+
*/
|
|
417
|
+
static fromMarkdownWithDirectoryMeta<T extends DocCustomSchema>(markdown: string, customSchema: T, config: DocClientConfig, directoryMeta: DocDirectoryMeta): DocFileIndexContentValue<T>;
|
|
411
418
|
/**
|
|
412
419
|
* Update content
|
|
413
420
|
*/
|
|
@@ -424,6 +431,10 @@ declare class DocFileIndexContentValue<T extends DocCustomSchema> {
|
|
|
424
431
|
* Generate default index.md content
|
|
425
432
|
*/
|
|
426
433
|
static empty<T extends DocCustomSchema = DocCustomSchema>(directoryName: string, customSchema: T, config: DocClientConfig): DocFileIndexContentValue<T>;
|
|
434
|
+
/**
|
|
435
|
+
* Generate default index.md content with .meta.json
|
|
436
|
+
*/
|
|
437
|
+
static emptyWithDirectoryMeta<T extends DocCustomSchema = DocCustomSchema>(directoryName: string, customSchema: T, config: DocClientConfig, directoryMeta: DocDirectoryMeta): DocFileIndexContentValue<T>;
|
|
427
438
|
/**
|
|
428
439
|
* Generate complete text combining FrontMatter and body
|
|
429
440
|
*/
|
|
@@ -488,14 +499,11 @@ declare class DocRelationFileValue {
|
|
|
488
499
|
* Convert to JSON format
|
|
489
500
|
*/
|
|
490
501
|
toJson(): DocRelationFile;
|
|
491
|
-
/**
|
|
492
|
-
* Extract file name from file path (without extension)
|
|
493
|
-
*/
|
|
494
|
-
private static extractFileName;
|
|
495
502
|
/**
|
|
496
503
|
* Create from file path and title
|
|
497
504
|
*/
|
|
498
505
|
static from(filePath: string, title: string | null): DocRelationFileValue;
|
|
506
|
+
private static extractFileName;
|
|
499
507
|
}
|
|
500
508
|
|
|
501
509
|
/**
|
|
@@ -542,41 +550,18 @@ declare class DocFileRelationReference {
|
|
|
542
550
|
private readonly props;
|
|
543
551
|
private readonly pathSystem;
|
|
544
552
|
constructor(props: Props$8);
|
|
553
|
+
get safe(): Safe<this>;
|
|
545
554
|
get fileSystem(): DocFileSystemInterface;
|
|
546
555
|
get basePath(): string;
|
|
547
|
-
/**
|
|
548
|
-
* Relation path
|
|
549
|
-
*/
|
|
550
556
|
get path(): string;
|
|
551
|
-
/**
|
|
552
|
-
* Full path
|
|
553
|
-
*/
|
|
554
557
|
get fullPath(): string;
|
|
555
|
-
read(): Promise<DocRelationValue |
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
*/
|
|
559
|
-
readFiles(): Promise<DocRelationFileValue[] | Error>;
|
|
560
|
-
/**
|
|
561
|
-
* Read single relation file
|
|
562
|
-
*/
|
|
563
|
-
readFile(filePath: string): Promise<DocRelationFileValue | Error | null>;
|
|
564
|
-
/**
|
|
565
|
-
* Check if file exists
|
|
566
|
-
*/
|
|
558
|
+
read(): Promise<DocRelationValue | null>;
|
|
559
|
+
readFiles(): Promise<DocRelationFileValue[]>;
|
|
560
|
+
readFile(filePath: string): Promise<DocRelationFileValue | null>;
|
|
567
561
|
exists(slug: string): Promise<boolean>;
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
readSlugs(): Promise<string[] | Error>;
|
|
572
|
-
/**
|
|
573
|
-
* Get file count
|
|
574
|
-
*/
|
|
575
|
-
count(): Promise<number | Error>;
|
|
576
|
-
/**
|
|
577
|
-
* Check if empty
|
|
578
|
-
*/
|
|
579
|
-
isEmpty(): Promise<boolean | Error>;
|
|
562
|
+
readSlugs(): Promise<string[]>;
|
|
563
|
+
count(): Promise<number>;
|
|
564
|
+
isEmpty(): Promise<boolean>;
|
|
580
565
|
}
|
|
581
566
|
|
|
582
567
|
type Props$7<T extends DocCustomSchema> = {
|
|
@@ -594,62 +579,31 @@ declare class DocFileIndexReference<T extends DocCustomSchema> {
|
|
|
594
579
|
private readonly pathSystem;
|
|
595
580
|
private readonly customSchema;
|
|
596
581
|
constructor(props: Props$7<T>);
|
|
582
|
+
get safe(): Safe<this>;
|
|
597
583
|
get fileSystem(): DocFileSystemInterface;
|
|
598
584
|
get basePath(): string;
|
|
599
585
|
get filePath(): string;
|
|
600
586
|
get fileFullPath(): string;
|
|
601
|
-
get
|
|
602
|
-
read(): Promise<DocFileIndexEntity<T
|
|
587
|
+
get directoryPath(): string;
|
|
588
|
+
read(): Promise<DocFileIndexEntity<T>>;
|
|
589
|
+
private readDirectoryMeta;
|
|
603
590
|
readSchemaValue(): Promise<DocFileIndexSchema<RecordKey>>;
|
|
604
|
-
|
|
605
|
-
* Read file content
|
|
606
|
-
*/
|
|
607
|
-
readContent(): Promise<Error | string>;
|
|
591
|
+
readContent(): Promise<string>;
|
|
608
592
|
/**
|
|
609
593
|
* Create empty DocFileIndexEntity
|
|
610
594
|
*/
|
|
611
595
|
empty(): DocFileIndexEntity<T>;
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
/**
|
|
617
|
-
* Write entity
|
|
618
|
-
*/
|
|
619
|
-
write(entity: DocFileIndexEntity<T>): Promise<Error | null>;
|
|
620
|
-
/**
|
|
621
|
-
* Create new file with default content
|
|
622
|
-
*/
|
|
623
|
-
writeDefault(): Promise<Error | null>;
|
|
624
|
-
/**
|
|
625
|
-
* Delete file
|
|
626
|
-
*/
|
|
627
|
-
delete(): Promise<Error | null>;
|
|
628
|
-
/**
|
|
629
|
-
* Check if file exists
|
|
630
|
-
*/
|
|
596
|
+
writeContent(content: string): Promise<void>;
|
|
597
|
+
write(entity: DocFileIndexEntity<T>): Promise<void>;
|
|
598
|
+
writeDefault(): Promise<void>;
|
|
599
|
+
delete(): Promise<void>;
|
|
631
600
|
exists(): Promise<boolean>;
|
|
632
|
-
relations(): Promise<DocFileRelationReference[]
|
|
633
|
-
readRelations(): Promise<DocRelationValue[]
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
size(): Promise<number | Error>;
|
|
638
|
-
/**
|
|
639
|
-
* Get last modified date
|
|
640
|
-
*/
|
|
641
|
-
lastModified(): Promise<Date | Error>;
|
|
642
|
-
/**
|
|
643
|
-
* Get file creation date
|
|
644
|
-
*/
|
|
645
|
-
createdAt(): Promise<Date | Error>;
|
|
646
|
-
/**
|
|
647
|
-
* Move file to archive and return new reference
|
|
648
|
-
*/
|
|
601
|
+
relations(): Promise<DocFileRelationReference[]>;
|
|
602
|
+
readRelations(): Promise<DocRelationValue[]>;
|
|
603
|
+
size(): Promise<number>;
|
|
604
|
+
lastModified(): Promise<Date>;
|
|
605
|
+
createdAt(): Promise<Date>;
|
|
649
606
|
archive(archiveDirectoryName?: string): Promise<DocFileIndexReference<T>>;
|
|
650
|
-
/**
|
|
651
|
-
* Restore file from archive and return new reference
|
|
652
|
-
*/
|
|
653
607
|
restore(archiveDirectoryName?: string): Promise<DocFileIndexReference<T>>;
|
|
654
608
|
}
|
|
655
609
|
|
|
@@ -677,7 +631,6 @@ declare class DocFileMdMetaValue<T extends DocCustomSchema> {
|
|
|
677
631
|
hasKey(key: keyof T): boolean;
|
|
678
632
|
toJson(): SchemaToValueType<T>;
|
|
679
633
|
toYaml(): string;
|
|
680
|
-
private validateValue;
|
|
681
634
|
private getValueField;
|
|
682
635
|
/**
|
|
683
636
|
* Generate from Markdown text
|
|
@@ -831,68 +784,30 @@ declare class DocFileUnknownReference<T extends DocCustomSchema> {
|
|
|
831
784
|
private readonly pathSystem;
|
|
832
785
|
private readonly customSchema;
|
|
833
786
|
constructor(props: Props$6<T>);
|
|
787
|
+
get safe(): Safe<this>;
|
|
834
788
|
get fileSystem(): DocFileSystemInterface;
|
|
835
789
|
get basePath(): string;
|
|
836
790
|
get path(): string;
|
|
837
791
|
get directoryPath(): string;
|
|
838
792
|
get fileFullPath(): string;
|
|
839
793
|
directory(): DocDirectoryReference<T>;
|
|
840
|
-
read(): Promise<
|
|
841
|
-
|
|
842
|
-
* Read file content
|
|
843
|
-
*/
|
|
844
|
-
readContent(): Promise<Error | string>;
|
|
794
|
+
read(): Promise<DocFileUnknownEntity>;
|
|
795
|
+
readContent(): Promise<string>;
|
|
845
796
|
/**
|
|
846
797
|
* Create empty DocFileUnknownEntity
|
|
847
798
|
*/
|
|
848
799
|
empty(): DocFileUnknownEntity;
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
/**
|
|
854
|
-
* Write entity
|
|
855
|
-
*/
|
|
856
|
-
write(entity: DocFileUnknownEntity): Promise<Error | null>;
|
|
857
|
-
/**
|
|
858
|
-
* Write raw content
|
|
859
|
-
*/
|
|
860
|
-
writeRaw(content: string): Promise<Error | null>;
|
|
861
|
-
/**
|
|
862
|
-
* Delete file
|
|
863
|
-
*/
|
|
864
|
-
delete(): Promise<Error | null>;
|
|
865
|
-
/**
|
|
866
|
-
* Check if file exists
|
|
867
|
-
*/
|
|
800
|
+
writeContent(content: string): Promise<void>;
|
|
801
|
+
write(entity: DocFileUnknownEntity): Promise<void>;
|
|
802
|
+
writeRaw(content: string): Promise<void>;
|
|
803
|
+
delete(): Promise<void>;
|
|
868
804
|
exists(): Promise<boolean>;
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
* Move file
|
|
875
|
-
*/
|
|
876
|
-
moveTo(destinationPath: string): Promise<Error | null>;
|
|
877
|
-
/**
|
|
878
|
-
* Get file size in bytes
|
|
879
|
-
*/
|
|
880
|
-
size(): Promise<number | Error>;
|
|
881
|
-
/**
|
|
882
|
-
* Get file last modified time
|
|
883
|
-
*/
|
|
884
|
-
lastModified(): Promise<Date | Error>;
|
|
885
|
-
/**
|
|
886
|
-
* Get file creation time
|
|
887
|
-
*/
|
|
888
|
-
createdAt(): Promise<Date | Error>;
|
|
889
|
-
/**
|
|
890
|
-
* Move file to archive and return new reference
|
|
891
|
-
*/
|
|
805
|
+
copyTo(destinationPath: string): Promise<void>;
|
|
806
|
+
moveTo(destinationPath: string): Promise<void>;
|
|
807
|
+
size(): Promise<number>;
|
|
808
|
+
lastModified(): Promise<Date>;
|
|
809
|
+
createdAt(): Promise<Date>;
|
|
892
810
|
archive(archiveDirectoryName?: string): Promise<DocFileUnknownReference<T>>;
|
|
893
|
-
/**
|
|
894
|
-
* Restore file from archive and return new reference
|
|
895
|
-
*/
|
|
896
811
|
restore(archiveDirectoryName?: string): Promise<DocFileUnknownReference<T>>;
|
|
897
812
|
}
|
|
898
813
|
|
|
@@ -915,6 +830,7 @@ declare class DocDirectoryReference<T extends DocCustomSchema> {
|
|
|
915
830
|
private readonly pathSystem;
|
|
916
831
|
private readonly customSchema;
|
|
917
832
|
constructor(props: Props$5<T>);
|
|
833
|
+
get safe(): Safe<this>;
|
|
918
834
|
get fileSystem(): DocFileSystemInterface;
|
|
919
835
|
get basePath(): string;
|
|
920
836
|
get config(): DocClientConfig;
|
|
@@ -932,10 +848,10 @@ declare class DocDirectoryReference<T extends DocCustomSchema> {
|
|
|
932
848
|
get indexFilePath(): string;
|
|
933
849
|
get archiveDirectoryName(): string;
|
|
934
850
|
get name(): string;
|
|
935
|
-
fileNames(): Promise<string[]
|
|
936
|
-
archivedFileNames(): Promise<string[]
|
|
851
|
+
fileNames(): Promise<string[]>;
|
|
852
|
+
archivedFileNames(): Promise<string[]>;
|
|
937
853
|
filesGenerator(): AsyncGenerator<DocFileDirectoryReference<T>, void, unknown>;
|
|
938
|
-
mdFilesGenerator(): AsyncGenerator<DocFileMdReference<T
|
|
854
|
+
mdFilesGenerator(): AsyncGenerator<DocFileMdReference<T>, void, unknown>;
|
|
939
855
|
files(): Promise<DocFileDirectoryReference<T>[]>;
|
|
940
856
|
mdFiles(): Promise<DocFileMdReference<T>[]>;
|
|
941
857
|
file<FileName extends string>(fileName: FileName): InferReference<FileName, T>;
|
|
@@ -943,30 +859,15 @@ declare class DocDirectoryReference<T extends DocCustomSchema> {
|
|
|
943
859
|
readFiles(): Promise<DocFileDirectoryEntity<T>[]>;
|
|
944
860
|
readMdFiles(): Promise<DocFileMdEntity<T>[]>;
|
|
945
861
|
readUnknownFiles(): Promise<DocFileUnknownEntity[]>;
|
|
946
|
-
/**
|
|
947
|
-
* Get list of subdirectory names
|
|
948
|
-
*/
|
|
949
862
|
directoryNames(): Promise<string[]>;
|
|
950
|
-
/**
|
|
951
|
-
* Get subdirectory references
|
|
952
|
-
*/
|
|
953
863
|
directories(): Promise<DocDirectoryReference<T>[]>;
|
|
954
|
-
/**
|
|
955
|
-
* Get single subdirectory reference
|
|
956
|
-
*/
|
|
957
864
|
directory(directoryName: string): DocDirectoryReference<T>;
|
|
958
865
|
directory<S extends DocCustomSchema>(directoryName: string, customSchema: S): DocDirectoryReference<S>;
|
|
959
866
|
indexFile(): DocFileIndexReference<T>;
|
|
960
|
-
readIndexFile(): Promise<DocFileIndexEntity<T
|
|
961
|
-
writeFile(entity: DocFileIndexEntity<T> | DocFileMdEntity<T> | DocFileUnknownEntity): Promise<
|
|
867
|
+
readIndexFile(): Promise<DocFileIndexEntity<T>>;
|
|
868
|
+
writeFile(entity: DocFileIndexEntity<T> | DocFileMdEntity<T> | DocFileUnknownEntity): Promise<void>;
|
|
962
869
|
exists(): Promise<boolean>;
|
|
963
|
-
/**
|
|
964
|
-
* Create new Markdown file
|
|
965
|
-
*/
|
|
966
870
|
createMdFile(fileName?: string): Promise<DocFileMdReference<T>>;
|
|
967
|
-
/**
|
|
968
|
-
* Generate unique filename
|
|
969
|
-
*/
|
|
970
871
|
private uniqueFileName;
|
|
971
872
|
}
|
|
972
873
|
|
|
@@ -985,6 +886,7 @@ declare class DocFileMdReference<T extends DocCustomSchema> {
|
|
|
985
886
|
private readonly pathSystem;
|
|
986
887
|
private readonly customSchema;
|
|
987
888
|
constructor(props: Props$4<T>);
|
|
889
|
+
get safe(): Safe<this>;
|
|
988
890
|
get fileSystem(): DocFileSystemInterface;
|
|
989
891
|
get basePath(): string;
|
|
990
892
|
get path(): string;
|
|
@@ -994,77 +896,36 @@ declare class DocFileMdReference<T extends DocCustomSchema> {
|
|
|
994
896
|
get name(): string;
|
|
995
897
|
get nameWithExtension(): string;
|
|
996
898
|
exists(): Promise<boolean>;
|
|
997
|
-
read(): Promise<DocFileMdEntity<T
|
|
998
|
-
|
|
999
|
-
* Read file content
|
|
1000
|
-
*/
|
|
1001
|
-
readText(): Promise<Error | string>;
|
|
899
|
+
read(): Promise<DocFileMdEntity<T>>;
|
|
900
|
+
readText(): Promise<string>;
|
|
1002
901
|
/**
|
|
1003
902
|
* Create empty DocFileMdEntity
|
|
1004
903
|
*/
|
|
1005
904
|
empty(): DocFileMdEntity<T>;
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
* Create new file with default content
|
|
1013
|
-
*/
|
|
1014
|
-
writeDefault(): Promise<Error | null>;
|
|
1015
|
-
/**
|
|
1016
|
-
* Delete file
|
|
1017
|
-
*/
|
|
1018
|
-
delete(): Promise<Error | null>;
|
|
1019
|
-
/**
|
|
1020
|
-
* Copy file
|
|
1021
|
-
*/
|
|
1022
|
-
copyTo(destinationPath: string): Promise<Error | null>;
|
|
1023
|
-
/**
|
|
1024
|
-
* Move file
|
|
1025
|
-
*/
|
|
1026
|
-
moveTo(destinationPath: string): Promise<Error | null>;
|
|
1027
|
-
/**
|
|
1028
|
-
* Move file to archive and return new reference
|
|
1029
|
-
*/
|
|
905
|
+
write(entity: DocFileMdEntity<T>): Promise<void>;
|
|
906
|
+
writeText(text: string): Promise<void>;
|
|
907
|
+
writeDefault(): Promise<void>;
|
|
908
|
+
delete(): Promise<void>;
|
|
909
|
+
copyTo(destinationPath: string): Promise<void>;
|
|
910
|
+
moveTo(destinationPath: string): Promise<void>;
|
|
1030
911
|
archive(archiveDirectoryName?: string): Promise<DocFileMdReference<T>>;
|
|
1031
|
-
/**
|
|
1032
|
-
* Restore file from archive and return new reference
|
|
1033
|
-
*/
|
|
1034
912
|
restore(archiveDirectoryName?: string): Promise<DocFileMdReference<T>>;
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
size(): Promise<number | Error>;
|
|
1039
|
-
/**
|
|
1040
|
-
* Get file last modified time
|
|
1041
|
-
*/
|
|
1042
|
-
lastModified(): Promise<Date | Error>;
|
|
1043
|
-
/**
|
|
1044
|
-
* Get file creation time
|
|
1045
|
-
*/
|
|
1046
|
-
createdAt(): Promise<Date | Error>;
|
|
913
|
+
size(): Promise<number>;
|
|
914
|
+
lastModified(): Promise<Date>;
|
|
915
|
+
createdAt(): Promise<Date>;
|
|
1047
916
|
directory(): DocDirectoryReference<T>;
|
|
917
|
+
relation(key: RelationKeys<T>): Promise<DocFileMdReference<DocCustomSchema> | null>;
|
|
918
|
+
relation<U extends DocCustomSchema>(key: RelationKeys<T>, targetSchema: U): Promise<DocFileMdReference<U> | null>;
|
|
1048
919
|
/**
|
|
1049
|
-
*
|
|
1050
|
-
|
|
1051
|
-
relation<U extends DocCustomSchema = DocCustomSchema>(key: RelationKeys<T>, targetSchema?: U): Promise<DocFileMdReference<U> | Error | null>;
|
|
1052
|
-
/**
|
|
1053
|
-
* Get index.md in the same directory
|
|
920
|
+
* スキーマで定義された relation の path を解決する。
|
|
921
|
+
* ".." 始まりの相対パスはファイルのディレクトリ基準で正規化する
|
|
1054
922
|
*/
|
|
923
|
+
private resolveRelationDirectory;
|
|
1055
924
|
directoryIndex(): Promise<DocFileIndexReference<T> | null>;
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
/**
|
|
1061
|
-
* File: Markdown > FrontMatter
|
|
1062
|
-
*/
|
|
1063
|
-
readFrontMatter(): Promise<DocFileMdMetaValue<T> | Error>;
|
|
1064
|
-
/**
|
|
1065
|
-
* File: Markdown > FrontMatter
|
|
1066
|
-
*/
|
|
1067
|
-
updateFrontMatter<K extends keyof T>(key: K, value: BaseFieldValueType<ExtractFieldType<T[K]>>): Promise<this | Error>;
|
|
925
|
+
relations(key: MultiRelationKeys<T>): Promise<DocFileMdReference<DocCustomSchema>[]>;
|
|
926
|
+
relations<U extends DocCustomSchema>(key: MultiRelationKeys<T>, customSchema: U): Promise<DocFileMdReference<U>[]>;
|
|
927
|
+
readFrontMatter(): Promise<DocFileMdMetaValue<T>>;
|
|
928
|
+
updateFrontMatter<K extends keyof T>(key: K, value: BaseFieldValueType<ExtractFieldType<T[K]>>): Promise<this>;
|
|
1068
929
|
}
|
|
1069
930
|
|
|
1070
931
|
/**
|
|
@@ -1367,6 +1228,10 @@ type RecordKey = PropertyKey;
|
|
|
1367
1228
|
* DocClient configuration
|
|
1368
1229
|
*/
|
|
1369
1230
|
type DocClientConfig = z.infer<typeof zDocClientConfig>;
|
|
1231
|
+
/**
|
|
1232
|
+
* Directory meta (.meta.json)
|
|
1233
|
+
*/
|
|
1234
|
+
type DocDirectoryMeta = z.infer<typeof zDocDirectoryMeta>;
|
|
1370
1235
|
/**
|
|
1371
1236
|
* Type definitions for DocFileMdMetaValue
|
|
1372
1237
|
*/
|
|
@@ -1502,10 +1367,18 @@ declare class DocFileTreeSystem {
|
|
|
1502
1367
|
* Create file node
|
|
1503
1368
|
*/
|
|
1504
1369
|
private createFileNode;
|
|
1370
|
+
/**
|
|
1371
|
+
* Read title from a file
|
|
1372
|
+
*/
|
|
1373
|
+
private readFileTitle;
|
|
1505
1374
|
/**
|
|
1506
1375
|
* Create directory node
|
|
1507
1376
|
*/
|
|
1508
1377
|
private createDirectoryNode;
|
|
1378
|
+
/**
|
|
1379
|
+
* Read title and icon from directory index file
|
|
1380
|
+
*/
|
|
1381
|
+
private readDirectoryIndexInfo;
|
|
1509
1382
|
/**
|
|
1510
1383
|
* Create index file reference
|
|
1511
1384
|
*/
|
|
@@ -1518,10 +1391,6 @@ declare class DocFileTreeSystem {
|
|
|
1518
1391
|
* Build directory tree recursively (directories only)
|
|
1519
1392
|
*/
|
|
1520
1393
|
buildDirectoryTree(directoryPath?: string): Promise<DocTreeDirectoryNodeValue[] | Error>;
|
|
1521
|
-
/**
|
|
1522
|
-
* Create directory node for directory tree
|
|
1523
|
-
*/
|
|
1524
|
-
private createDirectoryNodeForTree;
|
|
1525
1394
|
}
|
|
1526
1395
|
|
|
1527
1396
|
/**
|
|
@@ -1573,9 +1442,6 @@ type Props = {
|
|
|
1573
1442
|
pathSystem?: DocPathSystem;
|
|
1574
1443
|
markdownSystem?: DocMarkdownSystem;
|
|
1575
1444
|
fileTreeSystem?: DocFileTreeSystem;
|
|
1576
|
-
/**
|
|
1577
|
-
* Configuration
|
|
1578
|
-
*/
|
|
1579
1445
|
config?: DocClientConfig;
|
|
1580
1446
|
};
|
|
1581
1447
|
declare class DocClient {
|
|
@@ -1585,6 +1451,7 @@ declare class DocClient {
|
|
|
1585
1451
|
readonly fileTreeSystem: DocFileTreeSystem;
|
|
1586
1452
|
readonly config: DocClientConfig;
|
|
1587
1453
|
constructor(props: Props);
|
|
1454
|
+
get safe(): Safe<this>;
|
|
1588
1455
|
basePath(): string;
|
|
1589
1456
|
file<Path extends string>(relativePath: Path): InferReference<Path, DocCustomSchema>;
|
|
1590
1457
|
file<Path extends string, T extends DocCustomSchema>(relativePath: Path, customSchema: T): InferReference<Path, T>;
|
|
@@ -1714,6 +1581,7 @@ declare class DocCustomSchemaFieldValue<T extends DocCustomSchemaField> {
|
|
|
1714
1581
|
readonly value: T;
|
|
1715
1582
|
constructor(value: T);
|
|
1716
1583
|
validate(value: unknown): string | number | boolean | string[] | number[] | null;
|
|
1584
|
+
private fieldType;
|
|
1717
1585
|
}
|
|
1718
1586
|
|
|
1719
1587
|
/**
|
|
@@ -1903,4 +1771,4 @@ declare class DocRelationFieldValue {
|
|
|
1903
1771
|
}): DocRelationFieldValue;
|
|
1904
1772
|
}
|
|
1905
1773
|
|
|
1906
|
-
export { type BaseFieldValueType, type DetectFileType, DocClient, type DocClientConfig, type DocCustomSchema, type DocCustomSchemaField, type DocCustomSchemaFieldBoolean, type DocCustomSchemaFieldMultiNumber, type DocCustomSchemaFieldMultiRelation, type DocCustomSchemaFieldMultiSelectNumber, type DocCustomSchemaFieldMultiSelectText, type DocCustomSchemaFieldMultiText, type DocCustomSchemaFieldNumber, type DocCustomSchemaFieldRelation, type DocCustomSchemaFieldSelectNumber, type DocCustomSchemaFieldSelectText, type DocCustomSchemaFieldText, DocCustomSchemaFieldValue, type DocDirectory, type DocDirectoryFile, DocDirectoryPathValue, DocDirectoryReference, type DocFieldTypeLiteral, type DocFile, type DocFileAny, type DocFileEntity, type DocFileIndex, type DocFileIndexAny, type DocFileIndexContent, DocFileIndexContentValue, DocFileIndexEntity, type DocFileIndexMeta, DocFileIndexMetaValue, DocFileIndexReference, type DocFileIndexSchema, type DocFileIndexSchemaField, DocFileIndexSchemaValue, type DocFileMd, type DocFileMdAny, type DocFileMdContent, DocFileMdContentValue, DocFileMdEntity, type DocFileMdMeta, type DocFileMdMetaAny, DocFileMdMetaValue, DocFileMdReference, type DocFilePath, DocFilePathValue, DocFileRelationReference, DocFileTreeSystem, type DocFileUnknown, DocFileUnknownEntity, DocFileUnknownReference, DocMarkdownSystem, type DocMetaField, type DocMetaFieldBoolean, type DocMetaFieldMultiNumber, type DocMetaFieldMultiRelation, type DocMetaFieldMultiSelectNumber, type DocMetaFieldMultiSelectText, type DocMetaFieldMultiText, type DocMetaFieldNumber, type DocMetaFieldRelation, type DocMetaFieldSelectNumber, type DocMetaFieldSelectText, type DocMetaFieldText, type DocMetaFieldType, type DocMetaFieldTypeBoolean, type DocMetaFieldTypeNumber, type DocMetaFieldTypeRelation, type DocMetaFieldTypeSelectNumber, type DocMetaFieldTypeSelectText, type DocMetaFieldTypeText, DocPathSystem, DocPathSystemMock, type DocRelation, type DocRelationField, DocRelationFieldValue, type DocRelationFile, DocRelationFileValue, DocRelationValue, type DocSchemaFieldBoolean, type DocSchemaFieldMultiNumber, type DocSchemaFieldMultiRelation, type DocSchemaFieldMultiSelectNumber, type DocSchemaFieldMultiSelectText, type DocSchemaFieldMultiText, type DocSchemaFieldNumber, type DocSchemaFieldRelation, type DocSchemaFieldSelectNumber, type DocSchemaFieldSelectText, type DocSchemaFieldText, type DocSchemaRelationFieldUnion, type DocTreeDirectoryNode, DocTreeDirectoryNodeValue, type DocTreeFileNode, DocTreeFileNodeValue, type DocTreeNode, type DocTreeNodeValue, type Equals, type ExtractFieldType, type ExtractRequired, type FieldValueType, type GetIndexFieldType, type GetValueType, type InferDocFileMd, type InferReference, type MultiRelationKeys, type OptionalKeys, type RecordKey, type RelationKeys, type RequiredKeys, type SchemaToValueType, type UpdateFunction, assertType, defaultTestConfig, defineSchema, docCustomSchemaField, expectType };
|
|
1774
|
+
export { type BaseFieldValueType, type DetectFileType, DocClient, type DocClientConfig, type DocCustomSchema, type DocCustomSchemaField, type DocCustomSchemaFieldBoolean, type DocCustomSchemaFieldMultiNumber, type DocCustomSchemaFieldMultiRelation, type DocCustomSchemaFieldMultiSelectNumber, type DocCustomSchemaFieldMultiSelectText, type DocCustomSchemaFieldMultiText, type DocCustomSchemaFieldNumber, type DocCustomSchemaFieldRelation, type DocCustomSchemaFieldSelectNumber, type DocCustomSchemaFieldSelectText, type DocCustomSchemaFieldText, DocCustomSchemaFieldValue, type DocDirectory, type DocDirectoryFile, type DocDirectoryMeta, DocDirectoryPathValue, DocDirectoryReference, type DocFieldTypeLiteral, type DocFile, type DocFileAny, type DocFileEntity, type DocFileIndex, type DocFileIndexAny, type DocFileIndexContent, DocFileIndexContentValue, DocFileIndexEntity, type DocFileIndexMeta, DocFileIndexMetaValue, DocFileIndexReference, type DocFileIndexSchema, type DocFileIndexSchemaField, DocFileIndexSchemaValue, type DocFileMd, type DocFileMdAny, type DocFileMdContent, DocFileMdContentValue, DocFileMdEntity, type DocFileMdMeta, type DocFileMdMetaAny, DocFileMdMetaValue, DocFileMdReference, type DocFilePath, DocFilePathValue, DocFileRelationReference, DocFileTreeSystem, type DocFileUnknown, DocFileUnknownEntity, DocFileUnknownReference, DocMarkdownSystem, type DocMetaField, type DocMetaFieldBoolean, type DocMetaFieldMultiNumber, type DocMetaFieldMultiRelation, type DocMetaFieldMultiSelectNumber, type DocMetaFieldMultiSelectText, type DocMetaFieldMultiText, type DocMetaFieldNumber, type DocMetaFieldRelation, type DocMetaFieldSelectNumber, type DocMetaFieldSelectText, type DocMetaFieldText, type DocMetaFieldType, type DocMetaFieldTypeBoolean, type DocMetaFieldTypeNumber, type DocMetaFieldTypeRelation, type DocMetaFieldTypeSelectNumber, type DocMetaFieldTypeSelectText, type DocMetaFieldTypeText, DocPathSystem, DocPathSystemMock, type DocRelation, type DocRelationField, DocRelationFieldValue, type DocRelationFile, DocRelationFileValue, DocRelationValue, type DocSchemaFieldBoolean, type DocSchemaFieldMultiNumber, type DocSchemaFieldMultiRelation, type DocSchemaFieldMultiSelectNumber, type DocSchemaFieldMultiSelectText, type DocSchemaFieldMultiText, type DocSchemaFieldNumber, type DocSchemaFieldRelation, type DocSchemaFieldSelectNumber, type DocSchemaFieldSelectText, type DocSchemaFieldText, type DocSchemaRelationFieldUnion, type DocTreeDirectoryNode, DocTreeDirectoryNodeValue, type DocTreeFileNode, DocTreeFileNodeValue, type DocTreeNode, type DocTreeNodeValue, type Equals, type ExtractFieldType, type ExtractRequired, type FieldValueType, type GetIndexFieldType, type GetValueType, type InferDocFileMd, type InferReference, type MultiRelationKeys, type OptionalKeys, type RecordKey, type RelationKeys, type RequiredKeys, type Safe, type SchemaToValueType, type UpdateFunction, assertType, createSafeProxy, defaultTestConfig, defineSchema, docCustomSchemaField, expectType };
|