inlaycms 0.0.0-stage → 0.1.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 (364) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +462 -2
  3. package/assets/admin/admin.css +2 -0
  4. package/assets/admin/admin.js +1 -0
  5. package/assets/admin/editor.js +125 -0
  6. package/dist/adapters/admin/activity.d.ts +17 -0
  7. package/dist/adapters/admin/activity.js +59 -0
  8. package/dist/adapters/admin/assets.d.ts +14 -0
  9. package/dist/adapters/admin/assets.js +64 -0
  10. package/dist/adapters/admin/attention.d.ts +15 -0
  11. package/dist/adapters/admin/attention.js +34 -0
  12. package/dist/adapters/admin/context.d.ts +40 -0
  13. package/dist/adapters/admin/context.js +142 -0
  14. package/dist/adapters/admin/form/walk.d.ts +61 -0
  15. package/dist/adapters/admin/form/walk.js +565 -0
  16. package/dist/adapters/admin/pages.d.ts +38 -0
  17. package/dist/adapters/admin/pages.js +66 -0
  18. package/dist/adapters/admin/publish.d.ts +12 -0
  19. package/dist/adapters/admin/publish.js +195 -0
  20. package/dist/adapters/admin/routes.d.ts +47 -0
  21. package/dist/adapters/admin/routes.js +255 -0
  22. package/dist/adapters/admin/screens/backups.d.ts +11 -0
  23. package/dist/adapters/admin/screens/backups.js +223 -0
  24. package/dist/adapters/admin/screens/dashboard.d.ts +4 -0
  25. package/dist/adapters/admin/screens/dashboard.js +160 -0
  26. package/dist/adapters/admin/screens/editor.d.ts +67 -0
  27. package/dist/adapters/admin/screens/editor.js +416 -0
  28. package/dist/adapters/admin/screens/history.d.ts +4 -0
  29. package/dist/adapters/admin/screens/history.js +105 -0
  30. package/dist/adapters/admin/screens/lists.d.ts +4 -0
  31. package/dist/adapters/admin/screens/lists.js +297 -0
  32. package/dist/adapters/admin/screens/media.d.ts +20 -0
  33. package/dist/adapters/admin/screens/media.js +186 -0
  34. package/dist/adapters/admin/screens/pickers.d.ts +29 -0
  35. package/dist/adapters/admin/screens/pickers.js +134 -0
  36. package/dist/adapters/admin/screens/preview-pane.d.ts +10 -0
  37. package/dist/adapters/admin/screens/preview-pane.js +74 -0
  38. package/dist/adapters/admin/screens/redirects.d.ts +4 -0
  39. package/dist/adapters/admin/screens/redirects.js +137 -0
  40. package/dist/adapters/admin/screens/releases.d.ts +7 -0
  41. package/dist/adapters/admin/screens/releases.js +287 -0
  42. package/dist/adapters/admin/screens/search.d.ts +22 -0
  43. package/dist/adapters/admin/screens/search.js +113 -0
  44. package/dist/adapters/admin/screens/security.d.ts +4 -0
  45. package/dist/adapters/admin/screens/security.js +85 -0
  46. package/dist/adapters/admin/screens/users.d.ts +4 -0
  47. package/dist/adapters/admin/screens/users.js +330 -0
  48. package/dist/adapters/admin/theme.d.ts +1 -0
  49. package/dist/adapters/admin/theme.js +1 -0
  50. package/dist/adapters/admin/translations.d.ts +16 -0
  51. package/dist/adapters/admin/translations.js +23 -0
  52. package/dist/adapters/admin/upload.d.ts +8 -0
  53. package/dist/adapters/admin/upload.js +116 -0
  54. package/dist/adapters/admin/views/data-table.d.ts +82 -0
  55. package/dist/adapters/admin/views/data-table.js +117 -0
  56. package/dist/adapters/admin/views/icons.d.ts +48 -0
  57. package/dist/adapters/admin/views/icons.js +47 -0
  58. package/dist/adapters/admin/views/layout.d.ts +51 -0
  59. package/dist/adapters/admin/views/layout.js +145 -0
  60. package/dist/adapters/admin/views/sheet.d.ts +15 -0
  61. package/dist/adapters/admin/views/sheet.js +6 -0
  62. package/dist/adapters/admin/views/status.d.ts +32 -0
  63. package/dist/adapters/admin/views/status.js +74 -0
  64. package/dist/adapters/auth/handler.d.ts +10 -0
  65. package/dist/adapters/auth/handler.js +63 -0
  66. package/dist/adapters/auth/request.d.ts +8 -0
  67. package/dist/adapters/auth/request.js +14 -0
  68. package/dist/adapters/cli/bin.d.ts +2 -0
  69. package/dist/adapters/cli/bin.js +42 -0
  70. package/dist/adapters/cli/main.d.ts +7 -0
  71. package/dist/adapters/cli/main.js +982 -0
  72. package/dist/adapters/cli/remote.d.ts +52 -0
  73. package/dist/adapters/cli/remote.js +161 -0
  74. package/dist/adapters/mcp/agent-refs.d.ts +9 -0
  75. package/dist/adapters/mcp/agent-refs.js +25 -0
  76. package/dist/adapters/mcp/documents.d.ts +15 -0
  77. package/dist/adapters/mcp/documents.js +26 -0
  78. package/dist/adapters/mcp/fetch-url.d.ts +19 -0
  79. package/dist/adapters/mcp/fetch-url.js +244 -0
  80. package/dist/adapters/mcp/request-state.d.ts +15 -0
  81. package/dist/adapters/mcp/request-state.js +38 -0
  82. package/dist/adapters/mcp/results.d.ts +20 -0
  83. package/dist/adapters/mcp/results.js +61 -0
  84. package/dist/adapters/mcp/route.d.ts +34 -0
  85. package/dist/adapters/mcp/route.js +52 -0
  86. package/dist/adapters/mcp/server.d.ts +44 -0
  87. package/dist/adapters/mcp/server.js +49 -0
  88. package/dist/adapters/mcp/tools/history.d.ts +5 -0
  89. package/dist/adapters/mcp/tools/history.js +84 -0
  90. package/dist/adapters/mcp/tools/media.d.ts +5 -0
  91. package/dist/adapters/mcp/tools/media.js +102 -0
  92. package/dist/adapters/mcp/tools/publish.d.ts +5 -0
  93. package/dist/adapters/mcp/tools/publish.js +157 -0
  94. package/dist/adapters/mcp/tools/read.d.ts +5 -0
  95. package/dist/adapters/mcp/tools/read.js +279 -0
  96. package/dist/adapters/mcp/tools/redirects.d.ts +5 -0
  97. package/dist/adapters/mcp/tools/redirects.js +74 -0
  98. package/dist/adapters/mcp/tools/write.d.ts +5 -0
  99. package/dist/adapters/mcp/tools/write.js +304 -0
  100. package/dist/adapters/site/backup-schedule.d.ts +8 -0
  101. package/dist/adapters/site/backup-schedule.js +31 -0
  102. package/dist/adapters/site/cache.d.ts +29 -0
  103. package/dist/adapters/site/cache.js +63 -0
  104. package/dist/adapters/site/context.d.ts +29 -0
  105. package/dist/adapters/site/context.js +278 -0
  106. package/dist/adapters/site/head.d.ts +23 -0
  107. package/dist/adapters/site/head.js +44 -0
  108. package/dist/adapters/site/limiter.d.ts +17 -0
  109. package/dist/adapters/site/limiter.js +39 -0
  110. package/dist/adapters/site/lock.d.ts +30 -0
  111. package/dist/adapters/site/lock.js +143 -0
  112. package/dist/adapters/site/media-routes.d.ts +4 -0
  113. package/dist/adapters/site/media-routes.js +55 -0
  114. package/dist/adapters/site/plugin.d.ts +122 -0
  115. package/dist/adapters/site/plugin.js +436 -0
  116. package/dist/adapters/site/preview.d.ts +36 -0
  117. package/dist/adapters/site/preview.js +82 -0
  118. package/dist/adapters/site/public.d.ts +6 -0
  119. package/dist/adapters/site/public.js +87 -0
  120. package/dist/adapters/site/render.d.ts +45 -0
  121. package/dist/adapters/site/render.js +191 -0
  122. package/dist/adapters/site/routes.d.ts +17 -0
  123. package/dist/adapters/site/routes.js +125 -0
  124. package/dist/adapters/site/sitemap.d.ts +10 -0
  125. package/dist/adapters/site/sitemap.js +10 -0
  126. package/dist/adapters/web.d.ts +22 -0
  127. package/dist/adapters/web.js +75 -0
  128. package/dist/config.d.ts +21 -0
  129. package/dist/config.js +58 -0
  130. package/dist/core/agent/format.d.ts +62 -0
  131. package/dist/core/agent/format.js +211 -0
  132. package/dist/core/agent/schema.d.ts +6 -0
  133. package/dist/core/agent/schema.js +86 -0
  134. package/dist/core/archive.d.ts +12 -0
  135. package/dist/core/archive.js +72 -0
  136. package/dist/core/auth/auth.d.ts +4911 -0
  137. package/dist/core/auth/auth.js +61 -0
  138. package/dist/core/auth/roles.d.ts +10 -0
  139. package/dist/core/auth/roles.js +38 -0
  140. package/dist/core/auth/service.d.ts +118 -0
  141. package/dist/core/auth/service.js +424 -0
  142. package/dist/core/auth/upload-token.d.ts +8 -0
  143. package/dist/core/auth/upload-token.js +27 -0
  144. package/dist/core/backup/backup.d.ts +28 -0
  145. package/dist/core/backup/backup.js +126 -0
  146. package/dist/core/backup/restore.d.ts +41 -0
  147. package/dist/core/backup/restore.js +264 -0
  148. package/dist/core/backup/schedule.d.ts +12 -0
  149. package/dist/core/backup/schedule.js +29 -0
  150. package/dist/core/boot.d.ts +63 -0
  151. package/dist/core/boot.js +141 -0
  152. package/dist/core/check.d.ts +32 -0
  153. package/dist/core/check.js +111 -0
  154. package/dist/core/content/activity.d.ts +8 -0
  155. package/dist/core/content/activity.js +101 -0
  156. package/dist/core/content/delete.d.ts +5 -0
  157. package/dist/core/content/delete.js +100 -0
  158. package/dist/core/content/diff.d.ts +6 -0
  159. package/dist/core/content/diff.js +129 -0
  160. package/dist/core/content/dry-run.d.ts +24 -0
  161. package/dist/core/content/dry-run.js +69 -0
  162. package/dist/core/content/gaps.d.ts +25 -0
  163. package/dist/core/content/gaps.js +50 -0
  164. package/dist/core/content/hidden.d.ts +33 -0
  165. package/dist/core/content/hidden.js +103 -0
  166. package/dist/core/content/history.d.ts +15 -0
  167. package/dist/core/content/history.js +62 -0
  168. package/dist/core/content/patch.d.ts +40 -0
  169. package/dist/core/content/patch.js +287 -0
  170. package/dist/core/content/path.d.ts +6 -0
  171. package/dist/core/content/path.js +38 -0
  172. package/dist/core/content/publish.d.ts +26 -0
  173. package/dist/core/content/publish.js +211 -0
  174. package/dist/core/content/read.d.ts +99 -0
  175. package/dist/core/content/read.js +141 -0
  176. package/dist/core/content/reader.d.ts +37 -0
  177. package/dist/core/content/reader.js +195 -0
  178. package/dist/core/content/refs.d.ts +44 -0
  179. package/dist/core/content/refs.js +161 -0
  180. package/dist/core/content/release-migrations.d.ts +12 -0
  181. package/dist/core/content/release-migrations.js +154 -0
  182. package/dist/core/content/save.d.ts +25 -0
  183. package/dist/core/content/save.js +87 -0
  184. package/dist/core/content/schema.d.ts +22 -0
  185. package/dist/core/content/schema.js +127 -0
  186. package/dist/core/content/search.d.ts +8 -0
  187. package/dist/core/content/search.js +89 -0
  188. package/dist/core/content/shipped-input.d.ts +39 -0
  189. package/dist/core/content/shipped-input.js +221 -0
  190. package/dist/core/content/shipped.d.ts +112 -0
  191. package/dist/core/content/shipped.js +437 -0
  192. package/dist/core/content/slug.d.ts +23 -0
  193. package/dist/core/content/slug.js +182 -0
  194. package/dist/core/content/stats.d.ts +11 -0
  195. package/dist/core/content/stats.js +30 -0
  196. package/dist/core/content/translate.d.ts +3 -0
  197. package/dist/core/content/translate.js +68 -0
  198. package/dist/core/content/usages.d.ts +13 -0
  199. package/dist/core/content/usages.js +70 -0
  200. package/dist/core/content/validate.d.ts +21 -0
  201. package/dist/core/content/validate.js +124 -0
  202. package/dist/core/content/write.d.ts +10 -0
  203. package/dist/core/content/write.js +93 -0
  204. package/dist/core/core.d.ts +227 -0
  205. package/dist/core/core.js +251 -0
  206. package/dist/core/db/connection.d.ts +6 -0
  207. package/dist/core/db/connection.js +12 -0
  208. package/dist/core/db/migrate.d.ts +9 -0
  209. package/dist/core/db/migrate.js +42 -0
  210. package/dist/core/db/migrations/0001_content.d.ts +2 -0
  211. package/dist/core/db/migrations/0001_content.js +69 -0
  212. package/dist/core/db/migrations/0002_media.d.ts +2 -0
  213. package/dist/core/db/migrations/0002_media.js +26 -0
  214. package/dist/core/db/migrations/0003_redirects.d.ts +2 -0
  215. package/dist/core/db/migrations/0003_redirects.js +19 -0
  216. package/dist/core/db/migrations/0004_token_cutoffs.d.ts +3 -0
  217. package/dist/core/db/migrations/0004_token_cutoffs.js +8 -0
  218. package/dist/core/db/migrations/0005_site_lock.d.ts +3 -0
  219. package/dist/core/db/migrations/0005_site_lock.js +10 -0
  220. package/dist/core/db/migrations/0006_releases.d.ts +3 -0
  221. package/dist/core/db/migrations/0006_releases.js +34 -0
  222. package/dist/core/db/schema.d.ts +155 -0
  223. package/dist/core/db/schema.js +1 -0
  224. package/dist/core/errors.d.ts +27 -0
  225. package/dist/core/errors.js +15 -0
  226. package/dist/core/export/export.d.ts +17 -0
  227. package/dist/core/export/export.js +185 -0
  228. package/dist/core/export/format.d.ts +241 -0
  229. package/dist/core/export/format.js +106 -0
  230. package/dist/core/export/import.d.ts +54 -0
  231. package/dist/core/export/import.js +180 -0
  232. package/dist/core/export/read.d.ts +16 -0
  233. package/dist/core/export/read.js +234 -0
  234. package/dist/core/export/replace.d.ts +17 -0
  235. package/dist/core/export/replace.js +36 -0
  236. package/dist/core/export/report.d.ts +55 -0
  237. package/dist/core/export/report.js +50 -0
  238. package/dist/core/export/schema.d.ts +8 -0
  239. package/dist/core/export/schema.js +47 -0
  240. package/dist/core/export/stage.d.ts +25 -0
  241. package/dist/core/export/stage.js +192 -0
  242. package/dist/core/fields/builtins.d.ts +70 -0
  243. package/dist/core/fields/builtins.js +335 -0
  244. package/dist/core/fields/define.d.ts +86 -0
  245. package/dist/core/fields/define.js +34 -0
  246. package/dist/core/fields/walk.d.ts +49 -0
  247. package/dist/core/fields/walk.js +270 -0
  248. package/dist/core/fields/widgets.d.ts +27 -0
  249. package/dist/core/fields/widgets.js +330 -0
  250. package/dist/core/fields/zod-internals.d.ts +29 -0
  251. package/dist/core/fields/zod-internals.js +28 -0
  252. package/dist/core/media/detect.d.ts +5 -0
  253. package/dist/core/media/detect.js +66 -0
  254. package/dist/core/media/labels.d.ts +6 -0
  255. package/dist/core/media/labels.js +17 -0
  256. package/dist/core/media/library.d.ts +45 -0
  257. package/dist/core/media/library.js +239 -0
  258. package/dist/core/media/store.d.ts +11 -0
  259. package/dist/core/media/store.js +49 -0
  260. package/dist/core/media/variants.d.ts +10 -0
  261. package/dist/core/media/variants.js +59 -0
  262. package/dist/core/messages/en.d.ts +1278 -0
  263. package/dist/core/messages/en.js +1287 -0
  264. package/dist/core/messages/index.d.ts +7 -0
  265. package/dist/core/messages/index.js +14 -0
  266. package/dist/core/preview.d.ts +16 -0
  267. package/dist/core/preview.js +42 -0
  268. package/dist/core/redirects/collapse.d.ts +68 -0
  269. package/dist/core/redirects/collapse.js +153 -0
  270. package/dist/core/redirects/csv.d.ts +15 -0
  271. package/dist/core/redirects/csv.js +68 -0
  272. package/dist/core/redirects/redirects.d.ts +58 -0
  273. package/dist/core/redirects/redirects.js +545 -0
  274. package/dist/core/registry/content.d.ts +26 -0
  275. package/dist/core/registry/content.js +9 -0
  276. package/dist/core/registry/define.d.ts +145 -0
  277. package/dist/core/registry/define.js +41 -0
  278. package/dist/core/registry/migration.d.ts +44 -0
  279. package/dist/core/registry/migration.js +4 -0
  280. package/dist/core/registry/registry.d.ts +18 -0
  281. package/dist/core/registry/registry.js +255 -0
  282. package/dist/core/registry/render.d.ts +98 -0
  283. package/dist/core/registry/render.js +1 -0
  284. package/dist/core/registry/route.d.ts +42 -0
  285. package/dist/core/registry/route.js +3 -0
  286. package/dist/core/release/bundle.d.ts +21 -0
  287. package/dist/core/release/bundle.js +252 -0
  288. package/dist/core/release/keys.d.ts +11 -0
  289. package/dist/core/release/keys.js +60 -0
  290. package/dist/core/release/manifest.d.ts +103 -0
  291. package/dist/core/release/manifest.js +138 -0
  292. package/dist/core/release/pack.d.ts +20 -0
  293. package/dist/core/release/pack.js +97 -0
  294. package/dist/core/release/pointer.d.ts +19 -0
  295. package/dist/core/release/pointer.js +53 -0
  296. package/dist/core/release/read.d.ts +59 -0
  297. package/dist/core/release/read.js +256 -0
  298. package/dist/core/report.d.ts +31 -0
  299. package/dist/core/report.js +37 -0
  300. package/dist/core/richtext/html.d.ts +15 -0
  301. package/dist/core/richtext/html.js +81 -0
  302. package/dist/core/richtext/markdown.d.ts +19 -0
  303. package/dist/core/richtext/markdown.js +951 -0
  304. package/dist/core/richtext/schema.d.ts +98 -0
  305. package/dist/core/richtext/schema.js +275 -0
  306. package/dist/core/site/live.d.ts +56 -0
  307. package/dist/core/site/live.js +145 -0
  308. package/dist/core/site/paths.d.ts +15 -0
  309. package/dist/core/site/paths.js +64 -0
  310. package/dist/core/site/resolve.d.ts +9 -0
  311. package/dist/core/site/resolve.js +202 -0
  312. package/dist/core/site/sitemap.d.ts +11 -0
  313. package/dist/core/site/sitemap.js +24 -0
  314. package/dist/core/site-lock/site-lock.d.ts +21 -0
  315. package/dist/core/site-lock/site-lock.js +65 -0
  316. package/dist/core/site-lock/token.d.ts +7 -0
  317. package/dist/core/site-lock/token.js +24 -0
  318. package/dist/core/theme.d.ts +22 -0
  319. package/dist/core/theme.js +133 -0
  320. package/dist/core/types.d.ts +253 -0
  321. package/dist/core/types.js +1 -0
  322. package/dist/core/version.d.ts +1 -0
  323. package/dist/core/version.js +5 -0
  324. package/dist/host/activate.d.ts +53 -0
  325. package/dist/host/activate.js +162 -0
  326. package/dist/host/app.d.ts +46 -0
  327. package/dist/host/app.js +129 -0
  328. package/dist/host/bin.d.ts +5 -0
  329. package/dist/host/bin.js +8 -0
  330. package/dist/host/config.d.ts +36 -0
  331. package/dist/host/config.js +152 -0
  332. package/dist/host/dev.d.ts +10 -0
  333. package/dist/host/dev.js +293 -0
  334. package/dist/host/diff.d.ts +78 -0
  335. package/dist/host/diff.js +346 -0
  336. package/dist/host/hooks.d.ts +41 -0
  337. package/dist/host/hooks.js +49 -0
  338. package/dist/host/ipc.d.ts +123 -0
  339. package/dist/host/ipc.js +61 -0
  340. package/dist/host/preview-proxy.d.ts +24 -0
  341. package/dist/host/preview-proxy.js +154 -0
  342. package/dist/host/preview-worker.d.ts +42 -0
  343. package/dist/host/preview-worker.js +242 -0
  344. package/dist/host/primary.d.ts +38 -0
  345. package/dist/host/primary.js +357 -0
  346. package/dist/host/push.d.ts +125 -0
  347. package/dist/host/push.js +420 -0
  348. package/dist/host/serve.d.ts +16 -0
  349. package/dist/host/serve.js +150 -0
  350. package/dist/host/store.d.ts +48 -0
  351. package/dist/host/store.js +109 -0
  352. package/dist/host/worker.d.ts +67 -0
  353. package/dist/host/worker.js +310 -0
  354. package/dist/index.d.ts +47 -0
  355. package/dist/index.js +32 -0
  356. package/dist/jsx/html.d.ts +16 -0
  357. package/dist/jsx/html.js +65 -0
  358. package/dist/jsx/jsx-dev-runtime.d.ts +4 -0
  359. package/dist/jsx/jsx-dev-runtime.js +5 -0
  360. package/dist/jsx/jsx-runtime.d.ts +17 -0
  361. package/dist/jsx/jsx-runtime.js +41 -0
  362. package/dist/site.d.ts +17 -0
  363. package/dist/site.js +14 -0
  364. package/package.json +111 -3
@@ -0,0 +1,3 @@
1
+ import type { CoreDeps, Ctx, DocumentView } from '../types.js';
2
+ /** Copies the default-locale document of `groupId` into `locale` as an unpublished draft. */
3
+ export declare function createTranslation(deps: CoreDeps, groupId: string, locale: string, ctx: Ctx): Promise<DocumentView>;
@@ -0,0 +1,68 @@
1
+ import { assertCan } from '../auth/roles.js';
2
+ import { InlayError } from '../errors.js';
3
+ import { getDocument, parseData, summaryQuery, toSummary } from './read.js';
4
+ import { syncRefs } from './refs.js';
5
+ import { uniqueSlug } from './slug.js';
6
+ import { insertRevision } from './write.js';
7
+ import { withTransaction } from './dry-run.js';
8
+ /** Copies the default-locale document of `groupId` into `locale` as an unpublished draft. */
9
+ export async function createTranslation(deps, groupId, locale, ctx) {
10
+ assertCan(ctx, 'content.write');
11
+ const { registry } = deps;
12
+ if (locale === registry.defaultLocale)
13
+ throw new InlayError('invalid_operation', 'error.translateDefault', { locale });
14
+ if (!registry.locales.includes(locale)) {
15
+ const locales = registry.locales.filter((l) => l !== registry.defaultLocale).join(', ');
16
+ throw new InlayError('invalid_operation', 'error.translateLocale', { locale, locales });
17
+ }
18
+ const id = crypto.randomUUID();
19
+ await withTransaction(deps, async (tx) => {
20
+ const trx = tx.db;
21
+ const source = await summaryQuery(tx)
22
+ .where('documents.group_id', '=', groupId)
23
+ .where('documents.locale', '=', registry.defaultLocale)
24
+ .executeTakeFirst();
25
+ if (!source)
26
+ throw new InlayError('not_found', 'error.notFound', { name: groupId });
27
+ if (source.deleted_at !== null) {
28
+ throw new InlayError('invalid_operation', 'error.translateDeleted', { title: toSummary(tx, source).title });
29
+ }
30
+ const existing = await trx
31
+ .selectFrom('documents')
32
+ .select('id')
33
+ .where('group_id', '=', groupId)
34
+ .where('locale', '=', locale)
35
+ .executeTakeFirst();
36
+ if (existing)
37
+ throw new InlayError('invalid_operation', 'error.translationExists', { locale });
38
+ const data = parseData(tx, source.type, source.head_data);
39
+ const def = registry.getType(source.type);
40
+ if (def.kind === 'collection' && def.route !== null && data.slug !== undefined) {
41
+ data.slug = await uniqueSlug(tx, source.type, locale, data.slug);
42
+ }
43
+ const at = deps.now().toISOString();
44
+ await trx
45
+ .insertInto('documents')
46
+ .values({
47
+ id,
48
+ kind: source.kind,
49
+ type: source.type,
50
+ group_id: groupId,
51
+ locale,
52
+ head_rev: null,
53
+ published_rev: null,
54
+ head_slug: data.slug ?? null,
55
+ published_slug: null,
56
+ head_path: data.path ?? null,
57
+ published_path: null,
58
+ deleted_at: null,
59
+ created_at: at,
60
+ key: source.key,
61
+ })
62
+ .execute();
63
+ const revId = await insertRevision(tx, id, data, ctx, null, at);
64
+ await trx.updateTable('documents').set({ head_rev: revId }).where('id', '=', id).execute();
65
+ await syncRefs(tx, id);
66
+ });
67
+ return (await getDocument(deps, id));
68
+ }
@@ -0,0 +1,13 @@
1
+ import type { ContentRef, CoreDeps, DocumentSummary, Usage } from '../types.js';
2
+ /**
3
+ * Non-deleted documents whose head or published revision references `target`.
4
+ * A hidden document target has no usages.
5
+ * For a document target, the other locales of the same entry are not usages.
6
+ * Inside a transaction pass `{ ...deps, db: trx }`.
7
+ */
8
+ export declare function findUsages(deps: CoreDeps, target: ContentRef): Promise<Usage[]>;
9
+ /**
10
+ * Visible, non-deleted documents whose head or published revision links to content that
11
+ * has been deleted. Links to other languages of the same entry are not counted.
12
+ */
13
+ export declare function brokenReferences(deps: CoreDeps): Promise<DocumentSummary[]>;
@@ -0,0 +1,70 @@
1
+ import { sql } from 'kysely';
2
+ import { summaryQuery, toSummary, whereVisible } from './read.js';
3
+ /**
4
+ * Non-deleted documents whose head or published revision references `target`.
5
+ * A hidden document target has no usages.
6
+ * For a document target, the other locales of the same entry are not usages.
7
+ * Inside a transaction pass `{ ...deps, db: trx }`.
8
+ */
9
+ export async function findUsages(deps, target) {
10
+ if (target.kind === 'document') {
11
+ const visible = await deps.db
12
+ .selectFrom('documents')
13
+ .select('id')
14
+ .where('group_id', '=', target.id)
15
+ .$call(whereVisible(deps.registry))
16
+ .executeTakeFirst();
17
+ if (!visible)
18
+ return [];
19
+ }
20
+ const refRows = await deps.db
21
+ .selectFrom('refs')
22
+ .select(['from_document_id', 'from_revision_id'])
23
+ .where('to_kind', '=', target.kind)
24
+ .where('to_id', '=', target.id)
25
+ .execute();
26
+ if (refRows.length === 0)
27
+ return [];
28
+ const ids = [...new Set(refRows.map((r) => r.from_document_id))];
29
+ let query = summaryQuery(deps).where('documents.id', 'in', ids).where('documents.deleted_at', 'is', null);
30
+ if (target.kind === 'document')
31
+ query = query.where('documents.group_id', '!=', target.id);
32
+ const docs = await query.orderBy('documents.head_rev', 'asc').execute();
33
+ return docs.flatMap((doc) => {
34
+ const revs = new Set(refRows.filter((r) => r.from_document_id === doc.id).map((r) => r.from_revision_id));
35
+ const inDraft = revs.has(doc.head_rev);
36
+ const inPublished = doc.published_rev !== null && revs.has(doc.published_rev);
37
+ if (!inDraft && !inPublished)
38
+ return [];
39
+ return [
40
+ {
41
+ documentId: doc.id,
42
+ groupId: doc.group_id,
43
+ type: doc.type,
44
+ locale: doc.locale,
45
+ title: toSummary(deps, doc).title,
46
+ in: inDraft && inPublished ? 'draft-and-published' : inDraft ? 'draft' : 'published',
47
+ },
48
+ ];
49
+ });
50
+ }
51
+ /**
52
+ * Visible, non-deleted documents whose head or published revision links to content that
53
+ * has been deleted. Links to other languages of the same entry are not counted.
54
+ */
55
+ export async function brokenReferences(deps) {
56
+ const rows = await summaryQuery(deps)
57
+ .where('documents.deleted_at', 'is', null)
58
+ .where(sql `exists (
59
+ select 1 from refs
60
+ where refs.from_document_id = documents.id
61
+ and refs.to_kind = 'document'
62
+ and (refs.from_revision_id = documents.head_rev or refs.from_revision_id = documents.published_rev)
63
+ and refs.to_id != documents.group_id
64
+ and exists (select 1 from documents t where t.group_id = refs.to_id)
65
+ and not exists (select 1 from documents t where t.group_id = refs.to_id and t.deleted_at is null)
66
+ )`)
67
+ .orderBy('documents.id', 'asc')
68
+ .execute();
69
+ return rows.map((row) => toSummary(deps, row));
70
+ }
@@ -0,0 +1,21 @@
1
+ import { type MessageId } from '../messages/index.js';
2
+ import type { Registry } from '../registry/registry.js';
3
+ import type { ContentIssue, DocumentData, IssueCode, PathSegment } from '../types.js';
4
+ import { type Level } from './schema.js';
5
+ export type ValidationResult = {
6
+ ok: true;
7
+ data: DocumentData;
8
+ } | {
9
+ ok: false;
10
+ issues: ContentIssue[];
11
+ };
12
+ /** A plain-language issue for `path`, naming the field by its labels ("Hero → Headline is required."). */
13
+ export declare function contentIssue(path: PathSegment[], labels: string[], code: IssueCode, messageId: MessageId, params?: Record<string, string | number>): ContentIssue;
14
+ /** `first`, then each issue of `more` that isn't at or under the path of an issue already listed (general ones aside). */
15
+ export declare function mergeIssues(first: ContentIssue[], more: ContentIssue[]): ContentIssue[];
16
+ /**
17
+ * Validates `data` against `type` at `level`. A `null` or `''` value for a key
18
+ * in fields or slot data counts as the key being absent. On success returns
19
+ * the parsed data (defaults filled, unknown and blank keys stripped).
20
+ */
21
+ export declare function validateContent(registry: Registry, type: string, data: unknown, level: Level): ValidationResult;
@@ -0,0 +1,124 @@
1
+ import { DATE_CHECK, DATETIME_CHECK, NON_BLANK } from '../fields/builtins.js';
2
+ import { isRecord } from '../fields/zod-internals.js';
3
+ import { t } from '../messages/index.js';
4
+ import { docLabels, documentSchema } from './schema.js';
5
+ function valueAt(data, path) {
6
+ let current = data;
7
+ for (const segment of path) {
8
+ if (typeof current !== 'object' || current === null)
9
+ return undefined;
10
+ current = current[segment];
11
+ }
12
+ return current;
13
+ }
14
+ /** `value` with every object key whose value is `null` or `''` removed, at any depth. List elements are kept. */
15
+ function withoutBlanks(value) {
16
+ if (Array.isArray(value))
17
+ return value.map(withoutBlanks);
18
+ if (!isRecord(value))
19
+ return value;
20
+ const out = {};
21
+ for (const [key, child] of Object.entries(value)) {
22
+ if (child !== null && child !== '')
23
+ out[key] = withoutBlanks(child);
24
+ }
25
+ return out;
26
+ }
27
+ /** The document with `null` and `''` in its fields and slot data treated as absent. */
28
+ function blanksRemoved(data) {
29
+ if (!isRecord(data))
30
+ return data;
31
+ const out = { ...data };
32
+ if (isRecord(out.fields))
33
+ out.fields = withoutBlanks(out.fields);
34
+ if (isRecord(out.slots)) {
35
+ const slots = {};
36
+ for (const [key, slot] of Object.entries(out.slots)) {
37
+ slots[key] = isRecord(slot) && isRecord(slot.data) ? { ...slot, data: withoutBlanks(slot.data) } : slot;
38
+ }
39
+ out.slots = slots;
40
+ }
41
+ return out;
42
+ }
43
+ const isRequired = (issue, value) => value === undefined || (issue.code === 'custom' && issue.params?.check === NON_BLANK);
44
+ function bound(value) {
45
+ return typeof value === 'number' || typeof value === 'string' ? value : String(value);
46
+ }
47
+ /** The message for a value of the wrong type, by the type the field expects. */
48
+ const EXPECTED = {
49
+ string: 'issue.expectedText',
50
+ number: 'issue.expectedNumber',
51
+ boolean: 'issue.expectedBoolean',
52
+ array: 'issue.expectedList',
53
+ };
54
+ function mapIssue(issue, value) {
55
+ if (issue.code === 'too_big') {
56
+ const max = bound(issue.maximum);
57
+ if (issue.origin === 'string')
58
+ return { code: 'too_long', messageId: 'issue.tooLong', params: { max } };
59
+ if (issue.origin === 'array')
60
+ return { code: 'too_many', messageId: 'issue.tooMany', params: { max } };
61
+ if (issue.origin === 'number' || issue.origin === 'bigint') {
62
+ return { code: 'out_of_range', messageId: 'issue.tooHigh', params: { max } };
63
+ }
64
+ }
65
+ if (isRequired(issue, value))
66
+ return { code: 'required', messageId: 'issue.required', params: {} };
67
+ if (issue.code === 'too_small') {
68
+ const min = bound(issue.minimum);
69
+ if (issue.origin === 'string')
70
+ return { code: 'too_short', messageId: 'issue.tooShort', params: { min } };
71
+ if (issue.origin === 'array')
72
+ return { code: 'too_few', messageId: 'issue.tooFew', params: { min } };
73
+ if (issue.origin === 'number' || issue.origin === 'bigint') {
74
+ return { code: 'out_of_range', messageId: 'issue.tooLow', params: { min } };
75
+ }
76
+ }
77
+ if (issue.code === 'custom' && issue.params?.check === DATE_CHECK) {
78
+ return { code: 'invalid', messageId: 'issue.date', params: {} };
79
+ }
80
+ if (issue.code === 'custom' && issue.params?.check === DATETIME_CHECK) {
81
+ return { code: 'invalid', messageId: 'issue.datetime', params: {} };
82
+ }
83
+ if (issue.code === 'invalid_type') {
84
+ const messageId = EXPECTED[issue.expected];
85
+ if (messageId)
86
+ return { code: 'invalid', messageId, params: {} };
87
+ }
88
+ if (issue.code === 'invalid_value' && issue.values.every((v) => typeof v === 'string')) {
89
+ return { code: 'invalid', messageId: 'issue.choice', params: { options: issue.values.join(', ') } };
90
+ }
91
+ return { code: 'invalid', messageId: 'issue.invalid', params: {} };
92
+ }
93
+ /** A plain-language issue for `path`, naming the field by its labels ("Hero → Headline is required."). */
94
+ export function contentIssue(path, labels, code, messageId, params = {}) {
95
+ const field = labels.length > 0 ? labels.join(' → ') : t('label.content');
96
+ return { path, labels, code, message: t(messageId, { ...params, field }) };
97
+ }
98
+ /** `first`, then each issue of `more` that isn't at or under the path of an issue already listed (general ones aside). */
99
+ export function mergeIssues(first, more) {
100
+ const out = [...first];
101
+ const covered = (path) => out.some((i) => i.path.length > 0 && i.path.every((segment, n) => path[n] === segment));
102
+ for (const issue of more)
103
+ if (!covered(issue.path))
104
+ out.push(issue);
105
+ return out;
106
+ }
107
+ /**
108
+ * Validates `data` against `type` at `level`. A `null` or `''` value for a key
109
+ * in fields or slot data counts as the key being absent. On success returns
110
+ * the parsed data (defaults filled, unknown and blank keys stripped).
111
+ */
112
+ export function validateContent(registry, type, data, level) {
113
+ const input = blanksRemoved(data);
114
+ const result = documentSchema(registry, type, level).safeParse(input);
115
+ if (result.success)
116
+ return { ok: true, data: result.data };
117
+ const issues = result.error.issues.map((issue) => {
118
+ const path = issue.path.filter((s) => typeof s !== 'symbol');
119
+ const labels = docLabels(registry, type, path) ?? path.map(String);
120
+ const { code, messageId, params } = mapIssue(issue, valueAt(input, path));
121
+ return contentIssue(path, labels, code, messageId, params);
122
+ });
123
+ return { ok: false, issues };
124
+ }
@@ -0,0 +1,10 @@
1
+ import { InlayError } from '../errors.js';
2
+ import type { ContentInput, ContentIssue, CoreDeps, Ctx, DocumentData, DocumentView } from '../types.js';
3
+ export declare function validationError(issues: ContentIssue[]): InlayError;
4
+ /** Appends a revision of `documentId` and returns its id. Inside a transaction pass `{ ...deps, db: trx }`. */
5
+ export declare function insertRevision(deps: CoreDeps, documentId: string, data: DocumentData, ctx: Ctx, message: string | null, at: string): Promise<number>;
6
+ /** Creates a new collection entry in the default locale as an unpublished draft. */
7
+ export declare function createEntry(deps: CoreDeps, type: string, input: ContentInput & {
8
+ locale?: string;
9
+ message?: string;
10
+ }, ctx: Ctx): Promise<DocumentView>;
@@ -0,0 +1,93 @@
1
+ import { assertCan } from '../auth/roles.js';
2
+ import { InlayError } from '../errors.js';
3
+ import { getDocument } from './read.js';
4
+ import { checkReferences, syncRefs } from './refs.js';
5
+ import { normalizeContent } from './schema.js';
6
+ import { pathIssue } from './path.js';
7
+ import { slugify, slugIssue, uniqueSlug } from './slug.js';
8
+ import { validateContent } from './validate.js';
9
+ import { withTransaction } from './dry-run.js';
10
+ export function validationError(issues) {
11
+ return new InlayError('validation', 'error.validation', {}, { issues });
12
+ }
13
+ /** Appends a revision of `documentId` and returns its id. Inside a transaction pass `{ ...deps, db: trx }`. */
14
+ export async function insertRevision(deps, documentId, data, ctx, message, at) {
15
+ const rev = await deps.db
16
+ .insertInto('revisions')
17
+ .values({
18
+ document_id: documentId,
19
+ data: JSON.stringify(data),
20
+ author_id: ctx.actor.id,
21
+ author_name: ctx.actor.name,
22
+ source: ctx.source,
23
+ message,
24
+ created_at: at,
25
+ release_id: ctx.releaseId ?? null,
26
+ })
27
+ .returning('id')
28
+ .executeTakeFirstOrThrow();
29
+ return rev.id;
30
+ }
31
+ /** Creates a new collection entry in the default locale as an unpublished draft. */
32
+ export async function createEntry(deps, type, input, ctx) {
33
+ assertCan(ctx, 'content.write');
34
+ const { registry } = deps;
35
+ const def = registry.getType(type);
36
+ if (def.kind !== 'collection') {
37
+ throw new InlayError('invalid_operation', 'error.notCollection', { name: def.label });
38
+ }
39
+ const locale = input.locale ?? registry.defaultLocale;
40
+ if (locale !== registry.defaultLocale) {
41
+ throw new InlayError('invalid_operation', 'error.createLocale', { locale: registry.defaultLocale });
42
+ }
43
+ const validated = validateContent(registry, type, normalizeContent(registry, type, input), 'draft');
44
+ if (!validated.ok)
45
+ throw validationError(validated.issues);
46
+ const data = validated.data;
47
+ const id = crypto.randomUUID();
48
+ await withTransaction(deps, async (tx) => {
49
+ const trx = tx.db;
50
+ const issues = await checkReferences(tx, type, data);
51
+ if (def.route !== null) {
52
+ if (data.slug !== undefined) {
53
+ const clash = await slugIssue(tx, type, locale, data.slug);
54
+ if (clash)
55
+ issues.push(clash);
56
+ }
57
+ else {
58
+ const title = data.fields[def.titleField];
59
+ data.slug = await uniqueSlug(tx, type, locale, slugify(typeof title === 'string' ? title : ''));
60
+ }
61
+ }
62
+ if (data.path !== undefined) {
63
+ const clash = await pathIssue(tx, type, locale, data.path);
64
+ if (clash)
65
+ issues.push(clash);
66
+ }
67
+ if (issues.length > 0)
68
+ throw validationError(issues);
69
+ const at = deps.now().toISOString();
70
+ await trx
71
+ .insertInto('documents')
72
+ .values({
73
+ id,
74
+ kind: 'entry',
75
+ type,
76
+ group_id: crypto.randomUUID(),
77
+ locale,
78
+ head_rev: null,
79
+ published_rev: null,
80
+ head_slug: data.slug ?? null,
81
+ published_slug: null,
82
+ head_path: data.path ?? null,
83
+ published_path: null,
84
+ deleted_at: null,
85
+ created_at: at,
86
+ })
87
+ .execute();
88
+ const revId = await insertRevision(tx, id, data, ctx, input.message ?? null, at);
89
+ await trx.updateTable('documents').set({ head_rev: revId }).where('id', '=', id).execute();
90
+ await syncRefs(tx, id);
91
+ });
92
+ return (await getDocument(deps, id));
93
+ }
@@ -0,0 +1,227 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { type PublishResult } from './content/publish.js';
3
+ import { type ShippedItem, type ShippedReport } from './content/shipped.js';
4
+ import { type PatchOp } from './content/patch.js';
5
+ import { type SaveResult } from './content/save.js';
6
+ import { type Gap, type GapFilter, type GapSummary } from './content/gaps.js';
7
+ import { type HiddenContent, type HiddenDocuments } from './content/hidden.js';
8
+ import { type BackupInfo } from './backup/backup.js';
9
+ import { type ExportSummary } from './export/export.js';
10
+ import { type ImportResult } from './export/import.js';
11
+ import type { ImportReport } from './export/report.js';
12
+ import type { Database } from './db/schema.js';
13
+ import { type VariantFormat } from './media/variants.js';
14
+ import type { SiteDefinition } from './registry/define.js';
15
+ import type { ReleaseMigration } from './registry/migration.js';
16
+ import { type Registry } from './registry/registry.js';
17
+ import { type SiteLockStatus } from './site-lock/site-lock.js';
18
+ import { type SitemapEntry } from './site/sitemap.js';
19
+ import type { Activity, ContentInput, Ctx, DocumentData, DocumentSummary, DocumentView, ContentRef, Usage, DiffEntry, RevisionMeta, UploadLimits, MediaInfo, MediaStatus, LiveDocument, LiveState, RouteMatch, Redirect, RedirectInput } from './types.js';
20
+ export type { PatchOp, PublishResult, SaveResult, ShippedItem, ShippedReport };
21
+ export interface Core {
22
+ registry: Registry;
23
+ getDocument(id: string, opts?: {
24
+ state?: 'head' | 'published';
25
+ }): Promise<DocumentView | null>;
26
+ findSingleton(type: string, locale?: string): Promise<DocumentSummary | null>;
27
+ findTranslation(groupId: string, locale: string): Promise<DocumentSummary | null>;
28
+ listEntries(type: string, opts?: {
29
+ locale?: string;
30
+ includeDeleted?: boolean;
31
+ }): Promise<DocumentSummary[]>;
32
+ createEntry(type: string, input: ContentInput & {
33
+ locale?: string;
34
+ message?: string;
35
+ }, ctx: Ctx): Promise<DocumentView>;
36
+ saveDraft(documentId: string, input: {
37
+ baseRevisionId: number;
38
+ data: DocumentData;
39
+ message?: string;
40
+ }, ctx: Ctx): Promise<SaveResult>;
41
+ patchDraft(documentId: string, input: {
42
+ baseRevisionId: number;
43
+ ops: PatchOp[];
44
+ message?: string;
45
+ }, ctx: Ctx): Promise<SaveResult>;
46
+ findEntry(type: string, slug: string, locale?: string): Promise<DocumentSummary | null>;
47
+ searchEntries(type: string, query: string, opts?: {
48
+ locale?: string;
49
+ limit?: number;
50
+ }): Promise<Array<DocumentSummary & {
51
+ snippet: string;
52
+ }>>;
53
+ publish(documentIds: string[], ctx: Ctx, opts?: {
54
+ message?: string;
55
+ expect?: Record<string, number>;
56
+ dryRun?: boolean;
57
+ }): Promise<PublishResult>;
58
+ unpublish(documentIds: string[], ctx: Ctx, opts?: {
59
+ dryRun?: boolean;
60
+ }): Promise<PublishResult>;
61
+ describeChanges(documentIds: string[]): Promise<Array<{
62
+ document: DocumentSummary;
63
+ isNew: boolean;
64
+ lines: string[];
65
+ }>>;
66
+ listPendingChanges(): Promise<DocumentSummary[]>;
67
+ /** The latest edits and publishes, newest first (`limit` 20 by default, 1 to 100). */
68
+ recentActivity(opts?: {
69
+ limit?: number;
70
+ }): Promise<Activity[]>;
71
+ /**
72
+ * Creates or replaces documents from the site's shipped content by edition (spec §6.3).
73
+ * `validateAll` also checks shipped documents at editions already applied.
74
+ */
75
+ applyShippedContent(opts?: {
76
+ dryRun?: boolean;
77
+ validateAll?: boolean;
78
+ }): Promise<ShippedReport>;
79
+ /**
80
+ * Runs the release's migration functions it hasn't run yet, in order, in one transaction (spec §8.3).
81
+ * A throw rolls all of them back. Returns the names run.
82
+ */
83
+ runReleaseMigrations(releaseId: string, migrations: readonly ReleaseMigration[]): Promise<string[]>;
84
+ createTranslation(groupId: string, locale: string, ctx: Ctx): Promise<DocumentView>;
85
+ findUsages(target: ContentRef): Promise<Usage[]>;
86
+ /** Per collection: visible entries in the default language, and how many changed at or after `changedSince`. */
87
+ countEntries(opts?: {
88
+ changedSince?: string;
89
+ }): Promise<Record<string, {
90
+ total: number;
91
+ changed: number;
92
+ }>>;
93
+ mediaStats(): Promise<{
94
+ count: number;
95
+ totalBytes: number;
96
+ imagesWithoutAlt: number;
97
+ }>;
98
+ /** Documents that link to deleted content. */
99
+ brokenReferences(): Promise<DocumentSummary[]>;
100
+ listGaps(opts?: GapFilter): Promise<Gap[]>;
101
+ gapSummary(): Promise<GapSummary[]>;
102
+ /** Content the site no longer shows, with counts: documents of removed types and locales, unknown slots and fields. */
103
+ hiddenContent(): Promise<HiddenContent>;
104
+ /** Only the documents the site hides by type and by locale; cheap, as it reads no content. */
105
+ hiddenDocuments(): Promise<HiddenDocuments>;
106
+ deleteEntry(groupId: string, ctx: Ctx): Promise<void>;
107
+ restoreEntry(groupId: string, ctx: Ctx): Promise<DocumentView[]>;
108
+ listRevisions(documentId: string): Promise<RevisionMeta[]>;
109
+ getRevision(revisionId: number): Promise<{
110
+ meta: RevisionMeta;
111
+ documentId: string;
112
+ data: DocumentData;
113
+ } | null>;
114
+ diffRevisions(fromRevisionId: number | null, toRevisionId: number): Promise<DiffEntry[]>;
115
+ restoreRevision(documentId: string, revisionId: number, ctx: Ctx, opts?: {
116
+ message?: string;
117
+ }): Promise<SaveResult>;
118
+ addMedia(input: {
119
+ data: Uint8Array;
120
+ filename: string;
121
+ }, ctx: Ctx): Promise<{
122
+ media: MediaInfo;
123
+ reused: boolean;
124
+ }>;
125
+ getMedia(id: string): Promise<MediaInfo | null>;
126
+ listMedia(opts?: {
127
+ kind?: 'image' | 'file';
128
+ search?: string;
129
+ limit?: number;
130
+ offset?: number;
131
+ }): Promise<MediaInfo[]>;
132
+ setMediaAlt(id: string, alt: string | null, ctx: Ctx): Promise<MediaInfo>;
133
+ lookupMedia(ids: string[]): Promise<Map<string, MediaStatus>>;
134
+ deleteMedia(id: string, ctx: Ctx): Promise<void>;
135
+ mediaFile(id: string): Promise<{
136
+ path: string;
137
+ mime: string;
138
+ filename: string;
139
+ size: number;
140
+ }>;
141
+ mediaVariant(id: string, opts: {
142
+ width: number;
143
+ format: VariantFormat;
144
+ }): Promise<{
145
+ path: string;
146
+ mime: string;
147
+ }>;
148
+ /** Re-creates missing refs of visible documents; returns how many documents it synced. */
149
+ repairRefs(): Promise<number>;
150
+ /** Entries whose slug gives them a page another path hides; editors can't save them until it changes. */
151
+ shadowedEntries(): Promise<Array<{
152
+ document: DocumentSummary;
153
+ slug: string;
154
+ path: string;
155
+ }>>;
156
+ liveDocuments(groupIds: string[], locale: string, opts?: {
157
+ state?: LiveState;
158
+ }): Promise<Map<string, LiveDocument>>;
159
+ liveSingleton(type: string, locale: string, opts?: {
160
+ state?: LiveState;
161
+ }): Promise<LiveDocument | null>;
162
+ liveEntries(collection: string, locale: string, opts?: {
163
+ state?: LiveState;
164
+ }): Promise<LiveDocument[]>;
165
+ liveAlternates(groupId: string, opts?: {
166
+ state?: LiveState;
167
+ }): Promise<Array<{
168
+ locale: string;
169
+ path: string;
170
+ fallback: boolean;
171
+ }>>;
172
+ resolvePath(rawPath: string, opts?: {
173
+ state?: LiveState;
174
+ }): Promise<RouteMatch>;
175
+ sitemapEntries(): Promise<SitemapEntry[]>;
176
+ siteLock(): Promise<SiteLockStatus>;
177
+ setSiteLock(enabled: boolean, ctx: Ctx): Promise<SiteLockStatus>;
178
+ setSitePassword(password: string, ctx: Ctx): Promise<SiteLockStatus>;
179
+ checkSitePassword(password: string): Promise<boolean>;
180
+ listRedirects(): Promise<Redirect[]>;
181
+ createRedirect(input: RedirectInput, ctx: Ctx): Promise<Redirect>;
182
+ deleteRedirect(id: number, ctx: Ctx): Promise<void>;
183
+ importRedirects(csv: string, ctx: Ctx): Promise<{
184
+ created: number;
185
+ updated: number;
186
+ }>;
187
+ /** The backups on disk, newest first. Owners only. */
188
+ listBackups(ctx: Ctx): Promise<BackupInfo[]>;
189
+ /** Makes a manual backup of the database and media. Owners only. */
190
+ backup(ctx: Ctx): Promise<BackupInfo>;
191
+ /**
192
+ * Makes a `scheduled` backup unless one was made in the last 24 hours; otherwise a `post-publish` backup if
193
+ * something was published after the newest backup. Then prunes each kind to the newest `keep`. Null when neither is due.
194
+ */
195
+ scheduledBackup(keep: number): Promise<BackupInfo | null>;
196
+ /** The listed backup called `name`; `not_found` for anything else. Owners only. */
197
+ backupFile(name: string, ctx: Ctx): Promise<BackupInfo>;
198
+ /** Writes an export archive of all content to `target`. Owners only. */
199
+ exportContent(target: string, ctx: Ctx): Promise<ExportSummary>;
200
+ /** What restoring the export at `archive` would do, worked out on a scratch copy. Changes nothing. Owners only. */
201
+ importDryRun(archive: string, ctx: Ctx): Promise<ImportReport>;
202
+ /**
203
+ * Replaces all content with the export at `archive`, after a `pre-import` backup. Skips damaged
204
+ * media files; refuses when the site can't be brought up to date on top of it. Owners only.
205
+ */
206
+ importContent(archive: string, ctx: Ctx): Promise<ImportResult>;
207
+ /** Calls `listener` after every committed change to the live site. Returns an unsubscribe function. */
208
+ onLiveChange(listener: () => void): () => void;
209
+ }
210
+ export interface CreateCoreOptions {
211
+ site: SiteDefinition;
212
+ db: Kysely<Database>;
213
+ now?: () => Date;
214
+ media?: string;
215
+ backups?: string;
216
+ uploads?: UploadLimits;
217
+ /** A loaded release's shipped files, by source as written in the site. */
218
+ shippedFiles?: ReadonlyMap<string, string>;
219
+ }
220
+ /** Builds the registry and binds the core functions. Does not migrate the database. */
221
+ export declare function createCore(opts: CreateCoreOptions): Core;
222
+ /**
223
+ * `core` with every write refused with `read_only` (`error.previewReadOnly`), for a release preview: content,
224
+ * media, redirects, the site lock, backups and imports. Reads, dry runs and exports still work. The database the
225
+ * core was booted on may have been written before this (boot applies shipped content); nothing is after.
226
+ */
227
+ export declare function readOnlyCore(core: Core): Core;