@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.
Files changed (263) hide show
  1. package/build/index.d.ts +1921 -42
  2. package/build/index.js +4616 -39
  3. package/build/models.d.ts +34 -32
  4. package/build/models.js +219 -275
  5. package/package.json +4 -4
  6. package/tsup.config.ts +10 -0
  7. package/build/doc-client.d.ts +0 -59
  8. package/build/doc-client.d.ts.map +0 -1
  9. package/build/doc-client.js +0 -95
  10. package/build/doc-client.test.d.ts +0 -2
  11. package/build/doc-client.test.d.ts.map +0 -1
  12. package/build/doc-client.test.js +0 -38
  13. package/build/doc-directory-reference.d.ts +0 -65
  14. package/build/doc-directory-reference.d.ts.map +0 -1
  15. package/build/doc-directory-reference.js +0 -292
  16. package/build/doc-directory-reference.test.d.ts +0 -2
  17. package/build/doc-directory-reference.test.d.ts.map +0 -1
  18. package/build/doc-directory-reference.test.js +0 -100
  19. package/build/doc-file-index-reference.d.ts +0 -72
  20. package/build/doc-file-index-reference.d.ts.map +0 -1
  21. package/build/doc-file-index-reference.js +0 -191
  22. package/build/doc-file-index-reference.test.d.ts +0 -2
  23. package/build/doc-file-index-reference.test.d.ts.map +0 -1
  24. package/build/doc-file-index-reference.test.js +0 -77
  25. package/build/doc-file-md-reference.d.ts +0 -97
  26. package/build/doc-file-md-reference.d.ts.map +0 -1
  27. package/build/doc-file-md-reference.js +0 -297
  28. package/build/doc-file-md-reference.test.d.ts +0 -2
  29. package/build/doc-file-md-reference.test.d.ts.map +0 -1
  30. package/build/doc-file-md-reference.test.js +0 -465
  31. package/build/doc-file-relation-reference.d.ts +0 -54
  32. package/build/doc-file-relation-reference.d.ts.map +0 -1
  33. package/build/doc-file-relation-reference.js +0 -109
  34. package/build/doc-file-system-debug.d.ts +0 -81
  35. package/build/doc-file-system-debug.d.ts.map +0 -1
  36. package/build/doc-file-system-debug.js +0 -317
  37. package/build/doc-file-system.d.ts +0 -100
  38. package/build/doc-file-system.d.ts.map +0 -1
  39. package/build/doc-file-system.js +0 -210
  40. package/build/doc-file-tree-system.d.ts +0 -38
  41. package/build/doc-file-tree-system.d.ts.map +0 -1
  42. package/build/doc-file-tree-system.js +0 -153
  43. package/build/doc-file-tree-system.test.d.ts +0 -2
  44. package/build/doc-file-tree-system.test.d.ts.map +0 -1
  45. package/build/doc-file-tree-system.test.js +0 -105
  46. package/build/doc-file-unknown-reference.d.ts +0 -80
  47. package/build/doc-file-unknown-reference.d.ts.map +0 -1
  48. package/build/doc-file-unknown-reference.js +0 -181
  49. package/build/doc-file-unknown-reference.test.d.ts +0 -2
  50. package/build/doc-file-unknown-reference.test.d.ts.map +0 -1
  51. package/build/doc-file-unknown-reference.test.js +0 -73
  52. package/build/doc-markdown-system.d.ts +0 -44
  53. package/build/doc-markdown-system.d.ts.map +0 -1
  54. package/build/doc-markdown-system.js +0 -153
  55. package/build/doc-markdown-system.test.d.ts +0 -2
  56. package/build/doc-markdown-system.test.d.ts.map +0 -1
  57. package/build/doc-markdown-system.test.js +0 -124
  58. package/build/doc-path-system.d.ts +0 -43
  59. package/build/doc-path-system.d.ts.map +0 -1
  60. package/build/doc-path-system.js +0 -148
  61. package/build/doc-path-system.test.d.ts +0 -2
  62. package/build/doc-path-system.test.d.ts.map +0 -1
  63. package/build/doc-path-system.test.js +0 -67
  64. package/build/entities/doc-file-entity.d.ts +0 -5
  65. package/build/entities/doc-file-entity.d.ts.map +0 -1
  66. package/build/entities/doc-file-entity.js +0 -1
  67. package/build/entities/doc-file-index-entity.d.ts +0 -30
  68. package/build/entities/doc-file-index-entity.d.ts.map +0 -1
  69. package/build/entities/doc-file-index-entity.js +0 -49
  70. package/build/entities/doc-file-index-entity.test.d.ts +0 -2
  71. package/build/entities/doc-file-index-entity.test.d.ts.map +0 -1
  72. package/build/entities/doc-file-index-entity.test.js +0 -195
  73. package/build/entities/doc-file-md-entity.d.ts +0 -30
  74. package/build/entities/doc-file-md-entity.d.ts.map +0 -1
  75. package/build/entities/doc-file-md-entity.js +0 -49
  76. package/build/entities/doc-file-md-entity.test.d.ts +0 -2
  77. package/build/entities/doc-file-md-entity.test.d.ts.map +0 -1
  78. package/build/entities/doc-file-md-entity.test.js +0 -178
  79. package/build/entities/doc-file-unknown-entity.d.ts +0 -26
  80. package/build/entities/doc-file-unknown-entity.d.ts.map +0 -1
  81. package/build/entities/doc-file-unknown-entity.js +0 -45
  82. package/build/entities/doc-file-unknown-entity.test.d.ts +0 -2
  83. package/build/entities/doc-file-unknown-entity.test.d.ts.map +0 -1
  84. package/build/entities/doc-file-unknown-entity.test.js +0 -131
  85. package/build/index.d.ts.map +0 -1
  86. package/build/models.d.ts.map +0 -1
  87. package/build/types.d.ts +0 -154
  88. package/build/types.d.ts.map +0 -1
  89. package/build/types.js +0 -1
  90. package/build/values/doc-content-md-front-matter-value.d.ts +0 -49
  91. package/build/values/doc-content-md-front-matter-value.d.ts.map +0 -1
  92. package/build/values/doc-content-md-front-matter-value.js +0 -94
  93. package/build/values/doc-content-md-front-matter-value.test.d.ts +0 -2
  94. package/build/values/doc-content-md-front-matter-value.test.d.ts.map +0 -1
  95. package/build/values/doc-content-md-front-matter-value.test.js +0 -73
  96. package/build/values/doc-content-md-value.d.ts +0 -66
  97. package/build/values/doc-content-md-value.d.ts.map +0 -1
  98. package/build/values/doc-content-md-value.js +0 -218
  99. package/build/values/doc-content-md-value.test.d.ts +0 -2
  100. package/build/values/doc-content-md-value.test.d.ts.map +0 -1
  101. package/build/values/doc-content-md-value.test.js +0 -179
  102. package/build/values/doc-directory-path-value.d.ts +0 -89
  103. package/build/values/doc-directory-path-value.d.ts.map +0 -1
  104. package/build/values/doc-directory-path-value.js +0 -145
  105. package/build/values/doc-directory-path-value.test.d.ts +0 -2
  106. package/build/values/doc-directory-path-value.test.d.ts.map +0 -1
  107. package/build/values/doc-directory-path-value.test.js +0 -68
  108. package/build/values/doc-file-content-index-value.d.ts +0 -62
  109. package/build/values/doc-file-content-index-value.d.ts.map +0 -1
  110. package/build/values/doc-file-content-index-value.js +0 -134
  111. package/build/values/doc-file-content-index-value.test.d.ts +0 -2
  112. package/build/values/doc-file-content-index-value.test.d.ts.map +0 -1
  113. package/build/values/doc-file-content-index-value.test.js +0 -203
  114. package/build/values/doc-file-content-md-value.d.ts +0 -62
  115. package/build/values/doc-file-content-md-value.d.ts.map +0 -1
  116. package/build/values/doc-file-content-md-value.js +0 -139
  117. package/build/values/doc-file-content-md-value.test.d.ts +0 -2
  118. package/build/values/doc-file-content-md-value.test.d.ts.map +0 -1
  119. package/build/values/doc-file-content-md-value.test.js +0 -160
  120. package/build/values/doc-file-path-value.d.ts +0 -47
  121. package/build/values/doc-file-path-value.d.ts.map +0 -1
  122. package/build/values/doc-file-path-value.js +0 -83
  123. package/build/values/doc-file-path-value.test.d.ts +0 -2
  124. package/build/values/doc-file-path-value.test.d.ts.map +0 -1
  125. package/build/values/doc-file-path-value.test.js +0 -84
  126. package/build/values/doc-front-matter-index-value.d.ts +0 -66
  127. package/build/values/doc-front-matter-index-value.d.ts.map +0 -1
  128. package/build/values/doc-front-matter-index-value.js +0 -185
  129. package/build/values/doc-front-matter-index-value.test.d.ts +0 -2
  130. package/build/values/doc-front-matter-index-value.test.d.ts.map +0 -1
  131. package/build/values/doc-front-matter-index-value.test.js +0 -98
  132. package/build/values/doc-front-matter-md-value-accessor.test.d.ts +0 -2
  133. package/build/values/doc-front-matter-md-value-accessor.test.d.ts.map +0 -1
  134. package/build/values/doc-front-matter-md-value-accessor.test.js +0 -226
  135. package/build/values/doc-front-matter-md-value.d.ts +0 -80
  136. package/build/values/doc-front-matter-md-value.d.ts.map +0 -1
  137. package/build/values/doc-front-matter-md-value.js +0 -257
  138. package/build/values/doc-front-matter-md-value.test.d.ts +0 -2
  139. package/build/values/doc-front-matter-md-value.test.d.ts.map +0 -1
  140. package/build/values/doc-front-matter-md-value.test.js +0 -198
  141. package/build/values/doc-relation-field-value.d.ts +0 -57
  142. package/build/values/doc-relation-field-value.d.ts.map +0 -1
  143. package/build/values/doc-relation-field-value.js +0 -85
  144. package/build/values/doc-relation-field-value.test.d.ts +0 -2
  145. package/build/values/doc-relation-field-value.test.d.ts.map +0 -1
  146. package/build/values/doc-relation-field-value.test.js +0 -115
  147. package/build/values/doc-relation-file-value.d.ts +0 -33
  148. package/build/values/doc-relation-file-value.d.ts.map +0 -1
  149. package/build/values/doc-relation-file-value.js +0 -55
  150. package/build/values/doc-relation-file-value.test.d.ts +0 -2
  151. package/build/values/doc-relation-file-value.test.d.ts.map +0 -1
  152. package/build/values/doc-relation-file-value.test.js +0 -77
  153. package/build/values/doc-relation-value.d.ts +0 -34
  154. package/build/values/doc-relation-value.d.ts.map +0 -1
  155. package/build/values/doc-relation-value.js +0 -56
  156. package/build/values/doc-relation-value.test.d.ts +0 -2
  157. package/build/values/doc-relation-value.test.d.ts.map +0 -1
  158. package/build/values/doc-relation-value.test.js +0 -89
  159. package/build/values/doc-schema-field-boolean-multiple-value.d.ts +0 -23
  160. package/build/values/doc-schema-field-boolean-multiple-value.d.ts.map +0 -1
  161. package/build/values/doc-schema-field-boolean-multiple-value.js +0 -43
  162. package/build/values/doc-schema-field-boolean-multiple-value.test.d.ts +0 -2
  163. package/build/values/doc-schema-field-boolean-multiple-value.test.d.ts.map +0 -1
  164. package/build/values/doc-schema-field-boolean-multiple-value.test.js +0 -76
  165. package/build/values/doc-schema-field-boolean-single-value.d.ts +0 -23
  166. package/build/values/doc-schema-field-boolean-single-value.d.ts.map +0 -1
  167. package/build/values/doc-schema-field-boolean-single-value.js +0 -39
  168. package/build/values/doc-schema-field-boolean-single-value.test.d.ts +0 -2
  169. package/build/values/doc-schema-field-boolean-single-value.test.d.ts.map +0 -1
  170. package/build/values/doc-schema-field-boolean-single-value.test.js +0 -73
  171. package/build/values/doc-schema-field-factory.d.ts +0 -37
  172. package/build/values/doc-schema-field-factory.d.ts.map +0 -1
  173. package/build/values/doc-schema-field-factory.js +0 -151
  174. package/build/values/doc-schema-field-factory.test.d.ts +0 -2
  175. package/build/values/doc-schema-field-factory.test.d.ts.map +0 -1
  176. package/build/values/doc-schema-field-factory.test.js +0 -215
  177. package/build/values/doc-schema-field-number-multiple-value.d.ts +0 -23
  178. package/build/values/doc-schema-field-number-multiple-value.d.ts.map +0 -1
  179. package/build/values/doc-schema-field-number-multiple-value.js +0 -43
  180. package/build/values/doc-schema-field-number-multiple-value.test.d.ts +0 -2
  181. package/build/values/doc-schema-field-number-multiple-value.test.d.ts.map +0 -1
  182. package/build/values/doc-schema-field-number-multiple-value.test.js +0 -79
  183. package/build/values/doc-schema-field-number-single-value.d.ts +0 -23
  184. package/build/values/doc-schema-field-number-single-value.d.ts.map +0 -1
  185. package/build/values/doc-schema-field-number-single-value.js +0 -39
  186. package/build/values/doc-schema-field-number-single-value.test.d.ts +0 -2
  187. package/build/values/doc-schema-field-number-single-value.test.d.ts.map +0 -1
  188. package/build/values/doc-schema-field-number-single-value.test.js +0 -77
  189. package/build/values/doc-schema-field-relation-multiple-value.d.ts +0 -24
  190. package/build/values/doc-schema-field-relation-multiple-value.d.ts.map +0 -1
  191. package/build/values/doc-schema-field-relation-multiple-value.js +0 -46
  192. package/build/values/doc-schema-field-relation-multiple-value.test.d.ts +0 -2
  193. package/build/values/doc-schema-field-relation-multiple-value.test.d.ts.map +0 -1
  194. package/build/values/doc-schema-field-relation-multiple-value.test.js +0 -83
  195. package/build/values/doc-schema-field-relation-single-value.d.ts +0 -24
  196. package/build/values/doc-schema-field-relation-single-value.d.ts.map +0 -1
  197. package/build/values/doc-schema-field-relation-single-value.js +0 -42
  198. package/build/values/doc-schema-field-relation-single-value.test.d.ts +0 -2
  199. package/build/values/doc-schema-field-relation-single-value.test.d.ts.map +0 -1
  200. package/build/values/doc-schema-field-relation-single-value.test.js +0 -83
  201. package/build/values/doc-schema-field-select-number-multiple-value.d.ts +0 -25
  202. package/build/values/doc-schema-field-select-number-multiple-value.d.ts.map +0 -1
  203. package/build/values/doc-schema-field-select-number-multiple-value.js +0 -48
  204. package/build/values/doc-schema-field-select-number-multiple-value.test.d.ts +0 -2
  205. package/build/values/doc-schema-field-select-number-multiple-value.test.d.ts.map +0 -1
  206. package/build/values/doc-schema-field-select-number-multiple-value.test.js +0 -84
  207. package/build/values/doc-schema-field-select-number-single-value.d.ts +0 -25
  208. package/build/values/doc-schema-field-select-number-single-value.d.ts.map +0 -1
  209. package/build/values/doc-schema-field-select-number-single-value.js +0 -45
  210. package/build/values/doc-schema-field-select-number-single-value.test.d.ts +0 -2
  211. package/build/values/doc-schema-field-select-number-single-value.test.d.ts.map +0 -1
  212. package/build/values/doc-schema-field-select-number-single-value.test.js +0 -96
  213. package/build/values/doc-schema-field-select-text-multiple-value.d.ts +0 -25
  214. package/build/values/doc-schema-field-select-text-multiple-value.d.ts.map +0 -1
  215. package/build/values/doc-schema-field-select-text-multiple-value.js +0 -48
  216. package/build/values/doc-schema-field-select-text-multiple-value.test.d.ts +0 -2
  217. package/build/values/doc-schema-field-select-text-multiple-value.test.d.ts.map +0 -1
  218. package/build/values/doc-schema-field-select-text-multiple-value.test.js +0 -84
  219. package/build/values/doc-schema-field-select-text-single-value.d.ts +0 -25
  220. package/build/values/doc-schema-field-select-text-single-value.d.ts.map +0 -1
  221. package/build/values/doc-schema-field-select-text-single-value.js +0 -47
  222. package/build/values/doc-schema-field-select-text-single-value.test.d.ts +0 -2
  223. package/build/values/doc-schema-field-select-text-single-value.test.d.ts.map +0 -1
  224. package/build/values/doc-schema-field-select-text-single-value.test.js +0 -96
  225. package/build/values/doc-schema-field-text-multiple-value.d.ts +0 -23
  226. package/build/values/doc-schema-field-text-multiple-value.d.ts.map +0 -1
  227. package/build/values/doc-schema-field-text-multiple-value.js +0 -43
  228. package/build/values/doc-schema-field-text-multiple-value.test.d.ts +0 -2
  229. package/build/values/doc-schema-field-text-multiple-value.test.d.ts.map +0 -1
  230. package/build/values/doc-schema-field-text-multiple-value.test.js +0 -78
  231. package/build/values/doc-schema-field-text-single-value.d.ts +0 -23
  232. package/build/values/doc-schema-field-text-single-value.d.ts.map +0 -1
  233. package/build/values/doc-schema-field-text-single-value.js +0 -39
  234. package/build/values/doc-schema-field-text-single-value.test.d.ts +0 -2
  235. package/build/values/doc-schema-field-text-single-value.test.d.ts.map +0 -1
  236. package/build/values/doc-schema-field-text-single-value.test.js +0 -76
  237. package/build/values/doc-schema-field-type-value.d.ts +0 -61
  238. package/build/values/doc-schema-field-type-value.d.ts.map +0 -1
  239. package/build/values/doc-schema-field-type-value.js +0 -134
  240. package/build/values/doc-schema-field-type-value.test.d.ts +0 -2
  241. package/build/values/doc-schema-field-type-value.test.d.ts.map +0 -1
  242. package/build/values/doc-schema-field-type-value.test.js +0 -101
  243. package/build/values/doc-schema-field-value.d.ts +0 -45
  244. package/build/values/doc-schema-field-value.d.ts.map +0 -1
  245. package/build/values/doc-schema-field-value.js +0 -1
  246. package/build/values/doc-schema-value.d.ts +0 -99
  247. package/build/values/doc-schema-value.d.ts.map +0 -1
  248. package/build/values/doc-schema-value.js +0 -269
  249. package/build/values/doc-schema-value.test.d.ts +0 -2
  250. package/build/values/doc-schema-value.test.d.ts.map +0 -1
  251. package/build/values/doc-schema-value.test.js +0 -301
  252. package/build/values/doc-tree-directory-node-value.d.ts +0 -36
  253. package/build/values/doc-tree-directory-node-value.d.ts.map +0 -1
  254. package/build/values/doc-tree-directory-node-value.js +0 -71
  255. package/build/values/doc-tree-directory-node-value.test.d.ts +0 -2
  256. package/build/values/doc-tree-directory-node-value.test.d.ts.map +0 -1
  257. package/build/values/doc-tree-directory-node-value.test.js +0 -162
  258. package/build/values/doc-tree-file-node-value.d.ts +0 -33
  259. package/build/values/doc-tree-file-node-value.d.ts.map +0 -1
  260. package/build/values/doc-tree-file-node-value.js +0 -56
  261. package/build/values/doc-tree-file-node-value.test.d.ts +0 -2
  262. package/build/values/doc-tree-file-node-value.test.d.ts.map +0 -1
  263. package/build/values/doc-tree-file-node-value.test.js +0 -113
