@interactive-inc/docs-client 0.0.6 → 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/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
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "bun:test";
|
|
2
|
-
import { DocFrontMatterMdValue } from "./doc-front-matter-md-value";
|
|
3
|
-
test("DocFrontMatterMdValue - 基本的な作成とプロパティアクセス", () => {
|
|
4
|
-
const value = new DocFrontMatterMdValue({
|
|
5
|
-
title: "ドキュメントタイトル",
|
|
6
|
-
description: "ドキュメントの説明",
|
|
7
|
-
tags: ["tag1", "tag2"],
|
|
8
|
-
author: "作者名",
|
|
9
|
-
});
|
|
10
|
-
expect(value.value.title).toBe("ドキュメントタイトル");
|
|
11
|
-
expect(value.value.description).toBe("ドキュメントの説明");
|
|
12
|
-
expect(value.value.tags).toEqual(["tag1", "tag2"]);
|
|
13
|
-
expect(value.value.author).toBe("作者名");
|
|
14
|
-
});
|
|
15
|
-
test("DocFrontMatterMdValue - 空のFrontMatter", () => {
|
|
16
|
-
const value = new DocFrontMatterMdValue({});
|
|
17
|
-
expect(value.value).toEqual({});
|
|
18
|
-
});
|
|
19
|
-
test("DocFrontMatterMdValue - 一部のフィールドのみ", () => {
|
|
20
|
-
const value = new DocFrontMatterMdValue({
|
|
21
|
-
title: "タイトルのみ",
|
|
22
|
-
});
|
|
23
|
-
expect(value.value.title).toBe("タイトルのみ");
|
|
24
|
-
expect(value.value.description).toBeUndefined();
|
|
25
|
-
expect(value.value.tags).toBeUndefined();
|
|
26
|
-
});
|
|
27
|
-
test("DocFrontMatterMdValue - toYamlでYAML文字列を生成", () => {
|
|
28
|
-
const value = new DocFrontMatterMdValue({
|
|
29
|
-
title: "タイトル",
|
|
30
|
-
tags: ["tag1", "tag2"],
|
|
31
|
-
});
|
|
32
|
-
const yaml = value.toYaml();
|
|
33
|
-
expect(yaml).toContain("title: タイトル");
|
|
34
|
-
expect(yaml).toContain("tags:");
|
|
35
|
-
expect(yaml).toContain(" - tag1");
|
|
36
|
-
expect(yaml).toContain(" - tag2");
|
|
37
|
-
});
|
|
38
|
-
test("DocFrontMatterMdValue - 空のFrontMatterでtoYaml", () => {
|
|
39
|
-
const value = new DocFrontMatterMdValue({});
|
|
40
|
-
const yaml = value.toYaml();
|
|
41
|
-
expect(yaml).toBe("{}");
|
|
42
|
-
});
|
|
43
|
-
test("DocFrontMatterMdValue - 特殊文字を含む値でtoYaml", () => {
|
|
44
|
-
const value = new DocFrontMatterMdValue({
|
|
45
|
-
title: "タイトル with \"quotes\" and 'apostrophes'",
|
|
46
|
-
description: "説明文\n改行あり",
|
|
47
|
-
});
|
|
48
|
-
const yaml = value.toYaml();
|
|
49
|
-
expect(yaml).toContain("title:");
|
|
50
|
-
expect(yaml).toContain("description:");
|
|
51
|
-
// YAMLライブラリが適切にエスケープすることを確認
|
|
52
|
-
});
|
|
53
|
-
test("DocFrontMatterMdValue - toJsonで元のデータ構造を返す", () => {
|
|
54
|
-
const data = {
|
|
55
|
-
title: "タイトル",
|
|
56
|
-
tags: ["tag1"],
|
|
57
|
-
custom: "カスタムフィールド",
|
|
58
|
-
};
|
|
59
|
-
const value = new DocFrontMatterMdValue(data);
|
|
60
|
-
expect(value.toJson()).toEqual(data);
|
|
61
|
-
});
|
|
62
|
-
test("DocFrontMatterMdValue - 不変性の確認", () => {
|
|
63
|
-
const value = new DocFrontMatterMdValue({
|
|
64
|
-
title: "タイトル",
|
|
65
|
-
});
|
|
66
|
-
expect(() => {
|
|
67
|
-
// @ts-expect-error - 不変性のテスト
|
|
68
|
-
value.value = {};
|
|
69
|
-
}).toThrow();
|
|
70
|
-
});
|
|
71
|
-
test("text メソッドでテキスト型の値を取得できる", () => {
|
|
72
|
-
const frontMatter = new DocFrontMatterMdValue({
|
|
73
|
-
title: "テストタイトル",
|
|
74
|
-
description: "説明文",
|
|
75
|
-
count: 42,
|
|
76
|
-
});
|
|
77
|
-
expect(frontMatter.text("title")).toBe("テストタイトル");
|
|
78
|
-
expect(frontMatter.text("description")).toBe("説明文");
|
|
79
|
-
expect(frontMatter.text("count")).toBeNull(); // 数値型なのでnull
|
|
80
|
-
expect(frontMatter.text("missing")).toBeNull(); // 存在しないキー
|
|
81
|
-
});
|
|
82
|
-
test("number メソッドで数値型の値を取得できる", () => {
|
|
83
|
-
const frontMatter = new DocFrontMatterMdValue({
|
|
84
|
-
count: 42,
|
|
85
|
-
version: 1.5,
|
|
86
|
-
title: "テスト",
|
|
87
|
-
});
|
|
88
|
-
expect(frontMatter.number("count")).toBe(42);
|
|
89
|
-
expect(frontMatter.number("version")).toBe(1.5);
|
|
90
|
-
expect(frontMatter.number("title")).toBeNull(); // 文字列型なのでnull
|
|
91
|
-
expect(frontMatter.number("missing")).toBeNull();
|
|
92
|
-
});
|
|
93
|
-
test("boolean メソッドで真偽値型の値を取得できる", () => {
|
|
94
|
-
const frontMatter = new DocFrontMatterMdValue({
|
|
95
|
-
published: true,
|
|
96
|
-
draft: false,
|
|
97
|
-
title: "テスト",
|
|
98
|
-
});
|
|
99
|
-
expect(frontMatter.boolean("published")).toBe(true);
|
|
100
|
-
expect(frontMatter.boolean("draft")).toBe(false);
|
|
101
|
-
expect(frontMatter.boolean("title")).toBeNull();
|
|
102
|
-
expect(frontMatter.boolean("missing")).toBeNull();
|
|
103
|
-
});
|
|
104
|
-
test("relation メソッドで単一リレーションを取得できる", () => {
|
|
105
|
-
const frontMatter = new DocFrontMatterMdValue({
|
|
106
|
-
author: "user-123",
|
|
107
|
-
category: "tech",
|
|
108
|
-
tags: ["tag1", "tag2"],
|
|
109
|
-
});
|
|
110
|
-
expect(frontMatter.relation("author")).toBe("user-123");
|
|
111
|
-
expect(frontMatter.relation("category")).toBe("tech");
|
|
112
|
-
expect(frontMatter.relation("tags")).toBeNull(); // 配列なのでnull
|
|
113
|
-
expect(frontMatter.relation("missing")).toBeNull();
|
|
114
|
-
});
|
|
115
|
-
test("multiRelation メソッドで複数リレーションを取得できる", () => {
|
|
116
|
-
const frontMatter = new DocFrontMatterMdValue({
|
|
117
|
-
features: ["login", "logout", "signup"],
|
|
118
|
-
tags: ["tech", "tutorial"],
|
|
119
|
-
single: "value",
|
|
120
|
-
});
|
|
121
|
-
expect(frontMatter.multiRelation("features")).toEqual([
|
|
122
|
-
"login",
|
|
123
|
-
"logout",
|
|
124
|
-
"signup",
|
|
125
|
-
]);
|
|
126
|
-
expect(frontMatter.multiRelation("tags")).toEqual(["tech", "tutorial"]);
|
|
127
|
-
expect(frontMatter.multiRelation("single")).toEqual([]); // 単一値なので空配列
|
|
128
|
-
expect(frontMatter.multiRelation("missing")).toEqual([]);
|
|
129
|
-
});
|
|
130
|
-
test("multiText メソッドで複数テキストを取得できる", () => {
|
|
131
|
-
const frontMatter = new DocFrontMatterMdValue({
|
|
132
|
-
keywords: ["typescript", "javascript", "nodejs"],
|
|
133
|
-
authors: ["alice", "bob"],
|
|
134
|
-
});
|
|
135
|
-
expect(frontMatter.multiText("keywords")).toEqual([
|
|
136
|
-
"typescript",
|
|
137
|
-
"javascript",
|
|
138
|
-
"nodejs",
|
|
139
|
-
]);
|
|
140
|
-
expect(frontMatter.multiText("authors")).toEqual(["alice", "bob"]);
|
|
141
|
-
expect(frontMatter.multiText("missing")).toEqual([]);
|
|
142
|
-
});
|
|
143
|
-
test("multiNumber メソッドで複数数値を取得できる", () => {
|
|
144
|
-
const frontMatter = new DocFrontMatterMdValue({
|
|
145
|
-
scores: [85, 90, 78],
|
|
146
|
-
versions: [1.0, 1.1, 2.0],
|
|
147
|
-
});
|
|
148
|
-
expect(frontMatter.multiNumber("scores")).toEqual([85, 90, 78]);
|
|
149
|
-
expect(frontMatter.multiNumber("versions")).toEqual([1.0, 1.1, 2.0]);
|
|
150
|
-
expect(frontMatter.multiNumber("missing")).toEqual([]);
|
|
151
|
-
});
|
|
152
|
-
test("multiBoolean メソッドで複数真偽値を取得できる", () => {
|
|
153
|
-
const frontMatter = new DocFrontMatterMdValue({
|
|
154
|
-
flags: [true, false, true],
|
|
155
|
-
permissions: [false, false],
|
|
156
|
-
});
|
|
157
|
-
expect(frontMatter.multiBoolean("flags")).toEqual([true, false, true]);
|
|
158
|
-
expect(frontMatter.multiBoolean("permissions")).toEqual([false, false]);
|
|
159
|
-
expect(frontMatter.multiBoolean("missing")).toEqual([]);
|
|
160
|
-
});
|
|
161
|
-
test("has メソッドでプロパティの存在を確認できる", () => {
|
|
162
|
-
const frontMatter = new DocFrontMatterMdValue({
|
|
163
|
-
title: "テスト",
|
|
164
|
-
count: 0,
|
|
165
|
-
flag: false,
|
|
166
|
-
nullable: null,
|
|
167
|
-
});
|
|
168
|
-
expect(frontMatter.has("title")).toBe(true);
|
|
169
|
-
expect(frontMatter.has("count")).toBe(true);
|
|
170
|
-
expect(frontMatter.has("flag")).toBe(true);
|
|
171
|
-
expect(frontMatter.has("nullable")).toBe(true);
|
|
172
|
-
expect(frontMatter.has("missing")).toBe(false);
|
|
173
|
-
});
|
|
174
|
-
test("keys ゲッターですべてのキーを取得できる", () => {
|
|
175
|
-
const frontMatter = new DocFrontMatterMdValue({
|
|
176
|
-
title: "テスト",
|
|
177
|
-
version: 1.0,
|
|
178
|
-
published: true,
|
|
179
|
-
});
|
|
180
|
-
const keys = frontMatter.keys;
|
|
181
|
-
expect(keys).toHaveLength(3);
|
|
182
|
-
expect(keys).toContain("title");
|
|
183
|
-
expect(keys).toContain("version");
|
|
184
|
-
expect(keys).toContain("published");
|
|
185
|
-
});
|
|
186
|
-
test("空のFrontMatterでも正常に動作する", () => {
|
|
187
|
-
const frontMatter = DocFrontMatterMdValue.empty();
|
|
188
|
-
expect(frontMatter.text("any")).toBeNull();
|
|
189
|
-
expect(frontMatter.number("any")).toBeNull();
|
|
190
|
-
expect(frontMatter.boolean("any")).toBeNull();
|
|
191
|
-
expect(frontMatter.relation("any")).toBeNull();
|
|
192
|
-
expect(frontMatter.multiRelation("any")).toEqual([]);
|
|
193
|
-
expect(frontMatter.multiText("any")).toEqual([]);
|
|
194
|
-
expect(frontMatter.multiNumber("any")).toEqual([]);
|
|
195
|
-
expect(frontMatter.multiBoolean("any")).toEqual([]);
|
|
196
|
-
expect(frontMatter.has("any")).toBe(false);
|
|
197
|
-
expect(frontMatter.keys).toEqual([]);
|
|
198
|
-
});
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { DocRelationField } from "../types";
|
|
2
|
-
/**
|
|
3
|
-
* リレーションフィールド
|
|
4
|
-
*/
|
|
5
|
-
export declare class DocRelationFieldValue {
|
|
6
|
-
private readonly value;
|
|
7
|
-
constructor(value: DocRelationField);
|
|
8
|
-
/**
|
|
9
|
-
* フィールド名を取得
|
|
10
|
-
*/
|
|
11
|
-
get fieldName(): string;
|
|
12
|
-
/**
|
|
13
|
-
* リレーション先のパスを取得
|
|
14
|
-
*/
|
|
15
|
-
get relationPath(): string;
|
|
16
|
-
/**
|
|
17
|
-
* 配列型かどうかを取得
|
|
18
|
-
*/
|
|
19
|
-
get isArray(): boolean;
|
|
20
|
-
/**
|
|
21
|
-
* 単一リレーションかどうかを判定
|
|
22
|
-
*/
|
|
23
|
-
get isSingle(): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* 複数リレーションかどうかを判定
|
|
26
|
-
*/
|
|
27
|
-
get isMultiple(): boolean;
|
|
28
|
-
/**
|
|
29
|
-
* リレーション先のディレクトリ名を取得
|
|
30
|
-
*/
|
|
31
|
-
get targetDirectoryName(): string;
|
|
32
|
-
/**
|
|
33
|
-
* 完全なリレーションパスを生成
|
|
34
|
-
*/
|
|
35
|
-
getFullPath(basePath: string): string;
|
|
36
|
-
/**
|
|
37
|
-
* 等価性の判定
|
|
38
|
-
*/
|
|
39
|
-
equals(other: DocRelationFieldValue): boolean;
|
|
40
|
-
/**
|
|
41
|
-
* データから生成
|
|
42
|
-
*/
|
|
43
|
-
static from(data: unknown): DocRelationFieldValue;
|
|
44
|
-
/**
|
|
45
|
-
* プロパティから生成
|
|
46
|
-
*/
|
|
47
|
-
static fromProps(props: {
|
|
48
|
-
fieldName: string;
|
|
49
|
-
filePath: string;
|
|
50
|
-
isArray: boolean;
|
|
51
|
-
}): DocRelationFieldValue;
|
|
52
|
-
/**
|
|
53
|
-
* JSON形式に変換
|
|
54
|
-
*/
|
|
55
|
-
toJson(): DocRelationField;
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=doc-relation-field-value.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"doc-relation-field-value.d.ts","sourceRoot":"","sources":["../../lib/values/doc-relation-field-value.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAEhD;;GAEG;AACH,qBAAa,qBAAqB;IACpB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAAlC,YAA6B,KAAK,EAAE,gBAAgB,EAGnD;IAED;;OAEG;IACH,IAAI,SAAS,WAEZ;IAED;;OAEG;IACH,IAAI,YAAY,WAEf;IAED;;OAEG;IACH,IAAI,OAAO,YAEV;IAED;;OAEG;IACH,IAAI,QAAQ,YAEX;IAED;;OAEG;IACH,IAAI,UAAU,YAEb;IAED;;OAEG;IACH,IAAI,mBAAmB,WAGtB;IAED;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKpC;IAED;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAM5C;IAED;;OAEG;IACH,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,qBAAqB,CAGhD;IAED;;OAEG;IACH,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE;QACtB,SAAS,EAAE,MAAM,CAAA;QACjB,QAAQ,EAAE,MAAM,CAAA;QAChB,OAAO,EAAE,OAAO,CAAA;KACjB,GAAG,qBAAqB,CAExB;IAED;;OAEG;IACH,MAAM,IAAI,gBAAgB,CAEzB;CACF"}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { zDocRelationField } from "../models";
|
|
2
|
-
/**
|
|
3
|
-
* リレーションフィールド
|
|
4
|
-
*/
|
|
5
|
-
export class DocRelationFieldValue {
|
|
6
|
-
value;
|
|
7
|
-
constructor(value) {
|
|
8
|
-
this.value = value;
|
|
9
|
-
zDocRelationField.parse(value);
|
|
10
|
-
Object.freeze(this);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* フィールド名を取得
|
|
14
|
-
*/
|
|
15
|
-
get fieldName() {
|
|
16
|
-
return this.value.fieldName;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* リレーション先のパスを取得
|
|
20
|
-
*/
|
|
21
|
-
get relationPath() {
|
|
22
|
-
return this.value.filePath;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* 配列型かどうかを取得
|
|
26
|
-
*/
|
|
27
|
-
get isArray() {
|
|
28
|
-
return this.value.isArray;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* 単一リレーションかどうかを判定
|
|
32
|
-
*/
|
|
33
|
-
get isSingle() {
|
|
34
|
-
return !this.value.isArray;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* 複数リレーションかどうかを判定
|
|
38
|
-
*/
|
|
39
|
-
get isMultiple() {
|
|
40
|
-
return this.value.isArray;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* リレーション先のディレクトリ名を取得
|
|
44
|
-
*/
|
|
45
|
-
get targetDirectoryName() {
|
|
46
|
-
const parts = this.value.filePath.split("/");
|
|
47
|
-
return parts[parts.length - 1] || "";
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* 完全なリレーションパスを生成
|
|
51
|
-
*/
|
|
52
|
-
getFullPath(basePath) {
|
|
53
|
-
if (this.value.filePath.startsWith("/")) {
|
|
54
|
-
return this.value.filePath;
|
|
55
|
-
}
|
|
56
|
-
return `${basePath}/${this.value.filePath}`;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* 等価性の判定
|
|
60
|
-
*/
|
|
61
|
-
equals(other) {
|
|
62
|
-
return (this.fieldName === other.fieldName &&
|
|
63
|
-
this.relationPath === other.relationPath &&
|
|
64
|
-
this.isArray === other.isArray);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* データから生成
|
|
68
|
-
*/
|
|
69
|
-
static from(data) {
|
|
70
|
-
const validated = zDocRelationField.parse(data);
|
|
71
|
-
return new DocRelationFieldValue(validated);
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* プロパティから生成
|
|
75
|
-
*/
|
|
76
|
-
static fromProps(props) {
|
|
77
|
-
return new DocRelationFieldValue(props);
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* JSON形式に変換
|
|
81
|
-
*/
|
|
82
|
-
toJson() {
|
|
83
|
-
return { ...this.value };
|
|
84
|
-
}
|
|
85
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"doc-relation-field-value.test.d.ts","sourceRoot":"","sources":["../../lib/values/doc-relation-field-value.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "bun:test";
|
|
2
|
-
import { DocRelationFieldValue } from "./doc-relation-field-value";
|
|
3
|
-
test("リレーションフィールドの基本プロパティを取得できる", () => {
|
|
4
|
-
const field = new DocRelationFieldValue({
|
|
5
|
-
fieldName: "author",
|
|
6
|
-
filePath: "users/authors",
|
|
7
|
-
isArray: false,
|
|
8
|
-
});
|
|
9
|
-
expect(field.fieldName).toBe("author");
|
|
10
|
-
expect(field.relationPath).toBe("users/authors");
|
|
11
|
-
expect(field.isArray).toBe(false);
|
|
12
|
-
expect(field.isSingle).toBe(true);
|
|
13
|
-
expect(field.isMultiple).toBe(false);
|
|
14
|
-
});
|
|
15
|
-
test("配列型のリレーションフィールドを作成できる", () => {
|
|
16
|
-
const field = new DocRelationFieldValue({
|
|
17
|
-
fieldName: "tags",
|
|
18
|
-
filePath: "metadata/tags",
|
|
19
|
-
isArray: true,
|
|
20
|
-
});
|
|
21
|
-
expect(field.isArray).toBe(true);
|
|
22
|
-
expect(field.isSingle).toBe(false);
|
|
23
|
-
expect(field.isMultiple).toBe(true);
|
|
24
|
-
});
|
|
25
|
-
test("ターゲットディレクトリ名を取得できる", () => {
|
|
26
|
-
const field = new DocRelationFieldValue({
|
|
27
|
-
fieldName: "category",
|
|
28
|
-
filePath: "products/categories",
|
|
29
|
-
isArray: false,
|
|
30
|
-
});
|
|
31
|
-
expect(field.targetDirectoryName).toBe("categories");
|
|
32
|
-
});
|
|
33
|
-
test("空のパスの場合、空のディレクトリ名を返す", () => {
|
|
34
|
-
const field = new DocRelationFieldValue({
|
|
35
|
-
fieldName: "empty",
|
|
36
|
-
filePath: "",
|
|
37
|
-
isArray: false,
|
|
38
|
-
});
|
|
39
|
-
expect(field.targetDirectoryName).toBe("");
|
|
40
|
-
});
|
|
41
|
-
test("完全なリレーションパスを生成できる", () => {
|
|
42
|
-
const field = new DocRelationFieldValue({
|
|
43
|
-
fieldName: "author",
|
|
44
|
-
filePath: "users/authors",
|
|
45
|
-
isArray: false,
|
|
46
|
-
});
|
|
47
|
-
expect(field.getFullPath("/docs")).toBe("/docs/users/authors");
|
|
48
|
-
});
|
|
49
|
-
test("絶対パスの場合はそのまま返す", () => {
|
|
50
|
-
const field = new DocRelationFieldValue({
|
|
51
|
-
fieldName: "author",
|
|
52
|
-
filePath: "/users/authors",
|
|
53
|
-
isArray: false,
|
|
54
|
-
});
|
|
55
|
-
expect(field.getFullPath("/docs")).toBe("/users/authors");
|
|
56
|
-
});
|
|
57
|
-
test("等価性を判定できる", () => {
|
|
58
|
-
const field1 = new DocRelationFieldValue({
|
|
59
|
-
fieldName: "author",
|
|
60
|
-
filePath: "users/authors",
|
|
61
|
-
isArray: false,
|
|
62
|
-
});
|
|
63
|
-
const field2 = new DocRelationFieldValue({
|
|
64
|
-
fieldName: "author",
|
|
65
|
-
filePath: "users/authors",
|
|
66
|
-
isArray: false,
|
|
67
|
-
});
|
|
68
|
-
const field3 = new DocRelationFieldValue({
|
|
69
|
-
fieldName: "author",
|
|
70
|
-
filePath: "users/authors",
|
|
71
|
-
isArray: true,
|
|
72
|
-
});
|
|
73
|
-
expect(field1.equals(field2)).toBe(true);
|
|
74
|
-
expect(field1.equals(field3)).toBe(false);
|
|
75
|
-
});
|
|
76
|
-
test("fromメソッドでインスタンスを生成できる", () => {
|
|
77
|
-
const field = DocRelationFieldValue.from({
|
|
78
|
-
fieldName: "author",
|
|
79
|
-
filePath: "users/authors",
|
|
80
|
-
isArray: false,
|
|
81
|
-
});
|
|
82
|
-
expect(field.fieldName).toBe("author");
|
|
83
|
-
expect(field.relationPath).toBe("users/authors");
|
|
84
|
-
});
|
|
85
|
-
test("fromPropsメソッドでインスタンスを生成できる", () => {
|
|
86
|
-
const field = DocRelationFieldValue.fromProps({
|
|
87
|
-
fieldName: "tags",
|
|
88
|
-
filePath: "metadata/tags",
|
|
89
|
-
isArray: true,
|
|
90
|
-
});
|
|
91
|
-
expect(field.fieldName).toBe("tags");
|
|
92
|
-
expect(field.isArray).toBe(true);
|
|
93
|
-
});
|
|
94
|
-
test("JSON形式に変換できる", () => {
|
|
95
|
-
const field = new DocRelationFieldValue({
|
|
96
|
-
fieldName: "author",
|
|
97
|
-
filePath: "users/authors",
|
|
98
|
-
isArray: false,
|
|
99
|
-
});
|
|
100
|
-
const json = field.toJson();
|
|
101
|
-
expect(json).toEqual({
|
|
102
|
-
fieldName: "author",
|
|
103
|
-
filePath: "users/authors",
|
|
104
|
-
isArray: false,
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
test("無効なデータでエラーが発生する", () => {
|
|
108
|
-
expect(() => {
|
|
109
|
-
new DocRelationFieldValue({
|
|
110
|
-
fieldName: "",
|
|
111
|
-
filePath: "users/authors",
|
|
112
|
-
isArray: "not-boolean",
|
|
113
|
-
});
|
|
114
|
-
}).toThrow();
|
|
115
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { DocRelationFile } from "../types";
|
|
2
|
-
/**
|
|
3
|
-
* リレーションファイル
|
|
4
|
-
*/
|
|
5
|
-
export declare class DocRelationFileValue {
|
|
6
|
-
private readonly value;
|
|
7
|
-
constructor(value: DocRelationFile);
|
|
8
|
-
/**
|
|
9
|
-
* ファイルパス
|
|
10
|
-
*/
|
|
11
|
-
get id(): string;
|
|
12
|
-
/**
|
|
13
|
-
* スラッグ
|
|
14
|
-
*/
|
|
15
|
-
get slug(): string;
|
|
16
|
-
/**
|
|
17
|
-
* 表示用ラベル
|
|
18
|
-
*/
|
|
19
|
-
get label(): string;
|
|
20
|
-
/**
|
|
21
|
-
* ファイルパスとタイトルから生成
|
|
22
|
-
*/
|
|
23
|
-
static from(filePath: string, title: string | null): DocRelationFileValue;
|
|
24
|
-
/**
|
|
25
|
-
* ファイルパスからファイル名を抽出(拡張子なし)
|
|
26
|
-
*/
|
|
27
|
-
private static extractFileName;
|
|
28
|
-
/**
|
|
29
|
-
* JSON形式に変換
|
|
30
|
-
*/
|
|
31
|
-
toJson(): DocRelationFile;
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=doc-relation-file-value.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"doc-relation-file-value.d.ts","sourceRoot":"","sources":["../../lib/values/doc-relation-file-value.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C;;GAEG;AACH,qBAAa,oBAAoB;IACnB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAAlC,YAA6B,KAAK,EAAE,eAAe,EAIlD;IAED;;OAEG;IACH,IAAI,EAAE,WAEL;IAED;;OAEG;IACH,IAAI,IAAI,WAEP;IAED;;OAEG;IACH,IAAI,KAAK,WAER;IAED;;OAEG;IACH,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,oBAAoB,CAQxE;IAED;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;IAI9B;;OAEG;IACH,MAAM,IAAI,eAAe,CAExB;CACF"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { zDocRelationFile } from "../models";
|
|
2
|
-
/**
|
|
3
|
-
* リレーションファイル
|
|
4
|
-
*/
|
|
5
|
-
export class DocRelationFileValue {
|
|
6
|
-
value;
|
|
7
|
-
constructor(value) {
|
|
8
|
-
this.value = value;
|
|
9
|
-
zDocRelationFile.parse(value);
|
|
10
|
-
Object.freeze(this);
|
|
11
|
-
Object.freeze(this.value);
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* ファイルパス
|
|
15
|
-
*/
|
|
16
|
-
get id() {
|
|
17
|
-
return this.value.name;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* スラッグ
|
|
21
|
-
*/
|
|
22
|
-
get slug() {
|
|
23
|
-
return this.value.name;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* 表示用ラベル
|
|
27
|
-
*/
|
|
28
|
-
get label() {
|
|
29
|
-
return this.value.label || this.value.name;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* ファイルパスとタイトルから生成
|
|
33
|
-
*/
|
|
34
|
-
static from(filePath, title) {
|
|
35
|
-
const fileName = DocRelationFileValue.extractFileName(filePath);
|
|
36
|
-
return new DocRelationFileValue({
|
|
37
|
-
name: fileName,
|
|
38
|
-
label: title || fileName,
|
|
39
|
-
value: null,
|
|
40
|
-
path: null,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* ファイルパスからファイル名を抽出(拡張子なし)
|
|
45
|
-
*/
|
|
46
|
-
static extractFileName(filePath) {
|
|
47
|
-
return filePath.split("/").pop()?.replace(".md", "") || filePath;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* JSON形式に変換
|
|
51
|
-
*/
|
|
52
|
-
toJson() {
|
|
53
|
-
return { ...this.value };
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"doc-relation-file-value.test.d.ts","sourceRoot":"","sources":["../../lib/values/doc-relation-file-value.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "bun:test";
|
|
2
|
-
import { DocRelationFileValue } from "./doc-relation-file-value";
|
|
3
|
-
test("リレーションファイルの基本プロパティを取得できる", () => {
|
|
4
|
-
const file = new DocRelationFileValue({
|
|
5
|
-
name: "user-001",
|
|
6
|
-
label: "田中太郎",
|
|
7
|
-
value: null,
|
|
8
|
-
path: null,
|
|
9
|
-
});
|
|
10
|
-
expect(file.id).toBe("user-001");
|
|
11
|
-
expect(file.slug).toBe("user-001");
|
|
12
|
-
expect(file.label).toBe("田中太郎");
|
|
13
|
-
});
|
|
14
|
-
test("ラベルが未指定の場合はnameを使用する", () => {
|
|
15
|
-
const file = new DocRelationFileValue({
|
|
16
|
-
name: "category-tech",
|
|
17
|
-
label: null,
|
|
18
|
-
value: null,
|
|
19
|
-
path: null,
|
|
20
|
-
});
|
|
21
|
-
expect(file.label).toBe("category-tech");
|
|
22
|
-
});
|
|
23
|
-
test("fromメソッドでファイルパスとタイトルから生成できる", () => {
|
|
24
|
-
const file = DocRelationFileValue.from("docs/users/tanaka.md", "田中太郎");
|
|
25
|
-
expect(file.id).toBe("tanaka");
|
|
26
|
-
expect(file.label).toBe("田中太郎");
|
|
27
|
-
});
|
|
28
|
-
test("fromメソッドでタイトルがnullの場合はファイル名を使用する", () => {
|
|
29
|
-
const file = DocRelationFileValue.from("docs/categories/technology.md", null);
|
|
30
|
-
expect(file.id).toBe("technology");
|
|
31
|
-
expect(file.label).toBe("technology");
|
|
32
|
-
});
|
|
33
|
-
test("深いディレクトリ構造からもファイル名を抽出できる", () => {
|
|
34
|
-
const file = DocRelationFileValue.from("docs/products/client/features/login.md", "ログイン機能");
|
|
35
|
-
expect(file.id).toBe("login");
|
|
36
|
-
expect(file.label).toBe("ログイン機能");
|
|
37
|
-
});
|
|
38
|
-
test("拡張子なしのファイルパスも処理できる", () => {
|
|
39
|
-
const file = DocRelationFileValue.from("docs/users/admin", "管理者");
|
|
40
|
-
expect(file.id).toBe("admin");
|
|
41
|
-
expect(file.label).toBe("管理者");
|
|
42
|
-
});
|
|
43
|
-
test("ファイル名のみのパスも処理できる", () => {
|
|
44
|
-
const file = DocRelationFileValue.from("config.md", "設定");
|
|
45
|
-
expect(file.id).toBe("config");
|
|
46
|
-
expect(file.label).toBe("設定");
|
|
47
|
-
});
|
|
48
|
-
test("空のファイルパスの場合は元のパスを返す", () => {
|
|
49
|
-
const file = DocRelationFileValue.from("", "ラベル");
|
|
50
|
-
expect(file.id).toBe("");
|
|
51
|
-
expect(file.label).toBe("ラベル");
|
|
52
|
-
});
|
|
53
|
-
test("JSON形式に変換できる", () => {
|
|
54
|
-
const file = new DocRelationFileValue({
|
|
55
|
-
name: "feature-001",
|
|
56
|
-
label: "ログイン機能",
|
|
57
|
-
value: null,
|
|
58
|
-
path: null,
|
|
59
|
-
});
|
|
60
|
-
const json = file.toJson();
|
|
61
|
-
expect(json).toEqual({
|
|
62
|
-
name: "feature-001",
|
|
63
|
-
label: "ログイン機能",
|
|
64
|
-
value: null,
|
|
65
|
-
path: null,
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
test("無効なデータでエラーが発生する", () => {
|
|
69
|
-
expect(() => {
|
|
70
|
-
new DocRelationFileValue({
|
|
71
|
-
name: 123,
|
|
72
|
-
label: "ラベル",
|
|
73
|
-
value: null,
|
|
74
|
-
path: null,
|
|
75
|
-
});
|
|
76
|
-
}).toThrow();
|
|
77
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { DocRelation } from "../types";
|
|
2
|
-
import { DocRelationFileValue } from "./doc-relation-file-value";
|
|
3
|
-
/**
|
|
4
|
-
* リレーション情報を管理する
|
|
5
|
-
*/
|
|
6
|
-
export declare class DocRelationValue {
|
|
7
|
-
readonly value: DocRelation;
|
|
8
|
-
constructor(value: DocRelation);
|
|
9
|
-
/**
|
|
10
|
-
* リレーションパス
|
|
11
|
-
*/
|
|
12
|
-
get path(): string;
|
|
13
|
-
/**
|
|
14
|
-
* リレーション対象ファイル一覧(値オブジェクト)
|
|
15
|
-
*/
|
|
16
|
-
get files(): DocRelationFileValue[];
|
|
17
|
-
/**
|
|
18
|
-
* ファイル数を取得
|
|
19
|
-
*/
|
|
20
|
-
get fileCount(): number;
|
|
21
|
-
/**
|
|
22
|
-
* 空かどうか
|
|
23
|
-
*/
|
|
24
|
-
get isEmpty(): boolean;
|
|
25
|
-
/**
|
|
26
|
-
* 空のリレーションエンティティを作成
|
|
27
|
-
*/
|
|
28
|
-
static empty(path: string): DocRelationValue;
|
|
29
|
-
/**
|
|
30
|
-
* JSON形式で出力
|
|
31
|
-
*/
|
|
32
|
-
toJson(): DocRelation;
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=doc-relation-value.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"doc-relation-value.d.ts","sourceRoot":"","sources":["../../lib/values/doc-relation-value.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAEhE;;GAEG;AACH,qBAAa,gBAAgB;IACf,QAAQ,CAAC,KAAK,EAAE,WAAW;IAAvC,YAAqB,KAAK,EAAE,WAAW,EAItC;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,oBAAoB,EAAE,CAElC;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,OAAO,CAErB;IAED;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAK3C;IAED;;OAEG;IACH,MAAM,IAAI,WAAW,CAKpB;CACF"}
|