@crowi/api 2.0.0-alpha.0 → 2.0.0-alpha.2

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 (452) hide show
  1. package/dist/hono/handlers/access-token.d.ts +55 -55
  2. package/dist/hono/handlers/activation.d.ts +27 -27
  3. package/dist/hono/handlers/admin/app.d.ts +26 -26
  4. package/dist/hono/handlers/admin/auth.d.ts +24 -24
  5. package/dist/hono/handlers/admin/mail.d.ts +30 -30
  6. package/dist/hono/handlers/admin/plugins.d.ts +112 -112
  7. package/dist/hono/handlers/admin/search.d.ts +21 -21
  8. package/dist/hono/handlers/admin/security.d.ts +24 -24
  9. package/dist/hono/handlers/admin/storage.d.ts +19 -19
  10. package/dist/hono/handlers/admin/users.d.ts +399 -281
  11. package/dist/hono/handlers/admin/users.js +28 -0
  12. package/dist/hono/handlers/admin/users.js.map +1 -1
  13. package/dist/hono/handlers/adminCrypto.d.ts +32 -32
  14. package/dist/hono/handlers/app.d.ts +12 -8
  15. package/dist/hono/handlers/app.js +42 -1
  16. package/dist/hono/handlers/app.js.map +1 -1
  17. package/dist/hono/handlers/attachment-stream.js +23 -0
  18. package/dist/hono/handlers/attachment-stream.js.map +1 -1
  19. package/dist/hono/handlers/attachment.d.ts +180 -180
  20. package/dist/hono/handlers/autocomplete.d.ts +45 -45
  21. package/dist/hono/handlers/backlink.d.ts +33 -33
  22. package/dist/hono/handlers/bookmark.d.ts +95 -95
  23. package/dist/hono/handlers/comment.d.ts +55 -55
  24. package/dist/hono/handlers/draft.d.ts +27 -27
  25. package/dist/hono/handlers/draft.js +10 -0
  26. package/dist/hono/handlers/draft.js.map +1 -1
  27. package/dist/hono/handlers/emailChange.d.ts +25 -25
  28. package/dist/hono/handlers/installer.d.ts +16 -16
  29. package/dist/hono/handlers/inviteAccept.d.ts +37 -37
  30. package/dist/hono/handlers/me.d.ts +92 -92
  31. package/dist/hono/handlers/notification.d.ts +94 -94
  32. package/dist/hono/handlers/oauth.d.ts +58 -58
  33. package/dist/hono/handlers/page-collab.d.ts +20 -20
  34. package/dist/hono/handlers/page-preview.d.ts +7 -7
  35. package/dist/hono/handlers/page.d.ts +575 -324
  36. package/dist/hono/handlers/page.js +123 -6
  37. package/dist/hono/handlers/page.js.map +1 -1
  38. package/dist/hono/handlers/passwordReset.d.ts +37 -37
  39. package/dist/hono/handlers/presence.d.ts +44 -44
  40. package/dist/hono/handlers/revision.d.ts +99 -99
  41. package/dist/hono/handlers/search.d.ts +64 -64
  42. package/dist/hono/handlers/tokenAuth.d.ts +80 -80
  43. package/dist/hono/handlers/user.d.ts +102 -102
  44. package/dist/hono/handlers/user.js +15 -5
  45. package/dist/hono/handlers/user.js.map +1 -1
  46. package/dist/hono/index.d.ts +94 -94
  47. package/dist/mcp/result.d.ts +52 -11
  48. package/dist/mcp/result.js +66 -1
  49. package/dist/mcp/result.js.map +1 -1
  50. package/dist/mcp/tools/page.js +30 -5
  51. package/dist/mcp/tools/page.js.map +1 -1
  52. package/dist/mcp/tools/search.d.ts +12 -0
  53. package/dist/mcp/tools/search.js +21 -5
  54. package/dist/mcp/tools/search.js.map +1 -1
  55. package/dist/migration/helpers.d.ts +13 -0
  56. package/dist/migration/helpers.js +29 -0
  57. package/dist/migration/helpers.js.map +1 -0
  58. package/dist/migration/migrations/files-url-to-attachments.d.ts +35 -0
  59. package/dist/migration/migrations/files-url-to-attachments.js +291 -0
  60. package/dist/migration/migrations/files-url-to-attachments.js.map +1 -0
  61. package/dist/migration/migrations/index.js +6 -0
  62. package/dist/migration/migrations/index.js.map +1 -1
  63. package/dist/migration/migrations/published-current-revision.d.ts +47 -0
  64. package/dist/migration/migrations/published-current-revision.js +90 -0
  65. package/dist/migration/migrations/published-current-revision.js.map +1 -0
  66. package/dist/migration/migrations/relocate-reserved-api-paths.d.ts +3 -0
  67. package/dist/migration/migrations/relocate-reserved-api-paths.js +135 -0
  68. package/dist/migration/migrations/relocate-reserved-api-paths.js.map +1 -0
  69. package/dist/migration/migrations/wikilink-format.d.ts +0 -11
  70. package/dist/migration/migrations/wikilink-format.js +5 -156
  71. package/dist/migration/migrations/wikilink-format.js.map +1 -1
  72. package/dist/migration/migrations/wikilink-html-recover.d.ts +116 -0
  73. package/dist/migration/migrations/wikilink-html-recover.js +314 -0
  74. package/dist/migration/migrations/wikilink-html-recover.js.map +1 -0
  75. package/dist/models/page.d.ts +3 -0
  76. package/dist/models/page.js +40 -2
  77. package/dist/models/page.js.map +1 -1
  78. package/dist/models/user.d.ts +1 -0
  79. package/dist/models/user.js +40 -21
  80. package/dist/models/user.js.map +1 -1
  81. package/dist/renderer/core/headings.d.ts +12 -1
  82. package/dist/renderer/core/headings.js +48 -8
  83. package/dist/renderer/core/headings.js.map +1 -1
  84. package/dist/renderer/pipeline.d.ts +6 -0
  85. package/dist/renderer/pipeline.js.map +1 -1
  86. package/dist/util/page-response.js +19 -2
  87. package/dist/util/page-response.js.map +1 -1
  88. package/dist/util/replace-url.d.ts +85 -0
  89. package/dist/util/replace-url.js +251 -0
  90. package/dist/util/replace-url.js.map +1 -0
  91. package/package.json +13 -5
  92. package/public/images/file-not-found.png +0 -0
  93. package/views/mail/activation.mjml +9 -0
  94. package/views/mail/activation.text +13 -0
  95. package/views/mail/adminApprovalPending.mjml +7 -0
  96. package/views/mail/adminApprovalPending.text +11 -0
  97. package/views/mail/emailChange.mjml +9 -0
  98. package/views/mail/emailChange.text +13 -0
  99. package/views/mail/invite.mjml +9 -0
  100. package/views/mail/invite.text +13 -0
  101. package/views/mail/layout.mjml +38 -0
  102. package/views/mail/passwordChanged.mjml +4 -0
  103. package/views/mail/passwordChanged.text +9 -0
  104. package/views/mail/passwordReset.mjml +9 -0
  105. package/views/mail/passwordReset.text +13 -0
  106. package/views/mail/test.mjml +2 -0
  107. package/views/mail/test.text +7 -0
  108. package/dist/common/functions/path2name.d.ts +0 -1
  109. package/dist/common/functions/path2name.js +0 -22
  110. package/dist/common/functions/path2name.js.map +0 -1
  111. package/dist/common/functions/renderIcon.d.ts +0 -1
  112. package/dist/common/functions/renderIcon.js +0 -9
  113. package/dist/common/functions/renderIcon.js.map +0 -1
  114. package/dist/controllers/admin.d.ts +0 -3
  115. package/dist/controllers/admin.js +0 -474
  116. package/dist/controllers/admin.js.map +0 -1
  117. package/dist/controllers/attachment.d.ts +0 -4
  118. package/dist/controllers/attachment.js +0 -200
  119. package/dist/controllers/attachment.js.map +0 -1
  120. package/dist/controllers/backlink.d.ts +0 -3
  121. package/dist/controllers/backlink.js +0 -42
  122. package/dist/controllers/backlink.js.map +0 -1
  123. package/dist/controllers/bookmark.d.ts +0 -3
  124. package/dist/controllers/bookmark.js +0 -100
  125. package/dist/controllers/bookmark.js.map +0 -1
  126. package/dist/controllers/comment.d.ts +0 -3
  127. package/dist/controllers/comment.js +0 -111
  128. package/dist/controllers/comment.js.map +0 -1
  129. package/dist/controllers/index.d.ts +0 -25
  130. package/dist/controllers/index.js +0 -44
  131. package/dist/controllers/index.js.map +0 -1
  132. package/dist/controllers/installer.d.ts +0 -3
  133. package/dist/controllers/installer.js +0 -48
  134. package/dist/controllers/installer.js.map +0 -1
  135. package/dist/controllers/login.d.ts +0 -4
  136. package/dist/controllers/login.js +0 -438
  137. package/dist/controllers/login.js.map +0 -1
  138. package/dist/controllers/logout.d.ts +0 -5
  139. package/dist/controllers/logout.js +0 -11
  140. package/dist/controllers/logout.js.map +0 -1
  141. package/dist/controllers/me.d.ts +0 -4
  142. package/dist/controllers/me.js +0 -369
  143. package/dist/controllers/me.js.map +0 -1
  144. package/dist/controllers/notification.d.ts +0 -3
  145. package/dist/controllers/notification.js +0 -88
  146. package/dist/controllers/notification.js.map +0 -1
  147. package/dist/controllers/page.d.ts +0 -3
  148. package/dist/controllers/page.js +0 -881
  149. package/dist/controllers/page.js.map +0 -1
  150. package/dist/controllers/revision.d.ts +0 -3
  151. package/dist/controllers/revision.js +0 -91
  152. package/dist/controllers/revision.js.map +0 -1
  153. package/dist/controllers/search.d.ts +0 -3
  154. package/dist/controllers/search.js +0 -93
  155. package/dist/controllers/search.js.map +0 -1
  156. package/dist/controllers/share.d.ts +0 -3
  157. package/dist/controllers/share.js +0 -207
  158. package/dist/controllers/share.js.map +0 -1
  159. package/dist/controllers/shareAccess.d.ts +0 -3
  160. package/dist/controllers/shareAccess.js +0 -28
  161. package/dist/controllers/shareAccess.js.map +0 -1
  162. package/dist/controllers/slack.d.ts +0 -3
  163. package/dist/controllers/slack.js +0 -87
  164. package/dist/controllers/slack.js.map +0 -1
  165. package/dist/controllers/tokenAuth.d.ts +0 -10
  166. package/dist/controllers/tokenAuth.js +0 -292
  167. package/dist/controllers/tokenAuth.js.map +0 -1
  168. package/dist/controllers/user.d.ts +0 -3
  169. package/dist/controllers/user.js +0 -67
  170. package/dist/controllers/user.js.map +0 -1
  171. package/dist/controllers/version.d.ts +0 -4
  172. package/dist/controllers/version.js +0 -19
  173. package/dist/controllers/version.js.map +0 -1
  174. package/dist/crowi/express-init.d.ts +0 -4
  175. package/dist/crowi/express-init.js +0 -101
  176. package/dist/crowi/express-init.js.map +0 -1
  177. package/dist/form/admin/app.d.ts +0 -2
  178. package/dist/form/admin/app.js +0 -9
  179. package/dist/form/admin/app.js.map +0 -1
  180. package/dist/form/admin/auth.d.ts +0 -2
  181. package/dist/form/admin/auth.js +0 -9
  182. package/dist/form/admin/auth.js.map +0 -1
  183. package/dist/form/admin/aws.d.ts +0 -2
  184. package/dist/form/admin/aws.js +0 -13
  185. package/dist/form/admin/aws.js.map +0 -1
  186. package/dist/form/admin/github.d.ts +0 -2
  187. package/dist/form/admin/github.js +0 -15
  188. package/dist/form/admin/github.js.map +0 -1
  189. package/dist/form/admin/google.d.ts +0 -2
  190. package/dist/form/admin/google.js +0 -13
  191. package/dist/form/admin/google.js.map +0 -1
  192. package/dist/form/admin/mail.d.ts +0 -2
  193. package/dist/form/admin/mail.js +0 -13
  194. package/dist/form/admin/mail.js.map +0 -1
  195. package/dist/form/admin/sec.d.ts +0 -2
  196. package/dist/form/admin/sec.js +0 -10
  197. package/dist/form/admin/sec.js.map +0 -1
  198. package/dist/form/admin/slackSetting.d.ts +0 -2
  199. package/dist/form/admin/slackSetting.js +0 -13
  200. package/dist/form/admin/slackSetting.js.map +0 -1
  201. package/dist/form/admin/userEdit.d.ts +0 -2
  202. package/dist/form/admin/userEdit.js +0 -9
  203. package/dist/form/admin/userEdit.js.map +0 -1
  204. package/dist/form/admin/userInvite.d.ts +0 -2
  205. package/dist/form/admin/userInvite.js +0 -9
  206. package/dist/form/admin/userInvite.js.map +0 -1
  207. package/dist/form/comment.d.ts +0 -2
  208. package/dist/form/comment.js +0 -9
  209. package/dist/form/comment.js.map +0 -1
  210. package/dist/form/index.d.ts +0 -25
  211. package/dist/form/index.js +0 -48
  212. package/dist/form/index.js.map +0 -1
  213. package/dist/form/invited.d.ts +0 -2
  214. package/dist/form/invited.js +0 -13
  215. package/dist/form/invited.js.map +0 -1
  216. package/dist/form/login.d.ts +0 -2
  217. package/dist/form/login.js +0 -11
  218. package/dist/form/login.js.map +0 -1
  219. package/dist/form/me/apiToken.d.ts +0 -2
  220. package/dist/form/me/apiToken.js +0 -9
  221. package/dist/form/me/apiToken.js.map +0 -1
  222. package/dist/form/me/password.d.ts +0 -2
  223. package/dist/form/me/password.js +0 -11
  224. package/dist/form/me/password.js.map +0 -1
  225. package/dist/form/me/user.d.ts +0 -2
  226. package/dist/form/me/user.js +0 -9
  227. package/dist/form/me/user.js.map +0 -1
  228. package/dist/form/register.d.ts +0 -2
  229. package/dist/form/register.js +0 -13
  230. package/dist/form/register.js.map +0 -1
  231. package/dist/form/revision.d.ts +0 -2
  232. package/dist/form/revision.js +0 -13
  233. package/dist/form/revision.js.map +0 -1
  234. package/dist/hono/handlers/admin/share.d.ts +0 -106
  235. package/dist/hono/handlers/admin/share.js +0 -55
  236. package/dist/hono/handlers/admin/share.js.map +0 -1
  237. package/dist/middlewares/accessTokenParser.d.ts +0 -4
  238. package/dist/middlewares/accessTokenParser.js +0 -29
  239. package/dist/middlewares/accessTokenParser.js.map +0 -1
  240. package/dist/middlewares/adminRequired.d.ts +0 -10
  241. package/dist/middlewares/adminRequired.js +0 -35
  242. package/dist/middlewares/adminRequired.js.map +0 -1
  243. package/dist/middlewares/applicationInstalled.d.ts +0 -3
  244. package/dist/middlewares/applicationInstalled.js +0 -20
  245. package/dist/middlewares/applicationInstalled.js.map +0 -1
  246. package/dist/middlewares/applicationNotInstalled.d.ts +0 -3
  247. package/dist/middlewares/applicationNotInstalled.js +0 -13
  248. package/dist/middlewares/applicationNotInstalled.js.map +0 -1
  249. package/dist/middlewares/basicAuth.d.ts +0 -4
  250. package/dist/middlewares/basicAuth.js +0 -23
  251. package/dist/middlewares/basicAuth.js.map +0 -1
  252. package/dist/middlewares/csrfVerify.d.ts +0 -4
  253. package/dist/middlewares/csrfVerify.js +0 -24
  254. package/dist/middlewares/csrfVerify.js.map +0 -1
  255. package/dist/middlewares/encodeSpace.d.ts +0 -3
  256. package/dist/middlewares/encodeSpace.js +0 -14
  257. package/dist/middlewares/encodeSpace.js.map +0 -1
  258. package/dist/middlewares/fileAccessRightOrLoginRequired.d.ts +0 -4
  259. package/dist/middlewares/fileAccessRightOrLoginRequired.js +0 -29
  260. package/dist/middlewares/fileAccessRightOrLoginRequired.js.map +0 -1
  261. package/dist/middlewares/index.d.ts +0 -16
  262. package/dist/middlewares/index.js +0 -30
  263. package/dist/middlewares/index.js.map +0 -1
  264. package/dist/middlewares/jwtAdminRequired.d.ts +0 -8
  265. package/dist/middlewares/jwtAdminRequired.js +0 -35
  266. package/dist/middlewares/jwtAdminRequired.js.map +0 -1
  267. package/dist/middlewares/jwtAuth.d.ts +0 -4
  268. package/dist/middlewares/jwtAuth.js +0 -104
  269. package/dist/middlewares/jwtAuth.js.map +0 -1
  270. package/dist/middlewares/loginChecker.d.ts +0 -4
  271. package/dist/middlewares/loginChecker.js +0 -32
  272. package/dist/middlewares/loginChecker.js.map +0 -1
  273. package/dist/middlewares/loginRequired.d.ts +0 -4
  274. package/dist/middlewares/loginRequired.js +0 -88
  275. package/dist/middlewares/loginRequired.js.map +0 -1
  276. package/dist/routes/admin.d.ts +0 -4
  277. package/dist/routes/admin.js +0 -17
  278. package/dist/routes/admin.js.map +0 -1
  279. package/dist/routes/api/admin.d.ts +0 -4
  280. package/dist/routes/api/admin.js +0 -37
  281. package/dist/routes/api/admin.js.map +0 -1
  282. package/dist/routes/api/attachment.d.ts +0 -4
  283. package/dist/routes/api/attachment.js +0 -19
  284. package/dist/routes/api/attachment.js.map +0 -1
  285. package/dist/routes/api/bookmark.d.ts +0 -4
  286. package/dist/routes/api/bookmark.js +0 -15
  287. package/dist/routes/api/bookmark.js.map +0 -1
  288. package/dist/routes/api/comment.d.ts +0 -4
  289. package/dist/routes/api/comment.js +0 -14
  290. package/dist/routes/api/comment.js.map +0 -1
  291. package/dist/routes/api/index.d.ts +0 -4
  292. package/dist/routes/api/index.js +0 -36
  293. package/dist/routes/api/index.js.map +0 -1
  294. package/dist/routes/api/like.d.ts +0 -4
  295. package/dist/routes/api/like.js +0 -13
  296. package/dist/routes/api/like.js.map +0 -1
  297. package/dist/routes/api/notification.d.ts +0 -4
  298. package/dist/routes/api/notification.js +0 -15
  299. package/dist/routes/api/notification.js.map +0 -1
  300. package/dist/routes/api/page.d.ts +0 -4
  301. package/dist/routes/api/page.js +0 -24
  302. package/dist/routes/api/page.js.map +0 -1
  303. package/dist/routes/api/revision.d.ts +0 -4
  304. package/dist/routes/api/revision.js +0 -14
  305. package/dist/routes/api/revision.js.map +0 -1
  306. package/dist/routes/api/share.d.ts +0 -4
  307. package/dist/routes/api/share.js +0 -16
  308. package/dist/routes/api/share.js.map +0 -1
  309. package/dist/routes/api/version.d.ts +0 -4
  310. package/dist/routes/api/version.js +0 -10
  311. package/dist/routes/api/version.js.map +0 -1
  312. package/dist/routes/index.d.ts +0 -4
  313. package/dist/routes/index.js +0 -71
  314. package/dist/routes/index.js.map +0 -1
  315. package/dist/routes/login.d.ts +0 -4
  316. package/dist/routes/login.js +0 -18
  317. package/dist/routes/login.js.map +0 -1
  318. package/dist/routes/me.d.ts +0 -4
  319. package/dist/routes/me.js +0 -24
  320. package/dist/routes/me.js.map +0 -1
  321. package/dist/routes/ts-rest/admin/app.d.ts +0 -4
  322. package/dist/routes/ts-rest/admin/app.js +0 -67
  323. package/dist/routes/ts-rest/admin/app.js.map +0 -1
  324. package/dist/routes/ts-rest/admin/auth.d.ts +0 -4
  325. package/dist/routes/ts-rest/admin/auth.js +0 -95
  326. package/dist/routes/ts-rest/admin/auth.js.map +0 -1
  327. package/dist/routes/ts-rest/admin/index.d.ts +0 -10
  328. package/dist/routes/ts-rest/admin/index.js +0 -35
  329. package/dist/routes/ts-rest/admin/index.js.map +0 -1
  330. package/dist/routes/ts-rest/admin/mail.d.ts +0 -4
  331. package/dist/routes/ts-rest/admin/mail.js +0 -156
  332. package/dist/routes/ts-rest/admin/mail.js.map +0 -1
  333. package/dist/routes/ts-rest/admin/plugins.d.ts +0 -4
  334. package/dist/routes/ts-rest/admin/plugins.js +0 -317
  335. package/dist/routes/ts-rest/admin/plugins.js.map +0 -1
  336. package/dist/routes/ts-rest/admin/search.d.ts +0 -4
  337. package/dist/routes/ts-rest/admin/search.js +0 -67
  338. package/dist/routes/ts-rest/admin/search.js.map +0 -1
  339. package/dist/routes/ts-rest/admin/security.d.ts +0 -4
  340. package/dist/routes/ts-rest/admin/security.js +0 -114
  341. package/dist/routes/ts-rest/admin/security.js.map +0 -1
  342. package/dist/routes/ts-rest/admin/share.d.ts +0 -4
  343. package/dist/routes/ts-rest/admin/share.js +0 -69
  344. package/dist/routes/ts-rest/admin/share.js.map +0 -1
  345. package/dist/routes/ts-rest/admin/storage.d.ts +0 -4
  346. package/dist/routes/ts-rest/admin/storage.js +0 -59
  347. package/dist/routes/ts-rest/admin/storage.js.map +0 -1
  348. package/dist/routes/ts-rest/admin/users.d.ts +0 -4
  349. package/dist/routes/ts-rest/admin/users.js +0 -215
  350. package/dist/routes/ts-rest/admin/users.js.map +0 -1
  351. package/dist/routes/ts-rest/adminCrypto.d.ts +0 -4
  352. package/dist/routes/ts-rest/adminCrypto.js +0 -111
  353. package/dist/routes/ts-rest/adminCrypto.js.map +0 -1
  354. package/dist/routes/ts-rest/app.d.ts +0 -4
  355. package/dist/routes/ts-rest/app.js +0 -23
  356. package/dist/routes/ts-rest/app.js.map +0 -1
  357. package/dist/routes/ts-rest/attachment.d.ts +0 -4
  358. package/dist/routes/ts-rest/attachment.js +0 -830
  359. package/dist/routes/ts-rest/attachment.js.map +0 -1
  360. package/dist/routes/ts-rest/auth.d.ts +0 -4
  361. package/dist/routes/ts-rest/auth.js +0 -70
  362. package/dist/routes/ts-rest/auth.js.map +0 -1
  363. package/dist/routes/ts-rest/autocomplete.d.ts +0 -30
  364. package/dist/routes/ts-rest/autocomplete.js +0 -189
  365. package/dist/routes/ts-rest/autocomplete.js.map +0 -1
  366. package/dist/routes/ts-rest/backlink.d.ts +0 -4
  367. package/dist/routes/ts-rest/backlink.js +0 -106
  368. package/dist/routes/ts-rest/backlink.js.map +0 -1
  369. package/dist/routes/ts-rest/bookmark.d.ts +0 -4
  370. package/dist/routes/ts-rest/bookmark.js +0 -189
  371. package/dist/routes/ts-rest/bookmark.js.map +0 -1
  372. package/dist/routes/ts-rest/comment.d.ts +0 -4
  373. package/dist/routes/ts-rest/comment.js +0 -217
  374. package/dist/routes/ts-rest/comment.js.map +0 -1
  375. package/dist/routes/ts-rest/draft.d.ts +0 -22
  376. package/dist/routes/ts-rest/draft.js +0 -200
  377. package/dist/routes/ts-rest/draft.js.map +0 -1
  378. package/dist/routes/ts-rest/index.d.ts +0 -4
  379. package/dist/routes/ts-rest/index.js +0 -103
  380. package/dist/routes/ts-rest/index.js.map +0 -1
  381. package/dist/routes/ts-rest/installer.d.ts +0 -4
  382. package/dist/routes/ts-rest/installer.js +0 -77
  383. package/dist/routes/ts-rest/installer.js.map +0 -1
  384. package/dist/routes/ts-rest/me.d.ts +0 -4
  385. package/dist/routes/ts-rest/me.js +0 -410
  386. package/dist/routes/ts-rest/me.js.map +0 -1
  387. package/dist/routes/ts-rest/notification.d.ts +0 -4
  388. package/dist/routes/ts-rest/notification.js +0 -241
  389. package/dist/routes/ts-rest/notification.js.map +0 -1
  390. package/dist/routes/ts-rest/page-collab.d.ts +0 -29
  391. package/dist/routes/ts-rest/page-collab.js +0 -90
  392. package/dist/routes/ts-rest/page-collab.js.map +0 -1
  393. package/dist/routes/ts-rest/page-preview.d.ts +0 -26
  394. package/dist/routes/ts-rest/page-preview.js +0 -80
  395. package/dist/routes/ts-rest/page-preview.js.map +0 -1
  396. package/dist/routes/ts-rest/page.d.ts +0 -4
  397. package/dist/routes/ts-rest/page.js +0 -676
  398. package/dist/routes/ts-rest/page.js.map +0 -1
  399. package/dist/routes/ts-rest/presence.d.ts +0 -30
  400. package/dist/routes/ts-rest/presence.js +0 -155
  401. package/dist/routes/ts-rest/presence.js.map +0 -1
  402. package/dist/routes/ts-rest/revision.d.ts +0 -4
  403. package/dist/routes/ts-rest/revision.js +0 -240
  404. package/dist/routes/ts-rest/revision.js.map +0 -1
  405. package/dist/routes/ts-rest/search.d.ts +0 -4
  406. package/dist/routes/ts-rest/search.js +0 -121
  407. package/dist/routes/ts-rest/search.js.map +0 -1
  408. package/dist/routes/ts-rest/tokenAuth.d.ts +0 -4
  409. package/dist/routes/ts-rest/tokenAuth.js +0 -94
  410. package/dist/routes/ts-rest/tokenAuth.js.map +0 -1
  411. package/dist/routes/ts-rest/user.d.ts +0 -4
  412. package/dist/routes/ts-rest/user.js +0 -307
  413. package/dist/routes/ts-rest/user.js.map +0 -1
  414. package/dist/types/express.d.ts +0 -34
  415. package/dist/types/express.js +0 -50
  416. package/dist/types/express.js.map +0 -1
  417. package/dist/util/accessTokenParser.d.ts +0 -1
  418. package/dist/util/accessTokenParser.js +0 -34
  419. package/dist/util/accessTokenParser.js.map +0 -1
  420. package/dist/util/apiPaginate.d.ts +0 -11
  421. package/dist/util/apiPaginate.js +0 -33
  422. package/dist/util/apiPaginate.js.map +0 -1
  423. package/dist/util/apiResponse.d.ts +0 -9
  424. package/dist/util/apiResponse.js +0 -23
  425. package/dist/util/apiResponse.js.map +0 -1
  426. package/dist/util/auth.d.ts +0 -11
  427. package/dist/util/auth.js +0 -48
  428. package/dist/util/auth.js.map +0 -1
  429. package/dist/util/aws-config-migration.d.ts +0 -11
  430. package/dist/util/aws-config-migration.js +0 -68
  431. package/dist/util/aws-config-migration.js.map +0 -1
  432. package/dist/util/formUtil.d.ts +0 -2
  433. package/dist/util/formUtil.js +0 -15
  434. package/dist/util/formUtil.js.map +0 -1
  435. package/dist/util/githubAuth.d.ts +0 -2
  436. package/dist/util/githubAuth.js +0 -82
  437. package/dist/util/githubAuth.js.map +0 -1
  438. package/dist/util/googleAuth.d.ts +0 -2
  439. package/dist/util/googleAuth.js +0 -85
  440. package/dist/util/googleAuth.js.map +0 -1
  441. package/dist/util/mailer.d.ts +0 -7
  442. package/dist/util/mailer.js +0 -98
  443. package/dist/util/mailer.js.map +0 -1
  444. package/dist/util/page-status-migration.d.ts +0 -23
  445. package/dist/util/page-status-migration.js +0 -48
  446. package/dist/util/page-status-migration.js.map +0 -1
  447. package/dist/util/ssr.d.ts +0 -3
  448. package/dist/util/ssr.js +0 -9
  449. package/dist/util/ssr.js.map +0 -1
  450. package/dist/util/view.d.ts +0 -10
  451. package/dist/util/view.js +0 -99
  452. package/dist/util/view.js.map +0 -1
