@wonseok-han/confluence-sync 1.8.0 → 2.0.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 (518) hide show
  1. package/README.md +44 -410
  2. package/dist/cli/args.js +1 -1
  3. package/dist/cli/help.js +214 -115
  4. package/dist/cli/init.js +44 -5
  5. package/dist/cli/main.js +42 -11
  6. package/dist/cli/status.js +83 -0
  7. package/dist/confluence/client.js +121 -57
  8. package/dist/confluence/config.js +12 -8
  9. package/dist/confluence/env-file.js +23 -0
  10. package/dist/confluence/links.js +18 -0
  11. package/dist/conversion/asset-paths.js +5 -0
  12. package/dist/conversion/attachments.js +29 -7
  13. package/dist/conversion/convert.js +10 -22
  14. package/dist/conversion/footnotes.js +114 -11
  15. package/dist/conversion/markdown.js +26 -0
  16. package/dist/conversion/pdf-pages.js +10 -8
  17. package/dist/documents/anchors.js +9 -0
  18. package/dist/documents/callout-roundtrip.js +75 -0
  19. package/dist/documents/callouts.js +74 -0
  20. package/dist/documents/catalog.js +2 -2
  21. package/dist/documents/footnote-roundtrip.js +96 -0
  22. package/dist/documents/format.js +116 -0
  23. package/dist/documents/html-tables.js +30 -0
  24. package/dist/documents/html-to-markdown.js +47 -13
  25. package/dist/documents/markdown.js +46 -4
  26. package/dist/documents/obsidian.js +6 -3
  27. package/dist/documents/tables.js +89 -0
  28. package/dist/runtime/network.js +4 -0
  29. package/dist/shared/colors.js +2 -2
  30. package/dist/shared/progress.js +164 -0
  31. package/dist/shared/version.js +12 -0
  32. package/dist/site/assets/Monaco-LICENSE.txt +21 -0
  33. package/dist/site/assets/Monaco-ThirdPartyNotices.txt +448 -0
  34. package/dist/site/assets/PDFJS-LICENSE.txt +177 -0
  35. package/dist/site/assets/app.css +1 -0
  36. package/dist/site/assets/app.js +4 -0
  37. package/dist/site/assets/chunks/chunk-TEW74QPN.js +35 -0
  38. package/dist/site/assets/chunks/markdown-S6623E66.js +1 -0
  39. package/dist/site/assets/chunks/monaco-36ZGUH4Y.js +897 -0
  40. package/dist/site/assets/chunks/monaco-HFLEBJTI.css +1 -0
  41. package/dist/site/assets/chunks/pdf-DDN7TXTP.js +55 -0
  42. package/dist/site/assets/confluence-env-example.txt +32 -0
  43. package/dist/site/assets/editor.worker.js +1 -0
  44. package/dist/site/assets/favicon.svg +3 -0
  45. package/dist/site/assets/guide/01-account-settings.png +0 -0
  46. package/dist/site/assets/guide/02-atlassian-security.png +0 -0
  47. package/dist/site/assets/guide/03-api-tokens.png +0 -0
  48. package/dist/site/assets/guide/04-scope-api-token-step1.png +0 -0
  49. package/dist/site/assets/guide/05-scope-api-token-step2.png +0 -0
  50. package/dist/site/assets/guide/06-scope-api-token-step3.png +0 -0
  51. package/dist/site/assets/guide/07-scope-api-token-step4.png +0 -0
  52. package/dist/site/assets/guide/web/document-preview.png +0 -0
  53. package/dist/site/assets/guide/web/remote-diff.png +0 -0
  54. package/dist/site/assets/guide/web/sync-workspace.png +0 -0
  55. package/dist/site/assets/pdf/cmaps/78-EUC-H.bcmap +0 -0
  56. package/dist/site/assets/pdf/cmaps/78-EUC-V.bcmap +0 -0
  57. package/dist/site/assets/pdf/cmaps/78-H.bcmap +0 -0
  58. package/dist/site/assets/pdf/cmaps/78-RKSJ-H.bcmap +0 -0
  59. package/dist/site/assets/pdf/cmaps/78-RKSJ-V.bcmap +0 -0
  60. package/dist/site/assets/pdf/cmaps/78-V.bcmap +0 -0
  61. package/dist/site/assets/pdf/cmaps/78ms-RKSJ-H.bcmap +0 -0
  62. package/dist/site/assets/pdf/cmaps/78ms-RKSJ-V.bcmap +0 -0
  63. package/dist/site/assets/pdf/cmaps/83pv-RKSJ-H.bcmap +0 -0
  64. package/dist/site/assets/pdf/cmaps/90ms-RKSJ-H.bcmap +0 -0
  65. package/dist/site/assets/pdf/cmaps/90ms-RKSJ-V.bcmap +0 -0
  66. package/dist/site/assets/pdf/cmaps/90msp-RKSJ-H.bcmap +0 -0
  67. package/dist/site/assets/pdf/cmaps/90msp-RKSJ-V.bcmap +0 -0
  68. package/dist/site/assets/pdf/cmaps/90pv-RKSJ-H.bcmap +0 -0
  69. package/dist/site/assets/pdf/cmaps/90pv-RKSJ-V.bcmap +0 -0
  70. package/dist/site/assets/pdf/cmaps/Add-H.bcmap +0 -0
  71. package/dist/site/assets/pdf/cmaps/Add-RKSJ-H.bcmap +0 -0
  72. package/dist/site/assets/pdf/cmaps/Add-RKSJ-V.bcmap +0 -0
  73. package/dist/site/assets/pdf/cmaps/Add-V.bcmap +0 -0
  74. package/dist/site/assets/pdf/cmaps/Adobe-CNS1-0.bcmap +0 -0
  75. package/dist/site/assets/pdf/cmaps/Adobe-CNS1-1.bcmap +0 -0
  76. package/dist/site/assets/pdf/cmaps/Adobe-CNS1-2.bcmap +0 -0
  77. package/dist/site/assets/pdf/cmaps/Adobe-CNS1-3.bcmap +0 -0
  78. package/dist/site/assets/pdf/cmaps/Adobe-CNS1-4.bcmap +0 -0
  79. package/dist/site/assets/pdf/cmaps/Adobe-CNS1-5.bcmap +0 -0
  80. package/dist/site/assets/pdf/cmaps/Adobe-CNS1-6.bcmap +0 -0
  81. package/dist/site/assets/pdf/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  82. package/dist/site/assets/pdf/cmaps/Adobe-GB1-0.bcmap +0 -0
  83. package/dist/site/assets/pdf/cmaps/Adobe-GB1-1.bcmap +0 -0
  84. package/dist/site/assets/pdf/cmaps/Adobe-GB1-2.bcmap +0 -0
  85. package/dist/site/assets/pdf/cmaps/Adobe-GB1-3.bcmap +0 -0
  86. package/dist/site/assets/pdf/cmaps/Adobe-GB1-4.bcmap +0 -0
  87. package/dist/site/assets/pdf/cmaps/Adobe-GB1-5.bcmap +0 -0
  88. package/dist/site/assets/pdf/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  89. package/dist/site/assets/pdf/cmaps/Adobe-Japan1-0.bcmap +0 -0
  90. package/dist/site/assets/pdf/cmaps/Adobe-Japan1-1.bcmap +0 -0
  91. package/dist/site/assets/pdf/cmaps/Adobe-Japan1-2.bcmap +0 -0
  92. package/dist/site/assets/pdf/cmaps/Adobe-Japan1-3.bcmap +0 -0
  93. package/dist/site/assets/pdf/cmaps/Adobe-Japan1-4.bcmap +0 -0
  94. package/dist/site/assets/pdf/cmaps/Adobe-Japan1-5.bcmap +0 -0
  95. package/dist/site/assets/pdf/cmaps/Adobe-Japan1-6.bcmap +0 -0
  96. package/dist/site/assets/pdf/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  97. package/dist/site/assets/pdf/cmaps/Adobe-Korea1-0.bcmap +0 -0
  98. package/dist/site/assets/pdf/cmaps/Adobe-Korea1-1.bcmap +0 -0
  99. package/dist/site/assets/pdf/cmaps/Adobe-Korea1-2.bcmap +0 -0
  100. package/dist/site/assets/pdf/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  101. package/dist/site/assets/pdf/cmaps/B5-H.bcmap +0 -0
  102. package/dist/site/assets/pdf/cmaps/B5-V.bcmap +0 -0
  103. package/dist/site/assets/pdf/cmaps/B5pc-H.bcmap +0 -0
  104. package/dist/site/assets/pdf/cmaps/B5pc-V.bcmap +0 -0
  105. package/dist/site/assets/pdf/cmaps/CNS-EUC-H.bcmap +0 -0
  106. package/dist/site/assets/pdf/cmaps/CNS-EUC-V.bcmap +0 -0
  107. package/dist/site/assets/pdf/cmaps/CNS1-H.bcmap +0 -0
  108. package/dist/site/assets/pdf/cmaps/CNS1-V.bcmap +0 -0
  109. package/dist/site/assets/pdf/cmaps/CNS2-H.bcmap +0 -0
  110. package/dist/site/assets/pdf/cmaps/CNS2-V.bcmap +3 -0
  111. package/dist/site/assets/pdf/cmaps/ETHK-B5-H.bcmap +0 -0
  112. package/dist/site/assets/pdf/cmaps/ETHK-B5-V.bcmap +0 -0
  113. package/dist/site/assets/pdf/cmaps/ETen-B5-H.bcmap +0 -0
  114. package/dist/site/assets/pdf/cmaps/ETen-B5-V.bcmap +0 -0
  115. package/dist/site/assets/pdf/cmaps/ETenms-B5-H.bcmap +3 -0
  116. package/dist/site/assets/pdf/cmaps/ETenms-B5-V.bcmap +0 -0
  117. package/dist/site/assets/pdf/cmaps/EUC-H.bcmap +0 -0
  118. package/dist/site/assets/pdf/cmaps/EUC-V.bcmap +0 -0
  119. package/dist/site/assets/pdf/cmaps/Ext-H.bcmap +0 -0
  120. package/dist/site/assets/pdf/cmaps/Ext-RKSJ-H.bcmap +0 -0
  121. package/dist/site/assets/pdf/cmaps/Ext-RKSJ-V.bcmap +0 -0
  122. package/dist/site/assets/pdf/cmaps/Ext-V.bcmap +0 -0
  123. package/dist/site/assets/pdf/cmaps/GB-EUC-H.bcmap +0 -0
  124. package/dist/site/assets/pdf/cmaps/GB-EUC-V.bcmap +0 -0
  125. package/dist/site/assets/pdf/cmaps/GB-H.bcmap +4 -0
  126. package/dist/site/assets/pdf/cmaps/GB-V.bcmap +0 -0
  127. package/dist/site/assets/pdf/cmaps/GBK-EUC-H.bcmap +0 -0
  128. package/dist/site/assets/pdf/cmaps/GBK-EUC-V.bcmap +0 -0
  129. package/dist/site/assets/pdf/cmaps/GBK2K-H.bcmap +0 -0
  130. package/dist/site/assets/pdf/cmaps/GBK2K-V.bcmap +0 -0
  131. package/dist/site/assets/pdf/cmaps/GBKp-EUC-H.bcmap +0 -0
  132. package/dist/site/assets/pdf/cmaps/GBKp-EUC-V.bcmap +0 -0
  133. package/dist/site/assets/pdf/cmaps/GBT-EUC-H.bcmap +0 -0
  134. package/dist/site/assets/pdf/cmaps/GBT-EUC-V.bcmap +0 -0
  135. package/dist/site/assets/pdf/cmaps/GBT-H.bcmap +0 -0
  136. package/dist/site/assets/pdf/cmaps/GBT-V.bcmap +0 -0
  137. package/dist/site/assets/pdf/cmaps/GBTpc-EUC-H.bcmap +0 -0
  138. package/dist/site/assets/pdf/cmaps/GBTpc-EUC-V.bcmap +0 -0
  139. package/dist/site/assets/pdf/cmaps/GBpc-EUC-H.bcmap +0 -0
  140. package/dist/site/assets/pdf/cmaps/GBpc-EUC-V.bcmap +0 -0
  141. package/dist/site/assets/pdf/cmaps/H.bcmap +0 -0
  142. package/dist/site/assets/pdf/cmaps/HKdla-B5-H.bcmap +0 -0
  143. package/dist/site/assets/pdf/cmaps/HKdla-B5-V.bcmap +0 -0
  144. package/dist/site/assets/pdf/cmaps/HKdlb-B5-H.bcmap +0 -0
  145. package/dist/site/assets/pdf/cmaps/HKdlb-B5-V.bcmap +0 -0
  146. package/dist/site/assets/pdf/cmaps/HKgccs-B5-H.bcmap +0 -0
  147. package/dist/site/assets/pdf/cmaps/HKgccs-B5-V.bcmap +0 -0
  148. package/dist/site/assets/pdf/cmaps/HKm314-B5-H.bcmap +0 -0
  149. package/dist/site/assets/pdf/cmaps/HKm314-B5-V.bcmap +0 -0
  150. package/dist/site/assets/pdf/cmaps/HKm471-B5-H.bcmap +0 -0
  151. package/dist/site/assets/pdf/cmaps/HKm471-B5-V.bcmap +0 -0
  152. package/dist/site/assets/pdf/cmaps/HKscs-B5-H.bcmap +0 -0
  153. package/dist/site/assets/pdf/cmaps/HKscs-B5-V.bcmap +0 -0
  154. package/dist/site/assets/pdf/cmaps/Hankaku.bcmap +0 -0
  155. package/dist/site/assets/pdf/cmaps/Hiragana.bcmap +0 -0
  156. package/dist/site/assets/pdf/cmaps/KSC-EUC-H.bcmap +0 -0
  157. package/dist/site/assets/pdf/cmaps/KSC-EUC-V.bcmap +0 -0
  158. package/dist/site/assets/pdf/cmaps/KSC-H.bcmap +0 -0
  159. package/dist/site/assets/pdf/cmaps/KSC-Johab-H.bcmap +0 -0
  160. package/dist/site/assets/pdf/cmaps/KSC-Johab-V.bcmap +0 -0
  161. package/dist/site/assets/pdf/cmaps/KSC-V.bcmap +0 -0
  162. package/dist/site/assets/pdf/cmaps/KSCms-UHC-H.bcmap +0 -0
  163. package/dist/site/assets/pdf/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  164. package/dist/site/assets/pdf/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  165. package/dist/site/assets/pdf/cmaps/KSCms-UHC-V.bcmap +0 -0
  166. package/dist/site/assets/pdf/cmaps/KSCpc-EUC-H.bcmap +0 -0
  167. package/dist/site/assets/pdf/cmaps/KSCpc-EUC-V.bcmap +0 -0
  168. package/dist/site/assets/pdf/cmaps/Katakana.bcmap +0 -0
  169. package/dist/site/assets/pdf/cmaps/LICENSE +36 -0
  170. package/dist/site/assets/pdf/cmaps/NWP-H.bcmap +0 -0
  171. package/dist/site/assets/pdf/cmaps/NWP-V.bcmap +0 -0
  172. package/dist/site/assets/pdf/cmaps/RKSJ-H.bcmap +0 -0
  173. package/dist/site/assets/pdf/cmaps/RKSJ-V.bcmap +0 -0
  174. package/dist/site/assets/pdf/cmaps/Roman.bcmap +0 -0
  175. package/dist/site/assets/pdf/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  176. package/dist/site/assets/pdf/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  177. package/dist/site/assets/pdf/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  178. package/dist/site/assets/pdf/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  179. package/dist/site/assets/pdf/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  180. package/dist/site/assets/pdf/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  181. package/dist/site/assets/pdf/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  182. package/dist/site/assets/pdf/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  183. package/dist/site/assets/pdf/cmaps/UniGB-UCS2-H.bcmap +0 -0
  184. package/dist/site/assets/pdf/cmaps/UniGB-UCS2-V.bcmap +0 -0
  185. package/dist/site/assets/pdf/cmaps/UniGB-UTF16-H.bcmap +0 -0
  186. package/dist/site/assets/pdf/cmaps/UniGB-UTF16-V.bcmap +0 -0
  187. package/dist/site/assets/pdf/cmaps/UniGB-UTF32-H.bcmap +0 -0
  188. package/dist/site/assets/pdf/cmaps/UniGB-UTF32-V.bcmap +0 -0
  189. package/dist/site/assets/pdf/cmaps/UniGB-UTF8-H.bcmap +0 -0
  190. package/dist/site/assets/pdf/cmaps/UniGB-UTF8-V.bcmap +0 -0
  191. package/dist/site/assets/pdf/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  192. package/dist/site/assets/pdf/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  193. package/dist/site/assets/pdf/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  194. package/dist/site/assets/pdf/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  195. package/dist/site/assets/pdf/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  196. package/dist/site/assets/pdf/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  197. package/dist/site/assets/pdf/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  198. package/dist/site/assets/pdf/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  199. package/dist/site/assets/pdf/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  200. package/dist/site/assets/pdf/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  201. package/dist/site/assets/pdf/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  202. package/dist/site/assets/pdf/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  203. package/dist/site/assets/pdf/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  204. package/dist/site/assets/pdf/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  205. package/dist/site/assets/pdf/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  206. package/dist/site/assets/pdf/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  207. package/dist/site/assets/pdf/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  208. package/dist/site/assets/pdf/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  209. package/dist/site/assets/pdf/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  210. package/dist/site/assets/pdf/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  211. package/dist/site/assets/pdf/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  212. package/dist/site/assets/pdf/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  213. package/dist/site/assets/pdf/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  214. package/dist/site/assets/pdf/cmaps/UniKS-UCS2-H.bcmap +0 -0
  215. package/dist/site/assets/pdf/cmaps/UniKS-UCS2-V.bcmap +0 -0
  216. package/dist/site/assets/pdf/cmaps/UniKS-UTF16-H.bcmap +0 -0
  217. package/dist/site/assets/pdf/cmaps/UniKS-UTF16-V.bcmap +0 -0
  218. package/dist/site/assets/pdf/cmaps/UniKS-UTF32-H.bcmap +0 -0
  219. package/dist/site/assets/pdf/cmaps/UniKS-UTF32-V.bcmap +0 -0
  220. package/dist/site/assets/pdf/cmaps/UniKS-UTF8-H.bcmap +0 -0
  221. package/dist/site/assets/pdf/cmaps/UniKS-UTF8-V.bcmap +0 -0
  222. package/dist/site/assets/pdf/cmaps/V.bcmap +0 -0
  223. package/dist/site/assets/pdf/cmaps/WP-Symbol.bcmap +0 -0
  224. package/dist/site/assets/pdf/standard_fonts/FoxitDingbats.pfb +0 -0
  225. package/dist/site/assets/pdf/standard_fonts/FoxitFixed.pfb +0 -0
  226. package/dist/site/assets/pdf/standard_fonts/FoxitFixedBold.pfb +0 -0
  227. package/dist/site/assets/pdf/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
  228. package/dist/site/assets/pdf/standard_fonts/FoxitFixedItalic.pfb +0 -0
  229. package/dist/site/assets/pdf/standard_fonts/FoxitSerif.pfb +0 -0
  230. package/dist/site/assets/pdf/standard_fonts/FoxitSerifBold.pfb +0 -0
  231. package/dist/site/assets/pdf/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
  232. package/dist/site/assets/pdf/standard_fonts/FoxitSerifItalic.pfb +0 -0
  233. package/dist/site/assets/pdf/standard_fonts/FoxitSymbol.pfb +0 -0
  234. package/dist/site/assets/pdf/standard_fonts/LICENSE_FOXIT +27 -0
  235. package/dist/site/assets/pdf/standard_fonts/LICENSE_LIBERATION +363 -0
  236. package/dist/site/assets/pdf/standard_fonts/LiberationSans-Bold.ttf +0 -0
  237. package/dist/site/assets/pdf/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
  238. package/dist/site/assets/pdf/standard_fonts/LiberationSans-Italic.ttf +0 -0
  239. package/dist/site/assets/pdf/standard_fonts/LiberationSans-Regular.ttf +0 -0
  240. package/dist/site/assets/pdf/wasm/LICENSE_JBIG2 +196 -0
  241. package/dist/site/assets/pdf/wasm/LICENSE_OPENJPEG +39 -0
  242. package/dist/site/assets/pdf/wasm/LICENSE_PDFJS_JBIG2 +13 -0
  243. package/dist/site/assets/pdf/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
  244. package/dist/site/assets/pdf/wasm/LICENSE_PDFJS_QCMS +19 -0
  245. package/dist/site/assets/pdf/wasm/LICENSE_QCMS +21 -0
  246. package/dist/site/assets/pdf/wasm/jbig2.wasm +0 -0
  247. package/dist/site/assets/pdf/wasm/jbig2_nowasm_fallback.js +15 -0
  248. package/dist/site/assets/pdf/wasm/openjpeg.wasm +0 -0
  249. package/dist/site/assets/pdf/wasm/openjpeg_nowasm_fallback.js +17 -0
  250. package/dist/site/assets/pdf/wasm/qcms_bg.wasm +0 -0
  251. package/dist/site/assets/pdf/wasm/quickjs-eval.js +16 -0
  252. package/dist/site/assets/pdf/wasm/quickjs-eval.wasm +0 -0
  253. package/dist/site/assets/pdf.worker.min.mjs +29 -0
  254. package/dist/site/assets/workspace.worker.js +409 -0
  255. package/dist/site/index.html +253 -0
  256. package/dist/sync/baseline.js +45 -0
  257. package/dist/sync/changes.js +51 -0
  258. package/dist/sync/diff.js +80 -0
  259. package/dist/sync/fetch.js +287 -0
  260. package/dist/sync/ignore.js +4 -4
  261. package/dist/sync/local-state.js +12 -0
  262. package/dist/sync/mapping.js +31 -8
  263. package/dist/sync/metadata.js +57 -0
  264. package/dist/sync/prepare.js +52 -0
  265. package/dist/sync/pull.js +618 -141
  266. package/dist/sync/push.js +260 -213
  267. package/dist/sync/reconcile.js +51 -0
  268. package/dist/sync/references.js +2 -2
  269. package/dist/sync/remap.js +17 -5
  270. package/dist/sync/render.js +3 -2
  271. package/dist/sync/restore.js +28 -0
  272. package/dist/sync/scope.js +47 -0
  273. package/dist/sync/staging.js +193 -0
  274. package/dist/sync/workspace.js +100 -0
  275. package/dist/web/assets/PDFJS-LICENSE.txt +177 -0
  276. package/dist/web/assets/app.css +1 -1
  277. package/dist/web/assets/app.js +3 -938
  278. package/dist/web/assets/chunks/chunk-TEW74QPN.js +35 -0
  279. package/dist/web/assets/chunks/markdown-S6623E66.js +1 -0
  280. package/dist/web/assets/chunks/monaco-36ZGUH4Y.js +897 -0
  281. package/dist/web/assets/chunks/monaco-HFLEBJTI.css +1 -0
  282. package/dist/web/assets/chunks/pdf-DDN7TXTP.js +55 -0
  283. package/dist/web/assets/confluence-env-example.txt +32 -0
  284. package/dist/web/assets/editor.worker.js +1 -30
  285. package/dist/web/assets/favicon.svg +3 -0
  286. package/dist/web/assets/guide/01-account-settings.png +0 -0
  287. package/dist/web/assets/guide/02-atlassian-security.png +0 -0
  288. package/dist/web/assets/guide/03-api-tokens.png +0 -0
  289. package/dist/web/assets/guide/04-scope-api-token-step1.png +0 -0
  290. package/dist/web/assets/guide/05-scope-api-token-step2.png +0 -0
  291. package/dist/web/assets/guide/06-scope-api-token-step3.png +0 -0
  292. package/dist/web/assets/guide/07-scope-api-token-step4.png +0 -0
  293. package/dist/web/assets/guide/web/document-preview.png +0 -0
  294. package/dist/web/assets/guide/web/remote-diff.png +0 -0
  295. package/dist/web/assets/guide/web/sync-workspace.png +0 -0
  296. package/dist/web/assets/pdf/cmaps/78-EUC-H.bcmap +0 -0
  297. package/dist/web/assets/pdf/cmaps/78-EUC-V.bcmap +0 -0
  298. package/dist/web/assets/pdf/cmaps/78-H.bcmap +0 -0
  299. package/dist/web/assets/pdf/cmaps/78-RKSJ-H.bcmap +0 -0
  300. package/dist/web/assets/pdf/cmaps/78-RKSJ-V.bcmap +0 -0
  301. package/dist/web/assets/pdf/cmaps/78-V.bcmap +0 -0
  302. package/dist/web/assets/pdf/cmaps/78ms-RKSJ-H.bcmap +0 -0
  303. package/dist/web/assets/pdf/cmaps/78ms-RKSJ-V.bcmap +0 -0
  304. package/dist/web/assets/pdf/cmaps/83pv-RKSJ-H.bcmap +0 -0
  305. package/dist/web/assets/pdf/cmaps/90ms-RKSJ-H.bcmap +0 -0
  306. package/dist/web/assets/pdf/cmaps/90ms-RKSJ-V.bcmap +0 -0
  307. package/dist/web/assets/pdf/cmaps/90msp-RKSJ-H.bcmap +0 -0
  308. package/dist/web/assets/pdf/cmaps/90msp-RKSJ-V.bcmap +0 -0
  309. package/dist/web/assets/pdf/cmaps/90pv-RKSJ-H.bcmap +0 -0
  310. package/dist/web/assets/pdf/cmaps/90pv-RKSJ-V.bcmap +0 -0
  311. package/dist/web/assets/pdf/cmaps/Add-H.bcmap +0 -0
  312. package/dist/web/assets/pdf/cmaps/Add-RKSJ-H.bcmap +0 -0
  313. package/dist/web/assets/pdf/cmaps/Add-RKSJ-V.bcmap +0 -0
  314. package/dist/web/assets/pdf/cmaps/Add-V.bcmap +0 -0
  315. package/dist/web/assets/pdf/cmaps/Adobe-CNS1-0.bcmap +0 -0
  316. package/dist/web/assets/pdf/cmaps/Adobe-CNS1-1.bcmap +0 -0
  317. package/dist/web/assets/pdf/cmaps/Adobe-CNS1-2.bcmap +0 -0
  318. package/dist/web/assets/pdf/cmaps/Adobe-CNS1-3.bcmap +0 -0
  319. package/dist/web/assets/pdf/cmaps/Adobe-CNS1-4.bcmap +0 -0
  320. package/dist/web/assets/pdf/cmaps/Adobe-CNS1-5.bcmap +0 -0
  321. package/dist/web/assets/pdf/cmaps/Adobe-CNS1-6.bcmap +0 -0
  322. package/dist/web/assets/pdf/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  323. package/dist/web/assets/pdf/cmaps/Adobe-GB1-0.bcmap +0 -0
  324. package/dist/web/assets/pdf/cmaps/Adobe-GB1-1.bcmap +0 -0
  325. package/dist/web/assets/pdf/cmaps/Adobe-GB1-2.bcmap +0 -0
  326. package/dist/web/assets/pdf/cmaps/Adobe-GB1-3.bcmap +0 -0
  327. package/dist/web/assets/pdf/cmaps/Adobe-GB1-4.bcmap +0 -0
  328. package/dist/web/assets/pdf/cmaps/Adobe-GB1-5.bcmap +0 -0
  329. package/dist/web/assets/pdf/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  330. package/dist/web/assets/pdf/cmaps/Adobe-Japan1-0.bcmap +0 -0
  331. package/dist/web/assets/pdf/cmaps/Adobe-Japan1-1.bcmap +0 -0
  332. package/dist/web/assets/pdf/cmaps/Adobe-Japan1-2.bcmap +0 -0
  333. package/dist/web/assets/pdf/cmaps/Adobe-Japan1-3.bcmap +0 -0
  334. package/dist/web/assets/pdf/cmaps/Adobe-Japan1-4.bcmap +0 -0
  335. package/dist/web/assets/pdf/cmaps/Adobe-Japan1-5.bcmap +0 -0
  336. package/dist/web/assets/pdf/cmaps/Adobe-Japan1-6.bcmap +0 -0
  337. package/dist/web/assets/pdf/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  338. package/dist/web/assets/pdf/cmaps/Adobe-Korea1-0.bcmap +0 -0
  339. package/dist/web/assets/pdf/cmaps/Adobe-Korea1-1.bcmap +0 -0
  340. package/dist/web/assets/pdf/cmaps/Adobe-Korea1-2.bcmap +0 -0
  341. package/dist/web/assets/pdf/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  342. package/dist/web/assets/pdf/cmaps/B5-H.bcmap +0 -0
  343. package/dist/web/assets/pdf/cmaps/B5-V.bcmap +0 -0
  344. package/dist/web/assets/pdf/cmaps/B5pc-H.bcmap +0 -0
  345. package/dist/web/assets/pdf/cmaps/B5pc-V.bcmap +0 -0
  346. package/dist/web/assets/pdf/cmaps/CNS-EUC-H.bcmap +0 -0
  347. package/dist/web/assets/pdf/cmaps/CNS-EUC-V.bcmap +0 -0
  348. package/dist/web/assets/pdf/cmaps/CNS1-H.bcmap +0 -0
  349. package/dist/web/assets/pdf/cmaps/CNS1-V.bcmap +0 -0
  350. package/dist/web/assets/pdf/cmaps/CNS2-H.bcmap +0 -0
  351. package/dist/web/assets/pdf/cmaps/CNS2-V.bcmap +3 -0
  352. package/dist/web/assets/pdf/cmaps/ETHK-B5-H.bcmap +0 -0
  353. package/dist/web/assets/pdf/cmaps/ETHK-B5-V.bcmap +0 -0
  354. package/dist/web/assets/pdf/cmaps/ETen-B5-H.bcmap +0 -0
  355. package/dist/web/assets/pdf/cmaps/ETen-B5-V.bcmap +0 -0
  356. package/dist/web/assets/pdf/cmaps/ETenms-B5-H.bcmap +3 -0
  357. package/dist/web/assets/pdf/cmaps/ETenms-B5-V.bcmap +0 -0
  358. package/dist/web/assets/pdf/cmaps/EUC-H.bcmap +0 -0
  359. package/dist/web/assets/pdf/cmaps/EUC-V.bcmap +0 -0
  360. package/dist/web/assets/pdf/cmaps/Ext-H.bcmap +0 -0
  361. package/dist/web/assets/pdf/cmaps/Ext-RKSJ-H.bcmap +0 -0
  362. package/dist/web/assets/pdf/cmaps/Ext-RKSJ-V.bcmap +0 -0
  363. package/dist/web/assets/pdf/cmaps/Ext-V.bcmap +0 -0
  364. package/dist/web/assets/pdf/cmaps/GB-EUC-H.bcmap +0 -0
  365. package/dist/web/assets/pdf/cmaps/GB-EUC-V.bcmap +0 -0
  366. package/dist/web/assets/pdf/cmaps/GB-H.bcmap +4 -0
  367. package/dist/web/assets/pdf/cmaps/GB-V.bcmap +0 -0
  368. package/dist/web/assets/pdf/cmaps/GBK-EUC-H.bcmap +0 -0
  369. package/dist/web/assets/pdf/cmaps/GBK-EUC-V.bcmap +0 -0
  370. package/dist/web/assets/pdf/cmaps/GBK2K-H.bcmap +0 -0
  371. package/dist/web/assets/pdf/cmaps/GBK2K-V.bcmap +0 -0
  372. package/dist/web/assets/pdf/cmaps/GBKp-EUC-H.bcmap +0 -0
  373. package/dist/web/assets/pdf/cmaps/GBKp-EUC-V.bcmap +0 -0
  374. package/dist/web/assets/pdf/cmaps/GBT-EUC-H.bcmap +0 -0
  375. package/dist/web/assets/pdf/cmaps/GBT-EUC-V.bcmap +0 -0
  376. package/dist/web/assets/pdf/cmaps/GBT-H.bcmap +0 -0
  377. package/dist/web/assets/pdf/cmaps/GBT-V.bcmap +0 -0
  378. package/dist/web/assets/pdf/cmaps/GBTpc-EUC-H.bcmap +0 -0
  379. package/dist/web/assets/pdf/cmaps/GBTpc-EUC-V.bcmap +0 -0
  380. package/dist/web/assets/pdf/cmaps/GBpc-EUC-H.bcmap +0 -0
  381. package/dist/web/assets/pdf/cmaps/GBpc-EUC-V.bcmap +0 -0
  382. package/dist/web/assets/pdf/cmaps/H.bcmap +0 -0
  383. package/dist/web/assets/pdf/cmaps/HKdla-B5-H.bcmap +0 -0
  384. package/dist/web/assets/pdf/cmaps/HKdla-B5-V.bcmap +0 -0
  385. package/dist/web/assets/pdf/cmaps/HKdlb-B5-H.bcmap +0 -0
  386. package/dist/web/assets/pdf/cmaps/HKdlb-B5-V.bcmap +0 -0
  387. package/dist/web/assets/pdf/cmaps/HKgccs-B5-H.bcmap +0 -0
  388. package/dist/web/assets/pdf/cmaps/HKgccs-B5-V.bcmap +0 -0
  389. package/dist/web/assets/pdf/cmaps/HKm314-B5-H.bcmap +0 -0
  390. package/dist/web/assets/pdf/cmaps/HKm314-B5-V.bcmap +0 -0
  391. package/dist/web/assets/pdf/cmaps/HKm471-B5-H.bcmap +0 -0
  392. package/dist/web/assets/pdf/cmaps/HKm471-B5-V.bcmap +0 -0
  393. package/dist/web/assets/pdf/cmaps/HKscs-B5-H.bcmap +0 -0
  394. package/dist/web/assets/pdf/cmaps/HKscs-B5-V.bcmap +0 -0
  395. package/dist/web/assets/pdf/cmaps/Hankaku.bcmap +0 -0
  396. package/dist/web/assets/pdf/cmaps/Hiragana.bcmap +0 -0
  397. package/dist/web/assets/pdf/cmaps/KSC-EUC-H.bcmap +0 -0
  398. package/dist/web/assets/pdf/cmaps/KSC-EUC-V.bcmap +0 -0
  399. package/dist/web/assets/pdf/cmaps/KSC-H.bcmap +0 -0
  400. package/dist/web/assets/pdf/cmaps/KSC-Johab-H.bcmap +0 -0
  401. package/dist/web/assets/pdf/cmaps/KSC-Johab-V.bcmap +0 -0
  402. package/dist/web/assets/pdf/cmaps/KSC-V.bcmap +0 -0
  403. package/dist/web/assets/pdf/cmaps/KSCms-UHC-H.bcmap +0 -0
  404. package/dist/web/assets/pdf/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  405. package/dist/web/assets/pdf/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  406. package/dist/web/assets/pdf/cmaps/KSCms-UHC-V.bcmap +0 -0
  407. package/dist/web/assets/pdf/cmaps/KSCpc-EUC-H.bcmap +0 -0
  408. package/dist/web/assets/pdf/cmaps/KSCpc-EUC-V.bcmap +0 -0
  409. package/dist/web/assets/pdf/cmaps/Katakana.bcmap +0 -0
  410. package/dist/web/assets/pdf/cmaps/LICENSE +36 -0
  411. package/dist/web/assets/pdf/cmaps/NWP-H.bcmap +0 -0
  412. package/dist/web/assets/pdf/cmaps/NWP-V.bcmap +0 -0
  413. package/dist/web/assets/pdf/cmaps/RKSJ-H.bcmap +0 -0
  414. package/dist/web/assets/pdf/cmaps/RKSJ-V.bcmap +0 -0
  415. package/dist/web/assets/pdf/cmaps/Roman.bcmap +0 -0
  416. package/dist/web/assets/pdf/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  417. package/dist/web/assets/pdf/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  418. package/dist/web/assets/pdf/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  419. package/dist/web/assets/pdf/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  420. package/dist/web/assets/pdf/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  421. package/dist/web/assets/pdf/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  422. package/dist/web/assets/pdf/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  423. package/dist/web/assets/pdf/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  424. package/dist/web/assets/pdf/cmaps/UniGB-UCS2-H.bcmap +0 -0
  425. package/dist/web/assets/pdf/cmaps/UniGB-UCS2-V.bcmap +0 -0
  426. package/dist/web/assets/pdf/cmaps/UniGB-UTF16-H.bcmap +0 -0
  427. package/dist/web/assets/pdf/cmaps/UniGB-UTF16-V.bcmap +0 -0
  428. package/dist/web/assets/pdf/cmaps/UniGB-UTF32-H.bcmap +0 -0
  429. package/dist/web/assets/pdf/cmaps/UniGB-UTF32-V.bcmap +0 -0
  430. package/dist/web/assets/pdf/cmaps/UniGB-UTF8-H.bcmap +0 -0
  431. package/dist/web/assets/pdf/cmaps/UniGB-UTF8-V.bcmap +0 -0
  432. package/dist/web/assets/pdf/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  433. package/dist/web/assets/pdf/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  434. package/dist/web/assets/pdf/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  435. package/dist/web/assets/pdf/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  436. package/dist/web/assets/pdf/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  437. package/dist/web/assets/pdf/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  438. package/dist/web/assets/pdf/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  439. package/dist/web/assets/pdf/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  440. package/dist/web/assets/pdf/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  441. package/dist/web/assets/pdf/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  442. package/dist/web/assets/pdf/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  443. package/dist/web/assets/pdf/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  444. package/dist/web/assets/pdf/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  445. package/dist/web/assets/pdf/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  446. package/dist/web/assets/pdf/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  447. package/dist/web/assets/pdf/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  448. package/dist/web/assets/pdf/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  449. package/dist/web/assets/pdf/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  450. package/dist/web/assets/pdf/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  451. package/dist/web/assets/pdf/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  452. package/dist/web/assets/pdf/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  453. package/dist/web/assets/pdf/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  454. package/dist/web/assets/pdf/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  455. package/dist/web/assets/pdf/cmaps/UniKS-UCS2-H.bcmap +0 -0
  456. package/dist/web/assets/pdf/cmaps/UniKS-UCS2-V.bcmap +0 -0
  457. package/dist/web/assets/pdf/cmaps/UniKS-UTF16-H.bcmap +0 -0
  458. package/dist/web/assets/pdf/cmaps/UniKS-UTF16-V.bcmap +0 -0
  459. package/dist/web/assets/pdf/cmaps/UniKS-UTF32-H.bcmap +0 -0
  460. package/dist/web/assets/pdf/cmaps/UniKS-UTF32-V.bcmap +0 -0
  461. package/dist/web/assets/pdf/cmaps/UniKS-UTF8-H.bcmap +0 -0
  462. package/dist/web/assets/pdf/cmaps/UniKS-UTF8-V.bcmap +0 -0
  463. package/dist/web/assets/pdf/cmaps/V.bcmap +0 -0
  464. package/dist/web/assets/pdf/cmaps/WP-Symbol.bcmap +0 -0
  465. package/dist/web/assets/pdf/standard_fonts/FoxitDingbats.pfb +0 -0
  466. package/dist/web/assets/pdf/standard_fonts/FoxitFixed.pfb +0 -0
  467. package/dist/web/assets/pdf/standard_fonts/FoxitFixedBold.pfb +0 -0
  468. package/dist/web/assets/pdf/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
  469. package/dist/web/assets/pdf/standard_fonts/FoxitFixedItalic.pfb +0 -0
  470. package/dist/web/assets/pdf/standard_fonts/FoxitSerif.pfb +0 -0
  471. package/dist/web/assets/pdf/standard_fonts/FoxitSerifBold.pfb +0 -0
  472. package/dist/web/assets/pdf/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
  473. package/dist/web/assets/pdf/standard_fonts/FoxitSerifItalic.pfb +0 -0
  474. package/dist/web/assets/pdf/standard_fonts/FoxitSymbol.pfb +0 -0
  475. package/dist/web/assets/pdf/standard_fonts/LICENSE_FOXIT +27 -0
  476. package/dist/web/assets/pdf/standard_fonts/LICENSE_LIBERATION +363 -0
  477. package/dist/web/assets/pdf/standard_fonts/LiberationSans-Bold.ttf +0 -0
  478. package/dist/web/assets/pdf/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
  479. package/dist/web/assets/pdf/standard_fonts/LiberationSans-Italic.ttf +0 -0
  480. package/dist/web/assets/pdf/standard_fonts/LiberationSans-Regular.ttf +0 -0
  481. package/dist/web/assets/pdf/wasm/LICENSE_JBIG2 +196 -0
  482. package/dist/web/assets/pdf/wasm/LICENSE_OPENJPEG +39 -0
  483. package/dist/web/assets/pdf/wasm/LICENSE_PDFJS_JBIG2 +13 -0
  484. package/dist/web/assets/pdf/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
  485. package/dist/web/assets/pdf/wasm/LICENSE_PDFJS_QCMS +19 -0
  486. package/dist/web/assets/pdf/wasm/LICENSE_QCMS +21 -0
  487. package/dist/web/assets/pdf/wasm/jbig2.wasm +0 -0
  488. package/dist/web/assets/pdf/wasm/jbig2_nowasm_fallback.js +15 -0
  489. package/dist/web/assets/pdf/wasm/openjpeg.wasm +0 -0
  490. package/dist/web/assets/pdf/wasm/openjpeg_nowasm_fallback.js +17 -0
  491. package/dist/web/assets/pdf/wasm/qcms_bg.wasm +0 -0
  492. package/dist/web/assets/pdf/wasm/quickjs-eval.js +16 -0
  493. package/dist/web/assets/pdf/wasm/quickjs-eval.wasm +0 -0
  494. package/dist/web/assets/pdf.worker.min.mjs +29 -0
  495. package/dist/web/assets/workspace.worker.js +409 -0
  496. package/dist/web/document-source.js +14 -0
  497. package/dist/web/hosted-files.js +189 -0
  498. package/dist/web/hosted.js +316 -0
  499. package/dist/web/node-runner.js +26 -0
  500. package/dist/web/preview.js +74 -0
  501. package/dist/web/server.js +85 -240
  502. package/dist/web/sync.js +364 -70
  503. package/dist/web/table-editor-script.js +99 -0
  504. package/dist/web/table-format.js +224 -0
  505. package/dist/web/views/help.js +15 -10
  506. package/dist/web/views/sync-panel.js +90 -19
  507. package/dist/web/views/token-guide.js +27 -0
  508. package/dist/web/views/usage-guide.js +12 -0
  509. package/dist/web/views/workspace.js +85 -15
  510. package/dist/web/workspace-api.js +371 -0
  511. package/docs/user/CLI.md +366 -0
  512. package/docs/user/CONFIGURATION.md +125 -0
  513. package/docs/user/OBSIDIAN.md +117 -0
  514. package/docs/user/WEB.md +90 -0
  515. package/docs/user/images/web/document-preview.png +0 -0
  516. package/docs/user/images/web/remote-diff.png +0 -0
  517. package/docs/user/images/web/sync-workspace.png +0 -0
  518. package/package.json +23 -6
