agentic-domain-document 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/.tbls.yml +201 -0
  2. package/CHANGELOG.md +68 -0
  3. package/README.md +313 -0
  4. package/agent/agent.manifest.json +8 -0
  5. package/agent/capabilities/document-authoring.json +21 -0
  6. package/agent/capabilities/document-block.json +22 -0
  7. package/agent/capabilities/document-toc.json +21 -0
  8. package/agent/capabilities/document-validation.json +21 -0
  9. package/agent/examples/document-quality-examples.md +153 -0
  10. package/agent/examples/examples.md +172 -0
  11. package/agent/guides/10-document-authoring-guide.md +28 -0
  12. package/agent/guides/20-domain-boundary-guide.md +41 -0
  13. package/agent/guides/30-authoring-policy-guide.md +40 -0
  14. package/agent/guides/40-toc-authoring-guide.md +73 -0
  15. package/agent/guides/50-content-block-guide.md +57 -0
  16. package/agent/guides/51-paragraph-authoring-guide.md +68 -0
  17. package/agent/guides/52-table-authoring-guide.md +73 -0
  18. package/agent/guides/53-diagram-figure-authoring-guide.md +75 -0
  19. package/agent/guides/70-korean-writing-style-guide.md +65 -0
  20. package/agent/instructions/00-runtime-behavior.md +17 -0
  21. package/agent/instructions/10-scope-and-boundary.md +27 -0
  22. package/agent/instructions/20-task-procedures.md +69 -0
  23. package/agent/instructions/30-must-and-must-not.md +34 -0
  24. package/agent/resource-index.json +185 -0
  25. package/agent/resource-selection.json +205 -0
  26. package/agent/routing.json +34 -0
  27. package/agent/sources/reference-mapping.md +53 -0
  28. package/agent/validation/document-validation-rules.md +73 -0
  29. package/dist/agent/document-agent-contribution.d.ts +15 -0
  30. package/dist/agent/document-agent-contribution.d.ts.map +1 -0
  31. package/dist/agent/document-agent-contribution.js +39 -0
  32. package/dist/agent/document-agent-contribution.js.map +1 -0
  33. package/dist/agent/index.d.ts +2 -0
  34. package/dist/agent/index.d.ts.map +1 -0
  35. package/dist/agent/index.js +2 -0
  36. package/dist/agent/index.js.map +1 -0
  37. package/dist/database.d.ts +8 -0
  38. package/dist/database.d.ts.map +1 -0
  39. package/dist/database.js +76 -0
  40. package/dist/database.js.map +1 -0
  41. package/dist/index.d.ts +15 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +14 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/markdown-importer.d.ts +14 -0
  46. package/dist/markdown-importer.d.ts.map +1 -0
  47. package/dist/markdown-importer.js +386 -0
  48. package/dist/markdown-importer.js.map +1 -0
  49. package/dist/reader.d.ts +17 -0
  50. package/dist/reader.d.ts.map +1 -0
  51. package/dist/reader.js +332 -0
  52. package/dist/reader.js.map +1 -0
  53. package/dist/repositories.d.ts +118 -0
  54. package/dist/repositories.d.ts.map +1 -0
  55. package/dist/repositories.js +388 -0
  56. package/dist/repositories.js.map +1 -0
  57. package/dist/service.d.ts +35 -0
  58. package/dist/service.d.ts.map +1 -0
  59. package/dist/service.js +327 -0
  60. package/dist/service.js.map +1 -0
  61. package/dist/types.d.ts +276 -0
  62. package/dist/types.d.ts.map +1 -0
  63. package/dist/types.js +2 -0
  64. package/dist/types.js.map +1 -0
  65. package/dist/validators.d.ts +4 -0
  66. package/dist/validators.d.ts.map +1 -0
  67. package/dist/validators.js +255 -0
  68. package/dist/validators.js.map +1 -0
  69. package/docs/build.md +55 -0
  70. package/docs/configuration.md +34 -0
  71. package/docs/delivery.md +50 -0
  72. package/docs/operations.md +50 -0
  73. package/docs/publishing.md +69 -0
  74. package/docs/schema/generated/README.md +30 -0
  75. package/docs/schema/generated/document_annotations.md +119 -0
  76. package/docs/schema/generated/document_annotations.svg +60 -0
  77. package/docs/schema/generated/document_blocks.md +97 -0
  78. package/docs/schema/generated/document_blocks.svg +60 -0
  79. package/docs/schema/generated/document_change_events.md +135 -0
  80. package/docs/schema/generated/document_change_events.svg +88 -0
  81. package/docs/schema/generated/document_code_groups.md +70 -0
  82. package/docs/schema/generated/document_code_groups.svg +52 -0
  83. package/docs/schema/generated/document_codes.md +88 -0
  84. package/docs/schema/generated/document_codes.svg +52 -0
  85. package/docs/schema/generated/document_contents.md +87 -0
  86. package/docs/schema/generated/document_contents.svg +116 -0
  87. package/docs/schema/generated/document_documents.md +126 -0
  88. package/docs/schema/generated/document_documents.svg +222 -0
  89. package/docs/schema/generated/document_node_taxonomies.md +84 -0
  90. package/docs/schema/generated/document_node_taxonomies.svg +80 -0
  91. package/docs/schema/generated/document_node_taxonomy_levels.md +91 -0
  92. package/docs/schema/generated/document_node_taxonomy_levels.svg +52 -0
  93. package/docs/schema/generated/document_nodes.md +120 -0
  94. package/docs/schema/generated/document_nodes.svg +98 -0
  95. package/docs/schema/generated/document_revisions.md +107 -0
  96. package/docs/schema/generated/document_revisions.svg +116 -0
  97. package/docs/schema/generated/document_versions.md +126 -0
  98. package/docs/schema/generated/document_versions.svg +88 -0
  99. package/docs/schema/generated/schema.json +2534 -0
  100. package/docs/schema/generated/schema.mmd +170 -0
  101. package/docs/schema/generated/schema.svg +331 -0
  102. package/docs/schema/migrations.md +40 -0
  103. package/docs/usage.md +332 -0
  104. package/docs/validation-rules.md +69 -0
  105. package/package.json +30 -0
  106. package/src/database/migrations/0001_document_base.sql +753 -0
@@ -0,0 +1,119 @@
1
+ # document_annotations
2
+
3
+ ## Description
4
+
5
+ 문서 본문 밖의 note annotation을 관리한다.
6
+
7
+ <details>
8
+ <summary><strong>Table Definition</strong></summary>
9
+
10
+ ```sql
11
+ CREATE TABLE document_annotations (
12
+ -- annotation 식별자
13
+ annotation_id CHAR(36) PRIMARY KEY
14
+ CHECK (length(annotation_id) = 36),
15
+
16
+ -- 소속 문서 식별자
17
+ document_id CHAR(36) NOT NULL
18
+ CHECK (length(document_id) = 36),
19
+
20
+ -- annotation 대상 유형
21
+ target_type_code VARCHAR(32) NOT NULL
22
+ CHECK (target_type_code IN ('document', 'node', 'content', 'block')),
23
+
24
+ -- annotation 대상 식별자
25
+ target_id CHAR(36) NOT NULL
26
+ CHECK (length(target_id) = 36),
27
+
28
+ -- annotation 유형
29
+ annotation_type_code VARCHAR(32) NOT NULL DEFAULT 'note'
30
+ CHECK (annotation_type_code = 'note'),
31
+
32
+ -- annotation 상태
33
+ status_code VARCHAR(32) NOT NULL DEFAULT 'open'
34
+ CHECK (status_code IN ('open', 'resolved')),
35
+
36
+ -- note 내용
37
+ note_text TEXT NOT NULL,
38
+
39
+ -- 작성자 유형
40
+ author_type_code VARCHAR(32) NOT NULL DEFAULT 'user'
41
+ CHECK (author_type_code IN ('user', 'agent', 'system')),
42
+
43
+ -- 작성자 식별자
44
+ author_id VARCHAR(128),
45
+
46
+ -- 작성자 표시명
47
+ author_name VARCHAR(128),
48
+
49
+ -- 해결 시각
50
+ resolved_at DATETIME,
51
+
52
+ -- 생성 시각
53
+ created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
54
+
55
+ -- 수정 시각
56
+ updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
57
+
58
+ -- 확장 메타데이터
59
+ metadata_json JSON
60
+ CHECK (metadata_json IS NULL OR json_valid(metadata_json)),
61
+
62
+ FOREIGN KEY (document_id)
63
+ REFERENCES document_documents (document_id)
64
+ ON DELETE CASCADE
65
+ )
66
+ ```
67
+
68
+ </details>
69
+
70
+ ## Columns
71
+
72
+ | Name | Type | Default | Nullable | Parents | Comment |
73
+ | -------------------- | ------------ | ----------------- | -------- | ------------------------------------------- | ---------------------- |
74
+ | annotation_id | CHAR(36) | | true | | annotation 식별자 |
75
+ | document_id | CHAR(36) | | false | [document_documents](document_documents.md) | 소속 문서 식별자 |
76
+ | target_type_code | VARCHAR(32) | | false | | annotation 대상 유형 |
77
+ | target_id | CHAR(36) | | false | | annotation 대상 식별자 |
78
+ | annotation_type_code | VARCHAR(32) | 'note' | false | | annotation 유형 |
79
+ | status_code | VARCHAR(32) | 'open' | false | | annotation 상태 |
80
+ | note_text | TEXT | | false | | note 내용 |
81
+ | author_type_code | VARCHAR(32) | 'user' | false | | 작성자 유형 |
82
+ | author_id | VARCHAR(128) | | true | | 작성자 식별자 |
83
+ | author_name | VARCHAR(128) | | true | | 작성자 표시명 |
84
+ | resolved_at | DATETIME | | true | | 해결 시각 |
85
+ | created_at | DATETIME | CURRENT_TIMESTAMP | false | | 생성 시각 |
86
+ | updated_at | DATETIME | CURRENT_TIMESTAMP | false | | 수정 시각 |
87
+ | metadata_json | JSON | | true | | 확장 메타데이터 |
88
+
89
+ ## Constraints
90
+
91
+ | Name | Type | Definition |
92
+ | --------------------------------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------- |
93
+ | annotation_id | PRIMARY KEY | PRIMARY KEY (annotation_id) |
94
+ | - (Foreign key ID: 0) | FOREIGN KEY | FOREIGN KEY (document_id) REFERENCES document_documents (document_id) ON UPDATE NO ACTION ON DELETE CASCADE MATCH NONE |
95
+ | sqlite_autoindex_document_annotations_1 | PRIMARY KEY | PRIMARY KEY (annotation_id) |
96
+ | - | CHECK | CHECK (length(annotation_id) = 36) |
97
+ | - | CHECK | CHECK (length(document_id) = 36) |
98
+ | - | CHECK | CHECK (target_type_code IN ('document', 'node', 'content', 'block')) |
99
+ | - | CHECK | CHECK (length(target_id) = 36) |
100
+ | - | CHECK | CHECK (annotation_type_code = 'note') |
101
+ | - | CHECK | CHECK (status_code IN ('open', 'resolved')) |
102
+ | - | CHECK | CHECK (author_type_code IN ('user', 'agent', 'system')) |
103
+ | - | CHECK | CHECK (metadata_json IS NULL OR json_valid(metadata_json)) |
104
+
105
+ ## Indexes
106
+
107
+ | Name | Definition |
108
+ | --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
109
+ | idx_document_annotations_status | CREATE INDEX idx_document_annotations_status<br /> ON document_annotations (document_id, status_code) |
110
+ | idx_document_annotations_target | CREATE INDEX idx_document_annotations_target<br /> ON document_annotations (document_id, target_type_code, target_id) |
111
+ | sqlite_autoindex_document_annotations_1 | PRIMARY KEY (annotation_id) |
112
+
113
+ ## Relations
114
+
115
+ ![er](document_annotations.svg)
116
+
117
+ ---
118
+
119
+ > Generated by [tbls](https://github.com/k1LoW/tbls)
@@ -0,0 +1,60 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
3
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <!-- Generated by graphviz version 12.1.2 (20240928.0832)
5
+ -->
6
+ <!-- Title: document_annotations Pages: 1 -->
7
+ <svg width="435pt" height="469pt"
8
+ viewBox="0.00 0.00 435.19 468.80" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
9
+ <g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 464.8)">
10
+ <title>document_annotations</title>
11
+ <polygon fill="white" stroke="none" points="-4,4 -4,-464.8 431.19,-464.8 431.19,4 -4,4"/>
12
+ <!-- document_annotations -->
13
+ <g id="node1" class="node">
14
+ <title>document_annotations</title>
15
+ <polygon fill="#efefef" stroke="none" points="72.35,-368.6 72.35,-414.6 354.84,-414.6 354.84,-368.6 72.35,-368.6"/>
16
+ <polygon fill="none" stroke="black" points="72.35,-368.6 72.35,-414.6 354.84,-414.6 354.84,-368.6 72.35,-368.6"/>
17
+ <text text-anchor="start" x="97.48" y="-392.4" font-family="Arial Bold" font-size="18.00">document_annotations</text>
18
+ <text text-anchor="start" x="260.45" y="-392.4" font-family="Arial" font-size="14.00">    </text>
19
+ <text text-anchor="start" x="291.57" y="-392.4" font-family="Arial" font-size="14.00" fill="#666666">[table]</text>
20
+ <text text-anchor="start" x="91.42" y="-378" font-family="Arial" font-size="14.00" fill="#333333">문서 본문 밖의 note annotation을 관리한다.</text>
21
+ <polygon fill="none" stroke="black" points="72.35,-337.8 72.35,-368.6 354.84,-368.6 354.84,-337.8 72.35,-337.8"/>
22
+ <text text-anchor="start" x="79.35" y="-350" font-family="Arial" font-size="14.00">annotation_id </text>
23
+ <text text-anchor="start" x="167.31" y="-350" font-family="Arial" font-size="14.00" fill="#666666">[CHAR(36)]</text>
24
+ <text text-anchor="start" x="239.66" y="-350" font-family="Arial" font-size="14.00"> annotation 식별자</text>
25
+ <polygon fill="none" stroke="black" points="72.35,-307 72.35,-337.8 354.84,-337.8 354.84,-307 72.35,-307"/>
26
+ <text text-anchor="start" x="79.35" y="-319.2" font-family="Arial" font-size="14.00">document_id </text>
27
+ <text text-anchor="start" x="163.4" y="-319.2" font-family="Arial" font-size="14.00" fill="#666666">[CHAR(36)]</text>
28
+ <text text-anchor="start" x="235.75" y="-319.2" font-family="Arial" font-size="14.00"> 소속 문서 식별자</text>
29
+ <polygon fill="none" stroke="black" stroke-width="3" points="70.85,-305.5 70.85,-416.1 356.34,-416.1 356.34,-305.5 70.85,-305.5"/>
30
+ </g>
31
+ <!-- document_documents -->
32
+ <g id="node2" class="node">
33
+ <title>document_documents</title>
34
+ <polygon fill="#efefef" stroke="none" points="43.2,-135.6 43.2,-181.6 383.99,-181.6 383.99,-135.6 43.2,-135.6"/>
35
+ <polygon fill="none" stroke="black" points="43.2,-135.6 43.2,-181.6 383.99,-181.6 383.99,-135.6 43.2,-135.6"/>
36
+ <text text-anchor="start" x="99.98" y="-159.4" font-family="Arial Bold" font-size="18.00">document_documents</text>
37
+ <text text-anchor="start" x="257.95" y="-159.4" font-family="Arial" font-size="14.00">    </text>
38
+ <text text-anchor="start" x="289.07" y="-159.4" font-family="Arial" font-size="14.00" fill="#666666">[table]</text>
39
+ <text text-anchor="start" x="52.94" y="-145" font-family="Arial" font-size="14.00" fill="#333333">문서 단위 메타데이터, 작성자, taxonomy, 상태를 관리한다.</text>
40
+ <polygon fill="none" stroke="black" points="43.2,-104.8 43.2,-135.6 383.99,-135.6 383.99,-104.8 43.2,-104.8"/>
41
+ <text text-anchor="start" x="50.2" y="-117" font-family="Arial" font-size="14.00">document_id </text>
42
+ <text text-anchor="start" x="134.25" y="-117" font-family="Arial" font-size="14.00" fill="#666666">[CHAR(36)]</text>
43
+ <text text-anchor="start" x="206.6" y="-117" font-family="Arial" font-size="14.00"> 문서 식별자</text>
44
+ <polygon fill="none" stroke="black" points="43.2,-74 43.2,-104.8 383.99,-104.8 383.99,-74 43.2,-74"/>
45
+ <text text-anchor="start" x="50.2" y="-86.2" font-family="Arial" font-size="14.00">taxonomy_id </text>
46
+ <text text-anchor="start" x="133.47" y="-86.2" font-family="Arial" font-size="14.00" fill="#666666">[CHAR(36)]</text>
47
+ <text text-anchor="start" x="205.81" y="-86.2" font-family="Arial" font-size="14.00"> 적용 taxonomy 식별자</text>
48
+ <polygon fill="none" stroke="black" points="43.2,-43.2 43.2,-74 383.99,-74 383.99,-43.2 43.2,-43.2"/>
49
+ <text text-anchor="start" x="50.2" y="-55.4" font-family="Arial" font-size="14.00">source_document_id </text>
50
+ <text text-anchor="start" x="184.06" y="-55.4" font-family="Arial" font-size="14.00" fill="#666666">[CHAR(36)]</text>
51
+ <text text-anchor="start" x="256.41" y="-55.4" font-family="Arial" font-size="14.00"> 파생 원본 문서 식별자</text>
52
+ </g>
53
+ <!-- document_annotations&#45;&gt;document_documents -->
54
+ <g id="edge1" class="edge">
55
+ <title>document_annotations:document_id&#45;&gt;document_documents:document_id</title>
56
+ <path fill="none" stroke="black" d="M214.33,-295.62C224.69,-228.42 340.9,-292.35 383.99,-224.8 408.99,-185.6 431.48,-120.2 384.99,-120.2"/>
57
+ <polygon fill="black" stroke="black" points="214.33,-295.69 209.13,-305.35 213.95,-301.01 213.64,-305.33 213.64,-305.33 213.64,-305.33 213.95,-301.01 218.1,-305.99 214.33,-295.69"/>
58
+ </g>
59
+ </g>
60
+ </svg>
@@ -0,0 +1,97 @@
1
+ # document_blocks
2
+
3
+ ## Description
4
+
5
+ 문서 본문 표현 block을 관리한다.
6
+
7
+ <details>
8
+ <summary><strong>Table Definition</strong></summary>
9
+
10
+ ```sql
11
+ CREATE TABLE document_blocks (
12
+ -- block 식별자
13
+ block_id CHAR(36) PRIMARY KEY
14
+ CHECK (length(block_id) = 36),
15
+
16
+ -- 소속 content 식별자
17
+ content_id CHAR(36) NOT NULL
18
+ CHECK (length(content_id) = 36),
19
+
20
+ -- block 유형 코드
21
+ block_type_code VARCHAR(32) NOT NULL,
22
+
23
+ -- content 안에서의 순서
24
+ sort_order INTEGER NOT NULL DEFAULT 0,
25
+
26
+ -- 텍스트 중심 block 본문
27
+ content_text TEXT,
28
+
29
+ -- 구조형 block payload
30
+ content_json JSON
31
+ CHECK (content_json IS NULL OR json_valid(content_json)),
32
+
33
+ -- 생성 시각
34
+ created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
35
+
36
+ -- 수정 시각
37
+ updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
38
+
39
+ -- 확장 메타데이터
40
+ metadata_json JSON
41
+ CHECK (metadata_json IS NULL OR json_valid(metadata_json)),
42
+
43
+ FOREIGN KEY (content_id)
44
+ REFERENCES document_contents (content_id)
45
+ ON DELETE CASCADE,
46
+
47
+ UNIQUE (content_id, sort_order),
48
+
49
+ CHECK (content_text IS NOT NULL OR content_json IS NOT NULL)
50
+ )
51
+ ```
52
+
53
+ </details>
54
+
55
+ ## Columns
56
+
57
+ | Name | Type | Default | Nullable | Parents | Comment |
58
+ | --------------- | ----------- | ----------------- | -------- | ----------------------------------------- | ---------------------- |
59
+ | block_id | CHAR(36) | | true | | block 식별자 |
60
+ | content_id | CHAR(36) | | false | [document_contents](document_contents.md) | 소속 content 식별자 |
61
+ | block_type_code | VARCHAR(32) | | false | | block 유형 코드 |
62
+ | sort_order | INTEGER | 0 | false | | content 안에서의 순서 |
63
+ | content_text | TEXT | | true | | 텍스트 중심 block 본문 |
64
+ | content_json | JSON | | true | | 구조형 block payload |
65
+ | created_at | DATETIME | CURRENT_TIMESTAMP | false | | 생성 시각 |
66
+ | updated_at | DATETIME | CURRENT_TIMESTAMP | false | | 수정 시각 |
67
+ | metadata_json | JSON | | true | | 확장 메타데이터 |
68
+
69
+ ## Constraints
70
+
71
+ | Name | Type | Definition |
72
+ | ---------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------- |
73
+ | block_id | PRIMARY KEY | PRIMARY KEY (block_id) |
74
+ | - (Foreign key ID: 0) | FOREIGN KEY | FOREIGN KEY (content_id) REFERENCES document_contents (content_id) ON UPDATE NO ACTION ON DELETE CASCADE MATCH NONE |
75
+ | sqlite_autoindex_document_blocks_2 | UNIQUE | UNIQUE (content_id, sort_order) |
76
+ | sqlite_autoindex_document_blocks_1 | PRIMARY KEY | PRIMARY KEY (block_id) |
77
+ | - | CHECK | CHECK (length(block_id) = 36) |
78
+ | - | CHECK | CHECK (length(content_id) = 36) |
79
+ | - | CHECK | CHECK (content_json IS NULL OR json_valid(content_json)) |
80
+ | - | CHECK | CHECK (metadata_json IS NULL OR json_valid(metadata_json)) |
81
+ | - | CHECK | CHECK (content_text IS NOT NULL OR content_json IS NOT NULL) |
82
+
83
+ ## Indexes
84
+
85
+ | Name | Definition |
86
+ | ---------------------------------- | ------------------------------------------------------------------------------------------------- |
87
+ | idx_document_blocks_content_order | CREATE INDEX idx_document_blocks_content_order<br /> ON document_blocks (content_id, sort_order) |
88
+ | sqlite_autoindex_document_blocks_2 | UNIQUE (content_id, sort_order) |
89
+ | sqlite_autoindex_document_blocks_1 | PRIMARY KEY (block_id) |
90
+
91
+ ## Relations
92
+
93
+ ![er](document_blocks.svg)
94
+
95
+ ---
96
+
97
+ > Generated by [tbls](https://github.com/k1LoW/tbls)
@@ -0,0 +1,60 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
3
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <!-- Generated by graphviz version 12.1.2 (20240928.0832)
5
+ -->
6
+ <!-- Title: document_blocks Pages: 1 -->
7
+ <svg width="436pt" height="469pt"
8
+ viewBox="0.00 0.00 435.99 468.80" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
9
+ <g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 464.8)">
10
+ <title>document_blocks</title>
11
+ <polygon fill="white" stroke="none" points="-4,4 -4,-464.8 431.99,-464.8 431.99,4 -4,4"/>
12
+ <!-- document_blocks -->
13
+ <g id="node1" class="node">
14
+ <title>document_blocks</title>
15
+ <polygon fill="#efefef" stroke="none" points="78.61,-368.6 78.61,-414.6 349.39,-414.6 349.39,-368.6 78.61,-368.6"/>
16
+ <polygon fill="none" stroke="black" points="78.61,-368.6 78.61,-414.6 349.39,-414.6 349.39,-368.6 78.61,-368.6"/>
17
+ <text text-anchor="start" x="115.88" y="-392.4" font-family="Arial Bold" font-size="18.00">document_blocks</text>
18
+ <text text-anchor="start" x="242.86" y="-392.4" font-family="Arial" font-size="14.00">    </text>
19
+ <text text-anchor="start" x="273.97" y="-392.4" font-family="Arial" font-size="14.00" fill="#666666">[table]</text>
20
+ <text text-anchor="start" x="123.75" y="-378" font-family="Arial" font-size="14.00" fill="#333333">문서 본문 표현 block을 관리한다.</text>
21
+ <polygon fill="none" stroke="black" points="78.61,-337.8 78.61,-368.6 349.39,-368.6 349.39,-337.8 78.61,-337.8"/>
22
+ <text text-anchor="start" x="85.61" y="-350" font-family="Arial" font-size="14.00">block_id </text>
23
+ <text text-anchor="start" x="140.86" y="-350" font-family="Arial" font-size="14.00" fill="#666666">[CHAR(36)]</text>
24
+ <text text-anchor="start" x="213.21" y="-350" font-family="Arial" font-size="14.00"> block 식별자</text>
25
+ <polygon fill="none" stroke="black" points="78.61,-307 78.61,-337.8 349.39,-337.8 349.39,-307 78.61,-307"/>
26
+ <text text-anchor="start" x="85.61" y="-319.2" font-family="Arial" font-size="14.00">content_id </text>
27
+ <text text-anchor="start" x="154.1" y="-319.2" font-family="Arial" font-size="14.00" fill="#666666">[CHAR(36)]</text>
28
+ <text text-anchor="start" x="226.45" y="-319.2" font-family="Arial" font-size="14.00"> 소속 content 식별자</text>
29
+ <polygon fill="none" stroke="black" stroke-width="3" points="77.11,-305.5 77.11,-416.1 350.89,-416.1 350.89,-305.5 77.11,-305.5"/>
30
+ </g>
31
+ <!-- document_contents -->
32
+ <g id="node2" class="node">
33
+ <title>document_contents</title>
34
+ <polygon fill="#efefef" stroke="none" points="43.2,-135.6 43.2,-181.6 384.79,-181.6 384.79,-135.6 43.2,-135.6"/>
35
+ <polygon fill="none" stroke="black" points="43.2,-135.6 43.2,-181.6 384.79,-181.6 384.79,-135.6 43.2,-135.6"/>
36
+ <text text-anchor="start" x="109.39" y="-159.4" font-family="Arial Bold" font-size="18.00">document_contents</text>
37
+ <text text-anchor="start" x="249.35" y="-159.4" font-family="Arial" font-size="14.00">    </text>
38
+ <text text-anchor="start" x="280.47" y="-159.4" font-family="Arial" font-size="14.00" fill="#666666">[table]</text>
39
+ <text text-anchor="start" x="50.2" y="-145" font-family="Arial" font-size="14.00" fill="#333333">특정 document node에 붙는 block collection을 관리한다.</text>
40
+ <polygon fill="none" stroke="black" points="43.2,-104.8 43.2,-135.6 384.79,-135.6 384.79,-104.8 43.2,-104.8"/>
41
+ <text text-anchor="start" x="50.2" y="-117" font-family="Arial" font-size="14.00">content_id </text>
42
+ <text text-anchor="start" x="118.7" y="-117" font-family="Arial" font-size="14.00" fill="#666666">[CHAR(36)]</text>
43
+ <text text-anchor="start" x="191.04" y="-117" font-family="Arial" font-size="14.00"> content 식별자</text>
44
+ <polygon fill="none" stroke="black" points="43.2,-74 43.2,-104.8 384.79,-104.8 384.79,-74 43.2,-74"/>
45
+ <text text-anchor="start" x="50.2" y="-86.2" font-family="Arial" font-size="14.00">document_id </text>
46
+ <text text-anchor="start" x="134.25" y="-86.2" font-family="Arial" font-size="14.00" fill="#666666">[CHAR(36)]</text>
47
+ <text text-anchor="start" x="206.6" y="-86.2" font-family="Arial" font-size="14.00"> 소속 문서 식별자</text>
48
+ <polygon fill="none" stroke="black" points="43.2,-43.2 43.2,-74 384.79,-74 384.79,-43.2 43.2,-43.2"/>
49
+ <text text-anchor="start" x="50.2" y="-55.4" font-family="Arial" font-size="14.00">node_id </text>
50
+ <text text-anchor="start" x="103.92" y="-55.4" font-family="Arial" font-size="14.00" fill="#666666">[CHAR(36)]</text>
51
+ <text text-anchor="start" x="176.26" y="-55.4" font-family="Arial" font-size="14.00"> 소속 노드 식별자</text>
52
+ </g>
53
+ <!-- document_blocks&#45;&gt;document_contents -->
54
+ <g id="edge1" class="edge">
55
+ <title>document_blocks:content_id&#45;&gt;document_contents:content_id</title>
56
+ <path fill="none" stroke="black" d="M214.74,-295.6C225.11,-228.28 341.59,-292.46 384.79,-224.8 409.81,-185.62 432.28,-120.2 385.79,-120.2"/>
57
+ <polygon fill="black" stroke="black" points="214.73,-295.69 209.53,-305.35 214.35,-301.01 214.04,-305.33 214.04,-305.33 214.04,-305.33 214.35,-301.01 218.51,-305.99 214.73,-295.69"/>
58
+ </g>
59
+ </g>
60
+ </svg>
@@ -0,0 +1,135 @@
1
+ # document_change_events
2
+
3
+ ## Description
4
+
5
+ revision에 속하는 로그성 변경 이벤트를 관리한다.
6
+
7
+ <details>
8
+ <summary><strong>Table Definition</strong></summary>
9
+
10
+ ```sql
11
+ CREATE TABLE document_change_events (
12
+ -- event 식별자
13
+ event_id CHAR(36) PRIMARY KEY
14
+ CHECK (length(event_id) = 36),
15
+
16
+ -- 소속 revision 식별자
17
+ revision_id CHAR(36) NOT NULL
18
+ CHECK (length(revision_id) = 36),
19
+
20
+ -- 소속 문서 식별자
21
+ document_id CHAR(36) NOT NULL
22
+ CHECK (length(document_id) = 36),
23
+
24
+ -- revision 안에서의 event 순서
25
+ sequence_no INTEGER NOT NULL
26
+ CHECK (sequence_no >= 1),
27
+
28
+ -- 변경 대상 유형
29
+ target_type_code VARCHAR(32) NOT NULL
30
+ CHECK (target_type_code IN ('document', 'node', 'content', 'block', 'annotation')),
31
+
32
+ -- 변경 대상 식별자
33
+ target_id CHAR(36) NOT NULL
34
+ CHECK (length(target_id) = 36),
35
+
36
+ -- 변경 유형
37
+ change_type_code VARCHAR(64) NOT NULL
38
+ CHECK (change_type_code IN (
39
+ 'created',
40
+ 'updated',
41
+ 'deleted',
42
+ 'status_changed',
43
+ 'reordered',
44
+ 'annotated',
45
+ 'version_created',
46
+ 'new_draft_created'
47
+ )),
48
+
49
+ -- 개별 변경 사유
50
+ change_reason TEXT,
51
+
52
+ -- 변경자 유형
53
+ changed_by_type_code VARCHAR(32) NOT NULL DEFAULT 'user'
54
+ CHECK (changed_by_type_code IN ('user', 'agent', 'system')),
55
+
56
+ -- 변경자 식별자
57
+ changed_by_id VARCHAR(128),
58
+
59
+ -- 변경자 표시명
60
+ changed_by_name VARCHAR(128),
61
+
62
+ -- 변경 시각
63
+ changed_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
64
+
65
+ -- before/after preview 등 이벤트 메타데이터
66
+ metadata_json JSON
67
+ CHECK (metadata_json IS NULL OR json_valid(metadata_json)),
68
+
69
+ FOREIGN KEY (revision_id)
70
+ REFERENCES document_revisions (revision_id)
71
+ ON DELETE CASCADE,
72
+
73
+ FOREIGN KEY (document_id)
74
+ REFERENCES document_documents (document_id)
75
+ ON DELETE CASCADE,
76
+
77
+ UNIQUE (revision_id, sequence_no)
78
+ )
79
+ ```
80
+
81
+ </details>
82
+
83
+ ## Columns
84
+
85
+ | Name | Type | Default | Nullable | Parents | Comment |
86
+ | -------------------- | ------------ | ----------------- | -------- | ------------------------------------------- | ---------------------------- |
87
+ | event_id | CHAR(36) | | true | | event 식별자 |
88
+ | revision_id | CHAR(36) | | false | [document_revisions](document_revisions.md) | 소속 revision 식별자 |
89
+ | document_id | CHAR(36) | | false | [document_documents](document_documents.md) | 소속 문서 식별자 |
90
+ | sequence_no | INTEGER | | false | | revision 안에서의 event 순서 |
91
+ | target_type_code | VARCHAR(32) | | false | | 변경 대상 유형 |
92
+ | target_id | CHAR(36) | | false | | 변경 대상 식별자 |
93
+ | change_type_code | VARCHAR(64) | | false | | 변경 유형 |
94
+ | change_reason | TEXT | | true | | 개별 변경 사유 |
95
+ | changed_by_type_code | VARCHAR(32) | 'user' | false | | 변경자 유형 |
96
+ | changed_by_id | VARCHAR(128) | | true | | 변경자 식별자 |
97
+ | changed_by_name | VARCHAR(128) | | true | | 변경자 표시명 |
98
+ | changed_at | DATETIME | CURRENT_TIMESTAMP | false | | 변경 시각 |
99
+ | metadata_json | JSON | | true | | 이벤트 메타데이터 |
100
+
101
+ ## Constraints
102
+
103
+ | Name | Type | Definition |
104
+ | ----------------------------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
105
+ | event_id | PRIMARY KEY | PRIMARY KEY (event_id) |
106
+ | - (Foreign key ID: 0) | FOREIGN KEY | FOREIGN KEY (document_id) REFERENCES document_documents (document_id) ON UPDATE NO ACTION ON DELETE CASCADE MATCH NONE |
107
+ | - (Foreign key ID: 1) | FOREIGN KEY | FOREIGN KEY (revision_id) REFERENCES document_revisions (revision_id) ON UPDATE NO ACTION ON DELETE CASCADE MATCH NONE |
108
+ | sqlite_autoindex_document_change_events_2 | UNIQUE | UNIQUE (revision_id, sequence_no) |
109
+ | sqlite_autoindex_document_change_events_1 | PRIMARY KEY | PRIMARY KEY (event_id) |
110
+ | - | CHECK | CHECK (length(event_id) = 36) |
111
+ | - | CHECK | CHECK (length(revision_id) = 36) |
112
+ | - | CHECK | CHECK (length(document_id) = 36) |
113
+ | - | CHECK | CHECK (sequence_no >= 1) |
114
+ | - | CHECK | CHECK (target_type_code IN ('document', 'node', 'content', 'block', 'annotation')) |
115
+ | - | CHECK | CHECK (length(target_id) = 36) |
116
+ | - | CHECK | CHECK (change_type_code IN ( 'created', 'updated', 'deleted', 'status_changed', 'reordered', 'annotated', 'version_created', 'new_draft_created' )) |
117
+ | - | CHECK | CHECK (changed_by_type_code IN ('user', 'agent', 'system')) |
118
+ | - | CHECK | CHECK (metadata_json IS NULL OR json_valid(metadata_json)) |
119
+
120
+ ## Indexes
121
+
122
+ | Name | Definition |
123
+ | ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
124
+ | idx_document_change_events_changed_at | CREATE INDEX idx_document_change_events_changed_at<br /> ON document_change_events (document_id, changed_at) |
125
+ | idx_document_change_events_target | CREATE INDEX idx_document_change_events_target<br /> ON document_change_events (document_id, target_type_code, target_id) |
126
+ | sqlite_autoindex_document_change_events_2 | UNIQUE (revision_id, sequence_no) |
127
+ | sqlite_autoindex_document_change_events_1 | PRIMARY KEY (event_id) |
128
+
129
+ ## Relations
130
+
131
+ ![er](document_change_events.svg)
132
+
133
+ ---
134
+
135
+ > Generated by [tbls](https://github.com/k1LoW/tbls)
@@ -0,0 +1,88 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
3
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <!-- Generated by graphviz version 12.1.2 (20240928.0832)
5
+ -->
6
+ <!-- Title: document_change_events Pages: 1 -->
7
+ <svg width="896pt" height="500pt"
8
+ viewBox="0.00 0.00 895.94 499.60" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
9
+ <g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 495.6)">
10
+ <title>document_change_events</title>
11
+ <polygon fill="white" stroke="none" points="-4,4 -4,-495.6 891.94,-495.6 891.94,4 -4,4"/>
12
+ <!-- document_change_events -->
13
+ <g id="node1" class="node">
14
+ <title>document_change_events</title>
15
+ <polygon fill="#efefef" stroke="none" points="305.37,-399.4 305.37,-445.4 589.32,-445.4 589.32,-399.4 305.37,-399.4"/>
16
+ <polygon fill="none" stroke="black" points="305.37,-399.4 305.37,-445.4 589.32,-445.4 589.32,-399.4 305.37,-399.4"/>
17
+ <text text-anchor="start" x="319.75" y="-423.2" font-family="Arial Bold" font-size="18.00">document_change_events</text>
18
+ <text text-anchor="start" x="505.68" y="-423.2" font-family="Arial" font-size="14.00">    </text>
19
+ <text text-anchor="start" x="536.8" y="-423.2" font-family="Arial" font-size="14.00" fill="#666666">[table]</text>
20
+ <text text-anchor="start" x="312.37" y="-408.8" font-family="Arial" font-size="14.00" fill="#333333">revision에 속하는 로그성 변경 이벤트를 관리한다.</text>
21
+ <polygon fill="none" stroke="black" points="305.37,-368.6 305.37,-399.4 589.32,-399.4 589.32,-368.6 305.37,-368.6"/>
22
+ <text text-anchor="start" x="312.37" y="-380.8" font-family="Arial" font-size="14.00">event_id </text>
23
+ <text text-anchor="start" x="369.19" y="-380.8" font-family="Arial" font-size="14.00" fill="#666666">[CHAR(36)]</text>
24
+ <text text-anchor="start" x="441.53" y="-380.8" font-family="Arial" font-size="14.00"> event 식별자</text>
25
+ <polygon fill="none" stroke="black" points="305.37,-337.8 305.37,-368.6 589.32,-368.6 589.32,-337.8 305.37,-337.8"/>
26
+ <text text-anchor="start" x="312.37" y="-350" font-family="Arial" font-size="14.00">revision_id </text>
27
+ <text text-anchor="start" x="383.18" y="-350" font-family="Arial" font-size="14.00" fill="#666666">[CHAR(36)]</text>
28
+ <text text-anchor="start" x="455.53" y="-350" font-family="Arial" font-size="14.00"> 소속 revision 식별자</text>
29
+ <polygon fill="none" stroke="black" points="305.37,-307 305.37,-337.8 589.32,-337.8 589.32,-307 305.37,-307"/>
30
+ <text text-anchor="start" x="312.37" y="-319.2" font-family="Arial" font-size="14.00">document_id </text>
31
+ <text text-anchor="start" x="396.42" y="-319.2" font-family="Arial" font-size="14.00" fill="#666666">[CHAR(36)]</text>
32
+ <text text-anchor="start" x="468.77" y="-319.2" font-family="Arial" font-size="14.00"> 소속 문서 식별자</text>
33
+ <polygon fill="none" stroke="black" stroke-width="3" points="303.87,-305.5 303.87,-446.9 590.82,-446.9 590.82,-305.5 303.87,-305.5"/>
34
+ </g>
35
+ <!-- document_revisions -->
36
+ <g id="node2" class="node">
37
+ <title>document_revisions</title>
38
+ <polygon fill="#efefef" stroke="none" points="43.2,-120.2 43.2,-166.2 399.49,-166.2 399.49,-120.2 43.2,-120.2"/>
39
+ <polygon fill="none" stroke="black" points="43.2,-120.2 43.2,-166.2 399.49,-166.2 399.49,-120.2 43.2,-120.2"/>
40
+ <text text-anchor="start" x="114.23" y="-144" font-family="Arial Bold" font-size="18.00">document_revisions</text>
41
+ <text text-anchor="start" x="259.2" y="-144" font-family="Arial" font-size="14.00">    </text>
42
+ <text text-anchor="start" x="290.32" y="-144" font-family="Arial" font-size="14.00" fill="#666666">[table]</text>
43
+ <text text-anchor="start" x="50.2" y="-129.6" font-family="Arial" font-size="14.00" fill="#333333">하나 이상의 변경 이벤트를 묶는 의미 있는 변경 단위를 관리한다.</text>
44
+ <polygon fill="none" stroke="black" points="43.2,-89.4 43.2,-120.2 399.49,-120.2 399.49,-89.4 43.2,-89.4"/>
45
+ <text text-anchor="start" x="50.2" y="-101.6" font-family="Arial" font-size="14.00">revision_id </text>
46
+ <text text-anchor="start" x="121.01" y="-101.6" font-family="Arial" font-size="14.00" fill="#666666">[CHAR(36)]</text>
47
+ <text text-anchor="start" x="193.36" y="-101.6" font-family="Arial" font-size="14.00"> revision 식별자</text>
48
+ <polygon fill="none" stroke="black" points="43.2,-58.6 43.2,-89.4 399.49,-89.4 399.49,-58.6 43.2,-58.6"/>
49
+ <text text-anchor="start" x="50.2" y="-70.8" font-family="Arial" font-size="14.00">document_id </text>
50
+ <text text-anchor="start" x="134.25" y="-70.8" font-family="Arial" font-size="14.00" fill="#666666">[CHAR(36)]</text>
51
+ <text text-anchor="start" x="206.6" y="-70.8" font-family="Arial" font-size="14.00"> 소속 문서 식별자</text>
52
+ </g>
53
+ <!-- document_change_events&#45;&gt;document_revisions -->
54
+ <g id="edge1" class="edge">
55
+ <title>document_change_events:revision_id&#45;&gt;document_revisions:revision_id</title>
56
+ <path fill="none" stroke="black" d="M294.05,-351.64C267.39,-342.24 286.29,-292.57 305.37,-260.8 329.91,-219.94 374.97,-250.27 399.49,-209.4 423.4,-169.53 446.98,-104.8 400.49,-104.8"/>
57
+ <polygon fill="black" stroke="black" points="294.15,-351.65 303.36,-357.6 299.43,-352.45 303.71,-353.1 303.71,-353.1 303.71,-353.1 299.43,-352.45 304.71,-348.7 294.15,-351.65"/>
58
+ </g>
59
+ <!-- document_documents -->
60
+ <g id="node3" class="node">
61
+ <title>document_documents</title>
62
+ <polygon fill="#efefef" stroke="none" points="503.95,-135.6 503.95,-181.6 844.74,-181.6 844.74,-135.6 503.95,-135.6"/>
63
+ <polygon fill="none" stroke="black" points="503.95,-135.6 503.95,-181.6 844.74,-181.6 844.74,-135.6 503.95,-135.6"/>
64
+ <text text-anchor="start" x="560.73" y="-159.4" font-family="Arial Bold" font-size="18.00">document_documents</text>
65
+ <text text-anchor="start" x="718.7" y="-159.4" font-family="Arial" font-size="14.00">    </text>
66
+ <text text-anchor="start" x="749.82" y="-159.4" font-family="Arial" font-size="14.00" fill="#666666">[table]</text>
67
+ <text text-anchor="start" x="513.69" y="-145" font-family="Arial" font-size="14.00" fill="#333333">문서 단위 메타데이터, 작성자, taxonomy, 상태를 관리한다.</text>
68
+ <polygon fill="none" stroke="black" points="503.95,-104.8 503.95,-135.6 844.74,-135.6 844.74,-104.8 503.95,-104.8"/>
69
+ <text text-anchor="start" x="510.95" y="-117" font-family="Arial" font-size="14.00">document_id </text>
70
+ <text text-anchor="start" x="595.01" y="-117" font-family="Arial" font-size="14.00" fill="#666666">[CHAR(36)]</text>
71
+ <text text-anchor="start" x="667.35" y="-117" font-family="Arial" font-size="14.00"> 문서 식별자</text>
72
+ <polygon fill="none" stroke="black" points="503.95,-74 503.95,-104.8 844.74,-104.8 844.74,-74 503.95,-74"/>
73
+ <text text-anchor="start" x="510.95" y="-86.2" font-family="Arial" font-size="14.00">taxonomy_id </text>
74
+ <text text-anchor="start" x="594.22" y="-86.2" font-family="Arial" font-size="14.00" fill="#666666">[CHAR(36)]</text>
75
+ <text text-anchor="start" x="666.57" y="-86.2" font-family="Arial" font-size="14.00"> 적용 taxonomy 식별자</text>
76
+ <polygon fill="none" stroke="black" points="503.95,-43.2 503.95,-74 844.74,-74 844.74,-43.2 503.95,-43.2"/>
77
+ <text text-anchor="start" x="510.95" y="-55.4" font-family="Arial" font-size="14.00">source_document_id </text>
78
+ <text text-anchor="start" x="644.81" y="-55.4" font-family="Arial" font-size="14.00" fill="#666666">[CHAR(36)]</text>
79
+ <text text-anchor="start" x="717.16" y="-55.4" font-family="Arial" font-size="14.00"> 파생 원본 문서 식별자</text>
80
+ </g>
81
+ <!-- document_change_events&#45;&gt;document_documents -->
82
+ <g id="edge2" class="edge">
83
+ <title>document_change_events:document_id&#45;&gt;document_documents:document_id</title>
84
+ <path fill="none" stroke="black" d="M600.34,-319.76C613.57,-310.64 602.25,-279.95 589.32,-260.8 566.27,-226.68 526.88,-259 503.95,-224.8 478.06,-186.19 456.46,-120.2 502.95,-120.2"/>
85
+ <polygon fill="black" stroke="black" points="600.31,-319.77 589.5,-317.96 595.16,-321.13 590.97,-322.23 590.97,-322.23 590.97,-322.23 595.16,-321.13 591.79,-326.67 600.31,-319.77"/>
86
+ </g>
87
+ </g>
88
+ </svg>