alinea 2.0.0-preview.9 → 2.0.0-rc2

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/dist/.init/.mcp.json +11 -0
  2. package/dist/.init/AGENTS.md +17 -0
  3. package/dist/.init/CLAUDE.md +1 -0
  4. package/dist/.init/content/pages/welcome.json +1 -1
  5. package/dist/.init/package.json +1 -1
  6. package/dist/.init/src/cms.ts +4 -2
  7. package/dist/.init-pm/bun.lock +0 -0
  8. package/dist/.mcp/later/dev.json +1 -0
  9. package/dist/.mcp/lock/dev.json +1 -0
  10. package/dist/.mcp/online/dev.json +1 -0
  11. package/dist/LICENSES.md +2239 -294
  12. package/dist/adapter/next/cms.d.ts +2 -2
  13. package/dist/adapter/next/cms.js +66 -32
  14. package/dist/adapter/next/context.js +5 -6
  15. package/dist/adapter/next/dashboardUrl.d.ts +6 -0
  16. package/dist/adapter/next/dashboardUrl.js +13 -0
  17. package/dist/adapter/next/devCache.d.ts +16 -0
  18. package/dist/adapter/next/devCache.js +32 -0
  19. package/dist/adapter/next/handler.js +18 -4
  20. package/dist/adapter/next/syncCheck.d.ts +15 -2
  21. package/dist/adapter/next/syncCheck.js +26 -9
  22. package/dist/adapter/next/with-alinea.js +27 -20
  23. package/dist/backend/CommitEntries.d.ts +17 -0
  24. package/dist/backend/CommitEntries.js +39 -0
  25. package/dist/backend/Handler.d.ts +15 -1
  26. package/dist/backend/Handler.js +106 -32
  27. package/dist/backend/api/BasicAuth.js +5 -1
  28. package/dist/backend/api/BlobStore.d.ts +21 -0
  29. package/dist/backend/api/BlobStore.js +63 -0
  30. package/dist/backend/api/CreateBackend.js +10 -8
  31. package/dist/backend/api/DatabaseApi.d.ts +4 -1
  32. package/dist/backend/api/DatabaseApi.js +104 -7
  33. package/dist/backend/api/GithubApi.d.ts +13 -0
  34. package/dist/backend/api/GithubApi.js +217 -54
  35. package/dist/backend/api/OAuth2.js +21 -26
  36. package/dist/backend/api/ProxyMedia.js +3 -0
  37. package/dist/backend/api/database.js +6 -6
  38. package/dist/backend/store/GeneratedDatabase.js +4 -2
  39. package/dist/backend/store/GeneratedDatabaseNode.d.ts +5 -1
  40. package/dist/backend/store/GeneratedDatabaseNode.js +9 -19
  41. package/dist/backend/store/GeneratedRelease.d.ts +1 -1
  42. package/dist/backend/store/GeneratedRelease.js +3 -4
  43. package/dist/backend/util/JWKS.d.ts +4 -0
  44. package/dist/backend/util/JWKS.js +40 -0
  45. package/dist/backend/util/Syncable.d.ts +6 -0
  46. package/dist/backend/util/Syncable.js +3 -1
  47. package/dist/bundled.d.ts +7124 -1459
  48. package/dist/chunks/{node-sqlite-XVNTNMCY.js → bun-sqlite-RI6BYU5S.js} +3 -3
  49. package/dist/chunks/ccitt-Y7TDCCPM.js +90 -0
  50. package/dist/chunks/{chunk-ASYKC6IE.js → chunk-2PP7WJUJ.js} +2 -12
  51. package/dist/chunks/{chunk-DWR5A5KL.js → chunk-4VKHBA57.js} +25 -6
  52. package/dist/chunks/{chunk-QJGGYF6E.js → chunk-4ZA6KZHS.js} +5 -5
  53. package/dist/chunks/{chunk-OFEKTDRF.js → chunk-7DDPSWRY.js} +8383 -5156
  54. package/dist/chunks/{chunk-ETWOY4AL.js → chunk-A2I6MCCS.js} +1 -1
  55. package/dist/chunks/chunk-CYVOGRSD.js +218 -0
  56. package/dist/chunks/{chunk-TIJTT5ZI.js → chunk-G43W7AME.js} +1 -0
  57. package/dist/chunks/{chunk-KMLLLZ6X.js → chunk-NP4M2257.js} +1 -0
  58. package/dist/chunks/{chunk-D6RGFNUW.js → chunk-PMGIIYDD.js} +14215 -8950
  59. package/dist/chunks/{chunk-IYAQC63Y.js → chunk-PSSMQKAH.js} +1607 -744
  60. package/dist/chunks/{chunk-AIU6CMVT.js → chunk-PTYZMV5G.js} +1 -1
  61. package/dist/chunks/{chunk-66YZ47TY.js → chunk-RAR44T5O.js} +1 -1
  62. package/dist/chunks/chunk-RE6CDK2M.js +254 -0
  63. package/dist/chunks/{chunk-UPY2RUZF.js → chunk-TWBREZWC.js} +30 -0
  64. package/dist/chunks/{chunk-QSN6RH6X.js → chunk-VA6NC3MI.js} +1 -1
  65. package/dist/chunks/dist-IDG44KDI.js +7499 -0
  66. package/dist/chunks/jpeg-OJTBZV3C.js +292 -0
  67. package/dist/chunks/jpx-4VRYG2JB.js +667 -0
  68. package/dist/chunks/{bun-sqlite-5SHXN3AT.js → node-sqlite-C7VJ2NSN.js} +3 -3
  69. package/dist/cli/Generate.d.ts +2 -1
  70. package/dist/cli/Generate.js +55 -24
  71. package/dist/cli/Init.d.ts +43 -2
  72. package/dist/cli/Init.js +144 -28
  73. package/dist/cli/Mcp.d.ts +25 -0
  74. package/dist/cli/Mcp.js +106 -0
  75. package/dist/cli/Serve.d.ts +1 -1
  76. package/dist/cli/Serve.js +14 -6
  77. package/dist/cli/bin.js +33 -11
  78. package/dist/cli/build/BuildEmitter.d.ts +5 -1
  79. package/dist/cli/build/BuildEmitter.js +8 -3
  80. package/dist/cli/generate/CompileConfig.js +10 -6
  81. package/dist/cli/generate/CopyStaticFiles.d.ts +1 -1
  82. package/dist/cli/generate/CopyStaticFiles.js +27 -14
  83. package/dist/cli/generate/DevDB.d.ts +4 -1
  84. package/dist/cli/generate/DevDB.js +15 -7
  85. package/dist/cli/generate/GenerateContext.d.ts +3 -0
  86. package/dist/cli/generate/GenerateDashboard.d.ts +1 -1
  87. package/dist/cli/generate/GenerateDashboard.js +20 -6
  88. package/dist/cli/generate/GeneratedPaths.d.ts +21 -0
  89. package/dist/cli/generate/GeneratedPaths.js +33 -0
  90. package/dist/cli/generate/LinkMediaFiles.d.ts +7 -0
  91. package/dist/cli/generate/LinkMediaFiles.js +52 -0
  92. package/dist/cli/generate/MediaLocations.d.ts +18 -0
  93. package/dist/cli/generate/MediaLocations.js +69 -0
  94. package/dist/cli/serve/CreateLocalServer.d.ts +2 -1
  95. package/dist/cli/serve/CreateLocalServer.js +41 -11
  96. package/dist/cli/serve/DevLock.d.ts +11 -0
  97. package/dist/cli/serve/DevLock.js +42 -0
  98. package/dist/cli/serve/DevServer.d.ts +3 -2
  99. package/dist/cli/serve/DevServer.js +18 -6
  100. package/dist/cli/serve/LiveReload.d.ts +1 -1
  101. package/dist/cli/serve/LiveReload.js +3 -2
  102. package/dist/cli/serve/ServeContext.d.ts +0 -1
  103. package/dist/cli/serve/StartServer.d.ts +2 -1
  104. package/dist/cli/serve/StartServer.js +4 -2
  105. package/dist/cli/serve/mcp/DevMcp.d.ts +16 -0
  106. package/dist/cli/serve/mcp/DevMcp.js +50 -0
  107. package/dist/cli/serve/mcp/McpGraph.d.ts +35 -0
  108. package/dist/cli/serve/mcp/McpGraph.js +64 -0
  109. package/dist/cli/serve/mcp/McpInput.d.ts +11 -0
  110. package/dist/cli/serve/mcp/McpInput.js +254 -0
  111. package/dist/cli/serve/mcp/McpInstructions.d.ts +1 -0
  112. package/dist/cli/serve/mcp/McpInstructions.js +16 -0
  113. package/dist/cli/serve/mcp/McpSchema.d.ts +31 -0
  114. package/dist/cli/serve/mcp/McpSchema.js +184 -0
  115. package/dist/cli/serve/mcp/McpServer.d.ts +47 -0
  116. package/dist/cli/serve/mcp/McpServer.js +112 -0
  117. package/dist/cli/serve/mcp/McpTools.d.ts +25 -0
  118. package/dist/cli/serve/mcp/McpTools.js +618 -0
  119. package/dist/cli/static/dashboard/entry.js +2 -1
  120. package/dist/cli/static/init/agents.md +13 -0
  121. package/dist/cli/static/init/cms.js +4 -2
  122. package/dist/cli/util/ForwardCommand.js +4 -12
  123. package/dist/cli/util/PublicDefines.d.ts +1 -0
  124. package/dist/cli/util/PublicDefines.js +2 -1
  125. package/dist/cli/util/RunForwarded.d.ts +13 -0
  126. package/dist/cli/util/RunForwarded.js +166 -0
  127. package/dist/cli/util/WarnPublicEnv.js +2 -0
  128. package/dist/cloud/CloudHandshake.js +9 -46
  129. package/dist/cloud/CloudRemote.js +21 -7
  130. package/dist/cms.d.ts +21 -0
  131. package/dist/cms.js +49 -0
  132. package/dist/components/Alert.d.ts +29 -0
  133. package/dist/components/Alert.js +86 -0
  134. package/dist/components/AppShell.d.ts +15 -0
  135. package/dist/components/AppShell.js +38 -0
  136. package/dist/components/AsyncList.d.ts +52 -0
  137. package/dist/components/AsyncList.js +69 -0
  138. package/dist/components/Badge.d.ts +13 -0
  139. package/dist/components/Badge.js +53 -0
  140. package/dist/components/Blockquote.d.ts +7 -0
  141. package/dist/components/Blockquote.js +26 -0
  142. package/dist/components/Breadcrumbs.d.ts +39 -3
  143. package/dist/components/Breadcrumbs.js +103 -22
  144. package/dist/components/Button.d.ts +33 -8
  145. package/dist/components/Button.js +73 -23
  146. package/dist/components/Calendar.d.ts +28 -3
  147. package/dist/components/Calendar.js +163 -54
  148. package/dist/components/Checkbox.d.ts +18 -7
  149. package/dist/components/Checkbox.js +84 -38
  150. package/dist/components/CheckboxGroup.d.ts +11 -5
  151. package/dist/components/CheckboxGroup.js +55 -19
  152. package/dist/components/Code.d.ts +10 -0
  153. package/dist/components/Code.js +49 -0
  154. package/dist/components/Collapsible.d.ts +25 -0
  155. package/dist/components/Collapsible.js +146 -0
  156. package/dist/components/ColorSwatch.d.ts +9 -2
  157. package/dist/components/ColorSwatch.js +20 -20
  158. package/dist/components/ColorSwatchPicker.d.ts +18 -3
  159. package/dist/components/ColorSwatchPicker.js +31 -27
  160. package/dist/components/ComboBox.d.ts +46 -10
  161. package/dist/components/ComboBox.js +223 -94
  162. package/dist/components/Command.d.ts +66 -0
  163. package/dist/components/Command.js +237 -0
  164. package/dist/components/ContentCard.d.ts +32 -0
  165. package/dist/components/ContentCard.js +221 -0
  166. package/dist/components/ContentGrid.d.ts +58 -0
  167. package/dist/components/ContentGrid.js +220 -0
  168. package/dist/components/DataList.d.ts +27 -0
  169. package/dist/components/DataList.js +68 -0
  170. package/dist/components/DateField.d.ts +19 -4
  171. package/dist/components/DateField.js +51 -44
  172. package/dist/components/DatePicker.d.ts +17 -4
  173. package/dist/components/DatePicker.js +61 -68
  174. package/dist/components/DateRangePicker.d.ts +19 -4
  175. package/dist/components/DateRangePicker.js +69 -80
  176. package/dist/components/Dialog.d.ts +64 -3
  177. package/dist/components/Dialog.js +215 -20
  178. package/dist/components/DropZone.d.ts +25 -3
  179. package/dist/components/DropZone.js +99 -18
  180. package/dist/components/DropdownMenu.d.ts +78 -0
  181. package/dist/components/DropdownMenu.js +318 -0
  182. package/dist/components/Empty.d.ts +46 -0
  183. package/dist/components/Empty.js +93 -0
  184. package/dist/components/Field.d.ts +34 -0
  185. package/dist/components/Field.js +166 -0
  186. package/dist/components/FileTrigger.d.ts +21 -0
  187. package/dist/components/FileTrigger.js +53 -0
  188. package/dist/components/FoldIcon.js +2 -1
  189. package/dist/components/Form.d.ts +23 -0
  190. package/dist/components/Form.js +64 -0
  191. package/dist/components/Heading.d.ts +13 -0
  192. package/dist/components/Heading.js +48 -0
  193. package/dist/components/Icon.d.ts +1 -1
  194. package/dist/components/Icon.js +3 -3
  195. package/dist/components/Kbd.d.ts +8 -0
  196. package/dist/components/Kbd.js +27 -0
  197. package/dist/components/Link.d.ts +21 -4
  198. package/dist/components/Link.js +22 -20
  199. package/dist/components/List.d.ts +23 -63
  200. package/dist/components/List.js +131 -251
  201. package/dist/components/MediaPreview.d.ts +35 -0
  202. package/dist/components/MediaPreview.js +227 -0
  203. package/dist/components/MultipleSelect.d.ts +27 -20
  204. package/dist/components/MultipleSelect.js +234 -216
  205. package/dist/components/NavRail.d.ts +41 -0
  206. package/dist/components/NavRail.js +121 -0
  207. package/dist/components/NumberField.d.ts +23 -5
  208. package/dist/components/NumberField.js +103 -60
  209. package/dist/components/Page.d.ts +57 -0
  210. package/dist/components/Page.js +130 -0
  211. package/dist/components/Popover.d.ts +39 -5
  212. package/dist/components/Popover.js +146 -22
  213. package/dist/components/PreviewFrame.d.ts +46 -0
  214. package/dist/components/PreviewFrame.js +182 -0
  215. package/dist/components/RadioGroup.d.ts +20 -7
  216. package/dist/components/RadioGroup.js +121 -31
  217. package/dist/components/Resizable.d.ts +51 -0
  218. package/dist/components/Resizable.js +1349 -0
  219. package/dist/components/SearchField.d.ts +42 -6
  220. package/dist/components/SearchField.js +117 -56
  221. package/dist/components/Select.d.ts +38 -10
  222. package/dist/components/Select.js +179 -101
  223. package/dist/components/Sheet.d.ts +52 -0
  224. package/dist/components/Sheet.js +216 -0
  225. package/dist/components/Sidebar.d.ts +56 -0
  226. package/dist/components/Sidebar.js +136 -0
  227. package/dist/components/SortableList.d.ts +84 -0
  228. package/dist/components/SortableList.js +368 -0
  229. package/dist/components/Spinner.d.ts +8 -0
  230. package/dist/components/Spinner.js +86 -0
  231. package/dist/components/Stack.d.ts +20 -0
  232. package/dist/components/Stack.js +45 -0
  233. package/dist/components/Surface.js +13 -3
  234. package/dist/components/Switch.d.ts +15 -4
  235. package/dist/components/Switch.js +30 -18
  236. package/dist/components/Table.d.ts +121 -14
  237. package/dist/components/Table.js +537 -96
  238. package/dist/components/Tabs.d.ts +33 -12
  239. package/dist/components/Tabs.js +68 -51
  240. package/dist/components/TagGroup.d.ts +26 -9
  241. package/dist/components/TagGroup.js +97 -31
  242. package/dist/components/Text.d.ts +16 -0
  243. package/dist/components/Text.js +44 -0
  244. package/dist/components/TextField.d.ts +33 -9
  245. package/dist/components/TextField.js +152 -47
  246. package/dist/components/TimeField.d.ts +25 -4
  247. package/dist/components/TimeField.js +82 -42
  248. package/dist/components/Timestamp.d.ts +17 -0
  249. package/dist/components/Timestamp.js +131 -0
  250. package/dist/components/Toggle.d.ts +15 -7
  251. package/dist/components/Toggle.js +4 -54
  252. package/dist/components/ToggleGroup.d.ts +33 -0
  253. package/dist/components/ToggleGroup.js +90 -0
  254. package/dist/components/Toolbar.d.ts +27 -8
  255. package/dist/components/Toolbar.js +51 -40
  256. package/dist/components/Tooltip.d.ts +22 -4
  257. package/dist/components/Tooltip.js +78 -34
  258. package/dist/components/Tree.d.ts +47 -20
  259. package/dist/components/Tree.js +230 -98
  260. package/dist/components/internal/Accept.d.ts +5 -0
  261. package/dist/components/internal/Accept.js +17 -0
  262. package/dist/components/internal/DateControl.d.ts +18 -0
  263. package/dist/components/internal/DateControl.js +92 -0
  264. package/dist/components/internal/DateValue.d.ts +16 -0
  265. package/dist/components/internal/DateValue.js +40 -0
  266. package/dist/components/internal/FormScope.d.ts +2 -0
  267. package/dist/components/internal/FormScope.js +8 -0
  268. package/dist/components/internal/ListBoxGroup.d.ts +12 -0
  269. package/dist/components/internal/ListBoxGroup.js +46 -0
  270. package/dist/components/internal/ListBoxOption.d.ts +20 -0
  271. package/dist/components/internal/ListBoxOption.js +111 -0
  272. package/dist/components/internal/Locale.d.ts +7 -0
  273. package/dist/components/internal/Locale.js +18 -0
  274. package/dist/components/internal/Placement.d.ts +3 -0
  275. package/dist/components/internal/Placement.js +13 -0
  276. package/dist/components/internal/PopoverSurface.d.ts +21 -0
  277. package/dist/components/internal/PopoverSurface.js +67 -0
  278. package/dist/components/internal/SelectionCheckbox.d.ts +8 -0
  279. package/dist/components/internal/SelectionCheckbox.js +57 -0
  280. package/dist/components/internal/Slot.d.ts +7 -0
  281. package/dist/components/internal/Slot.js +26 -0
  282. package/dist/components/internal/ToggleButton.d.ts +26 -0
  283. package/dist/components/internal/ToggleButton.js +68 -0
  284. package/dist/components/internal/Trigger.d.ts +16 -0
  285. package/dist/components/internal/Trigger.js +34 -0
  286. package/dist/components/internal/sortableDrag.d.ts +19 -0
  287. package/dist/components/internal/sortableDrag.js +175 -0
  288. package/dist/components/internal/useDragDrop.d.ts +22 -0
  289. package/dist/components/internal/useDragDrop.js +110 -0
  290. package/dist/components/types.d.ts +110 -0
  291. package/dist/components/types.js +0 -0
  292. package/dist/components.d.ts +33 -5
  293. package/dist/components.js +32 -5
  294. package/dist/config.d.ts +2 -0
  295. package/dist/config.js +12 -0
  296. package/dist/core/Client.js +12 -1
  297. package/dist/core/Config.d.ts +60 -2
  298. package/dist/core/Config.js +162 -9
  299. package/dist/core/Connection.d.ts +13 -1
  300. package/dist/core/Connection.js +9 -1
  301. package/dist/core/DashboardEntry.d.ts +19 -0
  302. package/dist/core/DashboardEntry.js +0 -0
  303. package/dist/core/Document.d.ts +12 -2
  304. package/dist/core/Document.js +39 -7
  305. package/dist/core/EntryFields.d.ts +11 -0
  306. package/dist/core/EntrySeed.d.ts +5 -1
  307. package/dist/core/EntrySeed.js +5 -6
  308. package/dist/core/Expr.d.ts +11 -0
  309. package/dist/core/Field.d.ts +39 -3
  310. package/dist/core/Field.js +25 -2
  311. package/dist/core/Filter.d.ts +31 -1
  312. package/dist/core/Filter.js +5 -0
  313. package/dist/core/Graph.d.ts +36 -8
  314. package/dist/core/Infer.d.ts +17 -0
  315. package/dist/core/Internal.d.ts +3 -0
  316. package/dist/core/Internal.js +4 -0
  317. package/dist/core/Overview.d.ts +315 -0
  318. package/dist/core/Overview.js +48 -0
  319. package/dist/core/Role.d.ts +6 -1
  320. package/dist/core/Role.js +55 -53
  321. package/dist/core/Root.d.ts +32 -3
  322. package/dist/core/Root.js +17 -7
  323. package/dist/core/Schema.js +7 -2
  324. package/dist/core/Scope.d.ts +14 -0
  325. package/dist/core/Scope.js +88 -10
  326. package/dist/core/TextDoc.d.ts +14 -1
  327. package/dist/core/Type.d.ts +71 -11
  328. package/dist/core/Type.js +67 -17
  329. package/dist/core/Validation.d.ts +60 -0
  330. package/dist/core/Validation.js +116 -0
  331. package/dist/core/Workspace.d.ts +1 -0
  332. package/dist/core/Workspace.js +5 -1
  333. package/dist/core/db/EntryReference.d.ts +8 -1
  334. package/dist/core/db/LinkResolver.d.ts +3 -0
  335. package/dist/core/db/LocalStore.d.ts +19 -0
  336. package/dist/core/db/Operation.d.ts +28 -1
  337. package/dist/core/db/Operation.js +161 -25
  338. package/dist/core/db/SyncStats.d.ts +16 -0
  339. package/dist/core/db/SyncStats.js +56 -0
  340. package/dist/core/db/WriteableGraph.d.ts +6 -14
  341. package/dist/core/db/WriteableGraph.js +5 -3
  342. package/dist/core/field/CreateField.d.ts +2 -3
  343. package/dist/core/field/ListField.js +29 -10
  344. package/dist/core/field/RecordField.js +12 -4
  345. package/dist/core/field/RichTextField.js +81 -24
  346. package/dist/core/field/ScalarField.d.ts +2 -2
  347. package/dist/core/field/UnionField.js +27 -4
  348. package/dist/core/media/CompressPdf.browser.d.ts +5 -0
  349. package/dist/core/media/CompressPdf.browser.js +13 -0
  350. package/dist/core/media/CompressPdf.d.ts +6 -0
  351. package/dist/core/media/CompressPdf.js +45 -0
  352. package/dist/core/media/CreatePreview.browser.d.ts +5 -1
  353. package/dist/core/media/CreatePreview.browser.js +16 -0
  354. package/dist/core/media/CreatePreview.d.ts +2 -1
  355. package/dist/core/media/CreatePreview.js +2 -0
  356. package/dist/core/media/FileAccept.d.ts +7 -0
  357. package/dist/core/media/FileAccept.js +29 -0
  358. package/dist/core/media/FileKinds.d.ts +10 -0
  359. package/dist/core/media/FileKinds.js +25 -0
  360. package/dist/core/media/ImageTransform.d.ts +78 -0
  361. package/dist/core/media/ImageTransform.js +108 -0
  362. package/dist/core/media/MediaRoot.js +4 -4
  363. package/dist/core/media/MediaTypes.d.ts +137 -9
  364. package/dist/core/media/MediaTypes.js +277 -51
  365. package/dist/core/media/Pdf.d.ts +15 -0
  366. package/dist/core/media/Pdf.js +31 -0
  367. package/dist/core/media/Summary.d.ts +9 -9
  368. package/dist/core/media/Summary.js +10 -10
  369. package/dist/core/media/TransformImage.browser.d.ts +7 -0
  370. package/dist/core/media/TransformImage.browser.js +38 -0
  371. package/dist/core/media/TransformImage.d.ts +7 -0
  372. package/dist/core/media/TransformImage.js +38 -0
  373. package/dist/core/source/GithubSource.d.ts +4 -0
  374. package/dist/core/source/GithubSource.js +127 -25
  375. package/dist/core/source/GithubUsage.d.ts +21 -0
  376. package/dist/core/source/GithubUsage.js +47 -0
  377. package/dist/core/source/Source.d.ts +2 -0
  378. package/dist/core/source/Source.js +11 -0
  379. package/dist/core/text/MarkdownToTextDoc.d.ts +29 -0
  380. package/dist/core/text/MarkdownToTextDoc.js +524 -0
  381. package/dist/core/text/TextDocToMarkdown.d.ts +20 -0
  382. package/dist/core/text/TextDocToMarkdown.js +316 -0
  383. package/dist/core/util/Async.d.ts +2 -0
  384. package/dist/core/util/Async.js +12 -1
  385. package/dist/core/util/Checks.js +1 -1
  386. package/dist/core/util/JWT.d.ts +1 -1
  387. package/dist/core/util/Objects.d.ts +2 -0
  388. package/dist/core/util/Objects.js +7 -0
  389. package/dist/core/util/OrderKeys.d.ts +11 -0
  390. package/dist/core/util/OrderKeys.js +64 -0
  391. package/dist/core/util/Slugs.js +4 -3
  392. package/dist/core.d.ts +3 -0
  393. package/dist/core.js +8 -1
  394. package/dist/dashboard/App.css +56 -86
  395. package/dist/dashboard/App.d.ts +6 -2
  396. package/dist/dashboard/App.js +41 -20
  397. package/dist/dashboard/Href.d.ts +37 -0
  398. package/dist/dashboard/Href.js +46 -0
  399. package/dist/dashboard/ViewKeys.d.ts +2 -0
  400. package/dist/dashboard/ViewKeys.js +2 -0
  401. package/dist/dashboard/app/AccessDenied.js +26 -18
  402. package/dist/dashboard/app/ActivityStatus.d.ts +5 -4
  403. package/dist/dashboard/app/ActivityStatus.js +138 -153
  404. package/dist/dashboard/app/AppearanceToggle.js +31 -12
  405. package/dist/dashboard/app/AuthView.js +75 -63
  406. package/dist/dashboard/app/BlockSheet.d.ts +50 -0
  407. package/dist/dashboard/app/BlockSheet.js +207 -0
  408. package/dist/dashboard/app/BlockSheetStoryFrame.d.ts +6 -0
  409. package/dist/dashboard/app/BlockSheetStoryFrame.js +29 -0
  410. package/dist/dashboard/app/BlockTabs.d.ts +12 -0
  411. package/dist/dashboard/app/BlockTabs.js +26 -0
  412. package/dist/dashboard/app/CompactField.d.ts +19 -6
  413. package/dist/dashboard/app/CompactField.js +177 -50
  414. package/dist/dashboard/app/CroppedImage.d.ts +17 -0
  415. package/dist/dashboard/app/CroppedImage.js +73 -0
  416. package/dist/dashboard/app/DashboardErrorBoundary.js +27 -15
  417. package/dist/dashboard/app/DashboardLayout.d.ts +5 -3
  418. package/dist/dashboard/app/DashboardLayout.js +59 -37
  419. package/dist/dashboard/app/EntryActions.d.ts +11 -0
  420. package/dist/dashboard/app/EntryActions.js +30 -0
  421. package/dist/dashboard/app/EntryFields.d.ts +26 -13
  422. package/dist/dashboard/app/EntryFields.js +19 -9
  423. package/dist/dashboard/app/EntryForm.d.ts +6 -0
  424. package/dist/dashboard/app/EntryForm.js +28 -0
  425. package/dist/dashboard/app/EntryHeader.d.ts +2 -2
  426. package/dist/dashboard/app/EntryHeader.js +226 -144
  427. package/dist/dashboard/app/EntryHeaderActions.d.ts +4 -1
  428. package/dist/dashboard/app/EntryHeaderActions.js +8 -12
  429. package/dist/dashboard/app/EntryReferences.d.ts +13 -1
  430. package/dist/dashboard/app/EntryReferences.js +62 -55
  431. package/dist/dashboard/app/EntrySidebar.d.ts +7 -5
  432. package/dist/dashboard/app/EntrySidebar.js +104 -98
  433. package/dist/dashboard/app/EntrySidebarPreview.d.ts +4 -1
  434. package/dist/dashboard/app/EntrySidebarPreview.js +37 -106
  435. package/dist/dashboard/app/EntrySidebarToggle.js +5 -6
  436. package/dist/dashboard/app/EntryStatusIcon.d.ts +23 -0
  437. package/dist/dashboard/app/EntryStatusIcon.js +58 -0
  438. package/dist/dashboard/app/EntryTranslationBanner.js +37 -45
  439. package/dist/dashboard/app/EntryValidationModal.d.ts +13 -0
  440. package/dist/dashboard/app/EntryValidationModal.js +77 -0
  441. package/dist/dashboard/app/Explorer.d.ts +15 -6
  442. package/dist/dashboard/app/Explorer.js +276 -520
  443. package/dist/dashboard/app/ExplorerBatchActions.d.ts +19 -0
  444. package/dist/dashboard/app/ExplorerBatchActions.js +183 -0
  445. package/dist/dashboard/app/ExplorerBreadcrumbs.d.ts +13 -0
  446. package/dist/dashboard/app/ExplorerBreadcrumbs.js +119 -0
  447. package/dist/dashboard/app/ExplorerCards.d.ts +8 -3
  448. package/dist/dashboard/app/ExplorerCards.js +91 -289
  449. package/dist/dashboard/app/ExplorerControls.d.ts +20 -0
  450. package/dist/dashboard/app/ExplorerControls.js +170 -0
  451. package/dist/dashboard/app/ExplorerList.d.ts +7 -4
  452. package/dist/dashboard/app/ExplorerList.js +160 -95
  453. package/dist/dashboard/app/ExplorerModal.d.ts +2 -5
  454. package/dist/dashboard/app/ExplorerModal.js +7 -19
  455. package/dist/dashboard/app/ExplorerOverviewHeader.d.ts +6 -0
  456. package/dist/dashboard/app/ExplorerOverviewHeader.js +28 -0
  457. package/dist/dashboard/app/ExplorerPickerContent.d.ts +19 -3
  458. package/dist/dashboard/app/ExplorerPickerContent.js +87 -5
  459. package/dist/dashboard/app/ExplorerScope.d.ts +7 -0
  460. package/dist/dashboard/app/ExplorerScope.js +159 -0
  461. package/dist/dashboard/app/ExplorerTable.d.ts +8 -4
  462. package/dist/dashboard/app/ExplorerTable.js +150 -359
  463. package/dist/dashboard/app/ExplorerTabs.d.ts +12 -0
  464. package/dist/dashboard/app/ExplorerTabs.js +42 -0
  465. package/dist/dashboard/app/ExternalLinkPicker.js +45 -55
  466. package/dist/dashboard/app/FileKind.d.ts +8 -0
  467. package/dist/dashboard/app/FileKind.js +40 -0
  468. package/dist/dashboard/app/ImageEditor.d.ts +13 -0
  469. package/dist/dashboard/app/ImageEditor.js +302 -0
  470. package/dist/dashboard/app/ImageEditorCrop.d.ts +19 -0
  471. package/dist/dashboard/app/ImageEditorCrop.js +90 -0
  472. package/dist/dashboard/app/ImagePicker.d.ts +1 -1
  473. package/dist/dashboard/app/ImagePicker.js +30 -89
  474. package/dist/dashboard/app/LinkPicker.d.ts +1 -1
  475. package/dist/dashboard/app/LinkPicker.js +108 -126
  476. package/dist/dashboard/app/LocaleMenu.d.ts +4 -2
  477. package/dist/dashboard/app/LocaleMenu.js +59 -48
  478. package/dist/dashboard/app/MediaPreviewCell.d.ts +8 -0
  479. package/dist/dashboard/app/MediaPreviewCell.js +50 -0
  480. package/dist/dashboard/app/MoveConfirmDialog.d.ts +5 -0
  481. package/dist/dashboard/app/MoveConfirmDialog.js +79 -0
  482. package/dist/dashboard/app/MoveDialog.d.ts +10 -0
  483. package/dist/dashboard/app/MoveDialog.js +161 -0
  484. package/dist/dashboard/app/NodeEditor.d.ts +11 -0
  485. package/dist/dashboard/app/NodeEditor.js +13 -0
  486. package/dist/dashboard/app/OverviewCell.d.ts +15 -0
  487. package/dist/dashboard/app/OverviewCell.js +249 -0
  488. package/dist/dashboard/app/PendingUploadsDialog.d.ts +2 -0
  489. package/dist/dashboard/app/PendingUploadsDialog.js +49 -0
  490. package/dist/dashboard/app/PendingUploadsView.d.ts +20 -0
  491. package/dist/dashboard/app/PendingUploadsView.js +233 -0
  492. package/dist/dashboard/app/ReadOnlyBadge.d.ts +1 -1
  493. package/dist/dashboard/app/ReadOnlyBadge.js +1 -1
  494. package/dist/dashboard/app/RemoveDialog.d.ts +17 -0
  495. package/dist/dashboard/app/RemoveDialog.js +294 -0
  496. package/dist/dashboard/app/RemoveRedirect.d.ts +7 -0
  497. package/dist/dashboard/app/RemoveRedirect.js +123 -0
  498. package/dist/dashboard/app/SearchBar.d.ts +9 -0
  499. package/dist/dashboard/app/SearchBar.js +31 -0
  500. package/dist/dashboard/app/SidebarLayout.d.ts +2 -1
  501. package/dist/dashboard/app/SidebarLayout.js +28 -1133
  502. package/dist/dashboard/app/SidebarTree.d.ts +12 -6
  503. package/dist/dashboard/app/SidebarTree.js +220 -295
  504. package/dist/dashboard/app/ViewToggle.d.ts +1 -1
  505. package/dist/dashboard/app/ViewToggle.js +17 -10
  506. package/dist/dashboard/app/WorkspaceMenu.d.ts +5 -6
  507. package/dist/dashboard/app/WorkspaceMenu.js +76 -111
  508. package/dist/dashboard/app/WorkspaceRoots.d.ts +2 -4
  509. package/dist/dashboard/app/WorkspaceRoots.js +144 -172
  510. package/dist/dashboard/app/editor/FileEditor.js +161 -125
  511. package/dist/dashboard/app/editor/FilePreview.d.ts +8 -6
  512. package/dist/dashboard/app/editor/FilePreview.js +16 -143
  513. package/dist/dashboard/app/editor/MediaAltField.view.js +5 -5
  514. package/dist/dashboard/app/modals/CreateEntry.js +98 -106
  515. package/dist/dashboard/app/pages/EntryPage.d.ts +2 -1
  516. package/dist/dashboard/app/pages/EntryPage.js +139 -97
  517. package/dist/dashboard/app/pages/RootPage.js +4 -6
  518. package/dist/dashboard/app/pages/SplashPage.d.ts +19 -0
  519. package/dist/dashboard/app/pages/SplashPage.js +208 -193
  520. package/dist/dashboard/app/pages/UsersPage.d.ts +20 -1
  521. package/dist/dashboard/app/pages/UsersPage.js +182 -255
  522. package/dist/dashboard/app/ui/DashboardModal.d.ts +18 -12
  523. package/dist/dashboard/app/ui/DashboardModal.js +54 -69
  524. package/dist/dashboard/atoms/ReactiveNode.js +58 -19
  525. package/dist/dashboard/atoms/activity.d.ts +1 -0
  526. package/dist/dashboard/atoms/activity.js +8 -5
  527. package/dist/dashboard/atoms/auth.js +2 -2
  528. package/dist/dashboard/atoms/config.d.ts +5 -1
  529. package/dist/dashboard/atoms/core.d.ts +16 -2
  530. package/dist/dashboard/atoms/core.js +19 -7
  531. package/dist/dashboard/atoms/create.js +15 -14
  532. package/dist/dashboard/atoms/dashboard.d.ts +16 -0
  533. package/dist/dashboard/atoms/dashboard.js +11 -1
  534. package/dist/dashboard/atoms/editor.d.ts +7 -1
  535. package/dist/dashboard/atoms/editor.js +29 -42
  536. package/dist/dashboard/atoms/entry.d.ts +32 -42
  537. package/dist/dashboard/atoms/entry.js +240 -182
  538. package/dist/dashboard/atoms/entryTable.d.ts +10 -0
  539. package/dist/dashboard/atoms/entryTable.js +43 -0
  540. package/dist/dashboard/atoms/explorer.d.ts +212 -36
  541. package/dist/dashboard/atoms/explorer.js +597 -259
  542. package/dist/dashboard/atoms/graph.d.ts +5 -0
  543. package/dist/dashboard/atoms/graph.js +27 -2
  544. package/dist/dashboard/atoms/link.d.ts +2 -0
  545. package/dist/dashboard/atoms/link.js +11 -5
  546. package/dist/dashboard/atoms/move.d.ts +64 -0
  547. package/dist/dashboard/atoms/move.js +128 -0
  548. package/dist/dashboard/atoms/moveConfirmation.d.ts +34 -0
  549. package/dist/dashboard/atoms/moveConfirmation.js +95 -0
  550. package/dist/dashboard/atoms/nav.d.ts +36 -12
  551. package/dist/dashboard/atoms/nav.js +280 -53
  552. package/dist/dashboard/atoms/overview.d.ts +228 -0
  553. package/dist/dashboard/atoms/overview.js +519 -0
  554. package/dist/dashboard/atoms/remove.d.ts +112 -0
  555. package/dist/dashboard/atoms/remove.js +268 -0
  556. package/dist/dashboard/atoms/root.d.ts +44 -22
  557. package/dist/dashboard/atoms/root.js +294 -164
  558. package/dist/dashboard/atoms/upload.d.ts +105 -3
  559. package/dist/dashboard/atoms/upload.js +266 -11
  560. package/dist/dashboard/atoms/user.js +1 -1
  561. package/dist/dashboard/atoms/utils.d.ts +12 -4
  562. package/dist/dashboard/atoms/utils.js +35 -2
  563. package/dist/dashboard/boot/ActivityEvent.d.ts +1 -1
  564. package/dist/dashboard/boot/Boot.d.ts +2 -0
  565. package/dist/dashboard/boot/Boot.js +33 -18
  566. package/dist/dashboard/boot/BootDev.js +13 -10
  567. package/dist/dashboard/boot/BootProd.d.ts +6 -1
  568. package/dist/dashboard/boot/BootProd.js +3 -2
  569. package/dist/dashboard/boot/DashboardWorker.d.ts +7 -0
  570. package/dist/dashboard/boot/DashboardWorker.js +108 -24
  571. package/dist/dashboard/boot/LoadWorker.js +21 -11
  572. package/dist/dashboard/boot/SyncEvent.d.ts +7 -0
  573. package/dist/dashboard/boot/SyncEvent.js +14 -0
  574. package/dist/dashboard/boot/WorkerDB.d.ts +1 -0
  575. package/dist/dashboard/boot/WorkerDB.js +3 -0
  576. package/dist/dashboard/cms/EntryTable.d.ts +56 -0
  577. package/dist/dashboard/cms/EntryTable.js +273 -0
  578. package/dist/dashboard/cms/FieldChrome.d.ts +21 -0
  579. package/dist/dashboard/cms/FieldChrome.js +26 -0
  580. package/dist/dashboard/cms/ViewProps.d.ts +42 -0
  581. package/dist/dashboard/cms/ViewProps.js +0 -0
  582. package/dist/dashboard/cms/hooks.d.ts +120 -0
  583. package/dist/dashboard/cms/hooks.js +132 -0
  584. package/dist/dashboard/contexts.d.ts +59 -0
  585. package/dist/dashboard/contexts.js +43 -0
  586. package/dist/dashboard/editor/UseField.d.ts +29 -6
  587. package/dist/dashboard/fixture/cms.d.ts +2 -2
  588. package/dist/dashboard/hook/UseEntryEditor.d.ts +4 -1
  589. package/dist/dashboard/hook/UseEntryEditor.js +7 -3
  590. package/dist/dashboard/hook/UseGraph.d.ts +3 -1
  591. package/dist/dashboard/hook/UseLocale.d.ts +3 -1
  592. package/dist/dashboard/hook/UseRoot.d.ts +3 -1
  593. package/dist/dashboard/hook/UseSearchShortcut.d.ts +11 -0
  594. package/dist/dashboard/hook/UseSearchShortcut.js +32 -0
  595. package/dist/dashboard/hook/UseWorkspace.d.ts +3 -1
  596. package/dist/dashboard/hooks.d.ts +16 -98
  597. package/dist/dashboard/hooks.js +15 -90
  598. package/dist/dashboard/icons.d.ts +11 -0
  599. package/dist/dashboard/icons.js +125 -0
  600. package/dist/dashboard.d.ts +23 -1
  601. package/dist/dashboard.js +5 -2
  602. package/dist/database/BrowserEntryStore.d.ts +17 -24
  603. package/dist/database/BrowserEntryStore.js +139 -137
  604. package/dist/database/DatabaseTables.js +2 -2
  605. package/dist/database/EntryDatabase.d.ts +15 -1
  606. package/dist/database/EntryDatabase.js +61 -10
  607. package/dist/database/EntryStore.js +32 -20
  608. package/dist/database/EntryTransaction.d.ts +0 -5
  609. package/dist/database/EntryTransaction.js +173 -58
  610. package/dist/database/EntryUrlAliases.d.ts +4 -0
  611. package/dist/database/EntryUrlAliases.js +16 -10
  612. package/dist/database/Version.d.ts +2 -2
  613. package/dist/database/Version.js +1 -1
  614. package/dist/database/driver/RuntimeDatabase.js +3 -3
  615. package/dist/database/driver/WasmDatabase.d.ts +5 -18
  616. package/dist/database/driver/WasmDatabase.js +16 -15
  617. package/dist/database/entry/EntryTable.d.ts +5 -3
  618. package/dist/database/entry/EntryTable.js +34 -10
  619. package/dist/database/query/Condition.d.ts +9 -1
  620. package/dist/database/query/Condition.js +25 -6
  621. package/dist/database/query/EntryQuery.d.ts +4 -0
  622. package/dist/database/query/EntryQuery.js +148 -25
  623. package/dist/database/query/EntryReferences.d.ts +1 -1
  624. package/dist/database/query/EntryReferences.js +3 -2
  625. package/dist/database/query/Relation.d.ts +13 -1
  626. package/dist/database/query/Relation.js +33 -5
  627. package/dist/database/query/ResolveQuery.d.ts +1 -1
  628. package/dist/database/query/ResolveQuery.js +27 -18
  629. package/dist/database/query/Search.d.ts +10 -1
  630. package/dist/database/query/Search.js +83 -10
  631. package/dist/database/sync/Derive.d.ts +2 -1
  632. package/dist/database/sync/Derive.js +15 -10
  633. package/dist/database/sync/EntryParser.js +8 -7
  634. package/dist/database/sync/EntrySyncer.d.ts +3 -0
  635. package/dist/database/sync/EntrySyncer.js +10 -7
  636. package/dist/database/sync/Ingest.d.ts +2 -1
  637. package/dist/database/sync/Ingest.js +79 -49
  638. package/dist/database/sync/SyncQueries.d.ts +3 -2
  639. package/dist/database/sync/SyncQueries.js +19 -19
  640. package/dist/field/check/CheckField.js +3 -1
  641. package/dist/field/check/CheckField.view.js +13 -11
  642. package/dist/field/code/CodeField.d.ts +9 -0
  643. package/dist/field/code/CodeField.view.d.ts +3 -1
  644. package/dist/field/code/CodeField.view.js +30 -20
  645. package/dist/field/code/SimpleCodeEditor.js +0 -18
  646. package/dist/field/date/DateField.view.js +9 -25
  647. package/dist/field/link/EntryLink.d.ts +8 -9
  648. package/dist/field/link/FileLink.d.ts +11 -8
  649. package/dist/field/link/FileLink.js +7 -6
  650. package/dist/field/link/ImageLink.d.ts +16 -16
  651. package/dist/field/link/ImageLink.js +14 -23
  652. package/dist/field/link/Link.d.ts +1 -1
  653. package/dist/field/link/Link.js +2 -2
  654. package/dist/field/link/LinkField.d.ts +10 -5
  655. package/dist/field/link/LinkField.js +2 -0
  656. package/dist/field/link/LinkField.view.js +501 -684
  657. package/dist/field/link/UrlLink.d.ts +5 -4
  658. package/dist/field/link.d.ts +1 -0
  659. package/dist/field/list/ListField.d.ts +9 -5
  660. package/dist/field/list/ListField.js +10 -5
  661. package/dist/field/list/ListField.view.d.ts +15 -0
  662. package/dist/field/list/ListField.view.js +525 -645
  663. package/dist/field/localiser/LocalisedField.view.js +37 -88
  664. package/dist/field/localiser/LocalisedFieldTab.d.ts +7 -0
  665. package/dist/field/localiser/LocalisedFieldTab.js +30 -0
  666. package/dist/field/localiser/LocalisedFieldTabs.js +5 -5
  667. package/dist/field/localiser/Localiser.d.ts +17 -1
  668. package/dist/field/localiser/Localiser.js +152 -7
  669. package/dist/field/localiser/SelectLocale.d.ts +5 -0
  670. package/dist/field/localiser/SelectLocale.js +12 -0
  671. package/dist/field/metadata/MetadataAudit.d.ts +39 -0
  672. package/dist/field/metadata/MetadataAudit.js +124 -0
  673. package/dist/field/metadata/MetadataField.d.ts +20 -30
  674. package/dist/field/metadata/MetadataField.js +24 -107
  675. package/dist/field/metadata/MetadataField.view.d.ts +1 -0
  676. package/dist/field/metadata/MetadataField.view.js +36 -38
  677. package/dist/field/number/NumberField.view.js +9 -9
  678. package/dist/field/object/ObjectField.d.ts +3 -1
  679. package/dist/field/object/ObjectField.view.js +35 -25
  680. package/dist/field/path/PathField.view.js +3 -3
  681. package/dist/field/path/SlugField.d.ts +1 -2
  682. package/dist/field/path/SlugField.js +5 -7
  683. package/dist/field/richtext/PickTextAnchor.js +10 -10
  684. package/dist/field/richtext/PickTextLink.js +28 -41
  685. package/dist/field/richtext/RichTextBlock.d.ts +3 -1
  686. package/dist/field/richtext/RichTextBlock.js +190 -78
  687. package/dist/field/richtext/RichTextBlockHost.js +1 -1
  688. package/dist/field/richtext/RichTextExtensions.js +26 -20
  689. package/dist/field/richtext/RichTextField.story.d.ts +1 -0
  690. package/dist/field/richtext/RichTextField.view.js +13 -6
  691. package/dist/field/richtext/RichTextInsertMenu.js +59 -36
  692. package/dist/field/richtext/RichTextToolbar.js +82 -34
  693. package/dist/field/richtext/Toolbar.d.ts +9 -1
  694. package/dist/field/richtext/Toolbar.js +12 -2
  695. package/dist/field/richtext.d.ts +2 -0
  696. package/dist/field/richtext.js +2 -0
  697. package/dist/field/select/SelectField.view.js +15 -79
  698. package/dist/field/tabs/Tabs.d.ts +12 -3
  699. package/dist/field/tabs/Tabs.js +11 -2
  700. package/dist/field/tabs/Tabs.view.js +8 -8
  701. package/dist/field/text/TextField.view.js +9 -8
  702. package/dist/field/time/TimeField.view.js +10 -18
  703. package/dist/field/views.js +4 -0
  704. package/dist/field.d.ts +2 -2
  705. package/dist/field.js +3 -2
  706. package/dist/index.css +5408 -5223
  707. package/dist/index.d.ts +1 -0
  708. package/dist/index.js +3 -1
  709. package/dist/next.cjs +27 -20
  710. package/dist/next.d.ts +2 -0
  711. package/dist/next.edge.d.ts +2 -0
  712. package/dist/picker/entry/EntryPicker.d.ts +11 -4
  713. package/dist/picker/entry/EntryPicker.js +15 -1
  714. package/dist/picker/url/UrlPicker.js +1 -0
  715. package/dist/preview/react.js +3 -0
  716. package/dist/preview/widget.d.ts +3 -0
  717. package/dist/preview/widget.js +26 -8
  718. package/dist/query.d.ts +41 -266
  719. package/dist/query.js +4 -0
  720. package/dist/types.d.ts +12 -5
  721. package/dist/ui/RichText.js +31 -1
  722. package/dist/ui/Stack.d.ts +4 -2
  723. package/docs/ai-agents.md +316 -0
  724. package/docs/ai-setup.md +297 -0
  725. package/docs/cli.md +96 -0
  726. package/docs/components/alert.md +122 -0
  727. package/docs/components/app-shell.md +77 -0
  728. package/docs/components/badge.md +89 -0
  729. package/docs/components/blockquote.md +24 -0
  730. package/docs/components/breadcrumb.md +83 -0
  731. package/docs/components/button.md +142 -0
  732. package/docs/components/calendar.md +32 -0
  733. package/docs/components/checkbox-group.md +38 -0
  734. package/docs/components/checkbox.md +61 -0
  735. package/docs/components/code.md +37 -0
  736. package/docs/components/collapsible.md +53 -0
  737. package/docs/components/color-swatch-picker.md +47 -0
  738. package/docs/components/combo-box.md +146 -0
  739. package/docs/components/command.md +101 -0
  740. package/docs/components/content-card.md +64 -0
  741. package/docs/components/content-grid.md +71 -0
  742. package/docs/components/data-list.md +64 -0
  743. package/docs/components/date-field.md +34 -0
  744. package/docs/components/date-picker.md +35 -0
  745. package/docs/components/date-range-picker.md +34 -0
  746. package/docs/components/dialog.md +233 -0
  747. package/docs/components/drop-zone.md +45 -0
  748. package/docs/components/dropdown-menu.md +223 -0
  749. package/docs/components/empty.md +81 -0
  750. package/docs/components/field.md +66 -0
  751. package/docs/components/file-trigger.md +33 -0
  752. package/docs/components/fold-icon.md +34 -0
  753. package/docs/components/form.md +67 -0
  754. package/docs/components/heading.md +33 -0
  755. package/docs/components/icon.md +43 -0
  756. package/docs/components/kbd.md +29 -0
  757. package/docs/components/link.md +45 -0
  758. package/docs/components/list.md +105 -0
  759. package/docs/components/media-preview.md +43 -0
  760. package/docs/components/multiple-select.md +48 -0
  761. package/docs/components/nav-rail.md +79 -0
  762. package/docs/components/number-field.md +53 -0
  763. package/docs/components/page.md +97 -0
  764. package/docs/components/popover.md +71 -0
  765. package/docs/components/preview-frame.md +63 -0
  766. package/docs/components/radio-group.md +47 -0
  767. package/docs/components/resizable-panel-group.md +63 -0
  768. package/docs/components/search-field.md +54 -0
  769. package/docs/components/select.md +127 -0
  770. package/docs/components/sidebar.md +104 -0
  771. package/docs/components/sortable-list.md +110 -0
  772. package/docs/components/spinner.md +29 -0
  773. package/docs/components/stack.md +42 -0
  774. package/docs/components/surface.md +54 -0
  775. package/docs/components/switch.md +52 -0
  776. package/docs/components/table.md +262 -0
  777. package/docs/components/tabs.md +120 -0
  778. package/docs/components/tag-group.md +56 -0
  779. package/docs/components/text-field.md +142 -0
  780. package/docs/components/text.md +44 -0
  781. package/docs/components/time-field.md +41 -0
  782. package/docs/components/timestamp.md +45 -0
  783. package/docs/components/toggle-group.md +46 -0
  784. package/docs/components/toggle.md +37 -0
  785. package/docs/components/toolbar.md +96 -0
  786. package/docs/components/tooltip.md +78 -0
  787. package/docs/components/tree.md +67 -0
  788. package/docs/components.md +169 -0
  789. package/docs/configuration.md +177 -0
  790. package/docs/content-model.md +87 -0
  791. package/docs/custom-fields.md +359 -0
  792. package/docs/dashboard-ui.md +3 -0
  793. package/docs/deploy/alinea-cloud.md +26 -0
  794. package/docs/deploy/self-host.md +195 -0
  795. package/docs/deploy.md +127 -0
  796. package/docs/editing-content.md +195 -0
  797. package/docs/fields/check.md +40 -0
  798. package/docs/fields/code.md +35 -0
  799. package/docs/fields/date.md +90 -0
  800. package/docs/fields/entry.md +179 -0
  801. package/docs/fields/file.md +60 -0
  802. package/docs/fields/image.md +138 -0
  803. package/docs/fields/link.md +121 -0
  804. package/docs/fields/list.md +149 -0
  805. package/docs/fields/number.md +58 -0
  806. package/docs/fields/object.md +93 -0
  807. package/docs/fields/path.md +105 -0
  808. package/docs/fields/rich-text.md +267 -0
  809. package/docs/fields/select.md +99 -0
  810. package/docs/fields/tabs.md +111 -0
  811. package/docs/fields/text.md +46 -0
  812. package/docs/fields/url.md +51 -0
  813. package/docs/fields.md +231 -0
  814. package/docs/get-started.md +3 -0
  815. package/docs/guides.md +3 -0
  816. package/docs/index.md +140 -0
  817. package/docs/instant-publishing.md +61 -0
  818. package/docs/internationalization.md +218 -0
  819. package/docs/introduction.md +5 -0
  820. package/docs/live-previews.md +151 -0
  821. package/docs/mcp.md +500 -0
  822. package/docs/overviews.md +580 -0
  823. package/docs/query/advanced.md +123 -0
  824. package/docs/query/examples.md +231 -0
  825. package/docs/query/filtering.md +162 -0
  826. package/docs/query/related.md +178 -0
  827. package/docs/query/structural.md +165 -0
  828. package/docs/query.md +190 -0
  829. package/docs/quickstart.md +203 -0
  830. package/docs/reference.md +3 -0
  831. package/docs/roles-permissions.md +234 -0
  832. package/docs/schema/document.md +100 -0
  833. package/docs/schema/type.md +133 -0
  834. package/docs/schema.md +66 -0
  835. package/docs/tutorial/step-1-landing-page.md +244 -0
  836. package/docs/tutorial/step-2-block-list.md +364 -0
  837. package/docs/tutorial/step-3-layout-root.md +200 -0
  838. package/docs/tutorial/step-4-blog.md +384 -0
  839. package/docs/tutorial/step-5-catch-all.md +222 -0
  840. package/docs/tutorial.md +21 -0
  841. package/docs/typescript.md +115 -0
  842. package/docs/upgrading.md +368 -0
  843. package/docs/workspaces/media.md +134 -0
  844. package/docs/workspaces/root.md +127 -0
  845. package/docs/workspaces.md +98 -0
  846. package/llms-full.txt +13007 -3217
  847. package/package.json +25 -6
  848. package/readme.md +136 -55
  849. package/dist/adapter/next/previews.spec.d.ts +0 -1
  850. package/dist/chunks/chunk-AC4U3IMS.js +0 -205
  851. package/dist/chunks/chunk-DNJX6CRV.js +0 -129
  852. package/dist/chunks/chunk-NIVGVRDS.js +0 -6363
  853. package/dist/chunks/chunk-S4AU6SRS.js +0 -5503
  854. package/dist/chunks/chunk-SJBZFMQ2.js +0 -2966
  855. package/dist/components/Disclosure.d.ts +0 -5
  856. package/dist/components/Disclosure.js +0 -106
  857. package/dist/components/Label.d.ts +0 -48
  858. package/dist/components/Label.js +0 -210
  859. package/dist/components/Menu.d.ts +0 -16
  860. package/dist/components/Menu.js +0 -95
  861. package/dist/components/Modal.d.ts +0 -7
  862. package/dist/components/Modal.js +0 -58
  863. package/dist/components/ProgressCircle.d.ts +0 -6
  864. package/dist/components/ProgressCircle.js +0 -96
  865. package/dist/dashboard/app/AppShell.d.ts +0 -4
  866. package/dist/dashboard/app/AppShell.js +0 -29
  867. package/dist/dashboard/app/Badge.d.ts +0 -8
  868. package/dist/dashboard/app/Badge.js +0 -42
  869. package/dist/dashboard/app/EditorBackButton.d.ts +0 -5
  870. package/dist/dashboard/app/EditorBackButton.js +0 -33
  871. package/dist/dashboard/app/EntrySidebarPreview.spec.d.ts +0 -1
  872. package/dist/dashboard/app/ExplorerFileCard.d.ts +0 -10
  873. package/dist/dashboard/app/ExplorerFileCard.js +0 -115
  874. package/dist/dashboard/app/StatusBadge.d.ts +0 -6
  875. package/dist/dashboard/app/StatusBadge.js +0 -26
  876. package/dist/dashboard/app/WorkspaceMenu.spec.d.ts +0 -1
  877. package/dist/dashboard/app/WorkspaceMenu.stories.d.ts +0 -7
  878. package/dist/dashboard/app/ui/Rail.d.ts +0 -18
  879. package/dist/dashboard/app/ui/Rail.js +0 -41
  880. package/dist/dashboard/app/ui/Sidebar.d.ts +0 -15
  881. package/dist/dashboard/app/ui/Sidebar.js +0 -55
  882. package/dist/field/link/LinkField.spec.d.ts +0 -1
  883. package/dist/field/link/LinkField.stories.d.ts +0 -15
  884. package/dist/field/list/ListField.spec.d.ts +0 -1
  885. package/dist/field/list/ListField.stories.d.ts +0 -7
  886. package/dist/field/richtext/RichTextField.spec.d.ts +0 -1
  887. package/dist/chunks/{chunk-MOWR65LM.js → chunk-PYDOMKJZ.js} +71 -71