@@ -4,7 +4,9 @@ import { relative, resolve } from 'node:path';
4
4
  import { positionalArgs } from '../cli/args.js';
5
5
  import { collectMarkdown, readDoc, buildFolderIndex, parentKeyOf } from '../documents/catalog.js';
6
6
  import { buildIgnorer } from './ignore.js';
7
- import { MAPPING_FILE, saveMapping } from './mapping.js';
7
+ import { resolveSyncBase, loadWorkspace, inScope, inNestedWorkspace, requireScope } from './workspace.js';
8
+ import { mappingPath } from './metadata.js';
9
+ import { saveMapping } from './mapping.js';
8
10
  function readMapping(path) {
9
11
  if (!existsSync(path))
10
12
  return {};
@@ -39,11 +41,13 @@ export async function runRemap(argv) {
39
41
  }
40
42
  if (positionalArgs(argv).length !== 1)
41
43
  throw new Error('remap은 --base 전체를 대상으로 실행합니다.');
42
- const baseInput = opts['--base']?.[0] ?? process.env.CONFLUENCE_SYNC_BASE;
44
+ const baseInput = resolveSyncBase(opts['--base']?.[0]);
43
45
  if (!baseInput)
44
46
  throw new Error('remap: --base <dir> 또는 CONFLUENCE_SYNC_BASE가 필요합니다.');
45
47
  const base = resolve(baseInput);
46
- const output = resolve(opts['--mapping']?.[0] ?? resolve(base, MAPPING_FILE));
48
+ const workspace = loadWorkspace(base);
49
+ const scope = requireScope(workspace);
50
+ const output = resolve(opts['--mapping']?.[0] ?? mappingPath(base));
47
51
  const source = opts['--from-mapping']?.[0];
48
52
  if (source && !existsSync(resolve(source)))
49
53
  throw new Error(`원본 매핑이 없습니다: ${source}`);
@@ -57,7 +61,7 @@ export async function runRemap(argv) {
57
61
  mapping[key] ??= entry;
58
62
  }
59
63
  const ignorer = buildIgnorer(base, opts['--exclude'] ?? []);
60
- const files = collectMarkdown(base).map(f => relative(base, f).split('\\').join('/')).filter(f => !ignorer.ignores(f)).sort();
64
+ const files = collectMarkdown(base).map(f => relative(base, f).split('\\').join('/')).filter(f => !ignorer.ignores(f) && inScope(f, workspace) && !inNestedWorkspace(base, f)).sort();
61
65
  const folders = buildFolderIndex(files);
62
66
  const byId = new Map();
63
67
  for (const [key, entry] of Object.entries(mapping)) {
@@ -83,11 +87,19 @@ export async function runRemap(argv) {
83
87
  const prior = byId.get(id);
84
88
  if (prior?.[1].type === 'folder')
85
89
  throw new Error(`폴더 ID를 문서에 사용할 수 없습니다: ${key}`);
90
+ if (id === scope.id && (scope.type !== 'page' || key !== 'README.md'))
91
+ throw new Error('스코프 루트의 매핑 경로는 README.md로 유지해야 합니다.');
92
+ if (scope.type === 'page' && key === 'README.md') {
93
+ if (id !== scope.id)
94
+ throw new Error('루트 README.md의 pageId가 선택한 스코프와 다릅니다.');
95
+ console.log('스코프 루트 유지: README.md');
96
+ continue;
97
+ }
86
98
  if (prior)
87
99
  delete next[prior[0]];
88
100
  const entry = { ...(prior?.[1] ?? { pageId: id, title: doc.title }), pendingMove: { parentKey: parentKeyOf(key, folders) } };
89
101
  updates.push([key, entry]);
90
- console.log(`${prior?.[0] ?? `#${id}`} → ${key} (부모: ${entry.pendingMove.parentKey ?? 'ROOT'})${entry.hash ? '' : ' — 기존 해시 없음: sync 시 본문 갱신 대상'}`);
102
+ console.log(`${prior?.[0] ?? `#${id}`} → ${key} (부모: ${entry.pendingMove.parentKey ?? 'ROOT'})${entry.hash ? '' : ' — 기존 해시 없음: push 시 본문 갱신 대상'}`);
91
103
  }
92
104
  for (const [key, entry] of updates)
93
105
  next[key] = entry;
@@ -16,14 +16,15 @@ export function buildTreeRenderer(baseDir, rels, options) {
16
16
  // Obsidian [[wikilink]] 해석용 이름 인덱스
17
17
  const vault = buildVault(rels, collectAssets(baseDir).map((f) => relative(baseDir, f)));
18
18
  // 누가 어느 헤딩을 가리키는지 먼저 모은다 — 그 헤딩에만 Anchor 매크로를 심는다.
19
- const lookup = options ? buildReferenceLookup(baseDir, rels, options.referenceRoots, options.baseUrl) : null;
19
+ const lookup = options ? buildReferenceLookup(options.referenceBase ?? baseDir, rels, options.referenceRoots, options.baseUrl) : null;
20
20
  const anchorTargets = resolveAnchorTargets(docs, vault, lookup?.localTarget);
21
- const render = (rel, body, title) => {
21
+ const render = (rel, body, title, legacyCallouts = false) => {
22
22
  const warnings = new Set(), references = new Set();
23
23
  const linked = (message) => references.add(message);
24
24
  const warn = (message) => warnings.add(message);
25
25
  const ordinary = vaultResolver(rel, vault);
26
26
  const result = toStorage(body, rel, titles, baseDir, {
27
+ legacyCallouts,
27
28
  resolveLink: (target, embed) => {
28
29
  if (!lookup || embed || !!vault.assets[target.toLowerCase()])
29
30
  return ordinary(target, embed);
@@ -0,0 +1,28 @@
1
+ /** Recover selected local documents from Confluence; never deletes or writes remote content. */
2
+ import { positionalArgs } from '../cli/args.js';
3
+ import { resolveSyncBase } from './workspace.js';
4
+ import { runPull, validateRestorePaths } from './pull.js';
5
+ import { loadIndex, completeStaged } from './staging.js';
6
+ export async function runRestore(argv) {
7
+ let explicitBase;
8
+ for (let i = 0; i < argv.length; i++) {
9
+ if (argv[i] === '--base') {
10
+ const value = argv[++i];
11
+ if (!value || value.startsWith('-'))
12
+ throw new Error('--base 뒤에 작업공간 폴더를 지정하세요.');
13
+ explicitBase = value;
14
+ }
15
+ else if (argv[i].startsWith('-') && !['--no-color', '--obsidian', '--overwrite'].includes(argv[i]))
16
+ throw new Error(`지원하지 않는 restore 옵션: ${argv[i]}. csync restore --help를 확인하세요.`);
17
+ }
18
+ const base = resolveSyncBase(explicitBase);
19
+ if (!base)
20
+ throw new Error('작업공간을 지정하세요: csync restore README.md --base <폴더>');
21
+ const overwrite = argv.includes('--overwrite');
22
+ const paths = validateRestorePaths(base, positionalArgs(argv).slice(1), overwrite);
23
+ const staged = loadIndex(base).entries;
24
+ await runPull(['pull', '--base', base, ...(argv.includes('--obsidian') ? ['--obsidian'] : [])], { restorePaths: paths, restoreOverwrite: overwrite });
25
+ for (const path of paths)
26
+ completeStaged(base, path, staged[path]);
27
+ console.log('복구한 문서는 업로드 대상으로 추가하지 않습니다. 업로드하려면 직접 csync add로 선택하세요.');
28
+ }
@@ -0,0 +1,47 @@
1
+ import { loadMapping } from './mapping.js';
2
+ import { mappingPath } from './metadata.js';
3
+ /** Stable space-root connection shared by the CLI and Web. */
4
+ import { existsSync, statSync } from 'node:fs';
5
+ import { createClient } from '../confluence/client.js';
6
+ import { loadWorkspace, saveWorkspace, assertWorkspaceConnection, requireScope } from './workspace.js';
7
+ export function scopeClient(env) {
8
+ if (!env.baseUrl || !env.email || !env.token || !env.spaceKey)
9
+ throw new Error('사이트·계정·API 토큰·스페이스 설정이 필요합니다.');
10
+ const url = new URL(env.baseUrl);
11
+ if (url.protocol !== 'https:' || url.username || url.password || url.search || url.hash)
12
+ throw new Error('Confluence BASE_URL은 인증정보·쿼리가 없는 HTTPS 주소여야 합니다.');
13
+ return createClient({ baseUrl: env.baseUrl, email: env.email, token: env.token }, { force: false, verify: false, requestTimeoutMs: 20_000 });
14
+ }
15
+ /** Bind a workspace to a space homepage without changing its documents or mapping. */
16
+ export async function connectWorkspace(base, env) {
17
+ if (!existsSync(base) || !statSync(base).isDirectory())
18
+ throw new Error('기준 폴더는 존재하는 폴더여야 합니다.');
19
+ const prior = loadWorkspace(base);
20
+ if (prior.connection)
21
+ assertWorkspaceConnection(prior, env);
22
+ if (prior.version === 2 && prior.connection?.spaceId && prior.connection.homepageId && prior.remoteRoot) {
23
+ // Preserve the existing remote binding. Reconnecting never moves local or remote documents.
24
+ const workspace = { version: 2, connection: prior.connection, remoteRoot: prior.remoteRoot };
25
+ saveWorkspace(base, workspace);
26
+ return workspace;
27
+ }
28
+ const client = scopeClient(env), space = await client.getSpaceInfo(env.spaceKey);
29
+ if (!space.homepageId)
30
+ throw new Error('스페이스 홈페이지를 찾을 수 없습니다.');
31
+ const rootEntry = loadMapping(mappingPath(base))['README.md'];
32
+ if (rootEntry && rootEntry.pageId !== space.homepageId)
33
+ throw new Error('루트 README가 다른 원격 페이지에 연결되어 있습니다. 스페이스 전체를 위한 별도 기준 폴더를 사용하세요.');
34
+ const workspace = { version: 2, connection: { baseUrl: env.baseUrl, spaceKey: env.spaceKey, spaceId: space.id, homepageId: space.homepageId }, remoteRoot: { id: space.homepageId, type: 'page', path: '/' } };
35
+ saveWorkspace(base, workspace);
36
+ return workspace;
37
+ }
38
+ export async function verifyScope(client, workspace) {
39
+ const root = requireScope(workspace), connection = workspace.connection;
40
+ const space = await client.getSpaceInfo(connection.spaceKey);
41
+ if (space.id !== connection.spaceId || space.homepageId !== connection.homepageId)
42
+ throw new Error('스페이스 연결 기준이 변경되었습니다. 다시 설정하세요.');
43
+ const info = await client.getContentInfo(root.id);
44
+ if (info.spaceId !== space.id || info.type !== root.type)
45
+ throw new Error('스페이스 루트 연결이 변경되었습니다.');
46
+ return space.id;
47
+ }
@@ -0,0 +1,193 @@
1
+ import { green, cyan } from '../shared/colors.js';
2
+ import { reconcilePages } from './reconcile.js';
3
+ import { localStateHash } from './local-state.js';
4
+ import { buildTreeRenderer } from './render.js';
5
+ /** Document-level upload selection. Source files are never copied into the index. */
6
+ import { createHash, randomUUID } from 'node:crypto';
7
+ import { existsSync, lstatSync, readFileSync, mkdirSync, writeFileSync, renameSync, unlinkSync, realpathSync } from 'node:fs';
8
+ import { dirname, resolve, relative, join } from 'node:path';
9
+ import { collectMarkdown } from '../documents/catalog.js';
10
+ import { docHash } from '../documents/markdown.js';
11
+ import { buildIgnorer } from './ignore.js';
12
+ import { preparePushTree } from './prepare.js';
13
+ import { loadMapping } from './mapping.js';
14
+ import { mappingPath, workspacePath } from './metadata.js';
15
+ import { loadWorkspace, requireScope, inScope, inNestedWorkspace, resolveSyncBase } from './workspace.js';
16
+ import { readEnv } from '../confluence/config.js';
17
+ import { positionalArgs } from '../cli/args.js';
18
+ const digest = (bytes) => createHash('sha256').update(bytes).digest('hex');
19
+ export const sourceHash = (base, rel) => digest(readFileSync(resolve(base, rel)));
20
+ function location(base) {
21
+ workspacePath(base); // Shared metadata-directory validation, including symlinks.
22
+ const path = join(base, '.csync/index.json');
23
+ try {
24
+ if (!lstatSync(path).isFile())
25
+ throw new Error('업로드 대상 파일은 일반 파일이어야 합니다.');
26
+ }
27
+ catch (error) {
28
+ if (error.code !== 'ENOENT')
29
+ throw error;
30
+ }
31
+ return path;
32
+ }
33
+ function binding(base) {
34
+ const workspace = loadWorkspace(base);
35
+ requireScope(workspace);
36
+ const identity = [workspace.connection?.baseUrl, workspace.connection?.spaceKey, workspace.connection?.spaceId, workspace.remoteRoot?.id, workspace.remoteRoot?.type];
37
+ return { portable: digest(JSON.stringify(identity)), legacy: digest(JSON.stringify([realpathSync(base), ...identity])) };
38
+ }
39
+ function validPath(rel) { return !!rel && !rel.startsWith('/') && !rel.includes('\\') && rel.split('/').every(p => p && p !== '.' && p !== '..') && /\.md$/i.test(rel); }
40
+ export function loadIndex(base) {
41
+ const path = location(base), expected = binding(base);
42
+ if (!existsSync(path))
43
+ return { version: 2, binding: expected.portable, entries: {} };
44
+ const index = JSON.parse(readFileSync(path, 'utf8'));
45
+ if (![1, 2].includes(index?.version) || typeof index.binding !== 'string' || !/^[a-f0-9]{64}$/.test(index.binding) || !index.entries || Array.isArray(index.entries) || typeof index.entries !== 'object'
46
+ || Object.entries(index.entries).some(([rel, entry]) => !validPath(rel) || !entry || !/^[a-f0-9]{64}$/.test(entry.source) || !/^[a-f0-9]{64}$/.test(entry.hash) || entry.reviewRequired !== undefined && typeof entry.reviewRequired !== 'boolean'))
47
+ throw new Error('.csync/index.json이 손상되었습니다. 업로드 선택 정보를 확인하세요.');
48
+ const verified = index.binding === (index.version === 1 ? expected.legacy : expected.portable);
49
+ // Reading never rewrites the index. An unverifiable old selection remains
50
+ // visible, but requires an explicit add before it can authorize any upload.
51
+ const entries = Object.fromEntries(Object.entries(index.entries).map(([rel, entry]) => [rel, verified ? entry : { ...entry, reviewRequired: true }]));
52
+ return { version: 2, binding: expected.portable, entries };
53
+ }
54
+ function saveIndex(base, index) {
55
+ const path = location(base);
56
+ mkdirSync(dirname(path), { recursive: true });
57
+ const temp = `${path}.${randomUUID()}.tmp`;
58
+ try {
59
+ writeFileSync(temp, JSON.stringify(index, null, 2) + '\n', { flag: 'wx', mode: 0o600 });
60
+ renameSync(temp, path);
61
+ }
62
+ finally {
63
+ if (existsSync(temp))
64
+ unlinkSync(temp);
65
+ }
66
+ }
67
+ export function stagedPaths(base) {
68
+ const index = loadIndex(base), workspace = loadWorkspace(base);
69
+ const paths = Object.keys(index.entries);
70
+ if (!paths.length)
71
+ throw new Error('업로드 대상이 없습니다. csync add <파일·폴더>로 문서를 추가하세요.');
72
+ if (paths.some(path => index.entries[path].reviewRequired))
73
+ throw new Error('작업공간 연결 또는 이전 업로드 선택을 다시 확인해야 합니다. csync add로 문서를 다시 추가하세요.');
74
+ for (const rel of paths)
75
+ if (!inScope(rel, workspace))
76
+ throw new Error(`업로드 대상이 작업공간 밖입니다: ${rel}. unstage로 해제하고 기준 폴더를 확인하세요.`);
77
+ return paths;
78
+ }
79
+ export function assertStaged(base, rel, hash, entry) {
80
+ if (entry.reviewRequired)
81
+ throw new Error(`업로드 선택을 다시 확인해야 합니다: ${rel}. csync add로 다시 추가하세요.`);
82
+ if (sourceHash(base, rel) !== entry.source || hash !== entry.hash)
83
+ throw new Error(`추가 후 문서·첨부·링크가 변경되었습니다: ${rel}. csync add로 다시 추가하세요.`);
84
+ }
85
+ export function completeStaged(base, rel, expected) {
86
+ if (!expected)
87
+ return;
88
+ const index = loadIndex(base);
89
+ if (JSON.stringify(index.entries[rel]) !== JSON.stringify(expected))
90
+ return;
91
+ delete index.entries[rel];
92
+ saveIndex(base, index);
93
+ }
94
+ export async function inspectStaging(base, options = {}, only) {
95
+ const workspace = loadWorkspace(base);
96
+ requireScope(workspace);
97
+ const index = loadIndex(base), ignorer = buildIgnorer(base, []);
98
+ const all = collectMarkdown(base).map(p => relative(base, p).split('\\').join('/')).filter(p => !ignorer.ignores(p) && !inNestedWorkspace(base, p));
99
+ const selected = all.filter(p => inScope(p, workspace) && (!only || only.some(key => !key || p === key || p.startsWith(key + '/'))));
100
+ const sources = Object.fromEntries(selected.map(rel => [rel, sourceHash(base, rel)]));
101
+ const prepared = await preparePushTree(base, all, selected, { referenceRoots: options.referenceRoots ?? [], baseUrl: options.baseUrl });
102
+ try {
103
+ const originalMapping = loadMapping(mappingPath(base));
104
+ const mapping = reconcilePages(base, originalMapping, all, selected, requireScope(workspace));
105
+ const legacy = buildTreeRenderer(base, all);
106
+ const rows = selected.map(path => {
107
+ const doc = prepared.docs[path], rendered = prepared.render(path, doc.body, doc.title), hash = docHash(doc.title, rendered);
108
+ if (sourceHash(base, path) !== sources[path])
109
+ throw new Error('조회 중 문서가 변경되었습니다. 다시 시도하세요.');
110
+ const oldPath = doc.fm.pageId && Object.keys(originalMapping).find(key => originalMapping[key].pageId === doc.fm.pageId && !key.endsWith('/'));
111
+ const prior = originalMapping[path] ?? (oldPath ? originalMapping[oldPath] : undefined);
112
+ const reconciled = mapping[path];
113
+ const clean = prior?.localHash ? prior.localHash === localStateHash(base, path, rendered) : !!prior?.hash && (prior.hash === hash || prior.hash === docHash(legacy.docs[path].title, legacy.render(path, legacy.docs[path].body, legacy.docs[path].title))
114
+ || prior.hash === docHash(doc.title, prepared.render(path, doc.body, doc.title, 'panels'))
115
+ || prior.hash === docHash(doc.title, prepared.render(path, doc.body, doc.title, true))
116
+ || prior.hash === docHash(legacy.docs[path].title, legacy.render(path, legacy.docs[path].body, legacy.docs[path].title, 'panels'))
117
+ || prior.hash === docHash(legacy.docs[path].title, legacy.render(path, legacy.docs[path].body, legacy.docs[path].title, true)));
118
+ const renamed = !!prior?.pageId && !reconciled?.pendingMove && !!oldPath && oldPath !== path;
119
+ const status = !prior?.pageId ? 'new' : reconciled?.pendingMove ? 'moved' : renamed || !clean ? 'changed' : 'same';
120
+ const entry = { source: sources[path], hash };
121
+ const unmapped = !prior?.pageId && !!doc.fm.pageId;
122
+ const staged = !!index.entries[path], stale = staged && (unmapped || !!index.entries[path].reviewRequired || JSON.stringify(index.entries[path]) !== JSON.stringify(entry));
123
+ return { path, status, staged, stale, entry, ...(renamed && clean ? { renamed: true } : {}), pageId: prior?.pageId ?? doc.fm.pageId, ...(!prior?.pageId && doc.fm.pageId ? { unmapped: true, recoverable: doc.fm.spaceKey === workspace.connection?.spaceKey } : {}) };
124
+ });
125
+ for (const path of Object.keys(index.entries))
126
+ if (!rows.some(row => row.path === path))
127
+ rows.push({ path, status: 'unavailable', staged: true, stale: true, entry: index.entries[path], pageId: mapping[path]?.pageId });
128
+ return rows;
129
+ }
130
+ finally {
131
+ prepared.dispose();
132
+ }
133
+ }
134
+ export async function changeStaging(base, paths, action, options = {}) {
135
+ if (!paths.length)
136
+ throw new Error('파일 또는 폴더를 지정하세요. 전체 범위는 . 으로 지정하세요.');
137
+ const index = loadIndex(base);
138
+ const keys = paths.map(path => {
139
+ const key = relative(base, resolve(base, path)).split('\\').join('/');
140
+ if (key === '..' || key.startsWith('../'))
141
+ throw new Error('기준 폴더 밖의 경로는 추가할 수 없습니다.');
142
+ return key;
143
+ });
144
+ const rows = action === 'add' ? await inspectStaging(base, options, keys) : Object.keys(index.entries).map(path => ({ path, status: '', entry: index.entries[path] }));
145
+ const touched = [];
146
+ for (const key of keys) {
147
+ const matches = rows.filter(row => (!key || row.path === key || row.path.startsWith(key + '/')) && (action !== 'add' || row.status !== 'unavailable'));
148
+ if (!matches.length)
149
+ throw new Error(`작업공간에서 선택할 문서가 없습니다: ${key || '.'}`);
150
+ touched.push(...matches);
151
+ for (const row of matches)
152
+ if (action === 'add')
153
+ index.entries[row.path] = row.entry;
154
+ else
155
+ delete index.entries[row.path];
156
+ }
157
+ // Do not overwrite selections changed by another process while conversion was running.
158
+ const current = loadIndex(base);
159
+ for (const path of new Set([...Object.keys(current.entries), ...Object.keys(index.entries)])) {
160
+ if (keys.some(key => !key || path === key || path.startsWith(key + '/'))) {
161
+ if (index.entries[path])
162
+ current.entries[path] = index.entries[path];
163
+ else
164
+ delete current.entries[path];
165
+ }
166
+ }
167
+ saveIndex(base, current);
168
+ return touched;
169
+ }
170
+ export async function runStaging(argv) {
171
+ const command = positionalArgs(argv)[0];
172
+ if (command !== 'add' && command !== 'unstage')
173
+ throw new Error('문서 선택 명령은 add 또는 unstage를 사용하세요.');
174
+ for (let i = 0; i < argv.length; i++) {
175
+ if (argv[i] === '--base' || argv[i] === '--reference-root') {
176
+ const option = argv[i], value = argv[++i];
177
+ if (!value || value.startsWith('-'))
178
+ throw new Error(`${option} 뒤에 폴더를 지정하세요.`);
179
+ }
180
+ else if (argv[i].startsWith('-') && argv[i] !== '--no-color')
181
+ throw new Error(`지원하지 않는 ${command} 옵션: ${argv[i]}. csync ${command} --help를 확인하세요.`);
182
+ }
183
+ const at = argv.indexOf('--base'), base = resolveSyncBase(at < 0 ? undefined : argv[at + 1]);
184
+ if (!base)
185
+ throw new Error('작업공간을 지정하세요: --base <dir>');
186
+ const refs = [];
187
+ for (let i = 0; i < argv.length; i++)
188
+ if (argv[i] === '--reference-root')
189
+ refs.push(argv[++i]);
190
+ const options = { referenceRoots: refs, baseUrl: readEnv(base).baseUrl };
191
+ await changeStaging(base, positionalArgs(argv).slice(1), command === 'add' ? 'add' : 'remove', options);
192
+ console.log((command === 'add' ? green : cyan)(`업로드 대상 ${Object.keys(loadIndex(base).entries).length}개 저장됨`));
193
+ }
@@ -0,0 +1,100 @@
1
+ /** Shared workspace identity and persistent sync boundaries. No network access. */
2
+ import { existsSync, readFileSync, writeFileSync, realpathSync, mkdirSync } from 'node:fs';
3
+ import { dirname, join, relative, resolve, isAbsolute } from 'node:path';
4
+ import { parse } from 'dotenv';
5
+ import { workspacePath, hasMetadata } from './metadata.js';
6
+ export { WORKSPACE_FILE } from './metadata.js';
7
+ export function within(base, path) {
8
+ const rel = relative(base, path);
9
+ return !isAbsolute(rel) && rel !== '..' && !rel.startsWith(`..${process.platform === 'win32' ? '\\' : '/'}`);
10
+ }
11
+ export function findSyncBase(from) {
12
+ for (let dir = resolve(from);; dir = dirname(dir)) {
13
+ if (hasMetadata(dir))
14
+ return dir;
15
+ if (dirname(dir) === dir)
16
+ return undefined;
17
+ }
18
+ }
19
+ export function resolveSyncBase(explicit) {
20
+ if (explicit)
21
+ return resolve(explicit);
22
+ if (process.env.CONFLUENCE_SYNC_BASE)
23
+ return resolve(process.env.CONFLUENCE_SYNC_BASE);
24
+ const found = findSyncBase(process.cwd());
25
+ if (found)
26
+ return found;
27
+ const envPath = join(process.cwd(), '.env');
28
+ const value = existsSync(envPath) ? parse(readFileSync(envPath)).CONFLUENCE_SYNC_BASE : undefined;
29
+ return value ? resolve(value) : undefined;
30
+ }
31
+ export function loadWorkspace(base) {
32
+ const path = workspacePath(base);
33
+ if (!existsSync(path))
34
+ return { version: 1 };
35
+ const value = JSON.parse(readFileSync(path, 'utf8'));
36
+ if (!value || ![1, 2].includes(value.version) ||
37
+ (value.syncPaths !== undefined && (!Array.isArray(value.syncPaths) || !value.syncPaths.length || value.syncPaths.some((p) => typeof p !== 'string' || !p))) ||
38
+ (value.root !== undefined && (!value.root || typeof value.root.id !== 'string' || !value.root.id || !['page', 'folder'].includes(value.root.type) || typeof value.root.baseUrl !== 'string' || typeof value.root.spaceKey !== 'string'))) {
39
+ throw new Error(`잘못된 작업공간 설정: ${path}`);
40
+ }
41
+ // Read the old remote-scope shape without treating it as a selected local range.
42
+ if (value.scope?.id) {
43
+ value.remoteRoot = value.scope;
44
+ delete value.scope;
45
+ }
46
+ for (const path of value.syncPaths ?? [])
47
+ if (scopePath(base, path) !== path)
48
+ throw new Error(`관리 범위는 정규화된 상대 경로여야 합니다: ${path}`);
49
+ if (value.scopeCheckRequired !== undefined && typeof value.scopeCheckRequired !== 'boolean')
50
+ throw new Error('잘못된 스코프 검증 설정입니다.');
51
+ if (value.connection && (typeof value.connection.baseUrl !== 'string' || typeof value.connection.spaceKey !== 'string'))
52
+ throw new Error('잘못된 연결 설정입니다.');
53
+ if (value.scope && (!['file', 'folder'].includes(value.scope.type) || typeof value.scope.path !== 'string' || scopePath(base, value.scope.path) !== value.scope.path))
54
+ throw new Error('로컬 스코프가 올바르지 않습니다. 기준 폴더 안의 파일·폴더를 지정하세요.');
55
+ if (value.version === 2 && (!value.remoteRoot || typeof value.remoteRoot.id !== 'string' || !value.remoteRoot.id || !['page', 'folder'].includes(value.remoteRoot.type) || typeof value.remoteRoot.path !== 'string' || !value.remoteRoot.path.startsWith('/') ||
56
+ !value.connection?.baseUrl || !value.connection.spaceKey || !value.connection.spaceId || !value.connection.homepageId))
57
+ throw new Error('스페이스 연결이 올바르지 않습니다. csync init --connect로 다시 연결하세요.');
58
+ delete value.scope;
59
+ delete value.syncPaths;
60
+ return value;
61
+ }
62
+ export function saveWorkspace(base, value) {
63
+ const path = workspacePath(base);
64
+ mkdirSync(dirname(path), { recursive: true });
65
+ writeFileSync(path, JSON.stringify(value, null, 2) + '\n');
66
+ }
67
+ export function scopePath(base, path) {
68
+ const abs = resolve(base, path);
69
+ if (!within(base, abs))
70
+ throw new Error(`관리 범위가 작업공간 밖입니다: ${path}`);
71
+ let ancestor = abs;
72
+ while (!existsSync(ancestor) && dirname(ancestor) !== ancestor)
73
+ ancestor = dirname(ancestor);
74
+ if (existsSync(base) && !within(realpathSync(base), realpathSync(ancestor)))
75
+ throw new Error(`관리 범위가 작업공간 밖입니다: ${path}`);
76
+ return relative(base, abs).split('\\').join('/') || '.';
77
+ }
78
+ /** The workspace root is the whole managed space; individual Push selection is separate. */
79
+ export function inScope(_rel, workspace) {
80
+ return workspace.version === 2 && !!workspace.remoteRoot && !!workspace.connection;
81
+ }
82
+ export function requireScope(workspace) {
83
+ if (workspace.version !== 2 || !workspace.remoteRoot || !workspace.connection)
84
+ throw new Error('스페이스 연결이 없습니다. csync init --connect로 기준 폴더를 연결하거나 최초 Pull을 실행하세요.');
85
+ return workspace.remoteRoot;
86
+ }
87
+ export function assertWorkspaceConnection(workspace, env) {
88
+ const connection = workspace.connection;
89
+ if (connection && (connection.baseUrl.replace(/\/$/, '') !== env.baseUrl?.replace(/\/$/, '') || connection.spaceKey !== env.spaceKey)) {
90
+ throw new Error('작업공간의 Confluence 사이트·스페이스가 현재 설정과 다릅니다.');
91
+ }
92
+ }
93
+ /** Nested workspaces are independent; never traverse them from an outer sync. */
94
+ export function inNestedWorkspace(base, rel) {
95
+ for (let dir = dirname(resolve(base, rel)); dir !== base && within(base, dir); dir = dirname(dir)) {
96
+ if (hasMetadata(dir))
97
+ return true;
98
+ }
99
+ return false;
100
+ }
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS