@interactive-inc/docs-client 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/build/index.d.ts +1921 -42
- package/build/index.js +4616 -39
- package/build/models.d.ts +34 -32
- package/build/models.js +219 -275
- package/package.json +4 -4
- package/tsup.config.ts +10 -0
- package/build/doc-client.d.ts +0 -59
- package/build/doc-client.d.ts.map +0 -1
- package/build/doc-client.js +0 -95
- package/build/doc-client.test.d.ts +0 -2
- package/build/doc-client.test.d.ts.map +0 -1
- package/build/doc-client.test.js +0 -38
- package/build/doc-directory-reference.d.ts +0 -65
- package/build/doc-directory-reference.d.ts.map +0 -1
- package/build/doc-directory-reference.js +0 -292
- package/build/doc-directory-reference.test.d.ts +0 -2
- package/build/doc-directory-reference.test.d.ts.map +0 -1
- package/build/doc-directory-reference.test.js +0 -100
- package/build/doc-file-index-reference.d.ts +0 -72
- package/build/doc-file-index-reference.d.ts.map +0 -1
- package/build/doc-file-index-reference.js +0 -191
- package/build/doc-file-index-reference.test.d.ts +0 -2
- package/build/doc-file-index-reference.test.d.ts.map +0 -1
- package/build/doc-file-index-reference.test.js +0 -77
- package/build/doc-file-md-reference.d.ts +0 -97
- package/build/doc-file-md-reference.d.ts.map +0 -1
- package/build/doc-file-md-reference.js +0 -297
- package/build/doc-file-md-reference.test.d.ts +0 -2
- package/build/doc-file-md-reference.test.d.ts.map +0 -1
- package/build/doc-file-md-reference.test.js +0 -465
- package/build/doc-file-relation-reference.d.ts +0 -54
- package/build/doc-file-relation-reference.d.ts.map +0 -1
- package/build/doc-file-relation-reference.js +0 -109
- package/build/doc-file-system-debug.d.ts +0 -81
- package/build/doc-file-system-debug.d.ts.map +0 -1
- package/build/doc-file-system-debug.js +0 -317
- package/build/doc-file-system.d.ts +0 -100
- package/build/doc-file-system.d.ts.map +0 -1
- package/build/doc-file-system.js +0 -210
- package/build/doc-file-tree-system.d.ts +0 -38
- package/build/doc-file-tree-system.d.ts.map +0 -1
- package/build/doc-file-tree-system.js +0 -153
- package/build/doc-file-tree-system.test.d.ts +0 -2
- package/build/doc-file-tree-system.test.d.ts.map +0 -1
- package/build/doc-file-tree-system.test.js +0 -105
- package/build/doc-file-unknown-reference.d.ts +0 -80
- package/build/doc-file-unknown-reference.d.ts.map +0 -1
- package/build/doc-file-unknown-reference.js +0 -181
- package/build/doc-file-unknown-reference.test.d.ts +0 -2
- package/build/doc-file-unknown-reference.test.d.ts.map +0 -1
- package/build/doc-file-unknown-reference.test.js +0 -73
- package/build/doc-markdown-system.d.ts +0 -44
- package/build/doc-markdown-system.d.ts.map +0 -1
- package/build/doc-markdown-system.js +0 -153
- package/build/doc-markdown-system.test.d.ts +0 -2
- package/build/doc-markdown-system.test.d.ts.map +0 -1
- package/build/doc-markdown-system.test.js +0 -124
- package/build/doc-path-system.d.ts +0 -43
- package/build/doc-path-system.d.ts.map +0 -1
- package/build/doc-path-system.js +0 -148
- package/build/doc-path-system.test.d.ts +0 -2
- package/build/doc-path-system.test.d.ts.map +0 -1
- package/build/doc-path-system.test.js +0 -67
- package/build/entities/doc-file-entity.d.ts +0 -5
- package/build/entities/doc-file-entity.d.ts.map +0 -1
- package/build/entities/doc-file-entity.js +0 -1
- package/build/entities/doc-file-index-entity.d.ts +0 -30
- package/build/entities/doc-file-index-entity.d.ts.map +0 -1
- package/build/entities/doc-file-index-entity.js +0 -49
- package/build/entities/doc-file-index-entity.test.d.ts +0 -2
- package/build/entities/doc-file-index-entity.test.d.ts.map +0 -1
- package/build/entities/doc-file-index-entity.test.js +0 -195
- package/build/entities/doc-file-md-entity.d.ts +0 -30
- package/build/entities/doc-file-md-entity.d.ts.map +0 -1
- package/build/entities/doc-file-md-entity.js +0 -49
- package/build/entities/doc-file-md-entity.test.d.ts +0 -2
- package/build/entities/doc-file-md-entity.test.d.ts.map +0 -1
- package/build/entities/doc-file-md-entity.test.js +0 -178
- package/build/entities/doc-file-unknown-entity.d.ts +0 -26
- package/build/entities/doc-file-unknown-entity.d.ts.map +0 -1
- package/build/entities/doc-file-unknown-entity.js +0 -45
- package/build/entities/doc-file-unknown-entity.test.d.ts +0 -2
- package/build/entities/doc-file-unknown-entity.test.d.ts.map +0 -1
- package/build/entities/doc-file-unknown-entity.test.js +0 -131
- package/build/index.d.ts.map +0 -1
- package/build/models.d.ts.map +0 -1
- package/build/types.d.ts +0 -154
- package/build/types.d.ts.map +0 -1
- package/build/types.js +0 -1
- package/build/values/doc-content-md-front-matter-value.d.ts +0 -49
- package/build/values/doc-content-md-front-matter-value.d.ts.map +0 -1
- package/build/values/doc-content-md-front-matter-value.js +0 -94
- package/build/values/doc-content-md-front-matter-value.test.d.ts +0 -2
- package/build/values/doc-content-md-front-matter-value.test.d.ts.map +0 -1
- package/build/values/doc-content-md-front-matter-value.test.js +0 -73
- package/build/values/doc-content-md-value.d.ts +0 -66
- package/build/values/doc-content-md-value.d.ts.map +0 -1
- package/build/values/doc-content-md-value.js +0 -218
- package/build/values/doc-content-md-value.test.d.ts +0 -2
- package/build/values/doc-content-md-value.test.d.ts.map +0 -1
- package/build/values/doc-content-md-value.test.js +0 -179
- package/build/values/doc-directory-path-value.d.ts +0 -89
- package/build/values/doc-directory-path-value.d.ts.map +0 -1
- package/build/values/doc-directory-path-value.js +0 -145
- package/build/values/doc-directory-path-value.test.d.ts +0 -2
- package/build/values/doc-directory-path-value.test.d.ts.map +0 -1
- package/build/values/doc-directory-path-value.test.js +0 -68
- package/build/values/doc-file-content-index-value.d.ts +0 -62
- package/build/values/doc-file-content-index-value.d.ts.map +0 -1
- package/build/values/doc-file-content-index-value.js +0 -134
- package/build/values/doc-file-content-index-value.test.d.ts +0 -2
- package/build/values/doc-file-content-index-value.test.d.ts.map +0 -1
- package/build/values/doc-file-content-index-value.test.js +0 -203
- package/build/values/doc-file-content-md-value.d.ts +0 -62
- package/build/values/doc-file-content-md-value.d.ts.map +0 -1
- package/build/values/doc-file-content-md-value.js +0 -139
- package/build/values/doc-file-content-md-value.test.d.ts +0 -2
- package/build/values/doc-file-content-md-value.test.d.ts.map +0 -1
- package/build/values/doc-file-content-md-value.test.js +0 -160
- package/build/values/doc-file-path-value.d.ts +0 -47
- package/build/values/doc-file-path-value.d.ts.map +0 -1
- package/build/values/doc-file-path-value.js +0 -83
- package/build/values/doc-file-path-value.test.d.ts +0 -2
- package/build/values/doc-file-path-value.test.d.ts.map +0 -1
- package/build/values/doc-file-path-value.test.js +0 -84
- package/build/values/doc-front-matter-index-value.d.ts +0 -66
- package/build/values/doc-front-matter-index-value.d.ts.map +0 -1
- package/build/values/doc-front-matter-index-value.js +0 -185
- package/build/values/doc-front-matter-index-value.test.d.ts +0 -2
- package/build/values/doc-front-matter-index-value.test.d.ts.map +0 -1
- package/build/values/doc-front-matter-index-value.test.js +0 -98
- package/build/values/doc-front-matter-md-value-accessor.test.d.ts +0 -2
- package/build/values/doc-front-matter-md-value-accessor.test.d.ts.map +0 -1
- package/build/values/doc-front-matter-md-value-accessor.test.js +0 -226
- package/build/values/doc-front-matter-md-value.d.ts +0 -80
- package/build/values/doc-front-matter-md-value.d.ts.map +0 -1
- package/build/values/doc-front-matter-md-value.js +0 -257
- package/build/values/doc-front-matter-md-value.test.d.ts +0 -2
- package/build/values/doc-front-matter-md-value.test.d.ts.map +0 -1
- package/build/values/doc-front-matter-md-value.test.js +0 -198
- package/build/values/doc-relation-field-value.d.ts +0 -57
- package/build/values/doc-relation-field-value.d.ts.map +0 -1
- package/build/values/doc-relation-field-value.js +0 -85
- package/build/values/doc-relation-field-value.test.d.ts +0 -2
- package/build/values/doc-relation-field-value.test.d.ts.map +0 -1
- package/build/values/doc-relation-field-value.test.js +0 -115
- package/build/values/doc-relation-file-value.d.ts +0 -33
- package/build/values/doc-relation-file-value.d.ts.map +0 -1
- package/build/values/doc-relation-file-value.js +0 -55
- package/build/values/doc-relation-file-value.test.d.ts +0 -2
- package/build/values/doc-relation-file-value.test.d.ts.map +0 -1
- package/build/values/doc-relation-file-value.test.js +0 -77
- package/build/values/doc-relation-value.d.ts +0 -34
- package/build/values/doc-relation-value.d.ts.map +0 -1
- package/build/values/doc-relation-value.js +0 -56
- package/build/values/doc-relation-value.test.d.ts +0 -2
- package/build/values/doc-relation-value.test.d.ts.map +0 -1
- package/build/values/doc-relation-value.test.js +0 -89
- package/build/values/doc-schema-field-boolean-multiple-value.d.ts +0 -23
- package/build/values/doc-schema-field-boolean-multiple-value.d.ts.map +0 -1
- package/build/values/doc-schema-field-boolean-multiple-value.js +0 -43
- package/build/values/doc-schema-field-boolean-multiple-value.test.d.ts +0 -2
- package/build/values/doc-schema-field-boolean-multiple-value.test.d.ts.map +0 -1
- package/build/values/doc-schema-field-boolean-multiple-value.test.js +0 -76
- package/build/values/doc-schema-field-boolean-single-value.d.ts +0 -23
- package/build/values/doc-schema-field-boolean-single-value.d.ts.map +0 -1
- package/build/values/doc-schema-field-boolean-single-value.js +0 -39
- package/build/values/doc-schema-field-boolean-single-value.test.d.ts +0 -2
- package/build/values/doc-schema-field-boolean-single-value.test.d.ts.map +0 -1
- package/build/values/doc-schema-field-boolean-single-value.test.js +0 -73
- package/build/values/doc-schema-field-factory.d.ts +0 -37
- package/build/values/doc-schema-field-factory.d.ts.map +0 -1
- package/build/values/doc-schema-field-factory.js +0 -151
- package/build/values/doc-schema-field-factory.test.d.ts +0 -2
- package/build/values/doc-schema-field-factory.test.d.ts.map +0 -1
- package/build/values/doc-schema-field-factory.test.js +0 -215
- package/build/values/doc-schema-field-number-multiple-value.d.ts +0 -23
- package/build/values/doc-schema-field-number-multiple-value.d.ts.map +0 -1
- package/build/values/doc-schema-field-number-multiple-value.js +0 -43
- package/build/values/doc-schema-field-number-multiple-value.test.d.ts +0 -2
- package/build/values/doc-schema-field-number-multiple-value.test.d.ts.map +0 -1
- package/build/values/doc-schema-field-number-multiple-value.test.js +0 -79
- package/build/values/doc-schema-field-number-single-value.d.ts +0 -23
- package/build/values/doc-schema-field-number-single-value.d.ts.map +0 -1
- package/build/values/doc-schema-field-number-single-value.js +0 -39
- package/build/values/doc-schema-field-number-single-value.test.d.ts +0 -2
- package/build/values/doc-schema-field-number-single-value.test.d.ts.map +0 -1
- package/build/values/doc-schema-field-number-single-value.test.js +0 -77
- package/build/values/doc-schema-field-relation-multiple-value.d.ts +0 -24
- package/build/values/doc-schema-field-relation-multiple-value.d.ts.map +0 -1
- package/build/values/doc-schema-field-relation-multiple-value.js +0 -46
- package/build/values/doc-schema-field-relation-multiple-value.test.d.ts +0 -2
- package/build/values/doc-schema-field-relation-multiple-value.test.d.ts.map +0 -1
- package/build/values/doc-schema-field-relation-multiple-value.test.js +0 -83
- package/build/values/doc-schema-field-relation-single-value.d.ts +0 -24
- package/build/values/doc-schema-field-relation-single-value.d.ts.map +0 -1
- package/build/values/doc-schema-field-relation-single-value.js +0 -42
- package/build/values/doc-schema-field-relation-single-value.test.d.ts +0 -2
- package/build/values/doc-schema-field-relation-single-value.test.d.ts.map +0 -1
- package/build/values/doc-schema-field-relation-single-value.test.js +0 -83
- package/build/values/doc-schema-field-select-number-multiple-value.d.ts +0 -25
- package/build/values/doc-schema-field-select-number-multiple-value.d.ts.map +0 -1
- package/build/values/doc-schema-field-select-number-multiple-value.js +0 -48
- package/build/values/doc-schema-field-select-number-multiple-value.test.d.ts +0 -2
- package/build/values/doc-schema-field-select-number-multiple-value.test.d.ts.map +0 -1
- package/build/values/doc-schema-field-select-number-multiple-value.test.js +0 -84
- package/build/values/doc-schema-field-select-number-single-value.d.ts +0 -25
- package/build/values/doc-schema-field-select-number-single-value.d.ts.map +0 -1
- package/build/values/doc-schema-field-select-number-single-value.js +0 -45
- package/build/values/doc-schema-field-select-number-single-value.test.d.ts +0 -2
- package/build/values/doc-schema-field-select-number-single-value.test.d.ts.map +0 -1
- package/build/values/doc-schema-field-select-number-single-value.test.js +0 -96
- package/build/values/doc-schema-field-select-text-multiple-value.d.ts +0 -25
- package/build/values/doc-schema-field-select-text-multiple-value.d.ts.map +0 -1
- package/build/values/doc-schema-field-select-text-multiple-value.js +0 -48
- package/build/values/doc-schema-field-select-text-multiple-value.test.d.ts +0 -2
- package/build/values/doc-schema-field-select-text-multiple-value.test.d.ts.map +0 -1
- package/build/values/doc-schema-field-select-text-multiple-value.test.js +0 -84
- package/build/values/doc-schema-field-select-text-single-value.d.ts +0 -25
- package/build/values/doc-schema-field-select-text-single-value.d.ts.map +0 -1
- package/build/values/doc-schema-field-select-text-single-value.js +0 -47
- package/build/values/doc-schema-field-select-text-single-value.test.d.ts +0 -2
- package/build/values/doc-schema-field-select-text-single-value.test.d.ts.map +0 -1
- package/build/values/doc-schema-field-select-text-single-value.test.js +0 -96
- package/build/values/doc-schema-field-text-multiple-value.d.ts +0 -23
- package/build/values/doc-schema-field-text-multiple-value.d.ts.map +0 -1
- package/build/values/doc-schema-field-text-multiple-value.js +0 -43
- package/build/values/doc-schema-field-text-multiple-value.test.d.ts +0 -2
- package/build/values/doc-schema-field-text-multiple-value.test.d.ts.map +0 -1
- package/build/values/doc-schema-field-text-multiple-value.test.js +0 -78
- package/build/values/doc-schema-field-text-single-value.d.ts +0 -23
- package/build/values/doc-schema-field-text-single-value.d.ts.map +0 -1
- package/build/values/doc-schema-field-text-single-value.js +0 -39
- package/build/values/doc-schema-field-text-single-value.test.d.ts +0 -2
- package/build/values/doc-schema-field-text-single-value.test.d.ts.map +0 -1
- package/build/values/doc-schema-field-text-single-value.test.js +0 -76
- package/build/values/doc-schema-field-type-value.d.ts +0 -61
- package/build/values/doc-schema-field-type-value.d.ts.map +0 -1
- package/build/values/doc-schema-field-type-value.js +0 -134
- package/build/values/doc-schema-field-type-value.test.d.ts +0 -2
- package/build/values/doc-schema-field-type-value.test.d.ts.map +0 -1
- package/build/values/doc-schema-field-type-value.test.js +0 -101
- package/build/values/doc-schema-field-value.d.ts +0 -45
- package/build/values/doc-schema-field-value.d.ts.map +0 -1
- package/build/values/doc-schema-field-value.js +0 -1
- package/build/values/doc-schema-value.d.ts +0 -99
- package/build/values/doc-schema-value.d.ts.map +0 -1
- package/build/values/doc-schema-value.js +0 -269
- package/build/values/doc-schema-value.test.d.ts +0 -2
- package/build/values/doc-schema-value.test.d.ts.map +0 -1
- package/build/values/doc-schema-value.test.js +0 -301
- package/build/values/doc-tree-directory-node-value.d.ts +0 -36
- package/build/values/doc-tree-directory-node-value.d.ts.map +0 -1
- package/build/values/doc-tree-directory-node-value.js +0 -71
- package/build/values/doc-tree-directory-node-value.test.d.ts +0 -2
- package/build/values/doc-tree-directory-node-value.test.d.ts.map +0 -1
- package/build/values/doc-tree-directory-node-value.test.js +0 -162
- package/build/values/doc-tree-file-node-value.d.ts +0 -33
- package/build/values/doc-tree-file-node-value.d.ts.map +0 -1
- package/build/values/doc-tree-file-node-value.js +0 -56
- package/build/values/doc-tree-file-node-value.test.d.ts +0 -2
- package/build/values/doc-tree-file-node-value.test.d.ts.map +0 -1
- package/build/values/doc-tree-file-node-value.test.js +0 -113
package/build/doc-client.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { DocDirectoryReference } from "./doc-directory-reference";
|
|
2
|
-
import { DocFileIndexReference } from "./doc-file-index-reference";
|
|
3
|
-
import { DocFileMdReference } from "./doc-file-md-reference";
|
|
4
|
-
import { DocFileTreeSystem } from "./doc-file-tree-system";
|
|
5
|
-
import { DocFileUnknownReference } from "./doc-file-unknown-reference";
|
|
6
|
-
import { DocMarkdownSystem } from "./doc-markdown-system";
|
|
7
|
-
import { DocPathSystem } from "./doc-path-system";
|
|
8
|
-
export class DocClient {
|
|
9
|
-
fileSystem;
|
|
10
|
-
pathSystem;
|
|
11
|
-
markdownSystem;
|
|
12
|
-
fileTreeSystem;
|
|
13
|
-
indexFileName;
|
|
14
|
-
archiveDirectoryName;
|
|
15
|
-
constructor(props) {
|
|
16
|
-
this.fileSystem = props.fileSystem;
|
|
17
|
-
this.pathSystem = props.pathSystem ?? new DocPathSystem();
|
|
18
|
-
this.markdownSystem = props.markdownSystem ?? new DocMarkdownSystem();
|
|
19
|
-
this.indexFileName = props.indexFileName ?? "index.md";
|
|
20
|
-
this.archiveDirectoryName = props.archiveDirectoryName ?? "_";
|
|
21
|
-
this.fileTreeSystem =
|
|
22
|
-
props.fileTreeSystem ??
|
|
23
|
-
new DocFileTreeSystem({
|
|
24
|
-
fileSystem: this.fileSystem,
|
|
25
|
-
pathSystem: this.pathSystem,
|
|
26
|
-
indexFileName: this.indexFileName,
|
|
27
|
-
archiveDirectoryName: this.archiveDirectoryName,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
basePath() {
|
|
31
|
-
return this.fileSystem.getBasePath();
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* ファイル参照を取得
|
|
35
|
-
*/
|
|
36
|
-
file(relativePath) {
|
|
37
|
-
if (relativePath.endsWith(".md")) {
|
|
38
|
-
return this.mdFile(relativePath);
|
|
39
|
-
}
|
|
40
|
-
return new DocFileUnknownReference({
|
|
41
|
-
path: relativePath,
|
|
42
|
-
fileSystem: this.fileSystem,
|
|
43
|
-
pathSystem: this.pathSystem,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Markdownファイル参照を取得
|
|
48
|
-
*/
|
|
49
|
-
mdFile(relativePath) {
|
|
50
|
-
return new DocFileMdReference({
|
|
51
|
-
path: relativePath,
|
|
52
|
-
fileSystem: this.fileSystem,
|
|
53
|
-
pathSystem: this.pathSystem,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* インデックスファイル参照を取得
|
|
58
|
-
*/
|
|
59
|
-
indexFile(directoryPath) {
|
|
60
|
-
const indexPath = directoryPath === ""
|
|
61
|
-
? this.indexFileName
|
|
62
|
-
: `${directoryPath}/${this.indexFileName}`;
|
|
63
|
-
return new DocFileIndexReference({
|
|
64
|
-
path: indexPath,
|
|
65
|
-
fileSystem: this.fileSystem,
|
|
66
|
-
pathSystem: this.pathSystem,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* ディレクトリ参照を取得
|
|
71
|
-
*/
|
|
72
|
-
directory(relativePath) {
|
|
73
|
-
return new DocDirectoryReference({
|
|
74
|
-
path: relativePath,
|
|
75
|
-
indexFileName: this.indexFileName,
|
|
76
|
-
archiveDirectoryName: this.archiveDirectoryName,
|
|
77
|
-
fileSystem: this.fileSystem,
|
|
78
|
-
pathSystem: this.pathSystem,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* ファイルツリーを取得
|
|
83
|
-
*/
|
|
84
|
-
async fileTree(directoryPath = "") {
|
|
85
|
-
const results = await this.fileTreeSystem.buildFileTree(directoryPath);
|
|
86
|
-
return results.map((node) => node.toJson());
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* ディレクトリツリーを取得(ディレクトリのみ)
|
|
90
|
-
*/
|
|
91
|
-
async directoryTree(directoryPath = "") {
|
|
92
|
-
const results = await this.fileTreeSystem.buildDirectoryTree(directoryPath);
|
|
93
|
-
return results.map((node) => node.toJson());
|
|
94
|
-
}
|
|
95
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"doc-client.test.d.ts","sourceRoot":"","sources":["../lib/doc-client.test.ts"],"names":[],"mappings":""}
|
package/build/doc-client.test.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "bun:test";
|
|
2
|
-
import { DocClient } from "./doc-client";
|
|
3
|
-
import { DocFileSystem } from "./doc-file-system";
|
|
4
|
-
import { DocMarkdownSystem } from "./doc-markdown-system";
|
|
5
|
-
import { DocPathSystem } from "./doc-path-system";
|
|
6
|
-
test("DocClient - デフォルト値でインスタンスを作成", () => {
|
|
7
|
-
const pathSystem = new DocPathSystem();
|
|
8
|
-
const fileSystem = new DocFileSystem({ basePath: "/test", pathSystem });
|
|
9
|
-
const client = new DocClient({ fileSystem });
|
|
10
|
-
expect(client.fileSystem).toBe(fileSystem);
|
|
11
|
-
expect(client.pathSystem).toBeInstanceOf(DocPathSystem);
|
|
12
|
-
expect(client.markdownSystem).toBeInstanceOf(DocMarkdownSystem);
|
|
13
|
-
expect(client.indexFileName).toBe("index.md");
|
|
14
|
-
expect(client.archiveDirectoryName).toBe("_");
|
|
15
|
-
});
|
|
16
|
-
test("DocClient - カスタム値でインスタンスを作成", () => {
|
|
17
|
-
const pathSystem = new DocPathSystem();
|
|
18
|
-
const fileSystem = new DocFileSystem({ basePath: "/test", pathSystem });
|
|
19
|
-
const markdownSystem = new DocMarkdownSystem();
|
|
20
|
-
const client = new DocClient({
|
|
21
|
-
fileSystem,
|
|
22
|
-
pathSystem,
|
|
23
|
-
markdownSystem,
|
|
24
|
-
indexFileName: "README.md",
|
|
25
|
-
archiveDirectoryName: ".archive",
|
|
26
|
-
});
|
|
27
|
-
expect(client.fileSystem).toBe(fileSystem);
|
|
28
|
-
expect(client.pathSystem).toBe(pathSystem);
|
|
29
|
-
expect(client.markdownSystem).toBe(markdownSystem);
|
|
30
|
-
expect(client.indexFileName).toBe("README.md");
|
|
31
|
-
expect(client.archiveDirectoryName).toBe(".archive");
|
|
32
|
-
});
|
|
33
|
-
test("DocClient - basePathを取得", () => {
|
|
34
|
-
const pathSystem = new DocPathSystem();
|
|
35
|
-
const fileSystem = new DocFileSystem({ basePath: "/test/docs", pathSystem });
|
|
36
|
-
const client = new DocClient({ fileSystem });
|
|
37
|
-
expect(client.basePath()).toBe("/test/docs");
|
|
38
|
-
});
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { DocFileIndexReference } from "./doc-file-index-reference";
|
|
2
|
-
import { DocFileMdReference } from "./doc-file-md-reference";
|
|
3
|
-
import type { DocFileSystem } from "./doc-file-system";
|
|
4
|
-
import { DocFileUnknownReference } from "./doc-file-unknown-reference";
|
|
5
|
-
import type { DocPathSystem } from "./doc-path-system";
|
|
6
|
-
import { DocFileIndexEntity } from "./entities/doc-file-index-entity";
|
|
7
|
-
import { DocFileMdEntity } from "./entities/doc-file-md-entity";
|
|
8
|
-
import { DocFileUnknownEntity } from "./entities/doc-file-unknown-entity";
|
|
9
|
-
type Props = {
|
|
10
|
-
path: string;
|
|
11
|
-
indexFileName: string;
|
|
12
|
-
archiveDirectoryName: string;
|
|
13
|
-
fileSystem: DocFileSystem;
|
|
14
|
-
pathSystem: DocPathSystem;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* ディレクトリの参照
|
|
18
|
-
*/
|
|
19
|
-
export declare class DocDirectoryReference {
|
|
20
|
-
private readonly props;
|
|
21
|
-
private readonly pathSystem;
|
|
22
|
-
constructor(props: Props);
|
|
23
|
-
get fileSystem(): DocFileSystem;
|
|
24
|
-
get basePath(): string;
|
|
25
|
-
get relativePath(): string;
|
|
26
|
-
get absolutePath(): string;
|
|
27
|
-
get indexFileName(): string;
|
|
28
|
-
get indexFilePath(): string;
|
|
29
|
-
get archiveDirectoryName(): string;
|
|
30
|
-
fileNames(): Promise<string[]>;
|
|
31
|
-
archivedFileNames(): Promise<string[]>;
|
|
32
|
-
filesGenerator(): AsyncGenerator<DocFileMdReference | DocFileUnknownReference, void, unknown>;
|
|
33
|
-
mdFilesGenerator(): AsyncGenerator<DocFileMdReference, void, unknown>;
|
|
34
|
-
files(): Promise<(DocFileMdReference | DocFileUnknownReference)[]>;
|
|
35
|
-
mdFiles(): Promise<DocFileMdReference[]>;
|
|
36
|
-
file(fileName: string): DocFileMdReference | DocFileUnknownReference;
|
|
37
|
-
mdFile(fileName: string): DocFileMdReference;
|
|
38
|
-
readFiles(): Promise<(DocFileMdEntity | DocFileUnknownEntity)[]>;
|
|
39
|
-
readMdFiles(): Promise<DocFileMdEntity[]>;
|
|
40
|
-
readUnknownFiles(): Promise<DocFileUnknownEntity[]>;
|
|
41
|
-
/**
|
|
42
|
-
* サブディレクトリ名の一覧を取得
|
|
43
|
-
*/
|
|
44
|
-
directoryNames(): Promise<string[]>;
|
|
45
|
-
/**
|
|
46
|
-
* サブディレクトリの参照を取得
|
|
47
|
-
*/
|
|
48
|
-
directories(): Promise<DocDirectoryReference[]>;
|
|
49
|
-
/**
|
|
50
|
-
* 単一のサブディレクトリ参照を取得
|
|
51
|
-
*/
|
|
52
|
-
directory(directoryName: string): DocDirectoryReference;
|
|
53
|
-
indexFile(): DocFileIndexReference;
|
|
54
|
-
readIndexFile(): Promise<DocFileIndexEntity>;
|
|
55
|
-
writeFile(entity: DocFileIndexEntity | DocFileUnknownEntity | DocFileMdEntity): Promise<Error | null>;
|
|
56
|
-
exists(): Promise<boolean>;
|
|
57
|
-
private generateUniqueFileName;
|
|
58
|
-
private fileExists;
|
|
59
|
-
/**
|
|
60
|
-
* 新しいMarkdownファイルを作成する
|
|
61
|
-
*/
|
|
62
|
-
createMdFile(fileName?: string): Promise<DocFileMdReference>;
|
|
63
|
-
}
|
|
64
|
-
export {};
|
|
65
|
-
//# sourceMappingURL=doc-directory-reference.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"doc-directory-reference.d.ts","sourceRoot":"","sources":["../lib/doc-directory-reference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AAEzE,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,MAAM,CAAA;IACrB,oBAAoB,EAAE,MAAM,CAAA;IAC5B,UAAU,EAAE,aAAa,CAAA;IACzB,UAAU,EAAE,aAAa,CAAA;CAC1B,CAAA;AAED;;GAEG;AACH,qBAAa,qBAAqB;IAGpB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAFlC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAe;IAE1C,YAA6B,KAAK,EAAE,KAAK,EAGxC;IAED,IAAI,UAAU,IAAI,aAAa,CAE9B;IAED,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED,IAAI,aAAa,IAAI,MAAM,CAM1B;IAED,IAAI,oBAAoB,IAAI,MAAM,CAEjC;IAEK,SAAS,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAOnC;IAEK,iBAAiB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAW3C;IAEM,cAAc,IAAI,cAAc,CACrC,kBAAkB,GAAG,uBAAuB,EAC5C,IAAI,EACJ,OAAO,CACR,CA+CA;IAEM,gBAAgB,IAAI,cAAc,CAAC,kBAAkB,EAAE,IAAI,EAAE,OAAO,CAAC,CAQ3E;IAEK,KAAK,IAAI,OAAO,CAAC,CAAC,kBAAkB,GAAG,uBAAuB,CAAC,EAAE,CAAC,CAQvE;IAEK,OAAO,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAS7C;IAED,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,kBAAkB,GAAG,uBAAuB,CAgBnE;IAED,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,kBAAkB,CAM3C;IAEK,SAAS,IAAI,OAAO,CAAC,CAAC,eAAe,GAAG,oBAAoB,CAAC,EAAE,CAAC,CAUrE;IAEK,WAAW,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAW9C;IAEK,gBAAgB,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAWxD;IAED;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAmBxC;IAED;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAcpD;IAED;;OAEG;IACH,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,qBAAqB,CAUtD;IAED,SAAS,IAAI,qBAAqB,CAMjC;IAEK,aAAa,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAIjD;IAEK,SAAS,CACb,MAAM,EAAE,kBAAkB,GAAG,oBAAoB,GAAG,eAAe,GAClE,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAuBvB;IAEK,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,CAE/B;YAKa,sBAAsB;YAmBtB,UAAU;IAKxB;;OAEG;IACG,YAAY,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAqBjE;CACF"}
|
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
import { DocFileIndexReference } from "./doc-file-index-reference";
|
|
2
|
-
import { DocFileMdReference } from "./doc-file-md-reference";
|
|
3
|
-
import { DocFileUnknownReference } from "./doc-file-unknown-reference";
|
|
4
|
-
import { DocFileIndexEntity } from "./entities/doc-file-index-entity";
|
|
5
|
-
import { DocFileMdEntity } from "./entities/doc-file-md-entity";
|
|
6
|
-
import { DocFileUnknownEntity } from "./entities/doc-file-unknown-entity";
|
|
7
|
-
/**
|
|
8
|
-
* ディレクトリの参照
|
|
9
|
-
*/
|
|
10
|
-
export class DocDirectoryReference {
|
|
11
|
-
props;
|
|
12
|
-
pathSystem;
|
|
13
|
-
constructor(props) {
|
|
14
|
-
this.props = props;
|
|
15
|
-
this.pathSystem = props.pathSystem;
|
|
16
|
-
Object.freeze(this);
|
|
17
|
-
}
|
|
18
|
-
get fileSystem() {
|
|
19
|
-
return this.props.fileSystem;
|
|
20
|
-
}
|
|
21
|
-
get basePath() {
|
|
22
|
-
return this.fileSystem.getBasePath();
|
|
23
|
-
}
|
|
24
|
-
get relativePath() {
|
|
25
|
-
return this.props.path;
|
|
26
|
-
}
|
|
27
|
-
get absolutePath() {
|
|
28
|
-
return this.pathSystem.join(this.basePath, this.relativePath);
|
|
29
|
-
}
|
|
30
|
-
get indexFileName() {
|
|
31
|
-
return this.props.indexFileName;
|
|
32
|
-
}
|
|
33
|
-
get indexFilePath() {
|
|
34
|
-
return this.pathSystem.join(this.basePath, this.relativePath, this.props.indexFileName);
|
|
35
|
-
}
|
|
36
|
-
get archiveDirectoryName() {
|
|
37
|
-
return this.props.archiveDirectoryName;
|
|
38
|
-
}
|
|
39
|
-
async fileNames() {
|
|
40
|
-
const filePaths = await this.fileSystem.readDirectoryFilePaths(this.relativePath);
|
|
41
|
-
return filePaths
|
|
42
|
-
.map((p) => this.pathSystem.basename(p))
|
|
43
|
-
.filter((name) => name.includes("."));
|
|
44
|
-
}
|
|
45
|
-
async archivedFileNames() {
|
|
46
|
-
const archivePath = this.pathSystem.join(this.relativePath, this.archiveDirectoryName);
|
|
47
|
-
const filePaths = await this.fileSystem.readDirectoryFilePaths(archivePath);
|
|
48
|
-
return filePaths
|
|
49
|
-
.map((p) => this.pathSystem.basename(p))
|
|
50
|
-
.filter((name) => name.includes("."));
|
|
51
|
-
}
|
|
52
|
-
async *filesGenerator() {
|
|
53
|
-
const fileNames = await this.fileNames();
|
|
54
|
-
// 通常のファイルを処理
|
|
55
|
-
for (const fileName of fileNames) {
|
|
56
|
-
if (fileName === "index.md")
|
|
57
|
-
continue;
|
|
58
|
-
if (fileName.endsWith(".md")) {
|
|
59
|
-
yield new DocFileMdReference({
|
|
60
|
-
path: this.pathSystem.join(this.relativePath, fileName),
|
|
61
|
-
fileSystem: this.fileSystem,
|
|
62
|
-
pathSystem: this.pathSystem,
|
|
63
|
-
});
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
yield new DocFileUnknownReference({
|
|
67
|
-
path: this.pathSystem.join(this.relativePath, fileName),
|
|
68
|
-
fileSystem: this.fileSystem,
|
|
69
|
-
pathSystem: this.pathSystem,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
// アーカイブされたファイルを処理
|
|
73
|
-
const archivedFileNames = await this.archivedFileNames();
|
|
74
|
-
for (const fileName of archivedFileNames) {
|
|
75
|
-
if (fileName === "index.md")
|
|
76
|
-
continue;
|
|
77
|
-
if (fileName.endsWith(".md")) {
|
|
78
|
-
yield new DocFileMdReference({
|
|
79
|
-
path: this.pathSystem.join(this.relativePath, this.archiveDirectoryName, fileName),
|
|
80
|
-
fileSystem: this.fileSystem,
|
|
81
|
-
pathSystem: this.pathSystem,
|
|
82
|
-
});
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
yield new DocFileUnknownReference({
|
|
86
|
-
path: this.pathSystem.join(this.relativePath, this.archiveDirectoryName, fileName),
|
|
87
|
-
fileSystem: this.fileSystem,
|
|
88
|
-
pathSystem: this.pathSystem,
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
async *mdFilesGenerator() {
|
|
93
|
-
const files = this.filesGenerator();
|
|
94
|
-
for await (const file of files) {
|
|
95
|
-
if (file instanceof DocFileMdReference) {
|
|
96
|
-
yield file;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
async files() {
|
|
101
|
-
const files = [];
|
|
102
|
-
for await (const file of this.filesGenerator()) {
|
|
103
|
-
files.push(file);
|
|
104
|
-
}
|
|
105
|
-
return files;
|
|
106
|
-
}
|
|
107
|
-
async mdFiles() {
|
|
108
|
-
const files = [];
|
|
109
|
-
for await (const file of this.filesGenerator()) {
|
|
110
|
-
if (file instanceof DocFileUnknownReference)
|
|
111
|
-
continue;
|
|
112
|
-
files.push(file);
|
|
113
|
-
}
|
|
114
|
-
return files;
|
|
115
|
-
}
|
|
116
|
-
file(fileName) {
|
|
117
|
-
const filePath = this.pathSystem.join(this.relativePath, fileName);
|
|
118
|
-
if (fileName.endsWith(".md")) {
|
|
119
|
-
return new DocFileMdReference({
|
|
120
|
-
path: filePath,
|
|
121
|
-
fileSystem: this.fileSystem,
|
|
122
|
-
pathSystem: this.pathSystem,
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
return new DocFileUnknownReference({
|
|
126
|
-
path: filePath,
|
|
127
|
-
fileSystem: this.fileSystem,
|
|
128
|
-
pathSystem: this.pathSystem,
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
mdFile(fileName) {
|
|
132
|
-
return new DocFileMdReference({
|
|
133
|
-
path: this.pathSystem.join(this.relativePath, fileName),
|
|
134
|
-
fileSystem: this.fileSystem,
|
|
135
|
-
pathSystem: this.pathSystem,
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
async readFiles() {
|
|
139
|
-
const entities = [];
|
|
140
|
-
for await (const file of this.filesGenerator()) {
|
|
141
|
-
const entity = await file.read();
|
|
142
|
-
if (entity instanceof Error)
|
|
143
|
-
continue;
|
|
144
|
-
entities.push(entity);
|
|
145
|
-
}
|
|
146
|
-
return entities;
|
|
147
|
-
}
|
|
148
|
-
async readMdFiles() {
|
|
149
|
-
const entities = [];
|
|
150
|
-
for await (const file of this.filesGenerator()) {
|
|
151
|
-
const entity = await file.read();
|
|
152
|
-
if (entity instanceof Error)
|
|
153
|
-
continue;
|
|
154
|
-
if (entity instanceof DocFileUnknownEntity)
|
|
155
|
-
continue;
|
|
156
|
-
entities.push(entity);
|
|
157
|
-
}
|
|
158
|
-
return entities;
|
|
159
|
-
}
|
|
160
|
-
async readUnknownFiles() {
|
|
161
|
-
const entities = [];
|
|
162
|
-
for await (const file of this.filesGenerator()) {
|
|
163
|
-
const entity = await file.read();
|
|
164
|
-
if (entity instanceof Error)
|
|
165
|
-
continue;
|
|
166
|
-
if (entity instanceof DocFileMdEntity)
|
|
167
|
-
continue;
|
|
168
|
-
entities.push(entity);
|
|
169
|
-
}
|
|
170
|
-
return entities;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* サブディレクトリ名の一覧を取得
|
|
174
|
-
*/
|
|
175
|
-
async directoryNames() {
|
|
176
|
-
const allFileNames = await this.fileSystem.readDirectoryFileNames(this.relativePath);
|
|
177
|
-
const directoryNames = [];
|
|
178
|
-
for (const fileName of allFileNames) {
|
|
179
|
-
// アーカイブディレクトリは除外
|
|
180
|
-
if (fileName.startsWith(this.archiveDirectoryName))
|
|
181
|
-
continue;
|
|
182
|
-
const filePath = this.pathSystem.join(this.relativePath, fileName);
|
|
183
|
-
const isDirectory = await this.fileSystem.isDirectory(filePath);
|
|
184
|
-
if (isDirectory) {
|
|
185
|
-
directoryNames.push(fileName);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return directoryNames;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* サブディレクトリの参照を取得
|
|
192
|
-
*/
|
|
193
|
-
async directories() {
|
|
194
|
-
const directoryNames = await this.directoryNames();
|
|
195
|
-
return directoryNames.map((dirName) => {
|
|
196
|
-
const dirPath = this.pathSystem.join(this.relativePath, dirName);
|
|
197
|
-
return new DocDirectoryReference({
|
|
198
|
-
path: dirPath,
|
|
199
|
-
indexFileName: this.indexFileName,
|
|
200
|
-
archiveDirectoryName: this.archiveDirectoryName,
|
|
201
|
-
fileSystem: this.fileSystem,
|
|
202
|
-
pathSystem: this.pathSystem,
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* 単一のサブディレクトリ参照を取得
|
|
208
|
-
*/
|
|
209
|
-
directory(directoryName) {
|
|
210
|
-
const dirPath = this.pathSystem.join(this.relativePath, directoryName);
|
|
211
|
-
return new DocDirectoryReference({
|
|
212
|
-
path: dirPath,
|
|
213
|
-
indexFileName: this.indexFileName,
|
|
214
|
-
archiveDirectoryName: this.archiveDirectoryName,
|
|
215
|
-
fileSystem: this.fileSystem,
|
|
216
|
-
pathSystem: this.pathSystem,
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
indexFile() {
|
|
220
|
-
return new DocFileIndexReference({
|
|
221
|
-
path: this.pathSystem.join(this.relativePath, this.indexFileName),
|
|
222
|
-
fileSystem: this.fileSystem,
|
|
223
|
-
pathSystem: this.pathSystem,
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
async readIndexFile() {
|
|
227
|
-
const ref = this.indexFile();
|
|
228
|
-
return ref.read();
|
|
229
|
-
}
|
|
230
|
-
async writeFile(entity) {
|
|
231
|
-
const filePath = this.pathSystem.join(this.relativePath, entity.value.path.nameWithExtension);
|
|
232
|
-
let content = null;
|
|
233
|
-
if (entity instanceof DocFileUnknownEntity) {
|
|
234
|
-
content = entity.value.content;
|
|
235
|
-
}
|
|
236
|
-
if (entity instanceof DocFileIndexEntity) {
|
|
237
|
-
content = entity.content.toText();
|
|
238
|
-
}
|
|
239
|
-
if (entity instanceof DocFileMdEntity) {
|
|
240
|
-
content = entity.content.toText();
|
|
241
|
-
}
|
|
242
|
-
if (content === null) {
|
|
243
|
-
return new Error("Entity content is undefined");
|
|
244
|
-
}
|
|
245
|
-
await this.fileSystem.writeFile(filePath, content);
|
|
246
|
-
return null;
|
|
247
|
-
}
|
|
248
|
-
async exists() {
|
|
249
|
-
return await this.fileSystem.exists(this.relativePath);
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* 一意なファイル名を生成する
|
|
253
|
-
*/
|
|
254
|
-
async generateUniqueFileName(prefix = "document") {
|
|
255
|
-
const now = new Date();
|
|
256
|
-
const timestamp = now.toISOString().slice(0, 19).replace(/[:-]/g, "");
|
|
257
|
-
let counter = 0;
|
|
258
|
-
let fileName;
|
|
259
|
-
do {
|
|
260
|
-
const suffix = counter > 0 ? `-${counter}` : "";
|
|
261
|
-
fileName = `${prefix}-${timestamp}${suffix}.md`;
|
|
262
|
-
counter++;
|
|
263
|
-
} while (await this.fileExists(fileName));
|
|
264
|
-
return fileName;
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* 指定されたファイル名のファイルが存在するかチェック
|
|
268
|
-
*/
|
|
269
|
-
async fileExists(fileName) {
|
|
270
|
-
const filePath = this.pathSystem.join(this.relativePath, fileName);
|
|
271
|
-
return await this.fileSystem.exists(filePath);
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* 新しいMarkdownファイルを作成する
|
|
275
|
-
*/
|
|
276
|
-
async createMdFile(fileName) {
|
|
277
|
-
const actualFileName = fileName || (await this.generateUniqueFileName("document"));
|
|
278
|
-
// .mdが付いていない場合は追加
|
|
279
|
-
const mdFileName = actualFileName.endsWith(".md")
|
|
280
|
-
? actualFileName
|
|
281
|
-
: `${actualFileName}.md`;
|
|
282
|
-
const filePath = this.pathSystem.join(this.relativePath, mdFileName);
|
|
283
|
-
const fileRef = new DocFileMdReference({
|
|
284
|
-
path: filePath,
|
|
285
|
-
fileSystem: this.fileSystem,
|
|
286
|
-
pathSystem: this.pathSystem,
|
|
287
|
-
});
|
|
288
|
-
// デフォルトコンテンツでファイルを作成
|
|
289
|
-
await fileRef.writeDefault();
|
|
290
|
-
return fileRef;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"doc-directory-reference.test.d.ts","sourceRoot":"","sources":["../lib/doc-directory-reference.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "bun:test";
|
|
2
|
-
import { DocDirectoryReference } from "./doc-directory-reference";
|
|
3
|
-
import { DocPathSystem } from "./doc-path-system";
|
|
4
|
-
test("DocDirectoryReference - directoryNames メソッドでサブディレクトリ名を取得できる", async () => {
|
|
5
|
-
const mockFileSystem = {
|
|
6
|
-
getBasePath: () => "/test",
|
|
7
|
-
readDirectoryFileNames: async (path) => {
|
|
8
|
-
if (path === "docs") {
|
|
9
|
-
return ["file1.md", "subdir1", "subdir2", "_archive", "file2.txt"];
|
|
10
|
-
}
|
|
11
|
-
return [];
|
|
12
|
-
},
|
|
13
|
-
isDirectory: async (path) => {
|
|
14
|
-
return ["docs/subdir1", "docs/subdir2", "docs/_archive"].includes(path);
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
const pathSystem = new DocPathSystem();
|
|
18
|
-
const dirRef = new DocDirectoryReference({
|
|
19
|
-
path: "docs",
|
|
20
|
-
indexFileName: "index.md",
|
|
21
|
-
archiveDirectoryName: "_",
|
|
22
|
-
fileSystem: mockFileSystem,
|
|
23
|
-
pathSystem,
|
|
24
|
-
});
|
|
25
|
-
const dirNames = await dirRef.directoryNames();
|
|
26
|
-
expect(dirNames.length).toBe(2); // _archiveは除外
|
|
27
|
-
expect(dirNames).toContain("subdir1");
|
|
28
|
-
expect(dirNames).toContain("subdir2");
|
|
29
|
-
expect(dirNames).not.toContain("_archive");
|
|
30
|
-
expect(dirNames).not.toContain("file1.md");
|
|
31
|
-
expect(dirNames).not.toContain("file2.txt");
|
|
32
|
-
});
|
|
33
|
-
test("DocDirectoryReference - directories メソッドでサブディレクトリ参照を取得できる", async () => {
|
|
34
|
-
const mockFileSystem = {
|
|
35
|
-
getBasePath: () => "/test",
|
|
36
|
-
readDirectoryFileNames: async (path) => {
|
|
37
|
-
if (path === "docs") {
|
|
38
|
-
return ["subdir1", "subdir2", "_archive"];
|
|
39
|
-
}
|
|
40
|
-
return [];
|
|
41
|
-
},
|
|
42
|
-
isDirectory: async (path) => {
|
|
43
|
-
return ["docs/subdir1", "docs/subdir2", "docs/_archive"].includes(path);
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
const pathSystem = new DocPathSystem();
|
|
47
|
-
const dirRef = new DocDirectoryReference({
|
|
48
|
-
path: "docs",
|
|
49
|
-
indexFileName: "index.md",
|
|
50
|
-
archiveDirectoryName: "_",
|
|
51
|
-
fileSystem: mockFileSystem,
|
|
52
|
-
pathSystem,
|
|
53
|
-
});
|
|
54
|
-
const directories = await dirRef.directories();
|
|
55
|
-
expect(directories.length).toBe(2); // _archiveは除外
|
|
56
|
-
expect(directories[0]).toBeInstanceOf(DocDirectoryReference);
|
|
57
|
-
expect(directories[0].relativePath).toBe("docs/subdir1");
|
|
58
|
-
expect(directories[1].relativePath).toBe("docs/subdir2");
|
|
59
|
-
});
|
|
60
|
-
test("DocDirectoryReference - 空のディレクトリでも正常に動作する", async () => {
|
|
61
|
-
const mockFileSystem = {
|
|
62
|
-
getBasePath: () => "/test",
|
|
63
|
-
readDirectoryFileNames: async (_path) => {
|
|
64
|
-
return []; // 空のディレクトリ
|
|
65
|
-
},
|
|
66
|
-
isDirectory: async (_path) => {
|
|
67
|
-
return false;
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
const pathSystem = new DocPathSystem();
|
|
71
|
-
const dirRef = new DocDirectoryReference({
|
|
72
|
-
path: "empty",
|
|
73
|
-
indexFileName: "index.md",
|
|
74
|
-
archiveDirectoryName: "_",
|
|
75
|
-
fileSystem: mockFileSystem,
|
|
76
|
-
pathSystem,
|
|
77
|
-
});
|
|
78
|
-
const dirNames = await dirRef.directoryNames();
|
|
79
|
-
const directories = await dirRef.directories();
|
|
80
|
-
expect(dirNames.length).toBe(0);
|
|
81
|
-
expect(directories.length).toBe(0);
|
|
82
|
-
});
|
|
83
|
-
test("DocDirectoryReference - directory メソッドで単一のサブディレクトリ参照を取得できる", () => {
|
|
84
|
-
const mockFileSystem = {
|
|
85
|
-
getBasePath: () => "/test",
|
|
86
|
-
};
|
|
87
|
-
const pathSystem = new DocPathSystem();
|
|
88
|
-
const dirRef = new DocDirectoryReference({
|
|
89
|
-
path: "docs",
|
|
90
|
-
indexFileName: "index.md",
|
|
91
|
-
archiveDirectoryName: "_",
|
|
92
|
-
fileSystem: mockFileSystem,
|
|
93
|
-
pathSystem,
|
|
94
|
-
});
|
|
95
|
-
const subdir = dirRef.directory("guides");
|
|
96
|
-
expect(subdir).toBeInstanceOf(DocDirectoryReference);
|
|
97
|
-
expect(subdir.relativePath).toBe("docs/guides");
|
|
98
|
-
expect(subdir.indexFileName).toBe("index.md");
|
|
99
|
-
expect(subdir.archiveDirectoryName).toBe("_");
|
|
100
|
-
});
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { DocFileRelationReference } from "./doc-file-relation-reference";
|
|
2
|
-
import type { DocFileSystem } from "./doc-file-system";
|
|
3
|
-
import type { DocPathSystem } from "./doc-path-system";
|
|
4
|
-
import { DocFileIndexEntity } from "./entities/doc-file-index-entity";
|
|
5
|
-
import type { DocRelationValue } from "./values/doc-relation-value";
|
|
6
|
-
type Props = {
|
|
7
|
-
path: string;
|
|
8
|
-
fileSystem: DocFileSystem;
|
|
9
|
-
pathSystem: DocPathSystem;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* ファイルを表すクラス
|
|
13
|
-
*/
|
|
14
|
-
export declare class DocFileIndexReference {
|
|
15
|
-
private readonly props;
|
|
16
|
-
private readonly pathSystem;
|
|
17
|
-
constructor(props: Props);
|
|
18
|
-
get fileSystem(): DocFileSystem;
|
|
19
|
-
get basePath(): string;
|
|
20
|
-
get filePath(): string;
|
|
21
|
-
get fileFullPath(): string;
|
|
22
|
-
get durectoryPath(): string;
|
|
23
|
-
read(): Promise<DocFileIndexEntity>;
|
|
24
|
-
/**
|
|
25
|
-
* ファイルの内容を読み込む
|
|
26
|
-
*/
|
|
27
|
-
readContent(): Promise<Error | string>;
|
|
28
|
-
/**
|
|
29
|
-
* ファイルに内容を書き込む
|
|
30
|
-
*/
|
|
31
|
-
writeContent(content: string): Promise<void>;
|
|
32
|
-
/**
|
|
33
|
-
* Entityを書き込む
|
|
34
|
-
*/
|
|
35
|
-
write(entity: DocFileIndexEntity): Promise<void>;
|
|
36
|
-
/**
|
|
37
|
-
* 新しいファイルをデフォルトコンテンツで作成
|
|
38
|
-
*/
|
|
39
|
-
writeDefault(): Promise<void>;
|
|
40
|
-
/**
|
|
41
|
-
* ファイルを削除
|
|
42
|
-
*/
|
|
43
|
-
delete(): Promise<Error | null>;
|
|
44
|
-
/**
|
|
45
|
-
* ファイルが存在するか確認
|
|
46
|
-
*/
|
|
47
|
-
exists(): Promise<boolean>;
|
|
48
|
-
relations(): Promise<DocFileRelationReference[]>;
|
|
49
|
-
readRelations(): Promise<DocRelationValue[]>;
|
|
50
|
-
/**
|
|
51
|
-
* ファイルのサイズを取得(バイト単位)
|
|
52
|
-
*/
|
|
53
|
-
size(): Promise<number>;
|
|
54
|
-
/**
|
|
55
|
-
* ファイルの最終更新日時を取得
|
|
56
|
-
*/
|
|
57
|
-
lastModified(): Promise<Date>;
|
|
58
|
-
/**
|
|
59
|
-
* ファイルの作成日時を取得
|
|
60
|
-
*/
|
|
61
|
-
createdAt(): Promise<Date>;
|
|
62
|
-
/**
|
|
63
|
-
* ファイルをアーカイブに移動し、新しい参照を返す
|
|
64
|
-
*/
|
|
65
|
-
archive(archiveDirectoryName?: string): Promise<DocFileIndexReference>;
|
|
66
|
-
/**
|
|
67
|
-
* ファイルをアーカイブから復元し、新しい参照を返す
|
|
68
|
-
*/
|
|
69
|
-
restore(archiveDirectoryName?: string): Promise<DocFileIndexReference>;
|
|
70
|
-
}
|
|
71
|
-
export {};
|
|
72
|
-
//# sourceMappingURL=doc-file-index-reference.d.ts.map
|