@@ -0,0 +1,13 @@
1
+ import type { MigrationContext } from './types';
2
+ /**
3
+ * Resolve the user id to credit a preflight migration's body rewrites to:
4
+ * 1. `CROWI_MIGRATE_USER=<email>` if set,
5
+ * 2. otherwise the oldest admin (`{ admin: true }` by `createdAt`).
6
+ *
7
+ * Throws with `migrationName` in the message when neither yields a user, so the
8
+ * operator sees which migration tripped instead of a per-page `user should have
9
+ * _id` failure deep inside the rewrite. Used by every preflight migration that
10
+ * pushes new revisions on the operator's behalf (`wikilink-format`,
11
+ * `files-url-to-attachments`, …).
12
+ */
13
+ export declare function resolveActingUserId(ctx: MigrationContext, migrationName: string): Promise<string>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveActingUserId = resolveActingUserId;
4
+ /**
5
+ * Resolve the user id to credit a preflight migration's body rewrites to:
6
+ * 1. `CROWI_MIGRATE_USER=<email>` if set,
7
+ * 2. otherwise the oldest admin (`{ admin: true }` by `createdAt`).
8
+ *
9
+ * Throws with `migrationName` in the message when neither yields a user, so the
10
+ * operator sees which migration tripped instead of a per-page `user should have
11
+ * _id` failure deep inside the rewrite. Used by every preflight migration that
12
+ * pushes new revisions on the operator's behalf (`wikilink-format`,
13
+ * `files-url-to-attachments`, …).
14
+ */
15
+ async function resolveActingUserId(ctx, migrationName) {
16
+ const User = ctx.crowi.model('User');
17
+ const explicit = process.env.CROWI_MIGRATE_USER;
18
+ if (explicit) {
19
+ const named = await User.findOne({ email: explicit }).select('_id').lean().exec();
20
+ if (named)
21
+ return String(named._id);
22
+ throw new Error(`CROWI_MIGRATE_USER='${explicit}' but no user with that email exists.`);
23
+ }
24
+ const admin = await User.findOne({ admin: true }).sort({ createdAt: 1 }).select('_id').lean().exec();
25
+ if (admin)
26
+ return String(admin._id);
27
+ throw new Error(`${migrationName}: no admin user found; set CROWI_MIGRATE_USER=<email> or create an admin user first.`);
28
+ }
29
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/migration/helpers.ts"],"names":[],"mappings":";;AAaA,kDAWC;AAtBD;;;;;;;;;;GAUG;AACI,KAAK,UAAU,mBAAmB,CAAC,GAAqB,EAAE,aAAqB;IACpF,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;IAChD,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;QAClF,IAAI,KAAK;YAAE,OAAO,MAAM,CAAE,KAA0B,CAAC,GAAG,CAAC,CAAC;QAC1D,MAAM,IAAI,KAAK,CAAC,uBAAuB,QAAQ,uCAAuC,CAAC,CAAC;IAC1F,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;IACrG,IAAI,KAAK;QAAE,OAAO,MAAM,CAAE,KAA0B,CAAC,GAAG,CAAC,CAAC;IAC1D,MAAM,IAAI,KAAK,CAAC,GAAG,aAAa,sFAAsF,CAAC,CAAC;AAC1H,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Per-body breakdown of what a rewrite touched / skipped, returned alongside
3
+ * the rewritten body so callers walk the regex once.
4
+ * - `relative`: rule 1 (relative `/files/<id>`) rewrites.
5
+ * - `selfHostAbsolute`: rule 2 (self-host absolute) rewrites.
6
+ * - `externalSkipped`: rule 3 (external absolute) left untouched.
7
+ */
8
+ export interface FilesUrlRewriteCounts {
9
+ relative: number;
10
+ selfHostAbsolute: number;
11
+ externalSkipped: number;
12
+ }
13
+ /**
14
+ * Single-pass detect-and-rewrite. Returns the rewritten body plus a count
15
+ * breakdown so callers don't walk the regex twice. Pure — no I/O. Returns
16
+ * `body` by reference when nothing changed (no rule-1/2 rewrite), letting
17
+ * callers cheap-skip via `result.body === body`.
18
+ *
19
+ * `origins` is the self-host allow-list (`getAppOrigins()`); pass `[]` to
20
+ * disable rule 2 (CLIENT_URL / BASE_URL unset).
21
+ */
22
+ export declare function rewriteFilesUrls(body: string, origins: readonly string[]): {
23
+ body: string;
24
+ counts: FilesUrlRewriteCounts;
25
+ };
26
+ /**
27
+ * True iff `body` holds at least one *rewritable* v1 file URL — a relative
28
+ * `/files/<id>` or a self-host absolute one (external-only bodies report
29
+ * false). `/files/` is a cheap prefilter so bodies that can't contain one skip
30
+ * the regex; the verdict itself is the full rule (external skips don't count)
31
+ * so a body whose only `/files/<id>` is external correctly reports false.
32
+ * Shared by `isPending` and `collectRewritablePages`.
33
+ */
34
+ export declare function bodyHasRewritableFilesUrl(body: string, origins: readonly string[]): boolean;
35
+ export declare const filesUrlToAttachments: import("../types").MigrationDefinition;
@@ -0,0 +1,291 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.filesUrlToAttachments = void 0;
7
+ exports.rewriteFilesUrls = rewriteFilesUrls;
8
+ exports.bodyHasRewritableFilesUrl = bodyHasRewritableFilesUrl;
9
+ const linkDetector_1 = __importDefault(require("../../util/linkDetector"));
10
+ const page_1 = require("../../models/page");
11
+ const helpers_1 = require("../helpers");
12
+ const types_1 = require("../types");
13
+ /**
14
+ * v1 → v2 — `files-url-to-attachments` (preflight layer).
15
+ *
16
+ * v1 embedded attachment / image references in page bodies as the v1 file
17
+ * URL `/files/<24hex>` (absolute `https://<host>/files/<id>` when the editor
18
+ * pasted a full URL, or relative `/files/<id>`). v2 serves attachments from a
19
+ * dedicated stream route at `/api/v2/attachments/<id>` and the legacy
20
+ * `/files/<id>` compat redirect was removed with the Express host (RFC-0006
21
+ * Phase 6 Sub-batch D), so those v1 URLs now 404 — every such image is
22
+ * broken. The id is identical in both forms (the same 24-hex `Attachment._id`;
23
+ * `attachment.ts` `ATTACHMENT_URI_RE` extracts the same id from either), so the
24
+ * fix is a pure URL rewrite — no id mapping.
25
+ *
26
+ * Modelled on `wikilink-format.ts` (the sibling v1→v2 body-rewrite preflight):
27
+ * walk published (+ legacy `null`) pages, rewrite each current-revision body
28
+ * with a single-pass detect-and-rewrite, route every write through
29
+ * `ctx.rewritePageBody` (the `updatePage`-equivalent path that nulls
30
+ * `yjsState` / `yjsCheckpointAt` so an active editor can't revert the rewrite
31
+ * from a stale `Y.Doc` — see wikilink-format §4.3.1), and use a cheap
32
+ * substring prefilter (`/files/`) before the detail regex in `isPending`.
33
+ *
34
+ * Rewrite rules (Markdown `![alt](url)` images and `[text](url)` links only —
35
+ * raw HTML `<img src>` / `<a href>` is out of scope; v1 emitted Markdown):
36
+ *
37
+ * 1. relative `/files/<id>` → `/api/v2/attachments/<id>`
38
+ * (unconditional — a root-relative path is always this site).
39
+ * 2. self-host absolute `https://<origin>/files/<id>`
40
+ * → `/api/v2/attachments/<id>`
41
+ * (relativised — drops the host so the URL is portable). `<origin>` must
42
+ * match `linkDetector.getAppOrigins()` (CLIENT_URL / BASE_URL).
43
+ * 3. external absolute `https://other/files/<id>` → left untouched
44
+ * (we must not rewrite an unrelated third-party `/files/<id>` image).
45
+ *
46
+ * Host moves (v1 domain ≠ v2 domain) are out of scope: the separate `replace
47
+ * url` admin-cli command rewrites the old host → new host first, after which
48
+ * the self-host absolute URLs match CLIENT_URL and rule 2 relativises them.
49
+ *
50
+ * Idempotent: the output `/api/v2/attachments/<id>` never matches the
51
+ * `/files/` regex, so a re-apply is a no-op (no double rewrite).
52
+ *
53
+ * CLIENT_URL / BASE_URL unset: `getAppOrigins()` returns `[]`, so the
54
+ * self-host alternation is empty and rule 2 is skipped — only relative
55
+ * `/files/<id>` (rule 1) is rewritten and absolute URLs are left alone.
56
+ */
57
+ /** v2 attachment URL prefix the rewrite targets. */
58
+ const V2_ATTACHMENT_PREFIX = '/api/v2/attachments/';
59
+ /**
60
+ * Substring that necessarily precedes every rewritable v1 file URL: `/files/`.
61
+ * Cheapest probe guaranteed present whenever a real `/files/<id>` reference
62
+ * exists, so a body without it can skip the regex entirely (no false
63
+ * negatives). The actual verdict still applies the full detect rule — see
64
+ * `bodyHasRewritableFilesUrl`.
65
+ */
66
+ const FILES_SUBSTRING_PROBE = '/files/';
67
+ const emptyCounts = () => ({ relative: 0, selfHostAbsolute: 0, externalSkipped: 0 });
68
+ /**
69
+ * Build the per-body rewrite regex. It matches a Markdown image/link whose URL
70
+ * payload points at `/files/<24hex>` in one of two forms:
71
+ *
72
+ * - relative: the URL part starts with `/files/<id>`
73
+ * - absolute: the URL part is `<scheme>://<host>.../files/<id>`
74
+ *
75
+ * The `![alt]` / `[text]` head and the trailing path/query/fragment after the
76
+ * id are captured verbatim and re-emitted unchanged; only the host + `/files/`
77
+ * → `/api/v2/attachments/` portion is rewritten. Self-host classification of
78
+ * absolute URLs is decided in the callback (not the regex) so external hosts
79
+ * fall through untouched.
80
+ *
81
+ * A fresh `RegExp` per call keeps `lastIndex` state local (the regex is `g`).
82
+ */
83
+ function buildFilesUrlRegex() {
84
+ // Group layout:
85
+ // 1: the markdown head `![alt]` or `[text]` (incl. the leading `!` if image)
86
+ // 2: optional `<scheme>://<host>` for an absolute URL (undefined when relative)
87
+ // 3: the 24-hex attachment id
88
+ // 4: the trailing remainder inside the parens after the id (path/query/#),
89
+ // excluding the closing `)` and whitespace
90
+ return /(!?\[[^\]]*\])\((https?:\/\/[^\s)/]+)?\/files\/([0-9a-fA-F]{24})([^\s)]*)\)/g;
91
+ }
92
+ /**
93
+ * Decide whether an absolute URL's `<scheme>://<host>` prefix belongs to this
94
+ * Crowi instance. `origins` are the normalised `getAppOrigins()` values
95
+ * (trailing slash trimmed). A match means the URL is self-host and should be
96
+ * relativised (rule 2); a non-match is external and left untouched (rule 3).
97
+ *
98
+ * The match is exact against the captured `<scheme>://<host>` (no path), so
99
+ * `https://wiki.example.com` matches origin `https://wiki.example.com` but not
100
+ * `https://evil.example.com`.
101
+ */
102
+ function isSelfHostOrigin(schemeAndHost, origins) {
103
+ return origins.includes(schemeAndHost);
104
+ }
105
+ /**
106
+ * Single-pass detect-and-rewrite. Returns the rewritten body plus a count
107
+ * breakdown so callers don't walk the regex twice. Pure — no I/O. Returns
108
+ * `body` by reference when nothing changed (no rule-1/2 rewrite), letting
109
+ * callers cheap-skip via `result.body === body`.
110
+ *
111
+ * `origins` is the self-host allow-list (`getAppOrigins()`); pass `[]` to
112
+ * disable rule 2 (CLIENT_URL / BASE_URL unset).
113
+ */
114
+ function rewriteFilesUrls(body, origins) {
115
+ const counts = emptyCounts();
116
+ const rewritten = body.replace(buildFilesUrlRegex(), (whole, head, schemeAndHost, id, rest) => {
117
+ if (schemeAndHost === undefined) {
118
+ // Rule 1 — relative `/files/<id>` is unconditionally this site.
119
+ counts.relative += 1;
120
+ return `${head}(${V2_ATTACHMENT_PREFIX}${id}${rest})`;
121
+ }
122
+ if (isSelfHostOrigin(schemeAndHost, origins)) {
123
+ // Rule 2 — self-host absolute URL; relativise (drop the host).
124
+ counts.selfHostAbsolute += 1;
125
+ return `${head}(${V2_ATTACHMENT_PREFIX}${id}${rest})`;
126
+ }
127
+ // Rule 3 — external host; leave untouched.
128
+ counts.externalSkipped += 1;
129
+ return whole;
130
+ });
131
+ const changed = counts.relative > 0 || counts.selfHostAbsolute > 0;
132
+ return { body: changed ? rewritten : body, counts };
133
+ }
134
+ /**
135
+ * True iff `body` holds at least one *rewritable* v1 file URL — a relative
136
+ * `/files/<id>` or a self-host absolute one (external-only bodies report
137
+ * false). `/files/` is a cheap prefilter so bodies that can't contain one skip
138
+ * the regex; the verdict itself is the full rule (external skips don't count)
139
+ * so a body whose only `/files/<id>` is external correctly reports false.
140
+ * Shared by `isPending` and `collectRewritablePages`.
141
+ */
142
+ function bodyHasRewritableFilesUrl(body, origins) {
143
+ if (!body.includes(FILES_SUBSTRING_PROBE))
144
+ return false;
145
+ const { counts } = rewriteFilesUrls(body, origins);
146
+ return counts.relative > 0 || counts.selfHostAbsolute > 0;
147
+ }
148
+ /**
149
+ * The self-host origins for the current instance, via the same
150
+ * `linkDetector.getAppOrigins()` helper backlink classification uses
151
+ * (CLIENT_URL + BASE_URL, trailing slash trimmed, deduped). Returns `[]` when
152
+ * neither is configured — rule 2 is then disabled (relative-only rewrite).
153
+ */
154
+ function resolveAppOrigins(ctx) {
155
+ return (0, linkDetector_1.default)(ctx.crowi).getAppOrigins();
156
+ }
157
+ /**
158
+ * One full scan of every published (+ legacy `null`) page (trash & deprecated
159
+ * are read-only fixtures — same scope as `wikilink-format`). Returns:
160
+ * - `rewritable`: the pages that actually change (≥1 relative / self-host
161
+ * rewrite), each with its rewritten body for `ctx.rewritePageBody`.
162
+ * - `totals`: the rewrite breakdown aggregated across **every** page with a
163
+ * `/files/` reference (so `externalSkipped` reflects external URLs even on
164
+ * pages with no rewritable URL — an operator signal for "why some /files/
165
+ * references remain").
166
+ * Stream-walks so memory stays constant on large installs.
167
+ */
168
+ async function scanFilesUrls(ctx, origins) {
169
+ const Page = ctx.crowi.model('Page');
170
+ const Revision = ctx.crowi.model('Revision');
171
+ const rewritable = [];
172
+ const totals = emptyCounts();
173
+ const cursor = Page.find({ $or: [{ status: page_1.STATUS_PUBLISHED }, { status: null }] })
174
+ .select('_id revision')
175
+ .lean()
176
+ .cursor();
177
+ for await (const page of cursor) {
178
+ const pageDoc = page;
179
+ if (!pageDoc.revision)
180
+ continue;
181
+ const revision = await Revision.findById(pageDoc.revision).select('body').lean().exec();
182
+ const body = revision?.body;
183
+ if (typeof body !== 'string')
184
+ continue;
185
+ if (!body.includes(FILES_SUBSTRING_PROBE))
186
+ continue;
187
+ const result = rewriteFilesUrls(body, origins);
188
+ totals.relative += result.counts.relative;
189
+ totals.selfHostAbsolute += result.counts.selfHostAbsolute;
190
+ totals.externalSkipped += result.counts.externalSkipped;
191
+ if (result.body === body)
192
+ continue;
193
+ rewritable.push({ pageId: String(pageDoc._id), newBody: result.body, counts: result.counts });
194
+ }
195
+ return { rewritable, totals };
196
+ }
197
+ exports.filesUrlToAttachments = (0, types_1.defineMigration)({
198
+ id: 'files-url-to-attachments',
199
+ fromVersion: '1.x',
200
+ toVersion: '2.1',
201
+ layer: 'preflight',
202
+ description: 'Rewrite v1 /files/<id> attachment URLs to v2 /api/v2/attachments/<id>',
203
+ /**
204
+ * Pending verdict = at least one published page whose **current** revision
205
+ * body still contains a rewritable v1 file URL. Mirrors `wikilink-format`:
206
+ *
207
+ * 1. The verdict uses the **full rule** (`bodyHasRewritableFilesUrl`), not
208
+ * the bare substring. `/files/` could appear in an external URL we leave
209
+ * alone (rule 3); counting that would report pending forever after apply
210
+ * (apply only rewrites self URLs), deadlocking boot under preflight +
211
+ * `block`. The full rule reports false once only external `/files/`
212
+ * references remain, so boot clears.
213
+ * 2. We scan only each page's **current** revision, never the whole
214
+ * `revisions` collection — historical revisions keep their original
215
+ * `/files/<id>` text forever (immutable), so a collection-wide scan
216
+ * would pend permanently after any such page ever existed.
217
+ *
218
+ * Short-circuits at the first rewritable page.
219
+ */
220
+ isPending: async (ctx) => {
221
+ const origins = resolveAppOrigins(ctx);
222
+ const Page = ctx.crowi.model('Page');
223
+ const Revision = ctx.crowi.model('Revision');
224
+ const cursor = Page.find({ $or: [{ status: page_1.STATUS_PUBLISHED }, { status: null }] })
225
+ .select('_id revision')
226
+ .lean()
227
+ .cursor();
228
+ for await (const page of cursor) {
229
+ const revisionId = page.revision;
230
+ if (!revisionId)
231
+ continue;
232
+ const revision = await Revision.findById(revisionId).select('body').lean().exec();
233
+ const body = revision?.body;
234
+ if (typeof body === 'string' && bodyHasRewritableFilesUrl(body, origins)) {
235
+ await cursor.close();
236
+ return true;
237
+ }
238
+ }
239
+ return false;
240
+ },
241
+ /**
242
+ * Full scan for `plan`: affected page count plus the rewrite breakdown
243
+ * (relative / self-host absolute rewrites + external skips, the last
244
+ * aggregated across every `/files/` page — see `scanFilesUrls`). Not called
245
+ * at boot.
246
+ */
247
+ detect: async (ctx) => {
248
+ const origins = resolveAppOrigins(ctx);
249
+ const { rewritable, totals } = await scanFilesUrls(ctx, origins);
250
+ const rewrites = totals.relative + totals.selfHostAbsolute;
251
+ return {
252
+ summary: `${rewritable.length} page(s) need a v1 /files/<id> rewrite (${rewrites} rewrite(s): ${totals.relative} relative, ${totals.selfHostAbsolute} self-host absolute; ${totals.externalSkipped} external skipped)`,
253
+ counts: {
254
+ pages: rewritable.length,
255
+ rewrites,
256
+ relative: totals.relative,
257
+ selfHostAbsolute: totals.selfHostAbsolute,
258
+ externalSkipped: totals.externalSkipped,
259
+ },
260
+ };
261
+ },
262
+ stages: [
263
+ {
264
+ name: 'rewrite-files-url',
265
+ fn: async (ctx) => {
266
+ const origins = resolveAppOrigins(ctx);
267
+ if (ctx.dryRun) {
268
+ const { rewritable } = await scanFilesUrls(ctx, origins);
269
+ return { name: 'rewrite-files-url', transformed: 0, stats: { wouldRewrite: rewritable.length } };
270
+ }
271
+ const actingUserId = await (0, helpers_1.resolveActingUserId)(ctx, 'files-url-to-attachments');
272
+ const { rewritable: pages } = await scanFilesUrls(ctx, origins);
273
+ ctx.progress.setTotal(pages.length);
274
+ let rewritten = 0;
275
+ // Serial walk through `ctx.rewritePageBody` (each call re-fetches the
276
+ // live page, prepares a revision, and pushes it via the updatePage
277
+ // path so yjsState / yjsCheckpointAt are nulled).
278
+ for (const page of pages) {
279
+ await ctx.rewritePageBody(page.pageId, page.newBody, { userId: actingUserId });
280
+ rewritten += 1;
281
+ ctx.progress.increment();
282
+ }
283
+ if (rewritten > 0) {
284
+ ctx.logger.info(`files-url-to-attachments: rewrote ${rewritten} page(s) via the updatePage path (yjsState invalidated)`);
285
+ }
286
+ return { name: 'rewrite-files-url', transformed: rewritten };
287
+ },
288
+ },
289
+ ],
290
+ });
291
+ //# sourceMappingURL=files-url-to-attachments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files-url-to-attachments.js","sourceRoot":"","sources":["../../../src/migration/migrations/files-url-to-attachments.ts"],"names":[],"mappings":";;;;;;AA+HA,4CAmBC;AAUD,8DAIC;AAhKD,yEAAwD;AACxD,0CA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EAAE,KAAK,EAAE,GAAG,MAAM,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;gBAChE,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;gBAEpC,IAAI,SAAS,GAAG,CAAC,CAAC;gBAClB,sEAAsE;gBACtE,mEAAmE;gBACnE,kDAAkD;gBAClD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;oBACzB,MAAM,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;oBAC/E,SAAS,IAAI,CAAC,CAAC;oBACf,GAAG,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;gBAC3B,CAAC;gBAED,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;oBAClB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,qCAAqC,SAAS,yDAAyD,CAAC,CAAC;gBAC3H,CAAC;gBACD,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;YAC/D,CAAC;SACF;KACF;CACF,CAAC,CAAC"}
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.allMigrations = void 0;
4
+ const files_url_to_attachments_1 = require("./files-url-to-attachments");
4
5
  const page_status_default_1 = require("./page-status-default");
