@crowi/api 2.0.0-alpha.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 (887) hide show
  1. package/LICENSE +21 -0
  2. package/dist/app.d.ts +8 -0
  3. package/dist/app.js +65 -0
  4. package/dist/app.js.map +1 -0
  5. package/dist/collab/attach.d.ts +33 -0
  6. package/dist/collab/attach.js +341 -0
  7. package/dist/collab/attach.js.map +1 -0
  8. package/dist/collab/extension-redis.d.ts +25 -0
  9. package/dist/collab/extension-redis.js +133 -0
  10. package/dist/collab/extension-redis.js.map +1 -0
  11. package/dist/common/functions/path2name.d.ts +1 -0
  12. package/dist/common/functions/path2name.js +22 -0
  13. package/dist/common/functions/path2name.js.map +1 -0
  14. package/dist/common/functions/renderIcon.d.ts +1 -0
  15. package/dist/common/functions/renderIcon.js +9 -0
  16. package/dist/common/functions/renderIcon.js.map +1 -0
  17. package/dist/controllers/admin.d.ts +3 -0
  18. package/dist/controllers/admin.js +474 -0
  19. package/dist/controllers/admin.js.map +1 -0
  20. package/dist/controllers/attachment.d.ts +4 -0
  21. package/dist/controllers/attachment.js +200 -0
  22. package/dist/controllers/attachment.js.map +1 -0
  23. package/dist/controllers/backlink.d.ts +3 -0
  24. package/dist/controllers/backlink.js +42 -0
  25. package/dist/controllers/backlink.js.map +1 -0
  26. package/dist/controllers/bookmark.d.ts +3 -0
  27. package/dist/controllers/bookmark.js +100 -0
  28. package/dist/controllers/bookmark.js.map +1 -0
  29. package/dist/controllers/comment.d.ts +3 -0
  30. package/dist/controllers/comment.js +111 -0
  31. package/dist/controllers/comment.js.map +1 -0
  32. package/dist/controllers/index.d.ts +25 -0
  33. package/dist/controllers/index.js +44 -0
  34. package/dist/controllers/index.js.map +1 -0
  35. package/dist/controllers/installer.d.ts +3 -0
  36. package/dist/controllers/installer.js +48 -0
  37. package/dist/controllers/installer.js.map +1 -0
  38. package/dist/controllers/login.d.ts +4 -0
  39. package/dist/controllers/login.js +438 -0
  40. package/dist/controllers/login.js.map +1 -0
  41. package/dist/controllers/logout.d.ts +5 -0
  42. package/dist/controllers/logout.js +11 -0
  43. package/dist/controllers/logout.js.map +1 -0
  44. package/dist/controllers/me.d.ts +4 -0
  45. package/dist/controllers/me.js +369 -0
  46. package/dist/controllers/me.js.map +1 -0
  47. package/dist/controllers/notification.d.ts +3 -0
  48. package/dist/controllers/notification.js +88 -0
  49. package/dist/controllers/notification.js.map +1 -0
  50. package/dist/controllers/page.d.ts +3 -0
  51. package/dist/controllers/page.js +881 -0
  52. package/dist/controllers/page.js.map +1 -0
  53. package/dist/controllers/revision.d.ts +3 -0
  54. package/dist/controllers/revision.js +91 -0
  55. package/dist/controllers/revision.js.map +1 -0
  56. package/dist/controllers/search.d.ts +3 -0
  57. package/dist/controllers/search.js +93 -0
  58. package/dist/controllers/search.js.map +1 -0
  59. package/dist/controllers/share.d.ts +3 -0
  60. package/dist/controllers/share.js +207 -0
  61. package/dist/controllers/share.js.map +1 -0
  62. package/dist/controllers/shareAccess.d.ts +3 -0
  63. package/dist/controllers/shareAccess.js +28 -0
  64. package/dist/controllers/shareAccess.js.map +1 -0
  65. package/dist/controllers/slack.d.ts +3 -0
  66. package/dist/controllers/slack.js +87 -0
  67. package/dist/controllers/slack.js.map +1 -0
  68. package/dist/controllers/tokenAuth.d.ts +10 -0
  69. package/dist/controllers/tokenAuth.js +292 -0
  70. package/dist/controllers/tokenAuth.js.map +1 -0
  71. package/dist/controllers/user.d.ts +3 -0
  72. package/dist/controllers/user.js +67 -0
  73. package/dist/controllers/user.js.map +1 -0
  74. package/dist/controllers/version.d.ts +4 -0
  75. package/dist/controllers/version.js +19 -0
  76. package/dist/controllers/version.js.map +1 -0
  77. package/dist/crowi/express-init.d.ts +4 -0
  78. package/dist/crowi/express-init.js +101 -0
  79. package/dist/crowi/express-init.js.map +1 -0
  80. package/dist/crowi/index.d.ts +245 -0
  81. package/dist/crowi/index.js +726 -0
  82. package/dist/crowi/index.js.map +1 -0
  83. package/dist/events/activity.d.ts +7 -0
  84. package/dist/events/activity.js +15 -0
  85. package/dist/events/activity.js.map +1 -0
  86. package/dist/events/bookmark.d.ts +8 -0
  87. package/dist/events/bookmark.js +16 -0
  88. package/dist/events/bookmark.js.map +1 -0
  89. package/dist/events/comment.d.ts +6 -0
  90. package/dist/events/comment.js +14 -0
  91. package/dist/events/comment.js.map +1 -0
  92. package/dist/events/config.d.ts +6 -0
  93. package/dist/events/config.js +12 -0
  94. package/dist/events/config.js.map +1 -0
  95. package/dist/events/index.d.ts +17 -0
  96. package/dist/events/index.js +22 -0
  97. package/dist/events/index.js.map +1 -0
  98. package/dist/events/mention-dispatch.d.ts +44 -0
  99. package/dist/events/mention-dispatch.js +151 -0
  100. package/dist/events/mention-dispatch.js.map +1 -0
  101. package/dist/events/notification.d.ts +7 -0
  102. package/dist/events/notification.js +15 -0
  103. package/dist/events/notification.js.map +1 -0
  104. package/dist/events/page.d.ts +44 -0
  105. package/dist/events/page.js +134 -0
  106. package/dist/events/page.js.map +1 -0
  107. package/dist/events/render-cache.d.ts +24 -0
  108. package/dist/events/render-cache.js +63 -0
  109. package/dist/events/render-cache.js.map +1 -0
  110. package/dist/events/user.d.ts +9 -0
  111. package/dist/events/user.js +39 -0
  112. package/dist/events/user.js.map +1 -0
  113. package/dist/form/admin/app.d.ts +2 -0
  114. package/dist/form/admin/app.js +9 -0
  115. package/dist/form/admin/app.js.map +1 -0
  116. package/dist/form/admin/auth.d.ts +2 -0
  117. package/dist/form/admin/auth.js +9 -0
  118. package/dist/form/admin/auth.js.map +1 -0
  119. package/dist/form/admin/aws.d.ts +2 -0
  120. package/dist/form/admin/aws.js +13 -0
  121. package/dist/form/admin/aws.js.map +1 -0
  122. package/dist/form/admin/github.d.ts +2 -0
  123. package/dist/form/admin/github.js +15 -0
  124. package/dist/form/admin/github.js.map +1 -0
  125. package/dist/form/admin/google.d.ts +2 -0
  126. package/dist/form/admin/google.js +13 -0
  127. package/dist/form/admin/google.js.map +1 -0
  128. package/dist/form/admin/mail.d.ts +2 -0
  129. package/dist/form/admin/mail.js +13 -0
  130. package/dist/form/admin/mail.js.map +1 -0
  131. package/dist/form/admin/sec.d.ts +2 -0
  132. package/dist/form/admin/sec.js +10 -0
  133. package/dist/form/admin/sec.js.map +1 -0
  134. package/dist/form/admin/slackSetting.d.ts +2 -0
  135. package/dist/form/admin/slackSetting.js +13 -0
  136. package/dist/form/admin/slackSetting.js.map +1 -0
  137. package/dist/form/admin/userEdit.d.ts +2 -0
  138. package/dist/form/admin/userEdit.js +9 -0
  139. package/dist/form/admin/userEdit.js.map +1 -0
  140. package/dist/form/admin/userInvite.d.ts +2 -0
  141. package/dist/form/admin/userInvite.js +9 -0
  142. package/dist/form/admin/userInvite.js.map +1 -0
  143. package/dist/form/comment.d.ts +2 -0
  144. package/dist/form/comment.js +9 -0
  145. package/dist/form/comment.js.map +1 -0
  146. package/dist/form/index.d.ts +25 -0
  147. package/dist/form/index.js +48 -0
  148. package/dist/form/index.js.map +1 -0
  149. package/dist/form/invited.d.ts +2 -0
  150. package/dist/form/invited.js +13 -0
  151. package/dist/form/invited.js.map +1 -0
  152. package/dist/form/login.d.ts +2 -0
  153. package/dist/form/login.js +11 -0
  154. package/dist/form/login.js.map +1 -0
  155. package/dist/form/me/apiToken.d.ts +2 -0
  156. package/dist/form/me/apiToken.js +9 -0
  157. package/dist/form/me/apiToken.js.map +1 -0
  158. package/dist/form/me/password.d.ts +2 -0
  159. package/dist/form/me/password.js +11 -0
  160. package/dist/form/me/password.js.map +1 -0
  161. package/dist/form/me/user.d.ts +2 -0
  162. package/dist/form/me/user.js +9 -0
  163. package/dist/form/me/user.js.map +1 -0
  164. package/dist/form/register.d.ts +2 -0
  165. package/dist/form/register.js +13 -0
  166. package/dist/form/register.js.map +1 -0
  167. package/dist/form/revision.d.ts +2 -0
  168. package/dist/form/revision.js +13 -0
  169. package/dist/form/revision.js.map +1 -0
  170. package/dist/hono/app.d.ts +19 -0
  171. package/dist/hono/app.js +21 -0
  172. package/dist/hono/app.js.map +1 -0
  173. package/dist/hono/handlers/_helpers/errors.d.ts +61 -0
  174. package/dist/hono/handlers/_helpers/errors.js +51 -0
  175. package/dist/hono/handlers/_helpers/errors.js.map +1 -0
  176. package/dist/hono/handlers/_helpers/user-shape.d.ts +46 -0
  177. package/dist/hono/handlers/_helpers/user-shape.js +23 -0
  178. package/dist/hono/handlers/_helpers/user-shape.js.map +1 -0
  179. package/dist/hono/handlers/access-token.d.ts +221 -0
  180. package/dist/hono/handlers/access-token.js +113 -0
  181. package/dist/hono/handlers/access-token.js.map +1 -0
  182. package/dist/hono/handlers/activation.d.ts +117 -0
  183. package/dist/hono/handlers/activation.js +77 -0
  184. package/dist/hono/handlers/activation.js.map +1 -0
  185. package/dist/hono/handlers/admin/app.d.ts +123 -0
  186. package/dist/hono/handlers/admin/app.js +76 -0
  187. package/dist/hono/handlers/admin/app.js.map +1 -0
  188. package/dist/hono/handlers/admin/auth.d.ts +127 -0
  189. package/dist/hono/handlers/admin/auth.js +91 -0
  190. package/dist/hono/handlers/admin/auth.js.map +1 -0
  191. package/dist/hono/handlers/admin/mail.d.ts +168 -0
  192. package/dist/hono/handlers/admin/mail.js +76 -0
  193. package/dist/hono/handlers/admin/mail.js.map +1 -0
  194. package/dist/hono/handlers/admin/plugins.d.ts +409 -0
  195. package/dist/hono/handlers/admin/plugins.js +257 -0
  196. package/dist/hono/handlers/admin/plugins.js.map +1 -0
  197. package/dist/hono/handlers/admin/search.d.ts +57 -0
  198. package/dist/hono/handlers/admin/search.js +55 -0
  199. package/dist/hono/handlers/admin/search.js.map +1 -0
  200. package/dist/hono/handlers/admin/security.d.ts +112 -0
  201. package/dist/hono/handlers/admin/security.js +71 -0
  202. package/dist/hono/handlers/admin/security.js.map +1 -0
  203. package/dist/hono/handlers/admin/share.d.ts +106 -0
  204. package/dist/hono/handlers/admin/share.js +55 -0
  205. package/dist/hono/handlers/admin/share.js.map +1 -0
  206. package/dist/hono/handlers/admin/storage.d.ts +55 -0
  207. package/dist/hono/handlers/admin/storage.js +40 -0
  208. package/dist/hono/handlers/admin/storage.js.map +1 -0
  209. package/dist/hono/handlers/admin/users.d.ts +1230 -0
  210. package/dist/hono/handlers/admin/users.js +316 -0
  211. package/dist/hono/handlers/admin/users.js.map +1 -0
  212. package/dist/hono/handlers/adminCrypto.d.ts +110 -0
  213. package/dist/hono/handlers/adminCrypto.js +151 -0
  214. package/dist/hono/handlers/adminCrypto.js.map +1 -0
  215. package/dist/hono/handlers/app.d.ts +26 -0
  216. package/dist/hono/handlers/app.js +34 -0
  217. package/dist/hono/handlers/app.js.map +1 -0
  218. package/dist/hono/handlers/attachment-stream.d.ts +4 -0
  219. package/dist/hono/handlers/attachment-stream.js +211 -0
  220. package/dist/hono/handlers/attachment-stream.js.map +1 -0
  221. package/dist/hono/handlers/attachment.d.ts +687 -0
  222. package/dist/hono/handlers/attachment.js +566 -0
  223. package/dist/hono/handlers/attachment.js.map +1 -0
  224. package/dist/hono/handlers/autocomplete.d.ts +160 -0
  225. package/dist/hono/handlers/autocomplete.js +181 -0
  226. package/dist/hono/handlers/autocomplete.js.map +1 -0
  227. package/dist/hono/handlers/backlink.d.ts +78 -0
  228. package/dist/hono/handlers/backlink.js +93 -0
  229. package/dist/hono/handlers/backlink.js.map +1 -0
  230. package/dist/hono/handlers/bookmark.d.ts +558 -0
  231. package/dist/hono/handlers/bookmark.js +166 -0
  232. package/dist/hono/handlers/bookmark.js.map +1 -0
  233. package/dist/hono/handlers/comment.d.ts +231 -0
  234. package/dist/hono/handlers/comment.js +191 -0
  235. package/dist/hono/handlers/comment.js.map +1 -0
  236. package/dist/hono/handlers/draft.d.ts +136 -0
  237. package/dist/hono/handlers/draft.js +191 -0
  238. package/dist/hono/handlers/draft.js.map +1 -0
  239. package/dist/hono/handlers/emailChange.d.ts +124 -0
  240. package/dist/hono/handlers/emailChange.js +79 -0
  241. package/dist/hono/handlers/emailChange.js.map +1 -0
  242. package/dist/hono/handlers/installer.d.ts +94 -0
  243. package/dist/hono/handlers/installer.js +93 -0
  244. package/dist/hono/handlers/installer.js.map +1 -0
  245. package/dist/hono/handlers/inviteAccept.d.ts +180 -0
  246. package/dist/hono/handlers/inviteAccept.js +94 -0
  247. package/dist/hono/handlers/inviteAccept.js.map +1 -0
  248. package/dist/hono/handlers/me.d.ts +401 -0
  249. package/dist/hono/handlers/me.js +390 -0
  250. package/dist/hono/handlers/me.js.map +1 -0
  251. package/dist/hono/handlers/notification.d.ts +274 -0
  252. package/dist/hono/handlers/notification.js +224 -0
  253. package/dist/hono/handlers/notification.js.map +1 -0
  254. package/dist/hono/handlers/oauth.d.ts +299 -0
  255. package/dist/hono/handlers/oauth.js +443 -0
  256. package/dist/hono/handlers/oauth.js.map +1 -0
  257. package/dist/hono/handlers/page-collab.d.ts +79 -0
  258. package/dist/hono/handlers/page-collab.js +98 -0
  259. package/dist/hono/handlers/page-collab.js.map +1 -0
  260. package/dist/hono/handlers/page-preview.d.ts +48 -0
  261. package/dist/hono/handlers/page-preview.js +83 -0
  262. package/dist/hono/handlers/page-preview.js.map +1 -0
  263. package/dist/hono/handlers/page.d.ts +2059 -0
  264. package/dist/hono/handlers/page.js +793 -0
  265. package/dist/hono/handlers/page.js.map +1 -0
  266. package/dist/hono/handlers/passwordReset.d.ts +181 -0
  267. package/dist/hono/handlers/passwordReset.js +101 -0
  268. package/dist/hono/handlers/passwordReset.js.map +1 -0
  269. package/dist/hono/handlers/presence.d.ts +178 -0
  270. package/dist/hono/handlers/presence.js +163 -0
  271. package/dist/hono/handlers/presence.js.map +1 -0
  272. package/dist/hono/handlers/revision.d.ts +345 -0
  273. package/dist/hono/handlers/revision.js +202 -0
  274. package/dist/hono/handlers/revision.js.map +1 -0
  275. package/dist/hono/handlers/search.d.ts +208 -0
  276. package/dist/hono/handlers/search.js +152 -0
  277. package/dist/hono/handlers/search.js.map +1 -0
  278. package/dist/hono/handlers/tokenAuth.d.ts +369 -0
  279. package/dist/hono/handlers/tokenAuth.js +240 -0
  280. package/dist/hono/handlers/tokenAuth.js.map +1 -0
  281. package/dist/hono/handlers/user.d.ts +710 -0
  282. package/dist/hono/handlers/user.js +212 -0
  283. package/dist/hono/handlers/user.js.map +1 -0
  284. package/dist/hono/index.d.ts +289 -0
  285. package/dist/hono/index.js +240 -0
  286. package/dist/hono/index.js.map +1 -0
  287. package/dist/hono/middleware/admin.d.ts +5 -0
  288. package/dist/hono/middleware/admin.js +34 -0
  289. package/dist/hono/middleware/admin.js.map +1 -0
  290. package/dist/hono/middleware/auth.d.ts +54 -0
  291. package/dist/hono/middleware/auth.js +142 -0
  292. package/dist/hono/middleware/auth.js.map +1 -0
  293. package/dist/hono/middleware/cors.d.ts +3 -0
  294. package/dist/hono/middleware/cors.js +86 -0
  295. package/dist/hono/middleware/cors.js.map +1 -0
  296. package/dist/hono/middleware/default-hook.d.ts +8 -0
  297. package/dist/hono/middleware/default-hook.js +17 -0
  298. package/dist/hono/middleware/default-hook.js.map +1 -0
  299. package/dist/hono/middleware/error-handler.d.ts +2 -0
  300. package/dist/hono/middleware/error-handler.js +20 -0
  301. package/dist/hono/middleware/error-handler.js.map +1 -0
  302. package/dist/hono/middleware/rate-limit.d.ts +57 -0
  303. package/dist/hono/middleware/rate-limit.js +42 -0
  304. package/dist/hono/middleware/rate-limit.js.map +1 -0
  305. package/dist/hono/middleware/require-scope.d.ts +50 -0
  306. package/dist/hono/middleware/require-scope.js +64 -0
  307. package/dist/hono/middleware/require-scope.js.map +1 -0
  308. package/dist/hono/path-rewrite.d.ts +15 -0
  309. package/dist/hono/path-rewrite.js +59 -0
  310. package/dist/hono/path-rewrite.js.map +1 -0
  311. package/dist/mail/i18n/en.d.ts +2 -0
  312. package/dist/mail/i18n/en.js +66 -0
  313. package/dist/mail/i18n/en.js.map +1 -0
  314. package/dist/mail/i18n/index.d.ts +46 -0
  315. package/dist/mail/i18n/index.js +31 -0
  316. package/dist/mail/i18n/index.js.map +1 -0
  317. package/dist/mail/i18n/ja.d.ts +2 -0
  318. package/dist/mail/i18n/ja.js +66 -0
  319. package/dist/mail/i18n/ja.js.map +1 -0
  320. package/dist/mcp/attach.d.ts +25 -0
  321. package/dist/mcp/attach.js +104 -0
  322. package/dist/mcp/attach.js.map +1 -0
  323. package/dist/mcp/dispatch.d.ts +59 -0
  324. package/dist/mcp/dispatch.js +70 -0
  325. package/dist/mcp/dispatch.js.map +1 -0
  326. package/dist/mcp/result.d.ts +40 -0
  327. package/dist/mcp/result.js +78 -0
  328. package/dist/mcp/result.js.map +1 -0
  329. package/dist/mcp/server.d.ts +67 -0
  330. package/dist/mcp/server.js +113 -0
  331. package/dist/mcp/server.js.map +1 -0
  332. package/dist/mcp/tools/page.d.ts +2 -0
  333. package/dist/mcp/tools/page.js +256 -0
  334. package/dist/mcp/tools/page.js.map +1 -0
  335. package/dist/mcp/tools/search.d.ts +2 -0
  336. package/dist/mcp/tools/search.js +36 -0
  337. package/dist/mcp/tools/search.js.map +1 -0
  338. package/dist/middlewares/accessTokenParser.d.ts +4 -0
  339. package/dist/middlewares/accessTokenParser.js +29 -0
  340. package/dist/middlewares/accessTokenParser.js.map +1 -0
  341. package/dist/middlewares/adminRequired.d.ts +10 -0
  342. package/dist/middlewares/adminRequired.js +35 -0
  343. package/dist/middlewares/adminRequired.js.map +1 -0
  344. package/dist/middlewares/applicationInstalled.d.ts +3 -0
  345. package/dist/middlewares/applicationInstalled.js +20 -0
  346. package/dist/middlewares/applicationInstalled.js.map +1 -0
  347. package/dist/middlewares/applicationNotInstalled.d.ts +3 -0
  348. package/dist/middlewares/applicationNotInstalled.js +13 -0
  349. package/dist/middlewares/applicationNotInstalled.js.map +1 -0
  350. package/dist/middlewares/basicAuth.d.ts +4 -0
  351. package/dist/middlewares/basicAuth.js +23 -0
  352. package/dist/middlewares/basicAuth.js.map +1 -0
  353. package/dist/middlewares/csrfVerify.d.ts +4 -0
  354. package/dist/middlewares/csrfVerify.js +24 -0
  355. package/dist/middlewares/csrfVerify.js.map +1 -0
  356. package/dist/middlewares/encodeSpace.d.ts +3 -0
  357. package/dist/middlewares/encodeSpace.js +14 -0
  358. package/dist/middlewares/encodeSpace.js.map +1 -0
  359. package/dist/middlewares/fileAccessRightOrLoginRequired.d.ts +4 -0
  360. package/dist/middlewares/fileAccessRightOrLoginRequired.js +29 -0
  361. package/dist/middlewares/fileAccessRightOrLoginRequired.js.map +1 -0
  362. package/dist/middlewares/index.d.ts +16 -0
  363. package/dist/middlewares/index.js +30 -0
  364. package/dist/middlewares/index.js.map +1 -0
  365. package/dist/middlewares/jwtAdminRequired.d.ts +8 -0
  366. package/dist/middlewares/jwtAdminRequired.js +35 -0
  367. package/dist/middlewares/jwtAdminRequired.js.map +1 -0
  368. package/dist/middlewares/jwtAuth.d.ts +4 -0
  369. package/dist/middlewares/jwtAuth.js +104 -0
  370. package/dist/middlewares/jwtAuth.js.map +1 -0
  371. package/dist/middlewares/loginChecker.d.ts +4 -0
  372. package/dist/middlewares/loginChecker.js +32 -0
  373. package/dist/middlewares/loginChecker.js.map +1 -0
  374. package/dist/middlewares/loginRequired.d.ts +4 -0
  375. package/dist/middlewares/loginRequired.js +88 -0
  376. package/dist/middlewares/loginRequired.js.map +1 -0
  377. package/dist/migration/cli-api.d.ts +83 -0
  378. package/dist/migration/cli-api.js +128 -0
  379. package/dist/migration/cli-api.js.map +1 -0
  380. package/dist/migration/migrations/index.d.ts +12 -0
  381. package/dist/migration/migrations/index.js +24 -0
  382. package/dist/migration/migrations/index.js.map +1 -0
  383. package/dist/migration/migrations/page-status-default.d.ts +25 -0
  384. package/dist/migration/migrations/page-status-default.js +79 -0
  385. package/dist/migration/migrations/page-status-default.js.map +1 -0
  386. package/dist/migration/migrations/revisions-schema-unify.d.ts +33 -0
  387. package/dist/migration/migrations/revisions-schema-unify.js +88 -0
  388. package/dist/migration/migrations/revisions-schema-unify.js.map +1 -0
  389. package/dist/migration/migrations/user-unique-prepare.d.ts +1 -0
  390. package/dist/migration/migrations/user-unique-prepare.js +214 -0
  391. package/dist/migration/migrations/user-unique-prepare.js.map +1 -0
  392. package/dist/migration/migrations/wikilink-format.d.ts +97 -0
  393. package/dist/migration/migrations/wikilink-format.js +418 -0
  394. package/dist/migration/migrations/wikilink-format.js.map +1 -0
  395. package/dist/migration/rebuild-api.d.ts +50 -0
  396. package/dist/migration/rebuild-api.js +45 -0
  397. package/dist/migration/rebuild-api.js.map +1 -0
  398. package/dist/migration/rebuild-runner.d.ts +64 -0
  399. package/dist/migration/rebuild-runner.js +42 -0
  400. package/dist/migration/rebuild-runner.js.map +1 -0
  401. package/dist/migration/rebuilds/index.d.ts +26 -0
  402. package/dist/migration/rebuilds/index.js +69 -0
  403. package/dist/migration/rebuilds/index.js.map +1 -0
  404. package/dist/migration/registry.d.ts +15 -0
  405. package/dist/migration/registry.js +96 -0
  406. package/dist/migration/registry.js.map +1 -0
  407. package/dist/migration/run-boot-migrations.d.ts +31 -0
  408. package/dist/migration/run-boot-migrations.js +95 -0
  409. package/dist/migration/run-boot-migrations.js.map +1 -0
  410. package/dist/migration/runner.d.ts +120 -0
  411. package/dist/migration/runner.js +276 -0
  412. package/dist/migration/runner.js.map +1 -0
  413. package/dist/migration/types.d.ts +153 -0
  414. package/dist/migration/types.js +13 -0
  415. package/dist/migration/types.js.map +1 -0
  416. package/dist/models/activity.d.ts +34 -0
  417. package/dist/models/activity.js +263 -0
  418. package/dist/models/activity.js.map +1 -0
  419. package/dist/models/attachment.d.ts +25 -0
  420. package/dist/models/attachment.js +82 -0
  421. package/dist/models/attachment.js.map +1 -0
  422. package/dist/models/backlink.d.ts +19 -0
  423. package/dist/models/backlink.js +138 -0
  424. package/dist/models/backlink.js.map +1 -0
  425. package/dist/models/bookmark.d.ts +28 -0
  426. package/dist/models/bookmark.js +136 -0
  427. package/dist/models/bookmark.js.map +1 -0
  428. package/dist/models/comment.d.ts +21 -0
  429. package/dist/models/comment.js +87 -0
  430. package/dist/models/comment.js.map +1 -0
  431. package/dist/models/config-sensitive.d.ts +21 -0
  432. package/dist/models/config-sensitive.js +71 -0
  433. package/dist/models/config-sensitive.js.map +1 -0
  434. package/dist/models/config.d.ts +34 -0
  435. package/dist/models/config.js +161 -0
  436. package/dist/models/config.js.map +1 -0
  437. package/dist/models/index.d.ts +30 -0
  438. package/dist/models/index.js +55 -0
  439. package/dist/models/index.js.map +1 -0
  440. package/dist/models/migration-application.d.ts +54 -0
  441. package/dist/models/migration-application.js +36 -0
  442. package/dist/models/migration-application.js.map +1 -0
  443. package/dist/models/notification.d.ts +28 -0
  444. package/dist/models/notification.js +285 -0
  445. package/dist/models/notification.js.map +1 -0
  446. package/dist/models/oauth-authorization-code.d.ts +34 -0
  447. package/dist/models/oauth-authorization-code.js +100 -0
  448. package/dist/models/oauth-authorization-code.js.map +1 -0
  449. package/dist/models/oauth-client.d.ts +36 -0
  450. package/dist/models/oauth-client.js +56 -0
  451. package/dist/models/oauth-client.js.map +1 -0
  452. package/dist/models/oauth-device-code.d.ts +55 -0
  453. package/dist/models/oauth-device-code.js +158 -0
  454. package/dist/models/oauth-device-code.js.map +1 -0
  455. package/dist/models/oauth-refresh-token.d.ts +31 -0
  456. package/dist/models/oauth-refresh-token.js +118 -0
  457. package/dist/models/oauth-refresh-token.js.map +1 -0
  458. package/dist/models/page-yjs-update.d.ts +35 -0
  459. package/dist/models/page-yjs-update.js +33 -0
  460. package/dist/models/page-yjs-update.js.map +1 -0
  461. package/dist/models/page.d.ts +200 -0
  462. package/dist/models/page.js +1117 -0
  463. package/dist/models/page.js.map +1 -0
  464. package/dist/models/personal-access-token.d.ts +30 -0
  465. package/dist/models/personal-access-token.js +107 -0
  466. package/dist/models/personal-access-token.js.map +1 -0
  467. package/dist/models/plugin-render-cache.d.ts +40 -0
  468. package/dist/models/plugin-render-cache.js +39 -0
  469. package/dist/models/plugin-render-cache.js.map +1 -0
  470. package/dist/models/revision.d.ts +145 -0
  471. package/dist/models/revision.js +241 -0
  472. package/dist/models/revision.js.map +1 -0
  473. package/dist/models/share.d.ts +38 -0
  474. package/dist/models/share.js +137 -0
  475. package/dist/models/share.js.map +1 -0
  476. package/dist/models/shareAccess.d.ts +20 -0
  477. package/dist/models/shareAccess.js +45 -0
  478. package/dist/models/shareAccess.js.map +1 -0
  479. package/dist/models/tracking.d.ts +14 -0
  480. package/dist/models/tracking.js +14 -0
  481. package/dist/models/tracking.js.map +1 -0
  482. package/dist/models/updatePost.d.ts +25 -0
  483. package/dist/models/updatePost.js +87 -0
  484. package/dist/models/updatePost.js.map +1 -0
  485. package/dist/models/user.d.ts +144 -0
  486. package/dist/models/user.js +681 -0
  487. package/dist/models/user.js.map +1 -0
  488. package/dist/models/watcher.d.ts +23 -0
  489. package/dist/models/watcher.js +75 -0
  490. package/dist/models/watcher.js.map +1 -0
  491. package/dist/notifications/attach.d.ts +63 -0
  492. package/dist/notifications/attach.js +426 -0
  493. package/dist/notifications/attach.js.map +1 -0
  494. package/dist/notifications/channel.d.ts +13 -0
  495. package/dist/notifications/channel.js +18 -0
  496. package/dist/notifications/channel.js.map +1 -0
  497. package/dist/plugin/index.d.ts +2 -0
  498. package/dist/plugin/index.js +6 -0
  499. package/dist/plugin/index.js.map +1 -0
  500. package/dist/plugin/plugin-context.d.ts +22 -0
  501. package/dist/plugin/plugin-context.js +126 -0
  502. package/dist/plugin/plugin-context.js.map +1 -0
  503. package/dist/plugin/plugin-manager.d.ts +164 -0
  504. package/dist/plugin/plugin-manager.js +328 -0
  505. package/dist/plugin/plugin-manager.js.map +1 -0
  506. package/dist/plugin/plugin-namespace.d.ts +28 -0
  507. package/dist/plugin/plugin-namespace.js +53 -0
  508. package/dist/plugin/plugin-namespace.js.map +1 -0
  509. package/dist/plugin/registries.d.ts +38 -0
  510. package/dist/plugin/registries.js +71 -0
  511. package/dist/plugin/registries.js.map +1 -0
  512. package/dist/plugin/schema-serializer.d.ts +34 -0
  513. package/dist/plugin/schema-serializer.js +122 -0
  514. package/dist/plugin/schema-serializer.js.map +1 -0
  515. package/dist/plugin/topo-sort.d.ts +15 -0
  516. package/dist/plugin/topo-sort.js +59 -0
  517. package/dist/plugin/topo-sort.js.map +1 -0
  518. package/dist/presence/attach.d.ts +36 -0
  519. package/dist/presence/attach.js +399 -0
  520. package/dist/presence/attach.js.map +1 -0
  521. package/dist/renderer/__fixtures__/echo-embed.d.ts +27 -0
  522. package/dist/renderer/__fixtures__/echo-embed.js +24 -0
  523. package/dist/renderer/__fixtures__/echo-embed.js.map +1 -0
  524. package/dist/renderer/cache/index.d.ts +60 -0
  525. package/dist/renderer/cache/index.js +219 -0
  526. package/dist/renderer/cache/index.js.map +1 -0
  527. package/dist/renderer/cache/mongodb-cache.d.ts +82 -0
  528. package/dist/renderer/cache/mongodb-cache.js +180 -0
  529. package/dist/renderer/cache/mongodb-cache.js.map +1 -0
  530. package/dist/renderer/cache/reservation.d.ts +20 -0
  531. package/dist/renderer/cache/reservation.js +115 -0
  532. package/dist/renderer/cache/reservation.js.map +1 -0
  533. package/dist/renderer/core/_mdast-walk.d.ts +35 -0
  534. package/dist/renderer/core/_mdast-walk.js +45 -0
  535. package/dist/renderer/core/_mdast-walk.js.map +1 -0
  536. package/dist/renderer/core/code-block-dispatch.d.ts +31 -0
  537. package/dist/renderer/core/code-block-dispatch.js +166 -0
  538. package/dist/renderer/core/code-block-dispatch.js.map +1 -0
  539. package/dist/renderer/core/code-blocks.d.ts +12 -0
  540. package/dist/renderer/core/code-blocks.js +32 -0
  541. package/dist/renderer/core/code-blocks.js.map +1 -0
  542. package/dist/renderer/core/embed-tags.d.ts +14 -0
  543. package/dist/renderer/core/embed-tags.js +154 -0
  544. package/dist/renderer/core/embed-tags.js.map +1 -0
  545. package/dist/renderer/core/headings.d.ts +16 -0
  546. package/dist/renderer/core/headings.js +31 -0
  547. package/dist/renderer/core/headings.js.map +1 -0
  548. package/dist/renderer/core/index.d.ts +65 -0
  549. package/dist/renderer/core/index.js +83 -0
  550. package/dist/renderer/core/index.js.map +1 -0
  551. package/dist/renderer/core/mention-resolve.d.ts +39 -0
  552. package/dist/renderer/core/mention-resolve.js +75 -0
  553. package/dist/renderer/core/mention-resolve.js.map +1 -0
  554. package/dist/renderer/core/mentions.d.ts +2 -0
  555. package/dist/renderer/core/mentions.js +83 -0
  556. package/dist/renderer/core/mentions.js.map +1 -0
  557. package/dist/renderer/core/syntax-highlight.d.ts +21 -0
  558. package/dist/renderer/core/syntax-highlight.js +64 -0
  559. package/dist/renderer/core/syntax-highlight.js.map +1 -0
  560. package/dist/renderer/core/url-inline-expand.d.ts +9 -0
  561. package/dist/renderer/core/url-inline-expand.js +157 -0
  562. package/dist/renderer/core/url-inline-expand.js.map +1 -0
  563. package/dist/renderer/core/wikilinks.d.ts +2 -0
  564. package/dist/renderer/core/wikilinks.js +118 -0
  565. package/dist/renderer/core/wikilinks.js.map +1 -0
  566. package/dist/renderer/index.d.ts +67 -0
  567. package/dist/renderer/index.js +99 -0
  568. package/dist/renderer/index.js.map +1 -0
  569. package/dist/renderer/pipeline.d.ts +134 -0
  570. package/dist/renderer/pipeline.js +203 -0
  571. package/dist/renderer/pipeline.js.map +1 -0
  572. package/dist/renderer/registry.d.ts +83 -0
  573. package/dist/renderer/registry.js +130 -0
  574. package/dist/renderer/registry.js.map +1 -0
  575. package/dist/renderer/serialize.d.ts +27 -0
  576. package/dist/renderer/serialize.js +46 -0
  577. package/dist/renderer/serialize.js.map +1 -0
  578. package/dist/renderer/version.d.ts +30 -0
  579. package/dist/renderer/version.js +34 -0
  580. package/dist/renderer/version.js.map +1 -0
  581. package/dist/routes/admin.d.ts +4 -0
  582. package/dist/routes/admin.js +17 -0
  583. package/dist/routes/admin.js.map +1 -0
  584. package/dist/routes/api/admin.d.ts +4 -0
  585. package/dist/routes/api/admin.js +37 -0
  586. package/dist/routes/api/admin.js.map +1 -0
  587. package/dist/routes/api/attachment.d.ts +4 -0
  588. package/dist/routes/api/attachment.js +19 -0
  589. package/dist/routes/api/attachment.js.map +1 -0
  590. package/dist/routes/api/bookmark.d.ts +4 -0
  591. package/dist/routes/api/bookmark.js +15 -0
  592. package/dist/routes/api/bookmark.js.map +1 -0
  593. package/dist/routes/api/comment.d.ts +4 -0
  594. package/dist/routes/api/comment.js +14 -0
  595. package/dist/routes/api/comment.js.map +1 -0
  596. package/dist/routes/api/index.d.ts +4 -0
  597. package/dist/routes/api/index.js +36 -0
  598. package/dist/routes/api/index.js.map +1 -0
  599. package/dist/routes/api/like.d.ts +4 -0
  600. package/dist/routes/api/like.js +13 -0
  601. package/dist/routes/api/like.js.map +1 -0
  602. package/dist/routes/api/notification.d.ts +4 -0
  603. package/dist/routes/api/notification.js +15 -0
  604. package/dist/routes/api/notification.js.map +1 -0
  605. package/dist/routes/api/page.d.ts +4 -0
  606. package/dist/routes/api/page.js +24 -0
  607. package/dist/routes/api/page.js.map +1 -0
  608. package/dist/routes/api/revision.d.ts +4 -0
  609. package/dist/routes/api/revision.js +14 -0
  610. package/dist/routes/api/revision.js.map +1 -0
  611. package/dist/routes/api/share.d.ts +4 -0
  612. package/dist/routes/api/share.js +16 -0
  613. package/dist/routes/api/share.js.map +1 -0
  614. package/dist/routes/api/version.d.ts +4 -0
  615. package/dist/routes/api/version.js +10 -0
  616. package/dist/routes/api/version.js.map +1 -0
  617. package/dist/routes/index.d.ts +4 -0
  618. package/dist/routes/index.js +71 -0
  619. package/dist/routes/index.js.map +1 -0
  620. package/dist/routes/login.d.ts +4 -0
  621. package/dist/routes/login.js +18 -0
  622. package/dist/routes/login.js.map +1 -0
  623. package/dist/routes/me.d.ts +4 -0
  624. package/dist/routes/me.js +24 -0
  625. package/dist/routes/me.js.map +1 -0
  626. package/dist/routes/ts-rest/admin/app.d.ts +4 -0
  627. package/dist/routes/ts-rest/admin/app.js +67 -0
  628. package/dist/routes/ts-rest/admin/app.js.map +1 -0
  629. package/dist/routes/ts-rest/admin/auth.d.ts +4 -0
  630. package/dist/routes/ts-rest/admin/auth.js +95 -0
  631. package/dist/routes/ts-rest/admin/auth.js.map +1 -0
  632. package/dist/routes/ts-rest/admin/index.d.ts +10 -0
  633. package/dist/routes/ts-rest/admin/index.js +35 -0
  634. package/dist/routes/ts-rest/admin/index.js.map +1 -0
  635. package/dist/routes/ts-rest/admin/mail.d.ts +4 -0
  636. package/dist/routes/ts-rest/admin/mail.js +156 -0
  637. package/dist/routes/ts-rest/admin/mail.js.map +1 -0
  638. package/dist/routes/ts-rest/admin/plugins.d.ts +4 -0
  639. package/dist/routes/ts-rest/admin/plugins.js +317 -0
  640. package/dist/routes/ts-rest/admin/plugins.js.map +1 -0
  641. package/dist/routes/ts-rest/admin/search.d.ts +4 -0
  642. package/dist/routes/ts-rest/admin/search.js +67 -0
  643. package/dist/routes/ts-rest/admin/search.js.map +1 -0
  644. package/dist/routes/ts-rest/admin/security.d.ts +4 -0
  645. package/dist/routes/ts-rest/admin/security.js +114 -0
  646. package/dist/routes/ts-rest/admin/security.js.map +1 -0
  647. package/dist/routes/ts-rest/admin/share.d.ts +4 -0
  648. package/dist/routes/ts-rest/admin/share.js +69 -0
  649. package/dist/routes/ts-rest/admin/share.js.map +1 -0
  650. package/dist/routes/ts-rest/admin/storage.d.ts +4 -0
  651. package/dist/routes/ts-rest/admin/storage.js +59 -0
  652. package/dist/routes/ts-rest/admin/storage.js.map +1 -0
  653. package/dist/routes/ts-rest/admin/users.d.ts +4 -0
  654. package/dist/routes/ts-rest/admin/users.js +215 -0
  655. package/dist/routes/ts-rest/admin/users.js.map +1 -0
  656. package/dist/routes/ts-rest/adminCrypto.d.ts +4 -0
  657. package/dist/routes/ts-rest/adminCrypto.js +111 -0
  658. package/dist/routes/ts-rest/adminCrypto.js.map +1 -0
  659. package/dist/routes/ts-rest/app.d.ts +4 -0
  660. package/dist/routes/ts-rest/app.js +23 -0
  661. package/dist/routes/ts-rest/app.js.map +1 -0
  662. package/dist/routes/ts-rest/attachment.d.ts +4 -0
  663. package/dist/routes/ts-rest/attachment.js +830 -0
  664. package/dist/routes/ts-rest/attachment.js.map +1 -0
  665. package/dist/routes/ts-rest/auth.d.ts +4 -0
  666. package/dist/routes/ts-rest/auth.js +70 -0
  667. package/dist/routes/ts-rest/auth.js.map +1 -0
  668. package/dist/routes/ts-rest/autocomplete.d.ts +30 -0
  669. package/dist/routes/ts-rest/autocomplete.js +189 -0
  670. package/dist/routes/ts-rest/autocomplete.js.map +1 -0
  671. package/dist/routes/ts-rest/backlink.d.ts +4 -0
  672. package/dist/routes/ts-rest/backlink.js +106 -0
  673. package/dist/routes/ts-rest/backlink.js.map +1 -0
  674. package/dist/routes/ts-rest/bookmark.d.ts +4 -0
  675. package/dist/routes/ts-rest/bookmark.js +189 -0
  676. package/dist/routes/ts-rest/bookmark.js.map +1 -0
  677. package/dist/routes/ts-rest/comment.d.ts +4 -0
  678. package/dist/routes/ts-rest/comment.js +217 -0
  679. package/dist/routes/ts-rest/comment.js.map +1 -0
  680. package/dist/routes/ts-rest/draft.d.ts +22 -0
  681. package/dist/routes/ts-rest/draft.js +200 -0
  682. package/dist/routes/ts-rest/draft.js.map +1 -0
  683. package/dist/routes/ts-rest/index.d.ts +4 -0
  684. package/dist/routes/ts-rest/index.js +103 -0
  685. package/dist/routes/ts-rest/index.js.map +1 -0
  686. package/dist/routes/ts-rest/installer.d.ts +4 -0
  687. package/dist/routes/ts-rest/installer.js +77 -0
  688. package/dist/routes/ts-rest/installer.js.map +1 -0
  689. package/dist/routes/ts-rest/me.d.ts +4 -0
  690. package/dist/routes/ts-rest/me.js +410 -0
  691. package/dist/routes/ts-rest/me.js.map +1 -0
  692. package/dist/routes/ts-rest/notification.d.ts +4 -0
  693. package/dist/routes/ts-rest/notification.js +241 -0
  694. package/dist/routes/ts-rest/notification.js.map +1 -0
  695. package/dist/routes/ts-rest/page-collab.d.ts +29 -0
  696. package/dist/routes/ts-rest/page-collab.js +90 -0
  697. package/dist/routes/ts-rest/page-collab.js.map +1 -0
  698. package/dist/routes/ts-rest/page-preview.d.ts +26 -0
  699. package/dist/routes/ts-rest/page-preview.js +80 -0
  700. package/dist/routes/ts-rest/page-preview.js.map +1 -0
  701. package/dist/routes/ts-rest/page.d.ts +4 -0
  702. package/dist/routes/ts-rest/page.js +676 -0
  703. package/dist/routes/ts-rest/page.js.map +1 -0
  704. package/dist/routes/ts-rest/presence.d.ts +30 -0
  705. package/dist/routes/ts-rest/presence.js +155 -0
  706. package/dist/routes/ts-rest/presence.js.map +1 -0
  707. package/dist/routes/ts-rest/revision.d.ts +4 -0
  708. package/dist/routes/ts-rest/revision.js +240 -0
  709. package/dist/routes/ts-rest/revision.js.map +1 -0
  710. package/dist/routes/ts-rest/search.d.ts +4 -0
  711. package/dist/routes/ts-rest/search.js +121 -0
  712. package/dist/routes/ts-rest/search.js.map +1 -0
  713. package/dist/routes/ts-rest/tokenAuth.d.ts +4 -0
  714. package/dist/routes/ts-rest/tokenAuth.js +94 -0
  715. package/dist/routes/ts-rest/tokenAuth.js.map +1 -0
  716. package/dist/routes/ts-rest/user.d.ts +4 -0
  717. package/dist/routes/ts-rest/user.js +307 -0
  718. package/dist/routes/ts-rest/user.js.map +1 -0
  719. package/dist/service/config.d.ts +50 -0
  720. package/dist/service/config.js +202 -0
  721. package/dist/service/config.js.map +1 -0
  722. package/dist/service/lru.d.ts +11 -0
  723. package/dist/service/lru.js +47 -0
  724. package/dist/service/lru.js.map +1 -0
  725. package/dist/service/mail.d.ts +107 -0
  726. package/dist/service/mail.js +220 -0
  727. package/dist/service/mail.js.map +1 -0
  728. package/dist/service/notification.d.ts +9 -0
  729. package/dist/service/notification.js +19 -0
  730. package/dist/service/notification.js.map +1 -0
  731. package/dist/service/presence.d.ts +219 -0
  732. package/dist/service/presence.js +602 -0
  733. package/dist/service/presence.js.map +1 -0
  734. package/dist/types/error.d.ts +13 -0
  735. package/dist/types/error.js +13 -0
  736. package/dist/types/error.js.map +1 -0
  737. package/dist/types/express.d.ts +34 -0
  738. package/dist/types/express.js +50 -0
  739. package/dist/types/express.js.map +1 -0
  740. package/dist/types/mongoose-extensions.d.ts +8 -0
  741. package/dist/types/mongoose-extensions.js +24 -0
  742. package/dist/types/mongoose-extensions.js.map +1 -0
  743. package/dist/util/accessTokenParser.d.ts +1 -0
  744. package/dist/util/accessTokenParser.js +34 -0
  745. package/dist/util/accessTokenParser.js.map +1 -0
  746. package/dist/util/activityDefine.d.ts +15 -0
  747. package/dist/util/activityDefine.js +52 -0
  748. package/dist/util/activityDefine.js.map +1 -0
  749. package/dist/util/admin-config.d.ts +57 -0
  750. package/dist/util/admin-config.js +99 -0
  751. package/dist/util/admin-config.js.map +1 -0
  752. package/dist/util/admin-pager.d.ts +24 -0
  753. package/dist/util/admin-pager.js +73 -0
  754. package/dist/util/admin-pager.js.map +1 -0
  755. package/dist/util/apiPaginate.d.ts +11 -0
  756. package/dist/util/apiPaginate.js +33 -0
  757. package/dist/util/apiPaginate.js.map +1 -0
  758. package/dist/util/apiResponse.d.ts +9 -0
  759. package/dist/util/apiResponse.js +23 -0
  760. package/dist/util/apiResponse.js.map +1 -0
  761. package/dist/util/auth.d.ts +11 -0
  762. package/dist/util/auth.js +48 -0
  763. package/dist/util/auth.js.map +1 -0
  764. package/dist/util/auto-watch.d.ts +35 -0
  765. package/dist/util/auto-watch.js +24 -0
  766. package/dist/util/auto-watch.js.map +1 -0
  767. package/dist/util/autocomplete-match.d.ts +44 -0
  768. package/dist/util/autocomplete-match.js +80 -0
  769. package/dist/util/autocomplete-match.js.map +1 -0
  770. package/dist/util/aws-config-migration.d.ts +11 -0
  771. package/dist/util/aws-config-migration.js +68 -0
  772. package/dist/util/aws-config-migration.js.map +1 -0
  773. package/dist/util/boot-reporter.d.ts +130 -0
  774. package/dist/util/boot-reporter.js +242 -0
  775. package/dist/util/boot-reporter.js.map +1 -0
  776. package/dist/util/collab-cap.d.ts +39 -0
  777. package/dist/util/collab-cap.js +90 -0
  778. package/dist/util/collab-cap.js.map +1 -0
  779. package/dist/util/crypto.d.ts +39 -0
  780. package/dist/util/crypto.js +105 -0
  781. package/dist/util/crypto.js.map +1 -0
  782. package/dist/util/dedup-users.d.ts +96 -0
  783. package/dist/util/dedup-users.js +149 -0
  784. package/dist/util/dedup-users.js.map +1 -0
  785. package/dist/util/editor-cap-counter.d.ts +90 -0
  786. package/dist/util/editor-cap-counter.js +175 -0
  787. package/dist/util/editor-cap-counter.js.map +1 -0
  788. package/dist/util/fileUploader.d.ts +55 -0
  789. package/dist/util/fileUploader.js +70 -0
  790. package/dist/util/fileUploader.js.map +1 -0
  791. package/dist/util/formUtil.d.ts +2 -0
  792. package/dist/util/formUtil.js +15 -0
  793. package/dist/util/formUtil.js.map +1 -0
  794. package/dist/util/githubAuth.d.ts +2 -0
  795. package/dist/util/githubAuth.js +82 -0
  796. package/dist/util/githubAuth.js.map +1 -0
  797. package/dist/util/googleAuth.d.ts +2 -0
  798. package/dist/util/googleAuth.js +85 -0
  799. package/dist/util/googleAuth.js.map +1 -0
  800. package/dist/util/jwt.d.ts +50 -0
  801. package/dist/util/jwt.js +127 -0
  802. package/dist/util/jwt.js.map +1 -0
  803. package/dist/util/linkDetector.d.ts +3 -0
  804. package/dist/util/linkDetector.js +91 -0
  805. package/dist/util/linkDetector.js.map +1 -0
  806. package/dist/util/mail-token.d.ts +24 -0
  807. package/dist/util/mail-token.js +117 -0
  808. package/dist/util/mail-token.js.map +1 -0
  809. package/dist/util/mailer.d.ts +7 -0
  810. package/dist/util/mailer.js +98 -0
  811. package/dist/util/mailer.js.map +1 -0
  812. package/dist/util/map-duplicate-key-error.d.ts +26 -0
  813. package/dist/util/map-duplicate-key-error.js +41 -0
  814. package/dist/util/map-duplicate-key-error.js.map +1 -0
  815. package/dist/util/mongoose-paginate.d.ts +10 -0
  816. package/dist/util/mongoose-paginate.js +23 -0
  817. package/dist/util/mongoose-paginate.js.map +1 -0
  818. package/dist/util/notifications-token.d.ts +35 -0
  819. package/dist/util/notifications-token.js +140 -0
  820. package/dist/util/notifications-token.js.map +1 -0
  821. package/dist/util/oauth-client-seed.d.ts +2 -0
  822. package/dist/util/oauth-client-seed.js +48 -0
  823. package/dist/util/oauth-client-seed.js.map +1 -0
  824. package/dist/util/oauth-redirect-uri.d.ts +2 -0
  825. package/dist/util/oauth-redirect-uri.js +55 -0
  826. package/dist/util/oauth-redirect-uri.js.map +1 -0
  827. package/dist/util/page-response.d.ts +113 -0
  828. package/dist/util/page-response.js +154 -0
  829. package/dist/util/page-response.js.map +1 -0
  830. package/dist/util/page-search-index.d.ts +19 -0
  831. package/dist/util/page-search-index.js +91 -0
  832. package/dist/util/page-search-index.js.map +1 -0
  833. package/dist/util/page-status-migration.d.ts +23 -0
  834. package/dist/util/page-status-migration.js +48 -0
  835. package/dist/util/page-status-migration.js.map +1 -0
  836. package/dist/util/path.d.ts +2 -0
  837. package/dist/util/path.js +12 -0
  838. package/dist/util/path.js.map +1 -0
  839. package/dist/util/pkce.d.ts +13 -0
  840. package/dist/util/pkce.js +30 -0
  841. package/dist/util/pkce.js.map +1 -0
  842. package/dist/util/presence-token.d.ts +21 -0
  843. package/dist/util/presence-token.js +120 -0
  844. package/dist/util/presence-token.js.map +1 -0
  845. package/dist/util/rate-limit.d.ts +67 -0
  846. package/dist/util/rate-limit.js +87 -0
  847. package/dist/util/rate-limit.js.map +1 -0
  848. package/dist/util/rebuild-backlink.d.ts +25 -0
  849. package/dist/util/rebuild-backlink.js +7 -0
  850. package/dist/util/rebuild-backlink.js.map +1 -0
  851. package/dist/util/rebuild-renderer.d.ts +31 -0
  852. package/dist/util/rebuild-renderer.js +7 -0
  853. package/dist/util/rebuild-renderer.js.map +1 -0
  854. package/dist/util/redis-opts.d.ts +17 -0
  855. package/dist/util/redis-opts.js +40 -0
  856. package/dist/util/redis-opts.js.map +1 -0
  857. package/dist/util/regex.d.ts +2 -0
  858. package/dist/util/regex.js +8 -0
  859. package/dist/util/regex.js.map +1 -0
  860. package/dist/util/search-rebuild.d.ts +18 -0
  861. package/dist/util/search-rebuild.js +28 -0
  862. package/dist/util/search-rebuild.js.map +1 -0
  863. package/dist/util/ssr.d.ts +3 -0
  864. package/dist/util/ssr.js +9 -0
  865. package/dist/util/ssr.js.map +1 -0
  866. package/dist/util/storage-copy.d.ts +40 -0
  867. package/dist/util/storage-copy.js +123 -0
  868. package/dist/util/storage-copy.js.map +1 -0
  869. package/dist/util/ts-rest-helpers.d.ts +110 -0
  870. package/dist/util/ts-rest-helpers.js +110 -0
  871. package/dist/util/ts-rest-helpers.js.map +1 -0
  872. package/dist/util/url.d.ts +1 -0
  873. package/dist/util/url.js +11 -0
  874. package/dist/util/url.js.map +1 -0
  875. package/dist/util/user-code.d.ts +10 -0
  876. package/dist/util/user-code.js +55 -0
  877. package/dist/util/user-code.js.map +1 -0
  878. package/dist/util/view.d.ts +10 -0
  879. package/dist/util/view.js +99 -0
  880. package/dist/util/view.js.map +1 -0
  881. package/dist/util/watcher-backfill.d.ts +30 -0
  882. package/dist/util/watcher-backfill.js +43 -0
  883. package/dist/util/watcher-backfill.js.map +1 -0
  884. package/dist/util/ws-token.d.ts +24 -0
  885. package/dist/util/ws-token.js +134 -0
  886. package/dist/util/ws-token.js.map +1 -0
  887. package/package.json +106 -0