@@ -1 +0,0 @@
1
- {"version":3,"file":"doc-file-index-reference.d.ts","sourceRoot":"","sources":["../lib/doc-file-index-reference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAA;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AAGrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAEnE,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,aAAa,CAAA;IACzB,UAAU,EAAE,aAAa,CAAA;CAC1B,CAAA;AAED;;GAEG;AACH,qBAAa,qBAAqB;IAGpB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAFlC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAe;IAE1C,YAA6B,KAAK,EAAE,KAAK,EAGxC;IAED,IAAI,UAAU,IAAI,aAAa,CAE9B;IAED,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,IAAI,aAAa,IAAI,MAAM,CAE1B;IAEK,IAAI,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAgCxC;IAED;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,CAM3C;IAED;;OAEG;IACG,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjD;IAED;;OAEG;IACG,KAAK,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAGrD;IAED;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CASlC;IAED;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAEpC;IAED;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,CAE/B;IAEK,SAAS,IAAI,OAAO,CAAC,wBAAwB,EAAE,CAAC,CA4BrD;IAEK,aAAa,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAYjD;IAED;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAE5B;IAED;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAElC;IAED;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAE/B;IAED;;OAEG;IACG,OAAO,CAAC,oBAAoB,SAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAkBxE;IAED;;OAEG;IACG,OAAO,CAAC,oBAAoB,SAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CA0BxE;CACF"}
@@ -1,191 +0,0 @@
1
- import { DocFileRelationReference } from "./doc-file-relation-reference";
2
- import { DocFileIndexEntity } from "./entities/doc-file-index-entity";
3
- import { DocFileContentIndexValue } from "./values/doc-file-content-index-value";
4
- import { DocFilePathValue } from "./values/doc-file-path-value";
5
- /**
6
- * ファイルを表すクラス
7
- */
8
- export class DocFileIndexReference {
9
- props;
10
- pathSystem;
11
- constructor(props) {
12
- this.props = props;
13
- this.pathSystem = props.pathSystem;
14
- Object.freeze(this);
15
- }
16
- get fileSystem() {
17
- return this.props.fileSystem;
18
- }
19
- get basePath() {
20
- return this.fileSystem.getBasePath();
21
- }
22
- get filePath() {
23
- return this.props.path;
24
- }
25
- get fileFullPath() {
26
- return this.pathSystem.join(this.basePath, this.filePath);
27
- }
28
- get durectoryPath() {
29
- return this.pathSystem.dirname(this.filePath);
30
- }
31
- async read() {
32
- const content = await this.fileSystem.readFile(this.filePath);
33
- if (content === null) {
34
- const dirName = this.filePath.split("/").pop() || "directory";
35
- const pathValue = DocFilePathValue.fromPathWithSystem(this.filePath, this.pathSystem, this.fileSystem.getBasePath());
36
- const contentValue = DocFileContentIndexValue.empty(dirName);
37
- return new DocFileIndexEntity({
38
- type: "index",
39
- path: pathValue.toJson(),
40
- content: contentValue.toJson(),
41
- isArchived: false,
42
- });
43
- }
44
- const pathValue = DocFilePathValue.fromPathWithSystem(this.filePath, this.pathSystem, this.fileSystem.getBasePath());
45
- const contentValue = DocFileContentIndexValue.fromMarkdown(content);
46
- return new DocFileIndexEntity({
47
- type: "index",
48
- path: pathValue.toJson(),
49
- content: contentValue.toJson(),
50
- isArchived: false,
51
- });
52
- }
53
- /**
54
- * ファイルの内容を読み込む
55
- */
56
- async readContent() {
57
- const entity = await this.read();
58
- if (entity instanceof Error) {
59
- return entity;
60
- }
61
- return entity.value.content.body;
62
- }
63
- /**
64
- * ファイルに内容を書き込む
65
- */
66
- async writeContent(content) {
67
- await this.fileSystem.writeFile(this.filePath, content);
68
- }
69
- /**
70
- * Entityを書き込む
71
- */
72
- async write(entity) {
73
- const content = entity.content.toText();
74
- await this.fileSystem.writeFile(this.filePath, content);
75
- }
76
- /**
77
- * 新しいファイルをデフォルトコンテンツで作成
78
- */
79
- async writeDefault() {
80
- const dirPath = this.pathSystem.dirname(this.filePath);
81
- const dirName = this.pathSystem.basename(dirPath) || "ディレクトリ";
82
- const defaultContent = [
83
- `# ${dirName}`,
84
- "",
85
- `${dirName}に関する概要をここに記載してください。`,
86
- ].join("\n");
87
- await this.fileSystem.writeFile(this.filePath, defaultContent);
88
- }
89
- /**
90
- * ファイルを削除
91
- */
92
- async delete() {
93
- return await this.fileSystem.deleteFile(this.filePath);
94
- }
95
- /**
96
- * ファイルが存在するか確認
97
- */
98
- async exists() {
99
- return this.fileSystem.exists(this.filePath);
100
- }
101
- async relations() {
102
- const indexFile = await this.read();
103
- if (indexFile instanceof Error) {
104
- return [];
105
- }
106
- const schema = indexFile.content.frontMatter.value.schema;
107
- if (!schema) {
108
- return [];
109
- }
110
- const relationFields = Object.entries(schema).filter(([_key, field]) => {
111
- return field.type === "relation" || field.type === "multi-relation";
112
- });
113
- return relationFields.map(([, field]) => {
114
- if ((field.type === "relation" || field.type === "multi-relation") &&
115
- field.path) {
116
- return new DocFileRelationReference({
117
- filePath: field.path,
118
- fileSystem: this.fileSystem,
119
- pathSystem: this.pathSystem,
120
- });
121
- }
122
- throw new Error("Unexpected field type or missing path");
123
- });
124
- }
125
- async readRelations() {
126
- const relations = await this.relations();
127
- const files = [];
128
- for (const relation of relations) {
129
- const entity = await relation.read();
130
- if (entity === null)
131
- continue;
132
- files.push(entity);
133
- }
134
- return files;
135
- }
136
- /**
137
- * ファイルのサイズを取得(バイト単位)
138
- */
139
- async size() {
140
- return this.fileSystem.getFileSize(this.filePath);
141
- }
142
- /**
143
- * ファイルの最終更新日時を取得
144
- */
145
- async lastModified() {
146
- return this.fileSystem.getFileModifiedTime(this.filePath);
147
- }
148
- /**
149
- * ファイルの作成日時を取得
150
- */
151
- async createdAt() {
152
- return this.fileSystem.getFileCreatedTime(this.filePath);
153
- }
154
- /**
155
- * ファイルをアーカイブに移動し、新しい参照を返す
156
- */
157
- async archive(archiveDirectoryName = "_") {
158
- const dirPath = this.pathSystem.dirname(this.filePath);
159
- const fileName = this.pathSystem.basename(this.filePath);
160
- const archivePath = this.pathSystem.join(dirPath, archiveDirectoryName, fileName);
161
- // ファイルを移動
162
- await this.fileSystem.moveFile(this.filePath, archivePath);
163
- // 新しいパスで参照を作成
164
- return new DocFileIndexReference({
165
- path: archivePath,
166
- fileSystem: this.fileSystem,
167
- pathSystem: this.pathSystem,
168
- });
169
- }
170
- /**
171
- * ファイルをアーカイブから復元し、新しい参照を返す
172
- */
173
- async restore(archiveDirectoryName = "_") {
174
- const dirPath = this.pathSystem.dirname(this.filePath);
175
- const parentDirName = this.pathSystem.basename(dirPath);
176
- // 親ディレクトリがアーカイブディレクトリでない場合はエラー
177
- if (parentDirName !== archiveDirectoryName) {
178
- throw new Error(`ファイルはアーカイブディレクトリにありません: ${this.filePath}`);
179
- }
180
- const fileName = this.pathSystem.basename(this.filePath);
181
- const restorePath = this.pathSystem.join(this.pathSystem.dirname(dirPath), fileName);
182
- // ファイルを移動
183
- await this.fileSystem.moveFile(this.filePath, restorePath);
184
- // 新しいパスで参照を作成
185
- return new DocFileIndexReference({
186
- path: restorePath,
187
- fileSystem: this.fileSystem,
188
- pathSystem: this.pathSystem,
189
- });
190
- }
191
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=doc-file-index-reference.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"doc-file-index-reference.test.d.ts","sourceRoot":"","sources":["../lib/doc-file-index-reference.test.ts"],"names":[],"mappings":""}
@@ -1,77 +0,0 @@
1
- import { expect, test } from "bun:test";
2
- import { DocFileIndexReference } from "./doc-file-index-reference";
3
- import { DocFileSystemDebug } from "./doc-file-system-debug";
4
- import { DocFileIndexEntity } from "./entities/doc-file-index-entity";
5
- test("DocFileIndexReference - writeメソッドがフロントマターを含む完全なテキストを書き込む", async () => {
6
- const fileSystem = DocFileSystemDebug.createWithFiles({
7
- fileContents: {
8
- "docs/products/features/index.md": [
9
- "---",
10
- "icon: 📄",
11
- "schema:",
12
- " milestone:",
13
- " type: relation",
14
- " required: false",
15
- " title: マイルストーン",
16
- " path: products/milestones",
17
- "---",
18
- "",
19
- "# 機能",
20
- "",
21
- "機能の説明",
22
- ].join("\n"),
23
- },
24
- });
25
- const ref = new DocFileIndexReference({
26
- path: "products/features/index.md",
27
- fileSystem,
28
- pathSystem: fileSystem.getPathSystem(),
29
- });
30
- // 既存のエンティティを読み込む
31
- const entity = await ref.read();
32
- expect(entity).toBeInstanceOf(DocFileIndexEntity);
33
- // タイトルを更新
34
- const updatedEntity = entity.withContent(entity.content.withTitle("新しいタイトル"));
35
- // ファイルに書き込む
36
- await ref.write(updatedEntity);
37
- // ファイルの内容を確認
38
- const writtenContent = fileSystem.getFileContent("docs/products/features/index.md");
39
- expect(writtenContent).toBeTruthy();
40
- // フロントマターが保持されていることを確認
41
- expect(writtenContent).toContain("---");
42
- expect(writtenContent).toContain("icon: 📄");
43
- expect(writtenContent).toContain("schema:");
44
- expect(writtenContent).toContain("type: relation");
45
- // タイトルが更新されていることを確認
46
- expect(writtenContent).toContain("# 新しいタイトル");
47
- // typeフィールドが含まれていないことを確認
48
- expect(writtenContent).not.toContain("type: index-frontmatter");
49
- });
50
- test("DocFileIndexReference - readメソッドが正しくエンティティを返す", async () => {
51
- const fileSystem = DocFileSystemDebug.createWithFiles({
52
- fileContents: {
53
- "docs/index.md": [
54
- "---",
55
- "icon: 📚",
56
- "schema: {}",
57
- "---",
58
- "",
59
- "# ドキュメント",
60
- "",
61
- "説明文",
62
- ].join("\n"),
63
- },
64
- });
65
- const ref = new DocFileIndexReference({
66
- path: "docs/index.md",
67
- fileSystem,
68
- pathSystem: fileSystem.getPathSystem(),
69
- });
70
- const entity = await ref.read();
71
- expect(entity).toBeInstanceOf(DocFileIndexEntity);
72
- // コンテンツの確認
73
- expect(entity.content.title).toBe("ドキュメント");
74
- expect(entity.content.description).toBe("説明文");
75
- expect(entity.content.frontMatter.value.icon).toBe("📚");
76
- expect(entity.content.frontMatter.value.schema).toEqual({});
77
- });
@@ -1,97 +0,0 @@
1
- import { DocDirectoryReference } from "./doc-directory-reference";
2
- import type { DocFileSystem } from "./doc-file-system";
3
- import type { DocPathSystem } from "./doc-path-system";
4
- import { DocFileMdEntity } from "./entities/doc-file-md-entity";
5
- type Props = {
6
- path: string;
7
- fileSystem: DocFileSystem;
8
- pathSystem: DocPathSystem;
9
- };
10
- /**
11
- * ファイルの参照
12
- */
13
- export declare class DocFileMdReference {
14
- private readonly props;
15
- private readonly pathSystem;
16
- constructor(props: Props);
17
- get fileSystem(): DocFileSystem;
18
- get basePath(): string;
19
- get path(): string;
20
- get fullPath(): string;
21
- get directoryPath(): string;
22
- get archivedPath(): string;
23
- get name(): string;
24
- get nameWithExtension(): string;
25
- directory(): DocDirectoryReference;
26
- read(): Promise<Error | DocFileMdEntity>;
27
- /**
28
- * ファイルの内容を読み込む
29
- */
30
- readContent(): Promise<Error | string>;
31
- /**
32
- * ファイルに内容を書き込む
33
- */
34
- writeContent(content: string): Promise<void>;
35
- /**
36
- * Entityを書き込む
37
- */
38
- write(entity: DocFileMdEntity): Promise<void>;
39
- /**
40
- * 新しいファイルをデフォルトコンテンツで作成
41
- */
42
- writeDefault(): Promise<void>;
43
- /**
44
- * ファイルを削除
45
- */
46
- delete(): Promise<Error | null>;
47
- /**
48
- * ファイルが存在するか確認(アーカイブも含む)
49
- */
50
- exists(): Promise<boolean>;
51
- /**
52
- * ファイルをコピー
53
- */
54
- copyTo(destinationPath: string): Promise<void>;
55
- /**
56
- * ファイルを移動
57
- */
58
- moveTo(destinationPath: string): Promise<void>;
59
- /**
60
- * ファイルのサイズを取得(バイト単位)
61
- */
62
- size(): Promise<number>;
63
- /**
64
- * ファイルの最終更新日時を取得
65
- */
66
- lastModified(): Promise<Date>;
67
- /**
68
- * ファイルの作成日時を取得
69
- */
70
- createdAt(): Promise<Date>;
71
- /**
72
- * ファイルをアーカイブに移動し、新しい参照を返す
73
- */
74
- archive(archiveDirectoryName?: string): Promise<DocFileMdReference>;
75
- /**
76
- * ファイルをアーカイブから復元し、新しい参照を返す
77
- */
78
- restore(archiveDirectoryName?: string): Promise<DocFileMdReference>;
79
- /**
80
- * スキーマに基づいてリレーションを取得する
81
- */
82
- relation(key: string): Promise<DocFileMdReference | Error | null>;
83
- /**
84
- * 同じディレクトリのindex.mdを取得する
85
- */
86
- getDirectoryIndex(): Promise<DocFileMdEntity | null>;
87
- /**
88
- * 複数のリレーションを取得する
89
- */
90
- relations(key: string): Promise<DocFileMdReference[]>;
91
- /**
92
- * スキーマに基づいて複数のリレーションを取得する
93
- */
94
- multiRelation(key: string): Promise<DocFileMdReference[]>;
95
- }
96
- export {};
97
- //# sourceMappingURL=doc-file-md-reference.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"doc-file-md-reference.d.ts","sourceRoot":"","sources":["../lib/doc-file-md-reference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAM/D,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,aAAa,CAAA;IACzB,UAAU,EAAE,aAAa,CAAA;CAC1B,CAAA;AAED;;GAEG;AACH,qBAAa,kBAAkB;IAGjB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAFlC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAe;IAE1C,YAA6B,KAAK,EAAE,KAAK,EAGxC;IAED,IAAI,UAAU,IAAI,aAAa,CAE9B;IAED,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,iBAAiB,IAAI,MAAM,CAE9B;IAED,SAAS,IAAI,qBAAqB,CAQjC;IAEK,IAAI,IAAI,OAAO,CAAC,KAAK,GAAG,eAAe,CAAC,CA4C7C;IAED;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,CAM3C;IAED;;OAEG;IACG,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjD;IAED;;OAEG;IACG,KAAK,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAGlD;IAED;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAQlC;IAED;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAEpC;IAED;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,CAY/B;IAED;;OAEG;IACG,MAAM,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnD;IAED;;OAEG;IACG,MAAM,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnD;IAED;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAE5B;IAED;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAElC;IAED;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAE/B;IAED;;OAEG;IACG,OAAO,CAAC,oBAAoB,SAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAkBrE;IAED;;OAEG;IACG,OAAO,CAAC,oBAAoB,SAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAyBrE;IAED;;OAEG;IACG,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,GAAG,KAAK,GAAG,IAAI,CAAC,CA2CtE;IAED;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAczD;IAED;;OAEG;IACG,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAE1D;IAED;;OAEG;IACG,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CA6C9D;CACF"}
@@ -1,297 +0,0 @@
1
- import { DocDirectoryReference } from "./doc-directory-reference";
2
- import { DocFileMdEntity } from "./entities/doc-file-md-entity";
3
- import { DocFileContentMdValue } from "./values/doc-file-content-md-value";
4
- import { DocFilePathValue } from "./values/doc-file-path-value";
5
- import { DocSchemaValue } from "./values/doc-schema-value";
6
- /**
7
- * ファイルの参照
8
- */
9
- export class DocFileMdReference {
10
- props;
11
- pathSystem;
12
- constructor(props) {
13
- this.props = props;
14
- this.pathSystem = props.pathSystem;
15
- Object.freeze(this);
16
- }
17
- get fileSystem() {
18
- return this.props.fileSystem;
19
- }
20
- get basePath() {
21
- return this.fileSystem.getBasePath();
22
- }
23
- get path() {
24
- return this.props.path;
25
- }
26
- get fullPath() {
27
- return this.pathSystem.join(this.basePath, this.path);
28
- }
29
- get directoryPath() {
30
- return this.pathSystem.dirname(this.path);
31
- }
32
- get archivedPath() {
33
- return this.pathSystem.join(this.directoryPath, "_", this.nameWithExtension);
34
- }
35
- get name() {
36
- return this.pathSystem.basename(this.path, ".md");
37
- }
38
- get nameWithExtension() {
39
- return `${this.name}.md`;
40
- }
41
- directory() {
42
- return new DocDirectoryReference({
43
- archiveDirectoryName: "_",
44
- indexFileName: "index.md",
45
- fileSystem: this.fileSystem,
46
- path: this.directoryPath,
47
- pathSystem: this.pathSystem,
48
- });
49
- }
50
- async read() {
51
- const content = await this.fileSystem.readFile(this.path);
52
- const actualPath = this.path;
53
- if (content === null) {
54
- const content = await this.fileSystem.readFile(this.archivedPath);
55
- if (content !== null) {
56
- const contentValue = DocFileContentMdValue.fromMarkdown(content);
57
- const pathValue = DocFilePathValue.fromPathWithSystem(actualPath, this.pathSystem, this.basePath);
58
- return new DocFileMdEntity({
59
- type: "markdown",
60
- content: contentValue.value,
61
- path: pathValue.value,
62
- isArchived: true,
63
- });
64
- }
65
- }
66
- if (content === null) {
67
- return new Error(`File not found at ${this.path} or in archive.`);
68
- }
69
- const contentValue = DocFileContentMdValue.fromMarkdown(content);
70
- const pathValue = DocFilePathValue.fromPathWithSystem(actualPath, this.pathSystem, this.basePath);
71
- // アーカイブディレクトリにあるファイルかどうかをチェック
72
- const isInArchiveDir = this.path.includes("/_/") || this.path.startsWith("_/");
73
- return new DocFileMdEntity({
74
- type: "markdown",
75
- content: contentValue.value,
76
- path: pathValue.value,
77
- isArchived: isInArchiveDir,
78
- });
79
- }
80
- /**
81
- * ファイルの内容を読み込む
82
- */
83
- async readContent() {
84
- const entity = await this.read();
85
- if (entity instanceof Error) {
86
- return entity;
87
- }
88
- return entity.value.content.body;
89
- }
90
- /**
91
- * ファイルに内容を書き込む
92
- */
93
- async writeContent(content) {
94
- return await this.fileSystem.writeFile(this.path, content);
95
- }
96
- /**
97
- * Entityを書き込む
98
- */
99
- async write(entity) {
100
- const content = entity.content.toText();
101
- return await this.fileSystem.writeFile(this.path, content);
102
- }
103
- /**
104
- * 新しいファイルをデフォルトコンテンツで作成
105
- */
106
- async writeDefault() {
107
- const fileName = this.pathSystem.basename(this.path, ".md");
108
- const defaultContent = [
109
- `# ${fileName}`,
110
- "",
111
- "ここに内容を記載してください。",
112
- ].join("\n");
113
- return await this.fileSystem.writeFile(this.path, defaultContent);
114
- }
115
- /**
116
- * ファイルを削除
117
- */
118
- async delete() {
119
- return await this.fileSystem.deleteFile(this.path);
120
- }
121
- /**
122
- * ファイルが存在するか確認(アーカイブも含む)
123
- */
124
- async exists() {
125
- // まず通常のパスを確認
126
- if (await this.fileSystem.exists(this.path)) {
127
- return true;
128
- }
129
- // アーカイブディレクトリを確認
130
- const dirPath = this.pathSystem.dirname(this.path);
131
- const fileName = this.pathSystem.basename(this.path);
132
- const archivePath = this.pathSystem.join(dirPath, "_", fileName);
133
- return this.fileSystem.exists(archivePath);
134
- }
135
- /**
136
- * ファイルをコピー
137
- */
138
- async copyTo(destinationPath) {
139
- await this.fileSystem.copyFile(this.path, destinationPath);
140
- }
141
- /**
142
- * ファイルを移動
143
- */
144
- async moveTo(destinationPath) {
145
- await this.fileSystem.moveFile(this.path, destinationPath);
146
- }
147
- /**
148
- * ファイルのサイズを取得(バイト単位)
149
- */
150
- async size() {
151
- return this.fileSystem.getFileSize(this.path);
152
- }
153
- /**
154
- * ファイルの最終更新日時を取得
155
- */
156
- async lastModified() {
157
- return this.fileSystem.getFileModifiedTime(this.path);
158
- }
159
- /**
160
- * ファイルの作成日時を取得
161
- */
162
- async createdAt() {
163
- return this.fileSystem.getFileCreatedTime(this.path);
164
- }
165
- /**
166
- * ファイルをアーカイブに移動し、新しい参照を返す
167
- */
168
- async archive(archiveDirectoryName = "_") {
169
- const dirPath = this.pathSystem.dirname(this.path);
170
- const fileName = this.pathSystem.basename(this.path);
171
- const archivePath = this.pathSystem.join(dirPath, archiveDirectoryName, fileName);
172
- await this.moveTo(archivePath);
173
- return new DocFileMdReference({
174
- path: archivePath,
175
- fileSystem: this.fileSystem,
176
- pathSystem: this.pathSystem,
177
- });
178
- }
179
- /**
180
- * ファイルをアーカイブから復元し、新しい参照を返す
181
- */
182
- async restore(archiveDirectoryName = "_") {
183
- const dirPath = this.pathSystem.dirname(this.path);
184
- const parentDirName = this.pathSystem.basename(dirPath);
185
- if (parentDirName !== archiveDirectoryName) {
186
- throw new Error(`ファイルはアーカイブディレクトリにありません: ${this.path}`);
187
- }
188
- const fileName = this.pathSystem.basename(this.path);
189
- const restorePath = this.pathSystem.join(this.pathSystem.dirname(dirPath), fileName);
190
- await this.moveTo(restorePath);
191
- return new DocFileMdReference({
192
- path: restorePath,
193
- fileSystem: this.fileSystem,
194
- pathSystem: this.pathSystem,
195
- });
196
- }
197
- /**
198
- * スキーマに基づいてリレーションを取得する
199
- */
200
- async relation(key) {
201
- const file = await this.read();
202
- if (file instanceof Error) {
203
- return file;
204
- }
205
- // FrontMatterからリレーション値を取得
206
- const relationValue = file.content.frontMatter.relation(key);
207
- if (relationValue === null) {
208
- return null;
209
- }
210
- // 同じディレクトリのindex.mdを取得
211
- const indexFile = await this.getDirectoryIndex();
212
- if (!indexFile) {
213
- return null;
214
- }
215
- const schemaData = indexFile.content.frontMatter.value.schema;
216
- if (!schemaData ||
217
- typeof schemaData !== "object" ||
218
- Array.isArray(schemaData)) {
219
- return null;
220
- }
221
- const schema = new DocSchemaValue(schemaData);
222
- const field = schema.field(key);
223
- // リレーションフィールドでない場合はnull
224
- if (!field || !("path" in field) || !field.path) {
225
- return null;
226
- }
227
- // スキーマで定義されたパスとリレーション値を組み合わせる
228
- const fullPath = this.pathSystem.join(field.path, `${relationValue}.md`);
229
- return new DocFileMdReference({
230
- path: fullPath,
231
- fileSystem: this.fileSystem,
232
- pathSystem: this.pathSystem,
233
- });
234
- }
235
- /**
236
- * 同じディレクトリのindex.mdを取得する
237
- */
238
- async getDirectoryIndex() {
239
- const indexPath = this.pathSystem.join(this.directoryPath, "index.md");
240
- const indexRef = new DocFileMdReference({
241
- path: indexPath,
242
- fileSystem: this.fileSystem,
243
- pathSystem: this.pathSystem,
244
- });
245
- const indexFile = await indexRef.read();
246
- if (indexFile instanceof Error) {
247
- return null;
248
- }
249
- return indexFile;
250
- }
251
- /**
252
- * 複数のリレーションを取得する
253
- */
254
- async relations(key) {
255
- return this.multiRelation(key);
256
- }
257
- /**
258
- * スキーマに基づいて複数のリレーションを取得する
259
- */
260
- async multiRelation(key) {
261
- const file = await this.read();
262
- if (file instanceof Error) {
263
- return [];
264
- }
265
- // FrontMatterから複数リレーション値を取得
266
- const relationValues = file.content.frontMatter.multiRelation(key);
267
- if (relationValues.length === 0) {
268
- return [];
269
- }
270
- // 同じディレクトリのindex.mdを取得
271
- const indexFile = await this.getDirectoryIndex();
272
- if (!indexFile) {
273
- return [];
274
- }
275
- const schemaData = indexFile.content.frontMatter.value.schema;
276
- if (!schemaData ||
277
- typeof schemaData !== "object" ||
278
- Array.isArray(schemaData)) {
279
- return [];
280
- }
281
- const schema = new DocSchemaValue(schemaData);
282
- const field = schema.field(key);
283
- // リレーションフィールドでない場合は空配列
284
- if (!field || !("path" in field) || !field.path) {
285
- return [];
286
- }
287
- // 各リレーション値に対してDocFileMdReferenceを作成
288
- return relationValues.map((relationValue) => {
289
- const fullPath = this.pathSystem.join(field.path, `${relationValue}.md`);
290
- return new DocFileMdReference({
291
- path: fullPath,
292
- fileSystem: this.fileSystem,
293
- pathSystem: this.pathSystem,
294
- });
295
- });
296
- }
297
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=doc-file-md-reference.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"doc-file-md-reference.test.d.ts","sourceRoot":"","sources":["../lib/doc-file-md-reference.test.ts"],"names":[],"mappings":""}