6
+ const relocate_reserved_api_paths_1 = require("./relocate-reserved-api-paths");
5
7
  const revisions_schema_unify_1 = require("./revisions-schema-unify");
6
8
  const user_unique_prepare_1 = require("./user-unique-prepare");
7
9
  const wikilink_format_1 = require("./wikilink-format");
10
+ const wikilink_html_recover_1 = require("./wikilink-html-recover");
8
11
  /**
9
12
  * RFC-0008 §5.5 — the migration barrel.
10
13
  *
@@ -20,5 +23,8 @@ exports.allMigrations = [
20
23
  wikilink_format_1.wikilinkFormat, // phase 3 (preflight)
21
24
  user_unique_prepare_1.userUniquePrepare, // phase 5 (preflight)
22
25
  revisions_schema_unify_1.revisionsSchemaUnify, // phase 6 (boot — RFC-classified preflight, see migration JSDoc)
26
+ relocate_reserved_api_paths_1.relocateReservedApiPaths, // fix/mcp-endpoint (preflight) — v2 /api namespace reservation
27
+ files_url_to_attachments_1.filesUrlToAttachments, // feature-migration-files-url-rewrite (preflight) — v1 /files/<id> body rewrite (independent regex from wikilink-format/html-tag-fixes)
28
+ wikilink_html_recover_1.wikilinkHtmlRecover, // migration-html-tag-fixes (preflight) — recover </font> etc. corrupted by wikilink-format
23
29
  ];
24
30
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/migration/migrations/index.ts"],"names":[],"mappings":";;;AACA,+DAA0D;AAC1D,qEAAgE;AAChE,+DAA0D;AAC1D,uDAAmD;AAEnD;;;;;;;;;GASG;AACU,QAAA,aAAa,GAA0B;IAClD,uCAAiB,EAAE,iBAAiB;IACpC,gCAAc,EAAE,sBAAsB;IACtC,uCAAiB,EAAE,sBAAsB;IACzC,6CAAoB,EAAE,iEAAiE;CACxF,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/migration/migrations/index.ts"],"names":[],"mappings":";;;AACA,yEAAmE;AACnE,+DAA0D;AAC1D,+EAAyE;AACzE,qEAAgE;AAChE,+DAA0D;AAC1D,uDAAmD;AACnD,mEAA8D;AAE9D;;;;;;;;;GASG;AACU,QAAA,aAAa,GAA0B;IAClD,uCAAiB,EAAE,iBAAiB;IACpC,gCAAc,EAAE,sBAAsB;IACtC,uCAAiB,EAAE,sBAAsB;IACzC,6CAAoB,EAAE,iEAAiE;IACvF,sDAAwB,EAAE,+DAA+D;IACzF,gDAAqB,EAAE,wIAAwI;IAC/J,2CAAmB,EAAE,2FAA2F;CACjH,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type { MigrationContext } from '../types';
2
+ /**
3
+ * Shared "walk every published page's current revision" helper for the
4
+ * preflight migrations that have to project a revision field (no index on
5
+ * `meta.toc.text` / `revision.body`, so an index-backed O(1) probe is
6
+ * impossible — matches `wikilink-format`'s accepted tradeoff). It exists so the
7
+ * walk skeleton + the page→revision pairing are defined once and cannot drift
8
+ * between `isPending` (early-stop verdict) and `detect`/stage (full scan).
9
+ *
10
+ * Streaming + batching:
11
+ * - streams the published-page collection projecting only `_id revision`
12
+ * (`status: published` or legacy `null`, treated as published — trash /
13
+ * deprecated pages are read-only fixtures and out of scope), and
14
+ * - batch-fetches the paired current revisions with a single
15
+ * `Revision.find({ _id: { $in: batch } })` per `batchSize` pages instead of
16
+ * one `findById` per page (eliminates the per-page N+1).
17
+ *
18
+ * Early stop: `visit` may return `STOP` to abort the walk at the first hit, so
19
+ * `isPending` can short-circuit without reading every page.
20
+ *
21
+ * NOTE: `wikilink-format` predates this helper and keeps its own copy on
22
+ * purpose (its tests pin the existing walk); it can adopt this later.
23
+ */
24
+ /** Sentinel a `visit` callback returns to abort the walk early. */
25
+ export declare const STOP: unique symbol;
26
+ /** A current revision, with the `select(projection)` fields plus its page. */
27
+ export interface RevisionVisit {
28
+ /** The projected revision fields (`select`-ed by `projection`). */
29
+ revision: Record<string, unknown>;
30
+ /** The owning page's `_id`, as a string. */
31
+ pageId: string;
32
+ }
33
+ export interface WalkOptions {
34
+ /**
35
+ * Mongoose `.select(...)` projection string for the revision fetch
36
+ * (e.g. `'meta.toc'`, `'body'`). `_id` is always available on the result.
37
+ */
38
+ projection: string;
39
+ /** Pages per `$in` revision batch. Defaults to 200. */
40
+ batchSize?: number;
41
+ }
42
+ /**
43
+ * Stream published pages, batch-fetch their current revisions with the given
44
+ * projection, and invoke `visit(revision)` for each. Returning `STOP` from
45
+ * `visit` aborts the walk immediately.
46
+ */
47
+ export declare function forEachPublishedCurrentRevision(ctx: MigrationContext, options: WalkOptions, visit: (entry: RevisionVisit) => typeof STOP | void | Promise<typeof STOP | void>): Promise<void>;
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.STOP = void 0;
4
+ exports.forEachPublishedCurrentRevision = forEachPublishedCurrentRevision;
5
+ const page_1 = require("../../models/page");
6
+ /**
7
+ * Shared "walk every published page's current revision" helper for the
8
+ * preflight migrations that have to project a revision field (no index on
9
+ * `meta.toc.text` / `revision.body`, so an index-backed O(1) probe is
10
+ * impossible — matches `wikilink-format`'s accepted tradeoff). It exists so the
11
+ * walk skeleton + the page→revision pairing are defined once and cannot drift
12
+ * between `isPending` (early-stop verdict) and `detect`/stage (full scan).
13
+ *
14
+ * Streaming + batching:
15
+ * - streams the published-page collection projecting only `_id revision`
16
+ * (`status: published` or legacy `null`, treated as published — trash /
17
+ * deprecated pages are read-only fixtures and out of scope), and
18
+ * - batch-fetches the paired current revisions with a single
19
+ * `Revision.find({ _id: { $in: batch } })` per `batchSize` pages instead of
20
+ * one `findById` per page (eliminates the per-page N+1).
21
+ *
22
+ * Early stop: `visit` may return `STOP` to abort the walk at the first hit, so
23
+ * `isPending` can short-circuit without reading every page.
24
+ *
25
+ * NOTE: `wikilink-format` predates this helper and keeps its own copy on
26
+ * purpose (its tests pin the existing walk); it can adopt this later.
27
+ */
28
+ /** Sentinel a `visit` callback returns to abort the walk early. */
29
+ exports.STOP = Symbol('stop-walk');
30
+ const DEFAULT_BATCH_SIZE = 200;
31
+ /**
32
+ * Stream published pages, batch-fetch their current revisions with the given
33
+ * projection, and invoke `visit(revision)` for each. Returning `STOP` from
34
+ * `visit` aborts the walk immediately.
35
+ */
36
+ async function forEachPublishedCurrentRevision(ctx, options, visit) {
37
+ const Page = ctx.crowi.model('Page');
38
+ const Revision = ctx.crowi.model('Revision');
39
+ const projection = options.projection;
40
+ const batchSize = options.batchSize ?? DEFAULT_BATCH_SIZE;
41
+ const cursor = Page.find({ $or: [{ status: page_1.STATUS_PUBLISHED }, { status: null }] })
42
+ .select('_id revision')
43
+ .lean()
44
+ .cursor();
45
+ // Buffer of pages whose current revision still needs fetching.
46
+ let batch = [];
47
+ // Fetch the batch's revisions in one `$in` round-trip and pair each back to
48
+ // its page (preserving page order). Returns STOP if `visit` asked to abort.
49
+ const flush = async () => {
50
+ if (batch.length === 0)
51
+ return;
52
+ const ids = batch.map((p) => p.revision);
53
+ const revisions = await Revision.find({ _id: { $in: ids } })
54
+ .select(projection)
55
+ .lean()
56
+ .exec();
57
+ const byId = new Map();
58
+ for (const rev of revisions) {
59
+ if (rev?._id != null)
60
+ byId.set(String(rev._id), rev);
61
+ }
62
+ const pages = batch;
63
+ batch = [];
64
+ for (const page of pages) {
65
+ const revision = byId.get(String(page.revision));
66
+ if (!revision)
67
+ continue;
68
+ const result = await visit({ revision, pageId: String(page._id) });
69
+ if (result === exports.STOP)
70
+ return exports.STOP;
71
+ }
72
+ };
73
+ try {
74
+ for await (const raw of cursor) {
75
+ const page = raw;
76
+ if (!page.revision)
77
+ continue;
78
+ batch.push(page);
79
+ if (batch.length >= batchSize) {
80
+ if ((await flush()) === exports.STOP)
81
+ return;
82
+ }
83
+ }
84
+ await flush();
85
+ }
86
+ finally {
87
+ await cursor.close();
88
+ }
89
+ }
90
+ //# sourceMappingURL=published-current-revision.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"published-current-revision.js","sourceRoot":"","sources":["../../../src/migration/migrations/published-current-revision.ts"],"names":[],"mappings":";;;AA4DA,0EAsDC;AAlHD,0CAAmD;AAGnD;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,mEAAmE;AACtD,QAAA,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;AA0BxC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE/B;;;;GAIG;AACI,KAAK,UAAU,+BAA+B,CACnD,GAAqB,EACrB,OAAoB,EACpB,KAAiF;IAEjF,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAG,GAAG,CAAC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M,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YACjD,IAAI,CAAC,QAAQ;gBAAE,SAAS;YACxB,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACnE,IAAI,MAAM,KAAK,YAAI;gBAAE,OAAO,YAAI,CAAC;QACnC,CAAC;IACH,CAAC,CAAC;IAEF,IAAI,CAAC;QACH,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YAC/B,MAAM,IAAI,GAAG,GAAc,CAAC;YAC5B,IAAI,CAAC,IAAI,CAAC,QAAQ;gBAAE,SAAS;YAC7B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjB,IAAI,KAAK,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;gBAC9B,IAAI,CAAC,MAAM,KAAK,EAAE,CAAC,KAAK,YAAI;oBAAE,OAAO;YACvC,CAAC;QACH,CAAC;QACD,MAAM,KAAK,EAAE,CAAC;IAChB,CAAC;YAAS,CAAC;QACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** `/api` → `/api-legacy`, `/api/foo` → `/api-legacy/foo`, `/api/` → `/api-legacy/`. */
2
+ export declare function relocatedApiPath(oldPath: string): string;
3
+ export declare const relocateReservedApiPaths: import("../types").MigrationDefinition;