@@ -4,7 +4,7 @@ import {
4
4
  object,
5
5
  optional,
6
6
  string
7
- } from "../chunks/chunk-UPY2RUZF.js";
7
+ } from "../chunks/chunk-TWBREZWC.js";
8
8
  import {
9
9
  PLazy
10
10
  } from "../chunks/chunk-IKINPSS5.js";
@@ -19,23 +19,31 @@ import {
19
19
  } from "alinea/core/BlobTransport";
20
20
  import { Config } from "alinea/core/Config";
21
21
  import { developmentKeyHeader } from "alinea/core/Connection";
22
+ import { loggedSync } from "alinea/core/db/SyncStats";
23
+ import {
24
+ committedEntries,
25
+ removedEntries
26
+ } from "./CommitEntries.js";
22
27
  import { Entry } from "alinea/core/Entry";
23
28
  import { ErrorCode, HttpError } from "alinea/core/HttpError";
24
29
  import { MediaLocation } from "alinea/core/media/MediaLocation";
25
- import { MediaFile } from "alinea/core/media/MediaTypes";
30
+ import { FileData } from "alinea/core/media/MediaTypes";
26
31
  import { assertUploadSize } from "alinea/core/media/UploadLimits";
27
32
  import { Permission, Policy } from "alinea/core/Role";
