@interactive-inc/docs-client 0.0.4 → 0.0.5
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 +228 -0
- package/build/doc-client.d.ts +59 -0
- package/build/doc-client.d.ts.map +1 -0
- package/build/doc-client.js +95 -0
- package/build/doc-client.test.d.ts +2 -0
- package/build/doc-client.test.d.ts.map +1 -0
- package/build/doc-client.test.js +38 -0
- package/build/doc-directory-reference.d.ts +65 -0
- package/build/doc-directory-reference.d.ts.map +1 -0
- package/build/doc-directory-reference.js +292 -0
- package/build/doc-directory-reference.test.d.ts +2 -0
- package/build/doc-directory-reference.test.d.ts.map +1 -0
- package/build/doc-directory-reference.test.js +100 -0
- package/build/doc-file-index-reference.d.ts +72 -0
- package/build/doc-file-index-reference.d.ts.map +1 -0
- package/build/doc-file-index-reference.js +191 -0
- package/build/doc-file-index-reference.test.d.ts +2 -0
- package/build/doc-file-index-reference.test.d.ts.map +1 -0
- package/build/doc-file-index-reference.test.js +77 -0
- package/build/doc-file-md-reference.d.ts +97 -0
- package/build/doc-file-md-reference.d.ts.map +1 -0
- package/build/doc-file-md-reference.js +297 -0
- package/build/doc-file-md-reference.test.d.ts +2 -0
- package/build/doc-file-md-reference.test.d.ts.map +1 -0
- package/build/doc-file-md-reference.test.js +465 -0
- package/build/doc-file-relation-reference.d.ts +54 -0
- package/build/doc-file-relation-reference.d.ts.map +1 -0
- package/build/doc-file-relation-reference.js +109 -0
- package/build/doc-file-system-debug.d.ts +81 -0
- package/build/doc-file-system-debug.d.ts.map +1 -0
- package/build/doc-file-system-debug.js +317 -0
- package/build/doc-file-system.d.ts +100 -0
- package/build/doc-file-system.d.ts.map +1 -0
- package/build/doc-file-system.js +210 -0
- package/build/doc-file-tree-system.d.ts +38 -0
- package/build/doc-file-tree-system.d.ts.map +1 -0
- package/build/doc-file-tree-system.js +153 -0
- package/build/doc-file-tree-system.test.d.ts +2 -0
- package/build/doc-file-tree-system.test.d.ts.map +1 -0
- package/build/doc-file-tree-system.test.js +105 -0
- package/build/doc-file-unknown-reference.d.ts +80 -0
- package/build/doc-file-unknown-reference.d.ts.map +1 -0
- package/build/doc-file-unknown-reference.js +181 -0
- package/build/doc-file-unknown-reference.test.d.ts +2 -0
- package/build/doc-file-unknown-reference.test.d.ts.map +1 -0
- package/build/doc-file-unknown-reference.test.js +73 -0
- package/build/doc-markdown-system.d.ts +44 -0
- package/build/doc-markdown-system.d.ts.map +1 -0
- package/build/doc-markdown-system.js +153 -0
- package/build/doc-markdown-system.test.d.ts +2 -0
- package/build/doc-markdown-system.test.d.ts.map +1 -0
- package/build/doc-markdown-system.test.js +124 -0
- package/build/doc-path-system.d.ts +43 -0
- package/build/doc-path-system.d.ts.map +1 -0
- package/build/doc-path-system.js +148 -0
- package/build/doc-path-system.test.d.ts +2 -0
- package/build/doc-path-system.test.d.ts.map +1 -0
- package/build/doc-path-system.test.js +67 -0
- package/build/entities/doc-file-entity.d.ts +5 -0
- package/build/entities/doc-file-entity.d.ts.map +1 -0
- package/build/entities/doc-file-entity.js +1 -0
- package/build/entities/doc-file-index-entity.d.ts +30 -0
- package/build/entities/doc-file-index-entity.d.ts.map +1 -0
- package/build/entities/doc-file-index-entity.js +49 -0
- package/build/entities/doc-file-index-entity.test.d.ts +2 -0
- package/build/entities/doc-file-index-entity.test.d.ts.map +1 -0
- package/build/entities/doc-file-index-entity.test.js +195 -0
- package/build/entities/doc-file-md-entity.d.ts +30 -0
- package/build/entities/doc-file-md-entity.d.ts.map +1 -0
- package/build/entities/doc-file-md-entity.js +49 -0
- package/build/entities/doc-file-md-entity.test.d.ts +2 -0
- package/build/entities/doc-file-md-entity.test.d.ts.map +1 -0
- package/build/entities/doc-file-md-entity.test.js +178 -0
- package/build/entities/doc-file-unknown-entity.d.ts +26 -0
- package/build/entities/doc-file-unknown-entity.d.ts.map +1 -0
- package/build/entities/doc-file-unknown-entity.js +45 -0
- package/build/entities/doc-file-unknown-entity.test.d.ts +2 -0
- package/build/entities/doc-file-unknown-entity.test.d.ts.map +1 -0
- package/build/entities/doc-file-unknown-entity.test.js +131 -0
- package/build/index.d.ts +42 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +39 -24064
- package/build/models.d.ts +818 -0
- package/build/models.d.ts.map +1 -0
- package/build/models.js +312 -0
- package/build/types.d.ts +154 -0
- package/build/types.d.ts.map +1 -0
- package/build/types.js +1 -0
- package/build/values/doc-content-md-front-matter-value.d.ts +49 -0
- package/build/values/doc-content-md-front-matter-value.d.ts.map +1 -0
- package/build/values/doc-content-md-front-matter-value.js +94 -0
- package/build/values/doc-content-md-front-matter-value.test.d.ts +2 -0
- package/build/values/doc-content-md-front-matter-value.test.d.ts.map +1 -0
- package/build/values/doc-content-md-front-matter-value.test.js +73 -0
- package/build/values/doc-content-md-value.d.ts +66 -0
- package/build/values/doc-content-md-value.d.ts.map +1 -0
- package/build/values/doc-content-md-value.js +218 -0
- package/build/values/doc-content-md-value.test.d.ts +2 -0
- package/build/values/doc-content-md-value.test.d.ts.map +1 -0
- package/build/values/doc-content-md-value.test.js +179 -0
- package/build/values/doc-directory-path-value.d.ts +89 -0
- package/build/values/doc-directory-path-value.d.ts.map +1 -0
- package/build/values/doc-directory-path-value.js +145 -0
- package/build/values/doc-directory-path-value.test.d.ts +2 -0
- package/build/values/doc-directory-path-value.test.d.ts.map +1 -0
- package/build/values/doc-directory-path-value.test.js +68 -0
- package/build/values/doc-file-content-index-value.d.ts +62 -0
- package/build/values/doc-file-content-index-value.d.ts.map +1 -0
- package/build/values/doc-file-content-index-value.js +134 -0
- package/build/values/doc-file-content-index-value.test.d.ts +2 -0
- package/build/values/doc-file-content-index-value.test.d.ts.map +1 -0
- package/build/values/doc-file-content-index-value.test.js +203 -0
- package/build/values/doc-file-content-md-value.d.ts +62 -0
- package/build/values/doc-file-content-md-value.d.ts.map +1 -0
- package/build/values/doc-file-content-md-value.js +139 -0
- package/build/values/doc-file-content-md-value.test.d.ts +2 -0
- package/build/values/doc-file-content-md-value.test.d.ts.map +1 -0
- package/build/values/doc-file-content-md-value.test.js +160 -0
- package/build/values/doc-file-path-value.d.ts +47 -0
- package/build/values/doc-file-path-value.d.ts.map +1 -0
- package/build/values/doc-file-path-value.js +83 -0
- package/build/values/doc-file-path-value.test.d.ts +2 -0
- package/build/values/doc-file-path-value.test.d.ts.map +1 -0
- package/build/values/doc-file-path-value.test.js +84 -0
- package/build/values/doc-front-matter-index-value.d.ts +66 -0
- package/build/values/doc-front-matter-index-value.d.ts.map +1 -0
- package/build/values/doc-front-matter-index-value.js +185 -0
- package/build/values/doc-front-matter-index-value.test.d.ts +2 -0
- package/build/values/doc-front-matter-index-value.test.d.ts.map +1 -0
- package/build/values/doc-front-matter-index-value.test.js +98 -0
- package/build/values/doc-front-matter-md-value-accessor.test.d.ts +2 -0
- package/build/values/doc-front-matter-md-value-accessor.test.d.ts.map +1 -0
- package/build/values/doc-front-matter-md-value-accessor.test.js +226 -0
- package/build/values/doc-front-matter-md-value.d.ts +80 -0
- package/build/values/doc-front-matter-md-value.d.ts.map +1 -0
- package/build/values/doc-front-matter-md-value.js +257 -0
- package/build/values/doc-front-matter-md-value.test.d.ts +2 -0
- package/build/values/doc-front-matter-md-value.test.d.ts.map +1 -0
- package/build/values/doc-front-matter-md-value.test.js +198 -0
- package/build/values/doc-relation-field-value.d.ts +57 -0
- package/build/values/doc-relation-field-value.d.ts.map +1 -0
- package/build/values/doc-relation-field-value.js +85 -0
- package/build/values/doc-relation-field-value.test.d.ts +2 -0
- package/build/values/doc-relation-field-value.test.d.ts.map +1 -0
- package/build/values/doc-relation-field-value.test.js +115 -0
- package/build/values/doc-relation-file-value.d.ts +33 -0
- package/build/values/doc-relation-file-value.d.ts.map +1 -0
- package/build/values/doc-relation-file-value.js +55 -0
- package/build/values/doc-relation-file-value.test.d.ts +2 -0
- package/build/values/doc-relation-file-value.test.d.ts.map +1 -0
- package/build/values/doc-relation-file-value.test.js +77 -0
- package/build/values/doc-relation-value.d.ts +34 -0
- package/build/values/doc-relation-value.d.ts.map +1 -0
- package/build/values/doc-relation-value.js +56 -0
- package/build/values/doc-relation-value.test.d.ts +2 -0
- package/build/values/doc-relation-value.test.d.ts.map +1 -0
- package/build/values/doc-relation-value.test.js +89 -0
- package/build/values/doc-schema-field-boolean-multiple-value.d.ts +23 -0
- package/build/values/doc-schema-field-boolean-multiple-value.d.ts.map +1 -0
- package/build/values/doc-schema-field-boolean-multiple-value.js +43 -0
- package/build/values/doc-schema-field-boolean-multiple-value.test.d.ts +2 -0
- package/build/values/doc-schema-field-boolean-multiple-value.test.d.ts.map +1 -0
- package/build/values/doc-schema-field-boolean-multiple-value.test.js +76 -0
- package/build/values/doc-schema-field-boolean-single-value.d.ts +23 -0
- package/build/values/doc-schema-field-boolean-single-value.d.ts.map +1 -0
- package/build/values/doc-schema-field-boolean-single-value.js +39 -0
- package/build/values/doc-schema-field-boolean-single-value.test.d.ts +2 -0
- package/build/values/doc-schema-field-boolean-single-value.test.d.ts.map +1 -0
- package/build/values/doc-schema-field-boolean-single-value.test.js +73 -0
- package/build/values/doc-schema-field-factory.d.ts +37 -0
- package/build/values/doc-schema-field-factory.d.ts.map +1 -0
- package/build/values/doc-schema-field-factory.js +151 -0
- package/build/values/doc-schema-field-factory.test.d.ts +2 -0
- package/build/values/doc-schema-field-factory.test.d.ts.map +1 -0
- package/build/values/doc-schema-field-factory.test.js +215 -0
- package/build/values/doc-schema-field-number-multiple-value.d.ts +23 -0
- package/build/values/doc-schema-field-number-multiple-value.d.ts.map +1 -0
- package/build/values/doc-schema-field-number-multiple-value.js +43 -0
- package/build/values/doc-schema-field-number-multiple-value.test.d.ts +2 -0
- package/build/values/doc-schema-field-number-multiple-value.test.d.ts.map +1 -0
- package/build/values/doc-schema-field-number-multiple-value.test.js +79 -0
- package/build/values/doc-schema-field-number-single-value.d.ts +23 -0
- package/build/values/doc-schema-field-number-single-value.d.ts.map +1 -0
- package/build/values/doc-schema-field-number-single-value.js +39 -0
- package/build/values/doc-schema-field-number-single-value.test.d.ts +2 -0
- package/build/values/doc-schema-field-number-single-value.test.d.ts.map +1 -0
- package/build/values/doc-schema-field-number-single-value.test.js +77 -0
- package/build/values/doc-schema-field-relation-multiple-value.d.ts +24 -0
- package/build/values/doc-schema-field-relation-multiple-value.d.ts.map +1 -0
- package/build/values/doc-schema-field-relation-multiple-value.js +46 -0
- package/build/values/doc-schema-field-relation-multiple-value.test.d.ts +2 -0
- package/build/values/doc-schema-field-relation-multiple-value.test.d.ts.map +1 -0
- package/build/values/doc-schema-field-relation-multiple-value.test.js +83 -0
- package/build/values/doc-schema-field-relation-single-value.d.ts +24 -0
- package/build/values/doc-schema-field-relation-single-value.d.ts.map +1 -0
- package/build/values/doc-schema-field-relation-single-value.js +42 -0
- package/build/values/doc-schema-field-relation-single-value.test.d.ts +2 -0
- package/build/values/doc-schema-field-relation-single-value.test.d.ts.map +1 -0
- package/build/values/doc-schema-field-relation-single-value.test.js +83 -0
- package/build/values/doc-schema-field-select-number-multiple-value.d.ts +25 -0
- package/build/values/doc-schema-field-select-number-multiple-value.d.ts.map +1 -0
- package/build/values/doc-schema-field-select-number-multiple-value.js +48 -0
- package/build/values/doc-schema-field-select-number-multiple-value.test.d.ts +2 -0
- package/build/values/doc-schema-field-select-number-multiple-value.test.d.ts.map +1 -0
- package/build/values/doc-schema-field-select-number-multiple-value.test.js +84 -0
- package/build/values/doc-schema-field-select-number-single-value.d.ts +25 -0
- package/build/values/doc-schema-field-select-number-single-value.d.ts.map +1 -0
- package/build/values/doc-schema-field-select-number-single-value.js +45 -0
- package/build/values/doc-schema-field-select-number-single-value.test.d.ts +2 -0
- package/build/values/doc-schema-field-select-number-single-value.test.d.ts.map +1 -0
- package/build/values/doc-schema-field-select-number-single-value.test.js +96 -0
- package/build/values/doc-schema-field-select-text-multiple-value.d.ts +25 -0
- package/build/values/doc-schema-field-select-text-multiple-value.d.ts.map +1 -0
- package/build/values/doc-schema-field-select-text-multiple-value.js +48 -0
- package/build/values/doc-schema-field-select-text-multiple-value.test.d.ts +2 -0
- package/build/values/doc-schema-field-select-text-multiple-value.test.d.ts.map +1 -0
- package/build/values/doc-schema-field-select-text-multiple-value.test.js +84 -0
- package/build/values/doc-schema-field-select-text-single-value.d.ts +25 -0
- package/build/values/doc-schema-field-select-text-single-value.d.ts.map +1 -0
- package/build/values/doc-schema-field-select-text-single-value.js +47 -0
- package/build/values/doc-schema-field-select-text-single-value.test.d.ts +2 -0
- package/build/values/doc-schema-field-select-text-single-value.test.d.ts.map +1 -0
- package/build/values/doc-schema-field-select-text-single-value.test.js +96 -0
- package/build/values/doc-schema-field-text-multiple-value.d.ts +23 -0
- package/build/values/doc-schema-field-text-multiple-value.d.ts.map +1 -0
- package/build/values/doc-schema-field-text-multiple-value.js +43 -0
- package/build/values/doc-schema-field-text-multiple-value.test.d.ts +2 -0
- package/build/values/doc-schema-field-text-multiple-value.test.d.ts.map +1 -0
- package/build/values/doc-schema-field-text-multiple-value.test.js +78 -0
- package/build/values/doc-schema-field-text-single-value.d.ts +23 -0
- package/build/values/doc-schema-field-text-single-value.d.ts.map +1 -0
- package/build/values/doc-schema-field-text-single-value.js +39 -0
- package/build/values/doc-schema-field-text-single-value.test.d.ts +2 -0
- package/build/values/doc-schema-field-text-single-value.test.d.ts.map +1 -0
- package/build/values/doc-schema-field-text-single-value.test.js +76 -0
- package/build/values/doc-schema-field-type-value.d.ts +61 -0
- package/build/values/doc-schema-field-type-value.d.ts.map +1 -0
- package/build/values/doc-schema-field-type-value.js +134 -0
- package/build/values/doc-schema-field-type-value.test.d.ts +2 -0
- package/build/values/doc-schema-field-type-value.test.d.ts.map +1 -0
- package/build/values/doc-schema-field-type-value.test.js +101 -0
- package/build/values/doc-schema-field-value.d.ts +45 -0
- package/build/values/doc-schema-field-value.d.ts.map +1 -0
- package/build/values/doc-schema-field-value.js +1 -0
- package/build/values/doc-schema-value.d.ts +99 -0
- package/build/values/doc-schema-value.d.ts.map +1 -0
- package/build/values/doc-schema-value.js +269 -0
- package/build/values/doc-schema-value.test.d.ts +2 -0
- package/build/values/doc-schema-value.test.d.ts.map +1 -0
- package/build/values/doc-schema-value.test.js +301 -0
- package/build/values/doc-tree-directory-node-value.d.ts +36 -0
- package/build/values/doc-tree-directory-node-value.d.ts.map +1 -0
- package/build/values/doc-tree-directory-node-value.js +71 -0
- package/build/values/doc-tree-directory-node-value.test.d.ts +2 -0
- package/build/values/doc-tree-directory-node-value.test.d.ts.map +1 -0
- package/build/values/doc-tree-directory-node-value.test.js +162 -0
- package/build/values/doc-tree-file-node-value.d.ts +33 -0
- package/build/values/doc-tree-file-node-value.d.ts.map +1 -0
- package/build/values/doc-tree-file-node-value.js +56 -0
- package/build/values/doc-tree-file-node-value.test.d.ts +2 -0
- package/build/values/doc-tree-file-node-value.test.d.ts.map +1 -0
- package/build/values/doc-tree-file-node-value.test.js +113 -0
- package/debug/debug.ts +108 -0
- package/package.json +7 -45
- package/bin/docs.js +0 -3
- package/build/assets/index.css +0 -1
- package/build/assets/index.js +0 -298
- package/build/index.html +0 -13
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { DocFilePathValue } from "./doc-file-path-value";
|
|
2
|
+
/**
|
|
3
|
+
* ディレクトリパスを表す値オブジェクト
|
|
4
|
+
*/
|
|
5
|
+
export class DocDirectoryPathValue {
|
|
6
|
+
value;
|
|
7
|
+
pathSystem;
|
|
8
|
+
constructor(value, pathSystem) {
|
|
9
|
+
this.value = value;
|
|
10
|
+
this.pathSystem = pathSystem;
|
|
11
|
+
Object.freeze(this);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 相対ディレクトリパス
|
|
15
|
+
*/
|
|
16
|
+
get path() {
|
|
17
|
+
return this.value.path;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* ディレクトリ名
|
|
21
|
+
*/
|
|
22
|
+
get name() {
|
|
23
|
+
return this.value.name;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 親ディレクトリパスを取得
|
|
27
|
+
*/
|
|
28
|
+
get parent() {
|
|
29
|
+
if (this.path === "." || this.path === "") {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
const parentPath = this.pathSystem.dirname(this.path);
|
|
33
|
+
const parentName = parentPath === "." ? "" : this.pathSystem.basename(parentPath);
|
|
34
|
+
return new DocDirectoryPathValue({
|
|
35
|
+
path: parentPath,
|
|
36
|
+
name: parentName,
|
|
37
|
+
fullPath: this.pathSystem.dirname(this.fullPath),
|
|
38
|
+
}, this.pathSystem);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 親ディレクトリパス
|
|
42
|
+
*/
|
|
43
|
+
get parentPath() {
|
|
44
|
+
return this.pathSystem.dirname(this.path);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 深さ(ディレクトリの階層数)
|
|
48
|
+
*/
|
|
49
|
+
get depth() {
|
|
50
|
+
if (this.path === "." || this.path === "") {
|
|
51
|
+
return 0;
|
|
52
|
+
}
|
|
53
|
+
return this.path.split(this.pathSystem.sep).filter(Boolean).length;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* パスセグメント(ディレクトリの配列)
|
|
57
|
+
*/
|
|
58
|
+
get segments() {
|
|
59
|
+
return this.path.split(this.pathSystem.sep).filter(Boolean);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* ルートからの相対パス(先頭のスラッシュなし)
|
|
63
|
+
*/
|
|
64
|
+
get normalizedPath() {
|
|
65
|
+
return this.path.replace(/^\/+/, "");
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* アーカイブディレクトリかどうか(ディレクトリ名が「_」の場合)
|
|
69
|
+
*/
|
|
70
|
+
get isArchived() {
|
|
71
|
+
return this.name === "_";
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* 隠しディレクトリかどうか
|
|
75
|
+
*/
|
|
76
|
+
get isHidden() {
|
|
77
|
+
return this.name.startsWith(".");
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* ルートディレクトリかどうか
|
|
81
|
+
*/
|
|
82
|
+
get isRoot() {
|
|
83
|
+
return this.path === "." || this.path === "";
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* 絶対パス
|
|
87
|
+
*/
|
|
88
|
+
get fullPath() {
|
|
89
|
+
return this.value.fullPath;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* インデックスファイルのパスを取得
|
|
93
|
+
*/
|
|
94
|
+
get indexFile() {
|
|
95
|
+
return DocFilePathValue.fromPathWithSystem(this.pathSystem.join(this.path, "index.md"), this.pathSystem, this.pathSystem.dirname(this.fullPath));
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* ファイルパスを作成
|
|
99
|
+
*/
|
|
100
|
+
file(fileName) {
|
|
101
|
+
return DocFilePathValue.fromPathWithSystem(this.pathSystem.join(this.path, fileName), this.pathSystem, this.pathSystem.dirname(this.fullPath));
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* サブディレクトリのパスを作成
|
|
105
|
+
*/
|
|
106
|
+
subdirectory(dirName) {
|
|
107
|
+
const subPath = this.pathSystem.join(this.path, dirName);
|
|
108
|
+
return new DocDirectoryPathValue({
|
|
109
|
+
path: subPath,
|
|
110
|
+
name: dirName,
|
|
111
|
+
fullPath: this.pathSystem.join(this.fullPath, dirName),
|
|
112
|
+
}, this.pathSystem);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* 相対パスからインスタンスを生成(DI対応)
|
|
116
|
+
*/
|
|
117
|
+
static fromPathWithSystem(dirPath, basePath, pathSystem) {
|
|
118
|
+
const name = dirPath === "." ? "" : pathSystem.basename(dirPath);
|
|
119
|
+
const fullPath = dirPath === "." ? basePath : pathSystem.join(basePath, dirPath);
|
|
120
|
+
return new DocDirectoryPathValue({
|
|
121
|
+
path: dirPath,
|
|
122
|
+
name,
|
|
123
|
+
fullPath,
|
|
124
|
+
}, pathSystem);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* JSON形式で出力
|
|
128
|
+
*/
|
|
129
|
+
toJson() {
|
|
130
|
+
return this.value;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* パスが等しいかどうか
|
|
134
|
+
*/
|
|
135
|
+
equals(other) {
|
|
136
|
+
return this.path === other.path;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* 指定されたディレクトリがこのディレクトリの子孫かどうか
|
|
140
|
+
*/
|
|
141
|
+
contains(other) {
|
|
142
|
+
const relative = this.pathSystem.relative(this.path, other.path);
|
|
143
|
+
return !relative.startsWith("..") && relative !== "";
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doc-directory-path-value.test.d.ts","sourceRoot":"","sources":["../../lib/values/doc-directory-path-value.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { expect, test } from "bun:test";
|
|
2
|
+
import { DocPathSystem } from "../doc-path-system";
|
|
3
|
+
import { DocDirectoryPathValue } from "./doc-directory-path-value";
|
|
4
|
+
test("DocDirectoryPathValue - 基本的な作成とプロパティアクセス", () => {
|
|
5
|
+
const pathSystem = new DocPathSystem();
|
|
6
|
+
const value = new DocDirectoryPathValue({
|
|
7
|
+
path: "docs/features",
|
|
8
|
+
name: "features",
|
|
9
|
+
fullPath: "/Users/test/docs/features",
|
|
10
|
+
}, pathSystem);
|
|
11
|
+
expect(value.path).toBe("docs/features");
|
|
12
|
+
expect(value.name).toBe("features");
|
|
13
|
+
expect(value.fullPath).toBe("/Users/test/docs/features");
|
|
14
|
+
});
|
|
15
|
+
test("DocDirectoryPathValue - ルートディレクトリの場合", () => {
|
|
16
|
+
const pathSystem = new DocPathSystem();
|
|
17
|
+
const value = new DocDirectoryPathValue({
|
|
18
|
+
path: ".",
|
|
19
|
+
name: "",
|
|
20
|
+
fullPath: "/Users/test",
|
|
21
|
+
}, pathSystem);
|
|
22
|
+
expect(value.path).toBe(".");
|
|
23
|
+
expect(value.name).toBe("");
|
|
24
|
+
expect(value.fullPath).toBe("/Users/test");
|
|
25
|
+
});
|
|
26
|
+
test("DocDirectoryPathValue - fromPathWithSystemで相対パスから生成", () => {
|
|
27
|
+
const pathSystem = new DocPathSystem();
|
|
28
|
+
const value = DocDirectoryPathValue.fromPathWithSystem("docs/products", "/Users/project", pathSystem);
|
|
29
|
+
expect(value.path).toBe("docs/products");
|
|
30
|
+
expect(value.name).toBe("products");
|
|
31
|
+
expect(value.fullPath).toBe("/Users/project/docs/products");
|
|
32
|
+
});
|
|
33
|
+
test("DocDirectoryPathValue - fromPathWithSystemでルートディレクトリ", () => {
|
|
34
|
+
const pathSystem = new DocPathSystem();
|
|
35
|
+
const value = DocDirectoryPathValue.fromPathWithSystem(".", "/Users/project", pathSystem);
|
|
36
|
+
expect(value.path).toBe(".");
|
|
37
|
+
expect(value.name).toBe("");
|
|
38
|
+
expect(value.fullPath).toBe("/Users/project");
|
|
39
|
+
});
|
|
40
|
+
test("DocDirectoryPathValue - fromPathWithSystemでネストしたディレクトリ", () => {
|
|
41
|
+
const pathSystem = new DocPathSystem();
|
|
42
|
+
const value = DocDirectoryPathValue.fromPathWithSystem("docs/products/app/features", "/Users/project", pathSystem);
|
|
43
|
+
expect(value.path).toBe("docs/products/app/features");
|
|
44
|
+
expect(value.name).toBe("features");
|
|
45
|
+
expect(value.fullPath).toBe("/Users/project/docs/products/app/features");
|
|
46
|
+
});
|
|
47
|
+
test("DocDirectoryPathValue - toJsonで元のデータ構造を返す", () => {
|
|
48
|
+
const pathSystem = new DocPathSystem();
|
|
49
|
+
const data = {
|
|
50
|
+
path: "docs/test",
|
|
51
|
+
name: "test",
|
|
52
|
+
fullPath: "/Users/test/docs/test",
|
|
53
|
+
};
|
|
54
|
+
const value = new DocDirectoryPathValue(data, pathSystem);
|
|
55
|
+
expect(value.toJson()).toEqual(data);
|
|
56
|
+
});
|
|
57
|
+
test("DocDirectoryPathValue - 不変性の確認", () => {
|
|
58
|
+
const pathSystem = new DocPathSystem();
|
|
59
|
+
const value = new DocDirectoryPathValue({
|
|
60
|
+
path: "docs/test",
|
|
61
|
+
name: "test",
|
|
62
|
+
fullPath: "/Users/test/docs/test",
|
|
63
|
+
}, pathSystem);
|
|
64
|
+
expect(() => {
|
|
65
|
+
// @ts-expect-error - 不変性のテスト
|
|
66
|
+
value.value = {};
|
|
67
|
+
}).toThrow();
|
|
68
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { DocFileContentIndex } from "../types";
|
|
2
|
+
import { DocFrontMatterIndexValue } from "./doc-front-matter-index-value";
|
|
3
|
+
/**
|
|
4
|
+
* Indexファイルコンテンツ情報の値オブジェクト
|
|
5
|
+
*/
|
|
6
|
+
export declare class DocFileContentIndexValue {
|
|
7
|
+
readonly value: DocFileContentIndex;
|
|
8
|
+
constructor(value: DocFileContentIndex);
|
|
9
|
+
/**
|
|
10
|
+
* コンテンツ本文(frontMatterを含まない)
|
|
11
|
+
*/
|
|
12
|
+
get body(): string;
|
|
13
|
+
/**
|
|
14
|
+
* タイトル
|
|
15
|
+
*/
|
|
16
|
+
get title(): string;
|
|
17
|
+
/**
|
|
18
|
+
* 説明
|
|
19
|
+
*/
|
|
20
|
+
get description(): string;
|
|
21
|
+
/**
|
|
22
|
+
* FrontMatter
|
|
23
|
+
*/
|
|
24
|
+
get frontMatter(): DocFrontMatterIndexValue;
|
|
25
|
+
/**
|
|
26
|
+
* タイトルを更新
|
|
27
|
+
*/
|
|
28
|
+
withTitle(title: string): DocFileContentIndexValue;
|
|
29
|
+
/**
|
|
30
|
+
* 説明を更新
|
|
31
|
+
*/
|
|
32
|
+
withDescription(description: string, defaultTitle?: string): DocFileContentIndexValue;
|
|
33
|
+
/**
|
|
34
|
+
* Markdownテキストから生成
|
|
35
|
+
*/
|
|
36
|
+
static fromMarkdown(markdown: string): DocFileContentIndexValue;
|
|
37
|
+
/**
|
|
38
|
+
* 完全なMarkdownテキストを生成
|
|
39
|
+
*/
|
|
40
|
+
toMarkdownText(): string;
|
|
41
|
+
/**
|
|
42
|
+
* コンテンツを更新
|
|
43
|
+
*/
|
|
44
|
+
withContent(content: string): DocFileContentIndexValue;
|
|
45
|
+
/**
|
|
46
|
+
* FrontMatterを更新
|
|
47
|
+
*/
|
|
48
|
+
withFrontMatter(frontMatter: DocFrontMatterIndexValue): DocFileContentIndexValue;
|
|
49
|
+
/**
|
|
50
|
+
* デフォルトのindex.mdコンテンツを生成
|
|
51
|
+
*/
|
|
52
|
+
static empty(directoryName: string): DocFileContentIndexValue;
|
|
53
|
+
/**
|
|
54
|
+
* FrontMatterとbodyを結合した完全なテキストを生成
|
|
55
|
+
*/
|
|
56
|
+
toText(): string;
|
|
57
|
+
/**
|
|
58
|
+
* JSON形式で出力
|
|
59
|
+
*/
|
|
60
|
+
toJson(): DocFileContentIndex;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=doc-file-content-index-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doc-file-content-index-value.d.ts","sourceRoot":"","sources":["../../lib/values/doc-file-content-index-value.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAA;AAEzE;;GAEG;AACH,qBAAa,wBAAwB;IACvB,QAAQ,CAAC,KAAK,EAAE,mBAAmB;IAA/C,YAAqB,KAAK,EAAE,mBAAmB,EAG9C;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;OAEG;IACH,IAAI,WAAW,IAAI,MAAM,CAExB;IAED;;OAEG;IACH,IAAI,WAAW,IAAI,wBAAwB,CAE1C;IAED;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,wBAAwB,CAYjD;IAED;;OAEG;IACH,eAAe,CACb,WAAW,EAAE,MAAM,EACnB,YAAY,CAAC,EAAE,MAAM,GACpB,wBAAwB,CAgB1B;IAED;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,wBAAwB,CAW9D;IAED;;OAEG;IACH,cAAc,IAAI,MAAM,CAEvB;IAED;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,wBAAwB,CASrD;IAED;;OAEG;IACH,eAAe,CAAC,WAAW,EAAE,wBAAwB,4BAQpD;IAED;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,MAAM,GAAG,wBAAwB,CAG5D;IAED;;OAEG;IACH,MAAM,IAAI,MAAM,CAEf;IAED;;OAEG;IACH,MAAM,IAAI,mBAAmB,CAE5B;CACF"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { DocMarkdownSystem } from "../doc-markdown-system";
|
|
2
|
+
import { zDocFileContentIndex } from "../models";
|
|
3
|
+
import { DocFrontMatterIndexValue } from "./doc-front-matter-index-value";
|
|
4
|
+
/**
|
|
5
|
+
* Indexファイルコンテンツ情報の値オブジェクト
|
|
6
|
+
*/
|
|
7
|
+
export class DocFileContentIndexValue {
|
|
8
|
+
value;
|
|
9
|
+
constructor(value) {
|
|
10
|
+
this.value = value;
|
|
11
|
+
zDocFileContentIndex.parse(value);
|
|
12
|
+
Object.freeze(this);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* コンテンツ本文(frontMatterを含まない)
|
|
16
|
+
*/
|
|
17
|
+
get body() {
|
|
18
|
+
return this.value.body;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* タイトル
|
|
22
|
+
*/
|
|
23
|
+
get title() {
|
|
24
|
+
return this.value.title;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 説明
|
|
28
|
+
*/
|
|
29
|
+
get description() {
|
|
30
|
+
return this.value.description;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* FrontMatter
|
|
34
|
+
*/
|
|
35
|
+
get frontMatter() {
|
|
36
|
+
return new DocFrontMatterIndexValue(this.value.frontMatter);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* タイトルを更新
|
|
40
|
+
*/
|
|
41
|
+
withTitle(title) {
|
|
42
|
+
const fullText = this.toText();
|
|
43
|
+
const engine = new DocMarkdownSystem();
|
|
44
|
+
const updatedText = engine.updateTitle(fullText, title);
|
|
45
|
+
const updatedBody = engine.extractBody(updatedText);
|
|
46
|
+
return new DocFileContentIndexValue({
|
|
47
|
+
type: "markdown-index",
|
|
48
|
+
body: updatedBody,
|
|
49
|
+
title,
|
|
50
|
+
description: this.description,
|
|
51
|
+
frontMatter: this.value.frontMatter,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 説明を更新
|
|
56
|
+
*/
|
|
57
|
+
withDescription(description, defaultTitle) {
|
|
58
|
+
const fullText = this.toText();
|
|
59
|
+
const engine = new DocMarkdownSystem();
|
|
60
|
+
const updatedText = engine.updateDescription(fullText, description, defaultTitle || this.title);
|
|
61
|
+
const updatedBody = engine.extractBody(updatedText);
|
|
62
|
+
return new DocFileContentIndexValue({
|
|
63
|
+
type: "markdown-index",
|
|
64
|
+
body: updatedBody,
|
|
65
|
+
title: this.title,
|
|
66
|
+
description,
|
|
67
|
+
frontMatter: this.value.frontMatter,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Markdownテキストから生成
|
|
72
|
+
*/
|
|
73
|
+
static fromMarkdown(markdown) {
|
|
74
|
+
const engine = new DocMarkdownSystem();
|
|
75
|
+
const frontMatter = DocFrontMatterIndexValue.from(markdown);
|
|
76
|
+
return new DocFileContentIndexValue({
|
|
77
|
+
type: "markdown-index",
|
|
78
|
+
body: engine.extractBody(markdown),
|
|
79
|
+
title: engine.extractTitle(markdown) || "",
|
|
80
|
+
description: engine.extractDescription(markdown) || "",
|
|
81
|
+
frontMatter: frontMatter.toJson(),
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* 完全なMarkdownテキストを生成
|
|
86
|
+
*/
|
|
87
|
+
toMarkdownText() {
|
|
88
|
+
return DocMarkdownSystem.from(this.title, this.description, this.body);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* コンテンツを更新
|
|
92
|
+
*/
|
|
93
|
+
withContent(content) {
|
|
94
|
+
const engine = new DocMarkdownSystem();
|
|
95
|
+
return new DocFileContentIndexValue({
|
|
96
|
+
type: "markdown-index",
|
|
97
|
+
body: content,
|
|
98
|
+
title: engine.extractTitle(content) || "",
|
|
99
|
+
description: engine.extractDescription(content) || "",
|
|
100
|
+
frontMatter: this.value.frontMatter,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* FrontMatterを更新
|
|
105
|
+
*/
|
|
106
|
+
withFrontMatter(frontMatter) {
|
|
107
|
+
return new DocFileContentIndexValue({
|
|
108
|
+
type: "markdown-index",
|
|
109
|
+
body: this.body,
|
|
110
|
+
title: this.title,
|
|
111
|
+
description: this.description,
|
|
112
|
+
frontMatter: frontMatter.toJson(),
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* デフォルトのindex.mdコンテンツを生成
|
|
117
|
+
*/
|
|
118
|
+
static empty(directoryName) {
|
|
119
|
+
const content = `---\ntitle: "${directoryName}"\ndescription: ""\nicon: ""\nschema: {}\n---\n\n# ${directoryName}\n`;
|
|
120
|
+
return DocFileContentIndexValue.fromMarkdown(content);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* FrontMatterとbodyを結合した完全なテキストを生成
|
|
124
|
+
*/
|
|
125
|
+
toText() {
|
|
126
|
+
return `---\n${this.frontMatter.toYaml()}\n---\n\n${this.body}`;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* JSON形式で出力
|
|
130
|
+
*/
|
|
131
|
+
toJson() {
|
|
132
|
+
return this.value;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doc-file-content-index-value.test.d.ts","sourceRoot":"","sources":["../../lib/values/doc-file-content-index-value.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { expect, test } from "bun:test";
|
|
2
|
+
import { DocFileContentIndexValue } from "./doc-file-content-index-value";
|
|
3
|
+
import { DocFrontMatterIndexValue } from "./doc-front-matter-index-value";
|
|
4
|
+
test("DocFileContentIndexValue - 基本的な作成とプロパティアクセス", () => {
|
|
5
|
+
const value = new DocFileContentIndexValue({
|
|
6
|
+
type: "markdown-index",
|
|
7
|
+
body: "# タイトル\n\n説明文\n\n本文",
|
|
8
|
+
title: "タイトル",
|
|
9
|
+
description: "説明文",
|
|
10
|
+
frontMatter: {
|
|
11
|
+
type: "index-frontmatter",
|
|
12
|
+
icon: "📁",
|
|
13
|
+
schema: {
|
|
14
|
+
name: {
|
|
15
|
+
type: "text",
|
|
16
|
+
required: true,
|
|
17
|
+
title: "名前",
|
|
18
|
+
description: "項目の名前",
|
|
19
|
+
default: "",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
expect(value.body).toBe("# タイトル\n\n説明文\n\n本文");
|
|
25
|
+
expect(value.title).toBe("タイトル");
|
|
26
|
+
expect(value.description).toBe("説明文");
|
|
27
|
+
expect(value.frontMatter.icon).toBe("📁");
|
|
28
|
+
});
|
|
29
|
+
test("DocFileContentIndexValue - frontMatter getterが値オブジェクトを返す", () => {
|
|
30
|
+
const value = new DocFileContentIndexValue({
|
|
31
|
+
type: "markdown-index",
|
|
32
|
+
body: "",
|
|
33
|
+
title: "",
|
|
34
|
+
description: "",
|
|
35
|
+
frontMatter: {
|
|
36
|
+
type: "index-frontmatter",
|
|
37
|
+
icon: "📁",
|
|
38
|
+
schema: {},
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
const frontMatter = value.frontMatter;
|
|
42
|
+
expect(frontMatter).toBeInstanceOf(DocFrontMatterIndexValue);
|
|
43
|
+
expect(frontMatter.icon).toBe("📁");
|
|
44
|
+
});
|
|
45
|
+
test("DocFileContentIndexValue - withTitleで新しいインスタンスを作成", () => {
|
|
46
|
+
const value = new DocFileContentIndexValue({
|
|
47
|
+
type: "markdown-index",
|
|
48
|
+
body: "# 古いタイトル\n\n説明文",
|
|
49
|
+
title: "古いタイトル",
|
|
50
|
+
description: "説明文",
|
|
51
|
+
frontMatter: {
|
|
52
|
+
type: "index-frontmatter",
|
|
53
|
+
icon: "",
|
|
54
|
+
schema: {},
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
const newValue = value.withTitle("新しいタイトル");
|
|
58
|
+
expect(newValue).not.toBe(value); // 新しいインスタンス
|
|
59
|
+
expect(newValue.title).toBe("新しいタイトル");
|
|
60
|
+
expect(newValue.body).toContain("# 新しいタイトル");
|
|
61
|
+
expect(value.title).toBe("古いタイトル"); // 元は変更されない
|
|
62
|
+
});
|
|
63
|
+
test("DocFileContentIndexValue - withDescriptionで新しいインスタンスを作成", () => {
|
|
64
|
+
const value = new DocFileContentIndexValue({
|
|
65
|
+
type: "markdown-index",
|
|
66
|
+
body: "# タイトル\n\n古い説明",
|
|
67
|
+
title: "タイトル",
|
|
68
|
+
description: "古い説明",
|
|
69
|
+
frontMatter: {
|
|
70
|
+
type: "index-frontmatter",
|
|
71
|
+
icon: "",
|
|
72
|
+
schema: {},
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
const newValue = value.withDescription("新しい説明");
|
|
76
|
+
expect(newValue).not.toBe(value);
|
|
77
|
+
expect(newValue.description).toBe("新しい説明");
|
|
78
|
+
expect(newValue.body).toContain("新しい説明");
|
|
79
|
+
});
|
|
80
|
+
test("DocFileContentIndexValue - withContentで新しいインスタンスを作成", () => {
|
|
81
|
+
const value = new DocFileContentIndexValue({
|
|
82
|
+
type: "markdown-index",
|
|
83
|
+
body: "古い内容",
|
|
84
|
+
title: "タイトル",
|
|
85
|
+
description: "説明",
|
|
86
|
+
frontMatter: {
|
|
87
|
+
type: "index-frontmatter",
|
|
88
|
+
icon: "",
|
|
89
|
+
schema: {},
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
const newValue = value.withContent("新しい内容");
|
|
93
|
+
expect(newValue).not.toBe(value);
|
|
94
|
+
expect(newValue.body).toBe("新しい内容");
|
|
95
|
+
// タイトルは新しい内容から解析される
|
|
96
|
+
expect(newValue.title).toBe("");
|
|
97
|
+
expect(newValue.description).toBe("");
|
|
98
|
+
});
|
|
99
|
+
test("DocFileContentIndexValue - withFrontMatterで新しいインスタンスを作成", () => {
|
|
100
|
+
const value = new DocFileContentIndexValue({
|
|
101
|
+
type: "markdown-index",
|
|
102
|
+
body: "# タイトル",
|
|
103
|
+
title: "タイトル",
|
|
104
|
+
description: "",
|
|
105
|
+
frontMatter: {
|
|
106
|
+
type: "index-frontmatter",
|
|
107
|
+
icon: "📁",
|
|
108
|
+
schema: {},
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
const newFrontMatter = new DocFrontMatterIndexValue({
|
|
112
|
+
type: "index-frontmatter",
|
|
113
|
+
icon: "📂",
|
|
114
|
+
schema: {
|
|
115
|
+
test: {
|
|
116
|
+
type: "text",
|
|
117
|
+
required: false,
|
|
118
|
+
title: "テスト",
|
|
119
|
+
description: "テスト項目",
|
|
120
|
+
default: "",
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
const newValue = value.withFrontMatter(newFrontMatter);
|
|
125
|
+
expect(newValue).not.toBe(value);
|
|
126
|
+
expect(newValue.frontMatter.icon).toBe("📂");
|
|
127
|
+
expect(value.frontMatter.icon).toBe("📁"); // 元は変更されない
|
|
128
|
+
});
|
|
129
|
+
test("DocFileContentIndexValue - fromMarkdownでMarkdownから生成", () => {
|
|
130
|
+
const markdown = `---
|
|
131
|
+
title: "メタタイトル"
|
|
132
|
+
description: "メタ説明"
|
|
133
|
+
icon: "📁"
|
|
134
|
+
schema: {}
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
# ドキュメントタイトル
|
|
138
|
+
|
|
139
|
+
これは説明文です。
|
|
140
|
+
|
|
141
|
+
本文の内容`;
|
|
142
|
+
const value = DocFileContentIndexValue.fromMarkdown(markdown);
|
|
143
|
+
expect(value.title).toBe("ドキュメントタイトル");
|
|
144
|
+
expect(value.description).toBe("これは説明文です。");
|
|
145
|
+
expect(value.body).toContain("# ドキュメントタイトル");
|
|
146
|
+
expect(value.frontMatter.icon).toBe("📁");
|
|
147
|
+
});
|
|
148
|
+
test("DocFileContentIndexValue - emptyでデフォルトコンテンツを生成", () => {
|
|
149
|
+
const value = DocFileContentIndexValue.empty("テストディレクトリ");
|
|
150
|
+
expect(value.title).toBe("テストディレクトリ");
|
|
151
|
+
expect(value.frontMatter.icon).toBe("");
|
|
152
|
+
expect(value.frontMatter.schema.toJson()).toEqual({});
|
|
153
|
+
expect(value.body).toContain("# テストディレクトリ");
|
|
154
|
+
});
|
|
155
|
+
test("DocFileContentIndexValue - toTextでFrontMatter付きテキストを生成", () => {
|
|
156
|
+
const value = new DocFileContentIndexValue({
|
|
157
|
+
type: "markdown-index",
|
|
158
|
+
body: "# タイトル\n\n本文",
|
|
159
|
+
title: "タイトル",
|
|
160
|
+
description: "",
|
|
161
|
+
frontMatter: {
|
|
162
|
+
type: "index-frontmatter",
|
|
163
|
+
icon: "📁",
|
|
164
|
+
schema: {},
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
const text = value.toText();
|
|
168
|
+
expect(text).toContain("---");
|
|
169
|
+
expect(text).toContain("icon: 📁");
|
|
170
|
+
expect(text).toContain("# タイトル");
|
|
171
|
+
expect(text).toContain("本文");
|
|
172
|
+
});
|
|
173
|
+
test("DocFileContentIndexValue - toMarkdownTextでbodyのみのテキストを生成", () => {
|
|
174
|
+
const value = new DocFileContentIndexValue({
|
|
175
|
+
type: "markdown-index",
|
|
176
|
+
body: "既存の本文",
|
|
177
|
+
title: "タイトル",
|
|
178
|
+
description: "説明",
|
|
179
|
+
frontMatter: {
|
|
180
|
+
type: "index-frontmatter",
|
|
181
|
+
icon: "",
|
|
182
|
+
schema: {},
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
const text = value.toMarkdownText();
|
|
186
|
+
expect(text).toBe("# タイトル\n\n説明\n\n既存の本文");
|
|
187
|
+
expect(text).not.toContain("---"); // FrontMatterは含まない
|
|
188
|
+
});
|
|
189
|
+
test("DocFileContentIndexValue - toJsonで元のデータ構造を返す", () => {
|
|
190
|
+
const data = {
|
|
191
|
+
type: "markdown-index",
|
|
192
|
+
body: "# タイトル",
|
|
193
|
+
title: "タイトル",
|
|
194
|
+
description: "説明",
|
|
195
|
+
frontMatter: {
|
|
196
|
+
type: "index-frontmatter",
|
|
197
|
+
icon: "📁",
|
|
198
|
+
schema: {},
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
const value = new DocFileContentIndexValue(data);
|
|
202
|
+
expect(value.toJson()).toEqual(data);
|
|
203
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { DocFileContentMd } from "../types";
|
|
2
|
+
import { DocFrontMatterMdValue } from "./doc-front-matter-md-value";
|
|
3
|
+
/**
|
|
4
|
+
* Markdownコンテンツ情報の値オブジェクト
|
|
5
|
+
*/
|
|
6
|
+
export declare class DocFileContentMdValue {
|
|
7
|
+
readonly value: DocFileContentMd;
|
|
8
|
+
constructor(value: DocFileContentMd);
|
|
9
|
+
/**
|
|
10
|
+
* コンテンツ本文(frontMatterを含まない)
|
|
11
|
+
*/
|
|
12
|
+
get body(): string;
|
|
13
|
+
/**
|
|
14
|
+
* タイトル
|
|
15
|
+
*/
|
|
16
|
+
get title(): string;
|
|
17
|
+
/**
|
|
18
|
+
* 説明
|
|
19
|
+
*/
|
|
20
|
+
get description(): string;
|
|
21
|
+
/**
|
|
22
|
+
* FrontMatter
|
|
23
|
+
*/
|
|
24
|
+
get frontMatter(): DocFrontMatterMdValue;
|
|
25
|
+
/**
|
|
26
|
+
* タイトルを更新
|
|
27
|
+
*/
|
|
28
|
+
withTitle(title: string): DocFileContentMdValue;
|
|
29
|
+
/**
|
|
30
|
+
* 説明を更新
|
|
31
|
+
*/
|
|
32
|
+
withDescription(description: string, defaultTitle?: string): DocFileContentMdValue;
|
|
33
|
+
/**
|
|
34
|
+
* コンテンツを更新
|
|
35
|
+
*/
|
|
36
|
+
withContent(content: string): DocFileContentMdValue;
|
|
37
|
+
/**
|
|
38
|
+
* FrontMatterを更新
|
|
39
|
+
*/
|
|
40
|
+
withFrontMatter(frontMatter: DocFrontMatterMdValue): DocFileContentMdValue;
|
|
41
|
+
/**
|
|
42
|
+
* Markdownテキストから生成
|
|
43
|
+
*/
|
|
44
|
+
static fromMarkdown(markdown: string): DocFileContentMdValue;
|
|
45
|
+
/**
|
|
46
|
+
* 完全なMarkdownテキストを生成
|
|
47
|
+
*/
|
|
48
|
+
toMarkdownText(): string;
|
|
49
|
+
/**
|
|
50
|
+
* FrontMatterとbodyを結合した完全なテキストを生成
|
|
51
|
+
*/
|
|
52
|
+
toText(): string;
|
|
53
|
+
/**
|
|
54
|
+
* 空のコンテンツを生成
|
|
55
|
+
*/
|
|
56
|
+
static empty(title: string): DocFileContentMdValue;
|
|
57
|
+
/**
|
|
58
|
+
* JSON形式で出力
|
|
59
|
+
*/
|
|
60
|
+
toJson(): DocFileContentMd;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=doc-file-content-md-value.d.ts.map
|