@@ -0,0 +1,726 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ const node_server_1 = require("@hono/node-server");
40
+ const csrf_1 = __importDefault(require("csrf"));
41
+ const debug_1 = __importDefault(require("debug"));
42
+ const http_1 = __importDefault(require("http"));
43
+ const mongoose_1 = __importDefault(require("mongoose"));
44
+ const path_1 = __importStar(require("path"));
45
+ const redis_1 = require("redis");
46
+ const attach_1 = require("../collab/attach");
47
+ const events_1 = __importDefault(require("../events"));
48
+ const mention_dispatch_1 = require("../events/mention-dispatch");
49
+ const render_cache_1 = require("../events/render-cache");
50
+ const hono_1 = require("../hono");
51
+ const path_rewrite_1 = require("../hono/path-rewrite");
52
+ const models_1 = __importDefault(require("../models"));
53
+ const attach_2 = require("../notifications/attach");
54
+ const plugin_1 = require("../plugin");
55
+ const attach_3 = require("../presence/attach");
56
+ const renderer_1 = require("../renderer");
57
+ const mail_1 = require("../service/mail");
58
+ const crypto_1 = require("../util/crypto");
59
+ const oauth_client_seed_1 = require("../util/oauth-client-seed");
60
+ const run_boot_migrations_1 = require("../migration/run-boot-migrations");
61
+ const boot_reporter_1 = require("../util/boot-reporter");
62
+ const redis_opts_1 = require("../util/redis-opts");
63
+ const config_1 = __importDefault(require("../service/config"));
64
+ const lru_1 = __importDefault(require("../service/lru"));
65
+ const pkg = require('../../package.json');
66
+ const debug = (0, debug_1.default)('crowi:crowi');
67
+ const bootDebug = (0, debug_1.default)('crowi:boot');
68
+ /**
69
+ * Emit a `crowi:boot` log after each init phase so we can tell which step
70
+ * dominates a slow dev startup. Per-phase duration is read off `debug`'s
71
+ * built-in `+Xms` (gap to the previous log on the same namespace); we
72
+ * only need to name the phase here.
73
+ */
74
+ async function step(name, fn) {
75
+ const result = await fn();
76
+ bootDebug(name);
77
+ return result;
78
+ }
79
+ class Crowi {
80
+ version;
81
+ rootDir;
82
+ pluginDir;
83
+ publicDir;
84
+ resourceDir;
85
+ tmpDir;
86
+ cacheDir;
87
+ mongoose = null;
88
+ // FIXME after service/config typed
89
+ config;
90
+ mailer = null;
91
+ lru = {};
92
+ tokens;
93
+ // FIXME: {} をアサインしないで済む方法を捜す
94
+ models = {};
95
+ events = {};
96
+ env;
97
+ baseUrl = null;
98
+ node_env;
99
+ port;
100
+ redis = null;
101
+ redisUrl;
102
+ redisOpts;
103
+ /**
104
+ * PluginManager + resolved registries. Available after `setupPlugins`
105
+ * runs in `init()`. `null` until then so a half-booted process is
106
+ * obvious in stack traces.
107
+ */
108
+ pluginManager = null;
109
+ pluginRegistries = null;
110
+ /**
111
+ * Markdown renderer pipeline + registry. Available after
112
+ * `setupRenderer` runs in `init()` (between `setupModels` and
113
+ * `setupPlugins` — so PluginManager can layer external plugins on
114
+ * top of the core registrations).
115
+ */
116
+ renderer = null;
117
+ /**
118
+ * Hocuspocus engine attach handle (RFC-0003 Phase 9 same-process).
119
+ * Built lazily in `start()` after the http.Server is listening so
120
+ * the `'upgrade'` event can be wired before any client connects.
121
+ * `null` outside of the running server (= `init()` finished but
122
+ * `start()` hasn't run yet, or after `shutdown()`).
123
+ */
124
+ collabAttachment = null;
125
+ /**
126
+ * Presence WebSocket attach handle (RFC-0005). Built in `start()`
127
+ * alongside `collabAttachment`; wires the `/presence` ws noServer
128
+ * handler so page viewers get the live-presence row. `null` outside
129
+ * of the running server.
130
+ */
131
+ presenceAttachment = null;
132
+ /**
133
+ * Notifications realtime invalidation WebSocket attach handle. Built
134
+ * in `start()` next to `collabAttachment` / `presenceAttachment`;
135
+ * wires the `/notifications/<userId>` ws noServer handler so the
136
+ * NotificationBell can drop its 30-second polling loop in favour of
137
+ * Redis-pub/sub-driven invalidation. `null` outside of the running
138
+ * server.
139
+ */
140
+ notificationsAttachment = null;
141
+ /**
142
+ * Docker-style boot progress reporter (feature-boot-progress-ui). Spans
143
+ * `init()` (core/config/services layers) and `start()` (server layer), so it
144
+ * lives on the instance rather than a local. `null` for the CLI lightweight
145
+ * init (`initForCli`) which keeps the legacy quiet UX.
146
+ */
147
+ bootReporter = null;
148
+ initialized = false;
149
+ /**
150
+ * In-flight fire-and-forget side effects (EventEmitter listeners +
151
+ * Mongoose `post('save')` hooks that start an un-awaited DB/redis write).
152
+ * `trackSideEffect` adds the promise here and removes it on settle;
153
+ * `drainSideEffects` awaits the set until it is empty.
154
+ *
155
+ * Production never calls `drainSideEffects`, so tracking is the only
156
+ * runtime cost on the request path (a Set add/delete per side effect) and
157
+ * the drain primitive is a no-op there. The test harness drains before
158
+ * disconnecting Mongo so settling writes do not race the close.
159
+ */
160
+ inFlightSideEffects = new Set();
161
+ constructor(rootdir, env) {
162
+ this.version = pkg.version;
163
+ this.env = env;
164
+ this.baseUrl = this.env.BASE_URL || null;
165
+ this.node_env = this.env.NODE_ENV || 'production';
166
+ this.port = this.env.PORT ? Number.parseInt(this.env.PORT) : 4301;
167
+ // Remove REDISTOGO_URL in the near future.
168
+ this.redisUrl = this.env.REDISTOGO_URL || this.env.REDIS_TLS_URL || this.env.REDIS_URL || null;
169
+ const redisRejectUnauthorized = this.env.REDIS_REJECT_UNAUTHORIZED !== '0';
170
+ this.redisOpts = this.buildRedisOpts(this.redisUrl, redisRejectUnauthorized);
171
+ this.rootDir = rootdir;
172
+ this.pluginDir = path_1.default.join(this.rootDir, 'node_modules') + path_1.sep;
173
+ this.publicDir = path_1.default.join(this.rootDir, 'public') + path_1.sep;
174
+ this.resourceDir = path_1.default.join(this.rootDir, 'resource') + path_1.sep;
175
+ this.tmpDir = path_1.default.join(this.rootDir, 'tmp') + path_1.sep;
176
+ this.cacheDir = path_1.default.join(this.tmpDir, 'cache');
177
+ this.setupEvents();
178
+ this.tokens = new csrf_1.default();
179
+ }
180
+ async init() {
181
+ const initStart = Date.now();
182
+ // Baseline log so the first phase's `+Xms` measures its own duration
183
+ // rather than reading +0ms (debug's default when there's no prior log
184
+ // on the namespace).
185
+ bootDebug('init start');
186
+ // Boot progress reporter — owns stdout (debug-independent) so operators
187
+ // see layered spinner/✓ progress without `DEBUG=crowi:*`. Degrades to
188
+ // structured plain lines on non-TTY (prod / `| cat`) or when DEBUG is set.
189
+ // Silenced under jest: each of the 100+ test files boots Crowi, so the
190
+ // per-layer `[boot] … ok` lines would otherwise flood the test output.
191
+ const reporter = (0, boot_reporter_1.createBootReporter)({ quiet: Boolean(process.env.JEST_WORKER_ID) });
192
+ this.bootReporter = reporter;
193
+ // A step throwing (DB/Redis down is the common dev case) rejects out of
194
+ // init(); without this guard the spinner interval keeps redrawing the same
195
+ // line — overwriting the fatal stack `exitOnError` prints — and the hidden
196
+ // cursor never comes back. Stop the spinner before the rejection
197
+ // propagates. `dispose()` is idempotent, so `exitOnError` calling it again
198
+ // is harmless.
199
+ try {
200
+ await this.runInitLayers(reporter);
201
+ }
202
+ catch (err) {
203
+ reporter.dispose();
204
+ throw err;
205
+ }
206
+ bootDebug(`init complete in ${Date.now() - initStart}ms`);
207
+ this.initialized = true;
208
+ }
209
+ async runInitLayers(reporter) {
210
+ // ── core: encryption / database / models / redis ──
211
+ reporter.beginLayer('core');
212
+ await step('setupEncryption', () => this.setupEncryption());
213
+ await step('setupDatabase', () => this.setupDatabase());
214
+ await step('setupModels', () => this.setupModels());
215
+ await step('setupRedisClient', () => this.setupRedisClient());
216
+ reporter.endLayer();
217
+ // ── config: load / migrations / oauth seed ──
218
+ reporter.beginLayer('config');
219
+ await step('setupConfig', () => this.setupConfig());
220
+ // RFC-0008: the migration framework's boot step. Applies any pending
221
+ // `layer:'boot'` migrations (currently `page-status-default`, the
222
+ // RFC-0004 backfill that stamps `status='published'` onto legacy pages
223
+ // predating the `Page.status` field — see
224
+ // `migration/migrations/page-status-default.ts`) and probes
225
+ // `layer:'preflight'` migrations, refusing boot when any is unapplied
226
+ // under the default `block` policy (§4.2.1/§4.2.7). `broadcastForceReload`
227
+ // is intentionally omitted here: the live Hocuspocus handle is attached
228
+ // later in `start()`, after init, so boot migrations rely on
229
+ // persistence-layer Yjs invalidation only.
230
+ await step('runBootMigrations', () => (0, run_boot_migrations_1.runBootMigrations)(this));
231
+ // RFC-0010 Phase 3: seed the first-party `crowi-cli` OAuth client.
232
+ // Idempotent upsert (`$setOnInsert`) — runs after setupModels so the
233
+ // OAuthClient model is registered; disjoint from the migrations above.
234
+ await step('seedOAuthClients', () => (0, oauth_client_seed_1.runOAuthClientSeed)(this));
235
+ reporter.endLayer();
236
+ // ── services: renderer / plugins / mailer / lru ──
237
+ reporter.beginLayer('services');
238
+ // Renderer must boot BEFORE plugins so PluginManager.activate()
239
+ // can hand plugins a registry that already has the core 4
240
+ // transforms (TOC / wikilinks / mentions / codeBlockLanguages)
241
+ // registered. External plugins append; they cannot insert before
242
+ // core in v2.1 phase 2.
243
+ await step('setupRenderer', () => this.setupRenderer());
244
+ // RFC-0003 Phase 9 (same-process attach): the cross-process
245
+ // pageEvent subscriber that used to fan collab saves into the
246
+ // api event loop is gone — the embedded Hocuspocus engine (see
247
+ // `src/collab/attach.ts`) calls `crowi.event('Page').emit(...)`
248
+ // directly after a save flow completes.
249
+ // Plugins must boot AFTER config/models are ready (so PluginContext
250
+ // can read config and access models) but BEFORE the legacy
251
+ // mailer initialiser — that is migrating to plugin-provided drivers
252
+ // and any conflict should fail noisily here.
253
+ await step('setupPlugins', () => this.setupPlugins());
254
+ await step('setupMailer', () => this.setupMailer());
255
+ await step('setupLRU', () => this.setupLRU());
256
+ reporter.endLayer();
257
+ }
258
+ /**
259
+ * Lightweight init for the `@crowi/admin-cli` operator CLI. Brings up
260
+ * just what's needed to read Config + reach storage drivers — Redis
261
+ * / mailer / search / LRU / the boot-time AWS migration are
262
+ * all skipped (the migration belongs to `init()` so the long-running
263
+ * server runs it once; the CLI shouldn't mutate Mongo as a side
264
+ * effect of starting up).
265
+ *
266
+ * `setupConfig` works without Redis because `service/config.ts:setupPubSub`
267
+ * short-circuits when `redisOpts === null`.
268
+ *
269
+ * The CLI follows up with `teardownForCli()` to disconnect Mongo so
270
+ * the Node process exits cleanly.
271
+ */
272
+ async initForCli() {
273
+ this.setupEncryption();
274
+ await this.setupDatabase();
275
+ await this.setupModels();
276
+ await this.setupConfig();
277
+ // Skip the page-save side-effect listeners (mention dispatch / render-cache
278
+ // invalidation): a migration's `updatePage` writes must not @-ping users or
279
+ // race the teardown connection close — see `setupRenderer`.
280
+ this.setupRenderer({ registerPageEventListeners: false });
281
+ await this.setupPlugins();
282
+ this.initialized = true;
283
+ }
284
+ /**
285
+ * Reverse of `initForCli`. Closes any connection the CLI helper opened
286
+ * so the Node process exits without dangling handles. Defensive about
287
+ * Redis (we never opened it in CLI mode, but a future helper might).
288
+ */
289
+ async teardownForCli() {
290
+ if (this.redis) {
291
+ try {
292
+ await this.redis.quit();
293
+ }
294
+ catch {
295
+ // best-effort — process is exiting anyway
296
+ }
297
+ this.redis = null;
298
+ }
299
+ if (this.mongoose) {
300
+ await this.mongoose.disconnect();
301
+ this.mongoose = null;
302
+ }
303
+ }
304
+ /**
305
+ * Track a fire-and-forget side effect so the test harness can drain it
306
+ * before tearing the connection down. The promise is removed from the
307
+ * in-flight set once it settles (resolve OR reject); we deliberately do
308
+ * NOT re-throw or alter the rejection — the caller keeps its own
309
+ * `.catch` and error-swallowing posture unchanged. This is purely
310
+ * drain bookkeeping.
311
+ *
312
+ * INVARIANT: a tracked side effect MUST be a finite chain. Never track
313
+ * work that re-schedules itself (recurring / periodic timers, retry
314
+ * loops with no terminal condition) — `drainSideEffects()` loops until
315
+ * the set empties, so a self-rescheduling effect makes the drain
316
+ * (`afterEach` + the test response barrier in `test/setup.ts`) never
317
+ * settle, and every HTTP test then hangs until jest's `testTimeout`.
318
+ * Multi-level fan-out is fine (each level settles); unbounded
319
+ * re-arming is not.
320
+ */
321
+ trackSideEffect(p) {
322
+ this.inFlightSideEffects.add(p);
323
+ p.finally(() => {
324
+ this.inFlightSideEffects.delete(p);
325
+ });
326
+ }
327
+ /**
328
+ * Wait until every tracked side effect has settled. Loops because a
329
+ * side effect can spawn a second-level fire-and-forget while draining
330
+ * (Activity `post('save')` → Notification fan-out; `userEvent`
331
+ * 'activated' → user-page creation → page events → backlink/watch/
332
+ * mention), and those are tracked too. Resolves once the set is empty.
333
+ *
334
+ * Production never calls this — it is the test-teardown drain hook.
335
+ */
336
+ async drainSideEffects() {
337
+ while (this.inFlightSideEffects.size > 0) {
338
+ await Promise.allSettled([...this.inFlightSideEffects]);
339
+ }
340
+ }
341
+ setupRenderer(options = {}) {
342
+ this.renderer = (0, renderer_1.createRenderer)(this);
343
+ // The page-save side-effect listeners below are skipped in CLI mode
344
+ // (`initForCli`): a bulk migration that rewrites page bodies via
345
+ // `updatePage` would otherwise fire mention notifications (wrong — nobody
346
+ // should be @-pinged by a syntax migration) and per-page render-cache
347
+ // invalidation (pointless in a one-shot process — and it races the CLI's
348
+ // `teardownForCli` connection close, logging spurious "client was closed"
349
+ // warnings). Deliberate cache rebuilds use `crowi-admin rebuild renderer`.
350
+ if (options.registerPageEventListeners ?? true) {
351
+ // Register cache invalidation listeners on pageEvent. Needs to
352
+ // happen here (not in setupEvents) because the listener captures
353
+ // the renderer.cache handle constructed one line above.
354
+ (0, render_cache_1.registerRenderCacheInvalidation)(this);
355
+ // RFC-0002 Phase 8: dispatch `@username` mention notifications on
356
+ // page save. Wired here (not in `setupEvents`) because the dispatcher
357
+ // reads `Revision.meta.mentions[]` produced by the renderer pipeline,
358
+ // so it must register after `setupRenderer` has run.
359
+ (0, mention_dispatch_1.registerMentionDispatch)(this);
360
+ }
361
+ // Eagerly initialise heavy ESM-only deps (jiti + shiki +
362
+ // remark-*). The first pipeline run otherwise pays ~200ms cold-
363
+ // load latency; we move that cost to boot time. Fire-and-forget —
364
+ // a warmup failure is logged inside `Renderer.warmup` and does
365
+ // not block boot.
366
+ if (this.renderer) {
367
+ void this.renderer.warmup();
368
+ }
369
+ }
370
+ /**
371
+ * Markdown renderer (parse → transform pipeline + extension registry).
372
+ * Throws if accessed before `setupRenderer` ran.
373
+ */
374
+ getRenderer() {
375
+ if (!this.renderer) {
376
+ throw new Error('Renderer has not been booted yet — call init() first.');
377
+ }
378
+ return this.renderer;
379
+ }
380
+ async setupPlugins() {
381
+ this.pluginManager = new plugin_1.PluginManager(this);
382
+ this.pluginRegistries = await this.pluginManager.bootstrap();
383
+ const loaded = this.pluginManager.getLoadedPlugins();
384
+ const summary = `[crowi] Loaded ${loaded.length} plugin(s): ${loaded.map((p) => `${p.name}@${p.version}`).join(', ')}`;
385
+ // Route through `bootNote` so the summary clears/re-draws the in-progress
386
+ // `services` spinner instead of corrupting it (plain console.log outside
387
+ // boot / in plain mode).
388
+ this.bootNote(() => console.log(summary));
389
+ }
390
+ /**
391
+ * Active storage / search / auth / notifier drivers resolved from
392
+ * `crowi.config.json`. Throws if accessed before `setupPlugins` ran.
393
+ */
394
+ getPlugins() {
395
+ if (!this.pluginRegistries) {
396
+ throw new Error('PluginManager has not been bootstrapped yet — call init() first.');
397
+ }
398
+ return this.pluginRegistries;
399
+ }
400
+ isInitialized() {
401
+ return this.initialized;
402
+ }
403
+ isPageId(pageId) {
404
+ if (!pageId) {
405
+ return false;
406
+ }
407
+ if (typeof pageId === 'string' && pageId.match(/^[\da-f]{24}$/)) {
408
+ return true;
409
+ }
410
+ }
411
+ setConfig(config) {
412
+ this.config.update(config);
413
+ }
414
+ getConfig() {
415
+ return this.config.get();
416
+ }
417
+ getConfigService() {
418
+ return this.config;
419
+ }
420
+ /**
421
+ * The site's public origin (the web app), used to build absolute URLs
422
+ * in emails (invite / activation / reset / email-change links) and for
423
+ * CORS. Sourced solely from the `CLIENT_URL` env — no fallback.
424
+ *
425
+ * Deliberately NOT derived from the incoming request: trusting the
426
+ * Host / Origin header here would let an attacker poison reset /
427
+ * activation links in a victim's inbox (host-header injection). When
428
+ * `CLIENT_URL` is unset this returns `null` and mail links fall back to
429
+ * relative paths — `setupMailer` warns about that at boot.
430
+ */
431
+ getBaseUrl() {
432
+ return this.env.CLIENT_URL || null;
433
+ }
434
+ /**
435
+ * The address the api server itself is listening on (`this.port`, default
436
+ * 4301). Used for the boot reporter's `🚀 API ready` banner and the
437
+ * `@@crowi:ready api <url>` marker that `scripts/dev.mjs` keys on.
438
+ *
439
+ * Deliberately NOT `getBaseUrl()`: that is `CLIENT_URL` / `app:url`, the
440
+ * public site origin, which in dev is the web app on :4302 — using it here
441
+ * would mislabel the api as the web port.
442
+ */
443
+ getApiReadyUrl() {
444
+ return `http://localhost:${this.port}`;
445
+ }
446
+ /**
447
+ * Emit a boot-time line (warning / error / info such as the plugin summary)
448
+ * without corrupting the live progress spinner. When the reporter is active
449
+ * it clears the current spinner line, runs `write`, then re-draws; otherwise
450
+ * (no reporter / plain mode) it just runs `write`. Keeps the existing
451
+ * console.warn/error/log visibility intact (these are not gated on DEBUG).
452
+ */
453
+ bootNote(write) {
454
+ if (this.bootReporter) {
455
+ this.bootReporter.note(write);
456
+ }
457
+ else {
458
+ write();
459
+ }
460
+ }
461
+ getEnv() {
462
+ return this.env;
463
+ }
464
+ buildRedisOpts(redisUrl, redisRejectUnauthorized) {
465
+ // Thin wrapper kept for back-compat with existing `crowi.buildRedisOpts`
466
+ // callers; the actual translation lives in `util/redis-opts.ts` so
467
+ // the collab process can pull the same helper through `api-dist.ts`.
468
+ return (0, redis_opts_1.buildRedisOpts)(redisUrl, redisRejectUnauthorized);
469
+ }
470
+ // getter/setter of model instance
471
+ //
472
+ model(name, model) {
473
+ if (model) {
474
+ return (this.models[name] = model);
475
+ }
476
+ return this.models[name];
477
+ }
478
+ // getter/setter of event instance
479
+ event(name, event) {
480
+ if (event) {
481
+ return (this.events[name] = event);
482
+ }
483
+ return this.events[name];
484
+ }
485
+ /**
486
+ * Validate CROWI_ENCRYPTION_KEY at boot. When set, it must base64-decode to
487
+ * exactly 32 bytes (AES-256). When unset we log a warning and let Config
488
+ * fall back to plaintext at-rest storage — same behaviour as pre-encryption
489
+ * deployments — so a missing key never blocks boot.
490
+ */
491
+ setupEncryption() {
492
+ const raw = process.env.CROWI_ENCRYPTION_KEY;
493
+ if (!raw) {
494
+ // `note()` clears the live boot spinner before warning so the line
495
+ // isn't corrupted (no-op passthrough outside boot / in plain mode).
496
+ this.bootNote(() => {
497
+ console.warn('[crowi] CROWI_ENCRYPTION_KEY is not set — sensitive Config values will be stored as plaintext (legacy mode).');
498
+ console.warn('[crowi] Generate a 32-byte key with: openssl rand -base64 32');
499
+ });
500
+ return;
501
+ }
502
+ const buf = Buffer.from(raw, 'base64');
503
+ if (buf.length !== 32) {
504
+ throw new Error(`Invalid CROWI_ENCRYPTION_KEY: expected 32 bytes after base64 decode, got ${buf.length}. Generate one with \`openssl rand -base64 32\`.`);
505
+ }
506
+ // Drop any cached key from a previous init in long-lived test processes.
507
+ (0, crypto_1.resetKeyProvider)();
508
+ debug('CROWI_ENCRYPTION_KEY is configured (sensitive Config values will be encrypted at rest)');
509
+ }
510
+ async setupDatabase() {
511
+ // mongoUri = mongodb://user:password@host/dbname
512
+ mongoose_1.default.Promise = global.Promise;
513
+ // Set strictQuery to true for schema consistency and query safety
514
+ mongoose_1.default.set('strictQuery', true);
515
+ const mongoUri = this.env.MONGOLAB_URI || // for B.C.
516
+ this.env.MONGODB_URI || // MONGOLAB changes their env name
517
+ this.env.MONGOHQ_URL ||
518
+ this.env.MONGO_URI ||
519
+ 'mongodb://localhost/crowi';
520
+ try {
521
+ // mongoose 7 removed the callback form of connect(); it is promise-only.
522
+ await mongoose_1.default.connect(mongoUri);
523
+ this.mongoose = mongoose_1.default;
524
+ return mongoose_1.default;
525
+ }
526
+ catch (e) {
527
+ debug('DB Connect Error: ', e);
528
+ debug('DB Connect Error: ', mongoUri);
529
+ // Fold the underlying driver message (ECONNREFUSED / auth / DNS) into
530
+ // the thrown error so the root cause is visible with DEBUG off — the
531
+ // raw `e` only ever reached the silenced debug line above. `cause`
532
+ // keeps the original error for anything that inspects it.
533
+ const err = e;
534
+ throw new Error(`Cannot connect to Database Server: ${err.message}`, { cause: e });
535
+ }
536
+ }
537
+ async setupRedisClient() {
538
+ if (this.redisOpts) {
539
+ try {
540
+ const redisClient = (0, redis_1.createClient)(this.redisOpts);
541
+ await redisClient.connect();
542
+ this.redis = redisClient;
543
+ debug('Redis client connected successfully');
544
+ }
545
+ catch (error) {
546
+ debug('Failed to connect to Redis:', error.message);
547
+ this.bootNote(() => console.warn('Redis connection failed. Continuing without Redis...'));
548
+ this.redis = null;
549
+ }
550
+ }
551
+ }
552
+ async setupModels() {
553
+ const keys = Object.keys(models_1.default);
554
+ keys.forEach((key) => {
555
+ this.model(key, models_1.default[key](this));
556
+ });
557
+ }
558
+ setupEvents() {
559
+ return Object.entries(events_1.default).forEach(([key, Event]) => {
560
+ this.event(key, new Event(this));
561
+ });
562
+ }
563
+ getMongo() {
564
+ return this.mongoose;
565
+ }
566
+ /**
567
+ * True when the Mongoose connection is in the `connected` state
568
+ * (`readyState === 1`). Used to guard fire-and-forget deferred writes:
569
+ * a side effect scheduled by a synchronous `emit()` / `post('save')`
570
+ * can fire after the harness has begun tearing the connection down
571
+ * (`connecting=2` / `disconnecting=3` / `disconnected=0`), at which
572
+ * point the write would throw a teardown-noise `MongoNotConnectedError`
573
+ * / `MongoPoolClosedError`. We skip the write instead. In normal
574
+ * operation `readyState === 1` always holds, so production behaviour is
575
+ * unchanged.
576
+ */
577
+ isMongoConnected() {
578
+ return this.mongoose?.connection?.readyState === 1;
579
+ }
580
+ getIo() {
581
+ // return this.io
582
+ return null;
583
+ }
584
+ /**
585
+ * Backwards-compat shim for legacy controllers that still reference
586
+ * `crowi.getSearcher()`. Returns the active search driver from the
587
+ * plugin registry, or `null` if none is configured / registered.
588
+ * New code should read `crowi.getPlugins().active.search` directly.
589
+ */
590
+ getSearcher() {
591
+ if (!this.pluginRegistries)
592
+ return null;
593
+ return this.pluginRegistries.active.search;
594
+ }
595
+ getMailer() {
596
+ if (!this.mailer) {
597
+ this.mailer = new mail_1.MailService(this);
598
+ }
599
+ return this.mailer;
600
+ }
601
+ async setupConfig() {
602
+ this.config = new config_1.default(this);
603
+ await this.config.setupPubSub();
604
+ return this.config.load();
605
+ }
606
+ setupMailer() {
607
+ // The MailService resolves the active sender lazily from the plugin
608
+ // registry on each send, so there is no transport state to build
609
+ // here — just construct the service. Kept as a boot step so the
610
+ // boot sequence reads uniformly and future eager checks have a home.
611
+ this.mailer = new mail_1.MailService(this);
612
+ // Absolute links in emails (invite / activation / reset /
613
+ // email-change) require a public origin. It comes solely from
614
+ // CLIENT_URL; without it links would be relative and unusable.
615
+ if (!this.getBaseUrl()) {
616
+ this.bootNote(() => console.warn('[crowi] CLIENT_URL is not set — links in outgoing emails (invite / activation / password reset / ' +
617
+ 'email change) will be relative and will not work. Set CLIENT_URL to the web app origin ' +
618
+ '(e.g. https://wiki.example.com).'));
619
+ }
620
+ }
621
+ setupLRU() {
622
+ this.lru = new lru_1.default(this);
623
+ }
624
+ getTokens() {
625
+ return this.tokens;
626
+ }
627
+ start = async () => {
628
+ if (!this.initialized) {
629
+ throw new Error('Must call init() before start().');
630
+ }
631
+ // RFC-0006 Phase 6 Sub-batch D — Hono is the sole HTTP host.
632
+ //
633
+ // `buildHonoApp(crowi)` returns the `/api/v2/*` route surface.
634
+ // Routes are registered at their un-prefixed paths
635
+ // (`/app/info`, `/pages/:id`, ...) to keep the inferred AppType
636
+ // chain shallow for the `hc<AppType>` client; the `/api/v2`
637
+ // prefix is stripped by `stripApiV2Prefix` on the boundary so
638
+ // production URLs match.
639
+ //
640
+ // We use `createAdaptorServer` instead of `serve` so the
641
+ // WebSocket `'upgrade'` handlers (collab / presence) can be
642
+ // wired **before** `server.listen()` runs — the upstream
643
+ // `serve()` helper listens immediately, which would race the
644
+ // first WS client against the upgrade hook.
645
+ // The server layer spans build → attach (collab/presence/notifications) →
646
+ // listen. The reporter was created in `init()`; if `start()` is somehow
647
+ // called without it (defensive), make a fresh one so the banner/marker
648
+ // still emit.
649
+ const reporter = this.bootReporter ?? (0, boot_reporter_1.createBootReporter)({ quiet: Boolean(process.env.JEST_WORKER_ID) });
650
+ this.bootReporter = reporter;
651
+ reporter.beginLayer('server');
652
+ const honoApp = (0, hono_1.buildHonoApp)(this);
653
+ const fetchFn = (request) => honoApp.fetch((0, path_rewrite_1.stripApiV2Prefix)(request));
654
+ const server = (0, node_server_1.createAdaptorServer)({
655
+ fetch: fetchFn,
656
+ createServer: http_1.default.createServer,
657
+ port: this.port,
658
+ });
659
+ // RFC-0003 Phase 9 — attach Hocuspocus to the http.Server
660
+ // **before** `listen()` so the `'upgrade'` event handler is wired
661
+ // when the first WebSocket client races the listen callback. The
662
+ // attach is async because it builds the editor-cap counter
663
+ // (Redis SCARD round-trip when configured); we await it here so
664
+ // the boot sequence stays serial and `start()` resolves only
665
+ // when the api is fully ready to accept WebSocket upgrades.
666
+ this.collabAttachment = await (0, attach_1.attachCollabServer)(server, this);
667
+ // RFC-0005 — attach the `/presence` WebSocket alongside `/collab`.
668
+ // Same `noServer` pattern; both upgrade handlers path-filter so
669
+ // they coexist on the one http.Server listener.
670
+ this.presenceAttachment = await (0, attach_3.attachPresenceServer)(server, this);
671
+ // Notifications realtime invalidation — third `ws noServer`
672
+ // handler alongside collab + presence. Path-filters on
673
+ // `/notifications/*`, so it coexists with the other two on the
674
+ // same http.Server listener. Redis subscriber is built lazily
675
+ // inside; when `crowi.redis === null` the handler still attaches
676
+ // and accepts connections but no pub/sub fan-out runs.
677
+ this.notificationsAttachment = await (0, attach_2.attachNotificationsServer)(server, this);
678
+ // Promisify `server.listen` so `start()` resolves only after the
679
+ // socket is actually bound. Callers (the bin entry, smoke tests)
680
+ // can then `await crowi.start()` and assume the api accepts
681
+ // connections — without this the previous async chain returned
682
+ // before listen() finished its background bind.
683
+ await new Promise((resolveListen, rejectListen) => {
684
+ const onError = (err) => {
685
+ server.off('listening', onListening);
686
+ rejectListen(err);
687
+ };
688
+ const onListening = () => {
689
+ server.off('error', onError);
690
+ // Close the server layer (✓ + duration), then emit the human banner
691
+ // and the machine-readable readiness marker. The marker is the only
692
+ // contract `scripts/dev.mjs` depends on; it is emitted TTY or not.
693
+ reporter.endLayer();
694
+ reporter.finish('api', this.getApiReadyUrl());
695
+ resolveListen();
696
+ };
697
+ server.once('error', onError);
698
+ server.once('listening', onListening);
699
+ server.listen(this.port);
700
+ });
701
+ return server;
702
+ };
703
+ // Arrow property so `this` stays bound when passed as
704
+ // `.catch(crowi.exitOnError)` from `app.ts` (the bare method would lose
705
+ // `this` and the dispose() below would throw).
706
+ exitOnError = (err) => {
707
+ debug('Critical error occured.');
708
+ // Tear the boot reporter down *first*: stop the spinner interval and
709
+ // restore the cursor so the fatal stack trace below isn't overwritten /
710
+ // the terminal isn't left cursorless. Idempotent — the init()/start()
711
+ // try-path may already have disposed.
712
+ this.bootReporter?.dispose();
713
+ // Machine-readable failure marker (own stdout line, mirrors the readiness
714
+ // marker). `scripts/dev.mjs` watches for this to tear the whole dev tree
715
+ // (api · web · deps) down — otherwise `tsx watch` survives the crash and
716
+ // web keeps serving against a dead api. Harmless in prod (a grep-able line
717
+ // before exit). Reason is the first line of the error, length-capped.
718
+ const reason = (err instanceof Error ? err.message : String(err)).split('\n')[0].slice(0, 200);
719
+ process.stdout.write(`${(0, boot_reporter_1.formatFailMarker)('api', reason)}\n`);
720
+ console.error(err);
721
+ console.error(err.stack);
722
+ process.exit(1);
723
+ };
724
+ }
725
+ exports.default = Crowi;
726
+ //# sourceMappingURL=index.js.map