28
33
  import { getScope } from "alinea/core/Scope";
29
34
  import { ShaMismatchError } from "alinea/core/source/ShaMismatchError";
35
+ import { sourceAtTree } from "alinea/core/source/Source";
30
36
  import { base64 } from "alinea/core/util/Encoding";
37
+ import { within } from "alinea/core/util/Async";
31
38
  import { isRecord } from "alinea/core/util/Objects";
32
- import { isAbsolute, normalize } from "alinea/core/util/Paths";
39
+ import { fileVersions } from "alinea/core/util/EntryFilenames";
40
+ import { isAbsolute, normalize, relative } from "alinea/core/util/Paths";
33
41
  import { InvalidCredentialsError, MissingCredentialsError } from "./Auth.js";
34
42
  import { HandleAction } from "./HandleAction.js";
35
43
  import { proxyMediaUrl } from "./api/ProxyMedia.js";
36
44
  import { applyPreview, decodePreviewRequest } from "./resolver/ParsePreview.js";
37
45
  import { compressResponse } from "./router/Router.js";
38
- import { createThrottledSync } from "./util/Syncable.js";
46
+ import { createThrottledSync, syncWait } from "./util/Syncable.js";
39
47
  var PrepareBody = object({
40
48
  filename: string,
41
49
  size: optional(number)
@@ -45,6 +53,7 @@ function createHandler({
45
53
  remote = (context) => new CloudRemote(context, cms.config),
46
54
  db,
47
55
  forwardMutations,
56
+ logSyncs = false,
48
57
  ...hooks
49
58
  }) {
50
59
  const throttle = createThrottledSync();
@@ -53,18 +62,22 @@ function createHandler({
53
62
  const local = await db;
54
63
  const simulateLatency = process.env.ALINEA_LATENCY;
55
64
  if (simulateLatency) await new Promise((resolve) => setTimeout(resolve, 2e3));
56
- async function syncForRead(cnx) {
65
+ async function syncForRead(sync2) {
57
66
  try {
58
- await local.syncWith(cnx);
67
+ await within(sync2, syncWait);
59
68
  } catch (error) {
60
69
  console.warn(
61
70
  `Alinea could not sync with the remote, serving current content: ${error instanceof Error ? error.message : String(error)}`
62
71
  );
63
72
  }
64
73
  }
74
+ function sync(remote2, reason) {
75
+ if (dev || !logSyncs) return local.syncWith(remote2);
76
+ return loggedSync(local, remote2, reason);
77
+ }
65
78
  async function periodicSync(cnx, syncInterval) {
66
79
  if (dev) return;
67
- return throttle(() => syncForRead(cnx), syncInterval);
80
+ return syncForRead(throttle(() => sync(cnx, "interval"), syncInterval));
68
81
  }
69
82
  try {
70
83
  const previews = new JWTPreviews(context.apiKey);
@@ -102,11 +115,11 @@ function createHandler({
102
115
  url: Entry.url,
103
116
  filePath: Entry.filePath,
104
117
  workspace: Entry.workspace,
105
- location: MediaFile.location,
106
- previewUrl: MediaFile.previewUrl
118
+ location: FileData.location,
119
+ previewUrl: FileData.previewUrl
107
120
  };
108
121
  const query = {
109
- type: MediaFile,
122
+ type: Config.fileTypes(cms.config),
110
123
  status: "published",
111
124
  main: true,
112
125
  select
@@ -152,7 +165,7 @@ function createHandler({
152
165
  if (!source || source === requestedUrl)
153
166
  return new Response("Not found", { status: 404 });
154
167
  if (!proxy) return redirectFile(source, "public, max-age=60");
155
- const deliveryBase = !context.isDev && Config.baseUrl(cms.config, "production") || context.handlerUrl;
168
+ const deliveryBase = context.publicUrl ?? (context.isDev ? context.handlerUrl : new URL(request.url));
156
169
  return proxyMedia(
157
170
  new URL(source, deliveryBase).href,
158
171
  "public, max-age=60"
@@ -258,7 +271,9 @@ function createHandler({
258
271
  } else {
259
272
  const preview = await decodePreviewRequest(query.preview);
260
273
  if ("contentHash" in preview && await local.sha !== preview.contentHash)
261
- await syncForRead(cnx);
274
+ await syncForRead(
275
+ sync(cnx, `preview at ${preview.contentHash.slice(0, 7)}`)
276
+ );
262
277
  query.preview = await applyPreview(local, preview);
263
278
  }
264
279
  return Response.json(await local.resolve(query) ?? null);
@@ -272,64 +287,101 @@ function createHandler({
272
287
  expectJson();
273
288
  const policy = await user.policy;
274
289
  let mutations = await body;
275
- await local.syncWith(cnx);
276
- const adjusted = await hooks.beforeCommit?.({ mutations });
290
+ await sync(cnx, "commit");
291
+ const adjusted = await hooks.beforeCommit?.({
292
+ mutations,
293
+ user: user.claims
294
+ });
277
295
  if (adjusted) mutations = adjusted;
296
+ const before = hooks.afterCommit ? await committedEntries(local, mutations) : [];
278
297
  const attempt = async (retry = 0) => {
279
- if (retry > 0) await local.syncWith(cnx);
298
+ if (retry > 0) await sync(cnx, "commit retry");
280
299
  const request2 = {
281
300
  ...await local.request(mutations, policy),
282
301
  user: user.claims
283
302
  };
303
+ let sha2;
284
304
  try {
285
- let { sha: sha2 } = await cnx.write(request2);
286
- if (sha2 === request2.intoSha) {
287
- await local.write(request2);
288
- } else {
289
- sha2 = await local.syncWith(cnx);
290
- }
291
- return sha2;
305
+ sha2 = (await cnx.write(request2)).sha;
292
306
  } catch (error) {
293
307
  const isConflict = error instanceof ShaMismatchError || error instanceof HttpError && error.code === 409 || error instanceof Response && error.status === 409;
294
308
  if (isConflict && retry < 3) return attempt(retry + 1);
295
309
  throw error;
296
310
  }
311
+ try {
312
+ if (sha2 === request2.intoSha) await local.write(request2);
313
+ else sha2 = await sync(cnx, "after commit");
314
+ } catch {
315
+ sha2 = await sync(cnx, "after commit").catch(() => sha2);
316
+ }
317
+ return sha2;
297
318
  };
298
319
  const sha = await attempt();
299
320
  try {
300
- await hooks.afterCommit?.({
301
- mutations,
302
- sha
303
- });
321
+ if (hooks.afterCommit) {
322
+ const entries = await committedEntries(local, mutations);
323
+ await hooks.afterCommit({
324
+ mutations,
325
+ sha,
326
+ user: user.claims,
327
+ entries,
328
+ removed: removedEntries(before, entries)
329
+ });
330
+ }
304
331
  } catch (error) {
305
332
  console.error("Alinea afterCommit hook failed", error);
306
333
  }
307
334
  return Response.json({ sha });
308
335
  }
309
336
  if (action === HandleAction.History && request.method === "GET") {
310
- expectUser();
337
+ const user = expectUser();
311
338
  expectJson();
312
339
  const file = string(url.searchParams.get("file"));
313
340
  const revisionId = string.nullable(url.searchParams.get("revisionId"));
314
- const result = await (revisionId ? cnx.revisionData(file, revisionId) : cnx.revisions(file));
341
+ const record = revisionId ? await cnx.revisionData(file, revisionId) : void 0;
342
+ const contentDir = Config.contentDir(cms.config);
343
+ const owners = () => historyEntries(local, contentDir, file, record);
344
+ let entries = await owners();
345
+ if (entries.length === 0) {
346
+ await syncForRead(sync(cnx, "history of an unknown entry"));
347
+ entries = await owners();
348
+ }
349
+ if (entries.length === 0)
350
+ throw new HttpError(ErrorCode.NotFound, "Entry not found");
351
+ const policy = await user.policy;
352
+ for (const entry of entries) policy.assert(Permission.Read, entry);
353
+ const result = revisionId ? record : await cnx.revisions(file);
315
354
  return Response.json(result ?? null);
316
355
  }
317
356
  if (action === HandleAction.Tree && request.method === "GET") {
318
357
  expectJson();
319
358
  const sha = string(url.searchParams.get("sha"));
320
- await syncForRead(cnx);
359
+ let source = cnx;
360
+ const start = performance.now();
361
+ try {
362
+ const remoteTree = await cnx.getTreeIfDifferent(sha);
363
+ if (!remoteTree) return Response.json(null);
364
+ source = sourceAtTree(cnx, remoteTree);
365
+ } catch {
366
+ }
367
+ const remoteMs = Math.round(performance.now() - start);
368
+ const reason = `tree from ${sha.slice(0, 7)}, remote tree ${remoteMs} ms`;
369
+ await syncForRead(sync(source, reason));
321
370
  const tree = await local.getTreeIfDifferent(sha);
322
371
  return compressResponse(request, Response.json(tree ?? null));
323
372
  }
324
373
  if (action === HandleAction.Sha && request.method === "GET") {
325
374
  expectJson();
326
- await syncForRead(cnx);
375
+ await syncForRead(sync(cnx, "sha"));
327
376
  return Response.json(await local.sha);
328
377
  }
329
378
  if (action === HandleAction.Blob && request.method === "POST") {
330
379
  const { shas } = object({ shas: array(string) })(await body);
331
- await periodicSync(cnx);
332
- const tree = await local.source.getTree();
380
+ let tree = await local.source.getTree();
381
+ if (!dev && shas.some((sha) => !tree.hasSha(sha))) {
382
+ await syncForRead(sync(cnx, "blobs of a newer tree"));
383
+ tree = await local.source.getTree();
384
+ }
333
385
  const fromLocal = [];
334
386
  const fromRemote = [];
335
387
  for (const sha of shas) {
@@ -418,6 +470,28 @@ function createHandler({
418
470
  }
419
471
  };
420
472
  }
473
+ var historyResource = {
474
+ id: Entry.id,
475
+ type: Entry.type,
476
+ workspace: Entry.workspace,
477
+ root: Entry.root,
478
+ parents: Entry.parents,
479
+ locale: Entry.locale
480
+ };
481
+ async function historyEntries(local, contentDir, file, record) {
482
+ const filePath = relative(contentDir, file);
483
+ if (filePath.startsWith("../")) return [];
484
+ const status = "all";
485
+ const select = historyResource;
486
+ const atFile = await local.find({
487
+ filePath: { in: fileVersions(filePath) },
488
+ status,
489
+ select
490
+ });
491
+ const id = record?._id;
492
+ if (atFile.length > 0 || typeof id !== "string") return atFile;
493
+ return local.find({ id, status, select });
494
+ }
421
495
  function redirectFile(location, cacheControl) {
422
496
  return new Response(null, {
423
497
  status: 307,
@@ -42,7 +42,11 @@ var BasicAuth = class {
42
42
  const [scheme, token] = auth.split(" ", 2);
43
43
  if (scheme !== "Basic")
44
44
  throw new MissingCredentialsError("Invalid authorization scheme");
45
- const [username, password] = atob(token).split(":");
45
+ const credentials = atob(token);
46
+ const colon = credentials.indexOf(":");
47
+ if (colon === -1) throw new InvalidCredentialsError("Invalid credentials");
48
+ const username = credentials.slice(0, colon);
49
+ const password = credentials.slice(colon + 1);
46
50
  const authorized = await this.#verify(username, password);
47
51
  if (!authorized) throw new InvalidCredentialsError("Invalid credentials");
48
52
  const user = typeof authorized === "boolean" ? {
@@ -0,0 +1,21 @@
1
+ import type { CommitApi, SyncApi } from 'alinea/core/Connection';
2
+ /**
3
+ * Content blobs kept where every handler instance finds them, such as the
4
+ * backend database: an instance that is behind reads what another one
5
+ * fetched or committed, instead of fetching it from the remote again.
6
+ */
7
+ export interface BlobStore {
8
+ /** The stored blobs among `shas`. */
9
+ readBlobs(shas: ReadonlyArray<string>): Promise<Map<string, Uint8Array>>;
10
+ /** Keep blobs, found again by their sha. */
11
+ storeBlobs(blobs: ReadonlyArray<[sha: string, blob: Uint8Array]>): Promise<void>;
12
+ }
13
+ export declare function isBlobStore<T extends object>(value: T): value is T & BlobStore;
14
+ /**
15
+ * Answer from the store what it has, and fetch the rest from the remote,
16
+ * storing it. The store only saves requests: when it fails, the remote
17
+ * answers instead.
18
+ */
19
+ export declare function storedBlobs(store: BlobStore, getBlobs: SyncApi['getBlobs']): SyncApi['getBlobs'];
20
+ /** Commit through the remote, and store the committed content. */
21
+ export declare function storedWrites(store: BlobStore, write: CommitApi['write']): CommitApi['write'];
@@ -0,0 +1,63 @@
1
+ import "../../chunks/chunk-CQ52GEHY.js";
2
+
3
+ // src/backend/api/BlobStore.ts
4
+ import { hashBlob } from "alinea/core/source/GitUtils";
5
+ var storeBatch = 100;
6
+ function isBlobStore(value) {
7
+ return "readBlobs" in value && typeof value.readBlobs === "function" && "storeBlobs" in value && typeof value.storeBlobs === "function";
8
+ }
9
+ function storedBlobs(store, getBlobs) {
10
+ return async function* (shas, options) {
11
+ const stored = await store.readBlobs(shas).catch((error) => {
12
+ console.warn("Alinea could not read stored blobs", error);
13
+ return /* @__PURE__ */ new Map();
14
+ });
15
+ for (const sha of shas) {
16
+ const blob = stored.get(sha);
17
+ if (blob) yield [sha, blob];
18
+ }
19
+ const missing = shas.filter((sha) => !stored.has(sha));
20
+ if (missing.length === 0) return;
21
+ let fetched = Array();
22
+ const keep = async () => {
23
+ const blobs = fetched;
24
+ fetched = [];
25
+ if (blobs.length > 0) await keepBlobs(store, blobs);
26
+ };
27
+ try {
28
+ for await (const entry of getBlobs(missing, options)) {
29
+ fetched.push(entry);
30
+ if (fetched.length >= storeBatch) await keep();
31
+ yield entry;
32
+ }
33
+ } finally {
34
+ await keep();
35
+ }
36
+ };
37
+ }
38
+ function storedWrites(store, write) {
39
+ return async (request) => {
40
+ const result = await write(request);
41
+ const encoder = new TextEncoder();
42
+ const blobs = Array();
43
+ for (const change of request.changes) {
44
+ if (change.op !== "addContent") continue;
45
+ const blob = encoder.encode(change.contents);
46
+ if (await hashBlob(blob) === change.sha) blobs.push([change.sha, blob]);
47
+ }
48
+ if (blobs.length > 0) await keepBlobs(store, blobs);
49
+ return result;
50
+ };
51
+ }
52
+ async function keepBlobs(store, blobs) {
53
+ try {
54
+ await store.storeBlobs(blobs);
55
+ } catch (error) {
56
+ console.warn("Alinea could not store blobs", error);
57
+ }
58
+ }
59
+ export {
60
+ isBlobStore,
61
+ storedBlobs,
62
+ storedWrites
63
+ };
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  driver_exports
3
- } from "../../chunks/chunk-QJGGYF6E.js";
4
- import "../../chunks/chunk-QSN6RH6X.js";
5
- import "../../chunks/chunk-ETWOY4AL.js";
6
- import "../../chunks/chunk-66YZ47TY.js";
7
- import "../../chunks/chunk-AIU6CMVT.js";
3
+ } from "../../chunks/chunk-4ZA6KZHS.js";
4
+ import "../../chunks/chunk-VA6NC3MI.js";
5
+ import "../../chunks/chunk-A2I6MCCS.js";
6
+ import "../../chunks/chunk-RAR44T5O.js";
7
+ import "../../chunks/chunk-PTYZMV5G.js";
8
8
  import "../../chunks/chunk-N47Y62CI.js";
9
9
  import "../../chunks/chunk-QBPYWU6C.js";
10
10
  import "../../chunks/chunk-2BJ2IFQM.js";
11
11
  import "../../chunks/chunk-XCZXR3C2.js";
12
- import "../../chunks/chunk-MOWR65LM.js";
12
+ import "../../chunks/chunk-PYDOMKJZ.js";
13
13
  import "../../chunks/chunk-76VMZTLN.js";
14
14
  import "../../chunks/chunk-2PIFHEYR.js";
15
15
  import "../../chunks/chunk-K62JP6HR.js";
@@ -20,6 +20,7 @@ import "../../chunks/chunk-CQ52GEHY.js";
20
20
  // src/backend/api/CreateBackend.ts
21
21
  import { assert } from "alinea/core/util/Assert";
22
22
  import { BasicAuth } from "./BasicAuth.js";
23
+ import { isBlobStore, storedBlobs, storedWrites } from "./BlobStore.js";
23
24
  import { DatabaseApi } from "./DatabaseApi.js";
24
25
  import { GithubApi } from "./GithubApi.js";
25
26
  import { OAuth2 } from "./OAuth2.js";
@@ -65,13 +66,14 @@ function composeBackend(...impl) {
65
66
  throw new Error(`Backend does not implement ${name}`);
66
67
  };
67
68
  };
69
+ const blobStore = impl.find(isBlobStore);
68
70
  return {
69
71
  authenticate: call("authenticate"),
70
72
  verify: call("verify"),
71
73
  capabilities: call("capabilities"),
72
74
  getTreeIfDifferent: call("getTreeIfDifferent"),
73
- getBlobs: call("getBlobs"),
74
- write: call("write"),
75
+ getBlobs: blobStore ? storedBlobs(blobStore, call("getBlobs")) : call("getBlobs"),
76
+ write: blobStore ? storedWrites(blobStore, call("write")) : call("write"),
75
77
  revisions: call("revisions"),
76
78
  revisionData: call("revisionData"),
77
79
  getDraft: call("getDraft"),
@@ -2,10 +2,11 @@ import type { DraftsApi, RequestContext, UploadResponse, UploadsApi, UserApi } f
2
2
  import { type Draft, type DraftKey } from 'alinea/core/Draft';
3
3
  import type { User, UserInput } from 'alinea/core/User';
4
4
  import { type Database } from 'rado';
5
+ import type { BlobStore } from './BlobStore.js';
5
6
  export interface DatabaseOptions {
6
7
  db: Database;
7
8
  }
8
- export declare class DatabaseApi implements DraftsApi, UploadsApi, UserApi {
9
+ export declare class DatabaseApi implements DraftsApi, UploadsApi, UserApi, BlobStore {
9
10
  #private;
10
11
  constructor(context: RequestContext, { db }: DatabaseOptions);
11
12
  getDraft(draftKey: DraftKey): Promise<Draft | undefined>;
@@ -13,6 +14,8 @@ export declare class DatabaseApi implements DraftsApi, UploadsApi, UserApi {
13
14
  prepareUpload(file: string): Promise<UploadResponse>;
14
15
  handleUpload(entryId: string, file: Blob): Promise<void>;
15
16
  previewUpload(entryId: string): Promise<Response>;
17
+ readBlobs(shas: ReadonlyArray<string>): Promise<Map<string, Uint8Array>>;
18
+ storeBlobs(blobs: ReadonlyArray<[sha: string, blob: Uint8Array]>): Promise<void>;
16
19
  enrichUser(user: User): Promise<User>;
17
20
  listUsers(): Promise<Array<User>>;
18
21
  createUser(user: UserInput): Promise<User>;
@@ -2,21 +2,25 @@ import {
2
2
  include
3
3
  } from "../../chunks/chunk-XTWYBWP2.js";
4
4
  import {
5
- blob,
6
5
  id,
7
6
  integer,
8
7
  text,
9
8
  varchar
10
- } from "../../chunks/chunk-ASYKC6IE.js";
9
+ } from "../../chunks/chunk-2PP7WJUJ.js";
11
10
  import {
12
11
  Builder
13
12
  } from "../../chunks/chunk-2BJ2IFQM.js";
14
13
  import {
15
- eq
14
+ and,
15
+ eq,
16
+ inArray,
17
+ lt
16
18
  } from "../../chunks/chunk-XCZXR3C2.js";
17
19
  import {
20
+ Column,
21
+ ColumnType,
18
22
  table
19
- } from "../../chunks/chunk-MOWR65LM.js";
23
+ } from "../../chunks/chunk-PYDOMKJZ.js";
20
24
  import "../../chunks/chunk-76VMZTLN.js";
21
25
  import "../../chunks/chunk-2PIFHEYR.js";
22
26
  import "../../chunks/chunk-K62JP6HR.js";
@@ -33,22 +37,35 @@ import "../../chunks/chunk-CQ52GEHY.js";
33
37
  import { createId } from "alinea/core/Id";
34
38
  import { assert } from "alinea/core/util/Assert";
35
39
  import { basename, extname } from "alinea/core/util/Paths";
40
+ import { chunks } from "alinea/core/util/Arrays";
36
41
  import { slugify } from "alinea/core/util/Slugs";
37
42
  import { HandleAction } from "../HandleAction.js";
38
43
  var UploadTable = table("alinea_upload", {
39
44
  entryId: varchar(void 0, { length: 27 }).primaryKey(),
40
- content: blob().notNull()
45
+ content: largeBlob().notNull()
41
46
  });
42
47
  var UserTable = table("alinea_user", {
43
48
  id: id(),
44
- email: text().notNull().unique(),
49
+ email: indexedText().notNull().unique(),
45
50
  name: text()
46
51
  });
47
52
  var UserRoleTable = table("alinea_user_role", {
48
53
  userId: integer().notNull().references(UserTable.id),
49
54
  role: text().notNull()
50
55
  });
51
- var tables = [UploadTable, UserTable, UserRoleTable];
56
+ var BlobTable = table("alinea_blob", {
57
+ sha: varchar(void 0, { length: 40 }).primaryKey(),
58
+ content: largeBlob().notNull(),
59
+ /** When the blob was last stored or read, in seconds */
60
+ usedAt: integer().notNull()
61
+ });
62
+ var tables = [UploadTable, UserTable, UserRoleTable, BlobTable];
63
+ var maxParams = 100;
64
+ var blobsPerStatement = 50;
65
+ var blobsPerInsert = Math.floor(maxParams / 3);
66
+ var day = 24 * 60 * 60;
67
+ var blobRetention = 30 * day;
68
+ var blobCleanups = /* @__PURE__ */ new WeakMap();
52
69
  var preparedDatabases = /* @__PURE__ */ new WeakMap();
53
70
  var selectUser = {
54
71
  ...UserTable,
@@ -108,6 +125,35 @@ var DatabaseApi = class {
108
125
  }
109
126
  });
110
127
  }
128
+ async readBlobs(shas) {
129
+ const db = await this.#db;
130
+ const found = /* @__PURE__ */ new Map();
131
+ for (const batch of chunks(shas, blobsPerStatement)) {
132
+ const rows = await db.select({ sha: BlobTable.sha, content: BlobTable.content }).from(BlobTable).where(inArray(BlobTable.sha, batch));
133
+ for (const row of rows) found.set(row.sha, row.content);
134
+ }
135
+ const now = seconds();
136
+ for (const batch of chunks([...found.keys()], blobsPerStatement))
137
+ await renewBlobs(db, batch, now);
138
+ await removeUnusedBlobs(db, now);
139
+ return found;
140
+ }
141
+ async storeBlobs(blobs) {
142
+ const db = await this.#db;
143
+ const now = seconds();
144
+ const unique = [...new Map(blobs)];
145
+ for (const batch of chunks(unique, blobsPerInsert)) {
146
+ const shas = batch.map(([sha]) => sha);
147
+ const stored = new Set(
148
+ await db.select(BlobTable.sha).from(BlobTable).where(inArray(BlobTable.sha, shas))
149
+ );
150
+ await renewBlobs(db, [...stored], now);
151
+ const rows = batch.filter(([sha]) => !stored.has(sha)).map(([sha, content]) => ({ sha, content, usedAt: now }));
152
+ if (rows.length === 0) continue;
153
+ await db.insert(BlobTable).values(rows).catch(() => insertMissingBlobs(db, rows));
154
+ }
155
+ await removeUnusedBlobs(db, now);
156
+ }
111
157
  async enrichUser(user) {
112
158
  const normalized = normalizeUser(user);
113
159
  const found = await this.#getUser(normalized.email);
@@ -191,6 +237,57 @@ function prepareDatabase(db) {
191
237
  preparedDatabases.set(db, prepared);
192
238
  return prepared;
193
239
  }
240
+ function largeBlob() {
241
+ return new Column({
242
+ type: new ColumnType(
243
+ "blob",
244
+ [],
245
+ sql.universal({
246
+ postgres: sql`bytea`,
247
+ mysql: sql`longblob`,
248
+ default: sql`blob`
249
+ })
250
+ ),
251
+ mapFromDriverValue(value) {
252
+ return new Uint8Array(value);
253
+ }
254
+ });
255
+ }
256
+ function indexedText() {
257
+ return new Column({
258
+ type: new ColumnType(
259
+ "text",
260
+ [],
261
+ sql.universal({
262
+ mysql: sql`varchar(255)`,
263
+ default: sql`text`
264
+ })
265
+ )
266
+ });
267
+ }
268
+ async function renewBlobs(db, shas, now) {
269
+ if (shas.length === 0) return;
270
+ await db.update(BlobTable).set({ usedAt: now }).where(and(inArray(BlobTable.sha, shas), lt(BlobTable.usedAt, now - day)));
271
+ }
272
+ async function insertMissingBlobs(db, rows) {
273
+ for (const row of rows) {
274
+ try {
275
+ await db.insert(BlobTable).values(row);
276
+ } catch (error) {
277
+ const stored = await db.select(BlobTable.sha).from(BlobTable).where(eq(BlobTable.sha, row.sha)).get();
278
+ if (!stored) throw error;
279
+ }
280
+ }
281
+ }
282
+ async function removeUnusedBlobs(db, now) {
283
+ const last = blobCleanups.get(db) ?? 0;
284
+ if (now - last < 60 * 60) return;
285
+ blobCleanups.set(db, now);
286
+ await db.delete(BlobTable).where(lt(BlobTable.usedAt, now - blobRetention));
287
+ }
288
+ function seconds() {
289
+ return Math.floor(Date.now() / 1e3);
290
+ }
194
291
  async function enablePostgresRowLevelSecurity(db) {
195
292
  if (db.dialect.runtime !== "postgres") return;
196
293
  for (const table2 of tables) {
@@ -3,6 +3,19 @@ import type { EntryRecord } from 'alinea/core/EntryRecord';
3
3
  import type { CommitRequest } from 'alinea/core/db/CommitRequest';
4
4
  import { GithubSource, type GithubSourceOptions } from 'alinea/core/source/GithubSource';
5
5
  export interface GithubOptions extends GithubSourceOptions {
6
+ /**
7
+ * Commit as this author instead of the account that owns the token. Such
8
+ * commits are written through the REST API, which GraphQL commits do not
9
+ * allow, so GitHub does not mark them as verified. A save usually spends
10
+ * three REST requests, plus one per uploaded file. Removing a file that is
11
+ * already gone costs one more tree request, and a branch that moved in
12
+ * the meantime repeats the save.
13
+ */
14
+ author?: GithubCommitAuthor;
15
+ }
16
+ export interface GithubCommitAuthor {
17
+ name: string;
18
+ email: string;
6
19
  }
7
20
  export declare class GithubApi extends GithubSource implements HistoryApi, CommitApi, SyncApi {
8
21
  #private;