inlaycms 0.0.0-stage → 0.2.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 +469 -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,253 @@
1
+ import type { Kysely } from 'kysely';
2
+ import type { Database } from './db/schema.js';
3
+ import type { MediaStore } from './media/store.js';
4
+ import type { RuleIndex } from './redirects/collapse.js';
5
+ import type { Registry } from './registry/registry.js';
6
+ export type PathSegment = string | number;
7
+ export type IssueCode = 'required' | 'invalid' | 'too_long' | 'too_short' | 'too_many' | 'too_few' | 'out_of_range' | 'unknown_field' | 'not_found' | 'wrong_collection' | 'not_routable' | 'duplicate_slug' | 'path_taken' | 'redirect_loop' | 'deleted_reference' | 'wrong_media_type' | 'missing_media';
8
+ export interface ContentIssue {
9
+ path: PathSegment[];
10
+ labels: string[];
11
+ code: IssueCode;
12
+ message: string;
13
+ }
14
+ /** Content as a developer writes it (shipped content, create input). `false` switches an optional slot off. */
15
+ export type ContentInput = {
16
+ slug?: string;
17
+ path?: string;
18
+ fields?: Record<string, unknown>;
19
+ slots?: Record<string, Record<string, unknown> | false>;
20
+ };
21
+ /** Content as stored in a revision. */
22
+ export type DocumentData = {
23
+ slug?: string;
24
+ path?: string;
25
+ fields: Record<string, unknown>;
26
+ slots: Record<string, {
27
+ enabled: boolean;
28
+ data: Record<string, unknown>;
29
+ }>;
30
+ };
31
+ export type DocumentKind = 'singleton' | 'entry' | 'global';
32
+ export interface Usage {
33
+ documentId: string;
34
+ groupId: string;
35
+ type: string;
36
+ locale: string;
37
+ title: string;
38
+ in: 'draft' | 'published' | 'draft-and-published';
39
+ }
40
+ export type ContentRef = {
41
+ kind: 'document' | 'media';
42
+ id: string;
43
+ };
44
+ export type LinkValue = {
45
+ text?: string;
46
+ } & ({
47
+ document: string;
48
+ } | {
49
+ url: string;
50
+ });
51
+ export type ImageValue = {
52
+ media: string;
53
+ alt?: string;
54
+ };
55
+ export type FileValue = {
56
+ media: string;
57
+ };
58
+ /** An image or file in shipped content: read from disk and imported when the document is written. */
59
+ export type ShippedFile = {
60
+ file: string | URL;
61
+ alt?: string;
62
+ };
63
+ export interface MediaInfo {
64
+ id: string;
65
+ filename: string;
66
+ mime: string;
67
+ size: number;
68
+ width: number | null;
69
+ height: number | null;
70
+ defaultAlt: string | null;
71
+ createdBy: string;
72
+ createdAt: string;
73
+ }
74
+ export type MediaStatus = {
75
+ status: 'present';
76
+ media: MediaInfo;
77
+ } | {
78
+ status: 'deleted';
79
+ filename: string;
80
+ deletedAt: string;
81
+ } | {
82
+ status: 'unknown';
83
+ };
84
+ export type Role = 'owner' | 'editor' | 'system';
85
+ export interface Actor {
86
+ id: string | null;
87
+ name: string;
88
+ role: Role;
89
+ }
90
+ export type RevisionSource = 'admin' | 'mcp' | 'restore' | 'import' | 'release' | 'system';
91
+ /** Who is acting and through which channel; recorded on every revision and publish event. */
92
+ export interface Ctx {
93
+ actor: Actor;
94
+ source: RevisionSource;
95
+ /** The release whose migration functions are writing; recorded on their revisions. */
96
+ releaseId?: string;
97
+ }
98
+ /** What every core module function takes first. `db` may be a transaction. */
99
+ export interface UploadLimits {
100
+ maxBytes?: number;
101
+ types?: string[];
102
+ }
103
+ export interface CoreDeps {
104
+ db: Kysely<Database>;
105
+ registry: Registry;
106
+ now: () => Date;
107
+ media: MediaStore | null;
108
+ /** Where backups are written; the backup methods need it. */
109
+ backups?: string;
110
+ uploads: {
111
+ maxBytes: number;
112
+ types: readonly string[];
113
+ };
114
+ /** Holds the redirect rules ready for matching across requests. Without it, they are read per request. */
115
+ rules?: RuleCache;
116
+ /** A loaded release's shipped files: each source as written in the site to where the release keeps the file. */
117
+ shippedFiles?: ReadonlyMap<string, string>;
118
+ }
119
+ /** A redirect rule as `resolvePath` matches it. */
120
+ export interface MatchRule {
121
+ from: string;
122
+ to_path: string | null;
123
+ to_group_id: string | null;
124
+ status: 301 | 302;
125
+ }
126
+ /** The rule index `resolvePath` last built, with the database change counters it was built at. */
127
+ export interface RuleCache {
128
+ current: {
129
+ key: string;
130
+ index: RuleIndex<MatchRule>;
131
+ } | null;
132
+ }
133
+ export interface DocumentSummary {
134
+ id: string;
135
+ groupId: string;
136
+ kind: DocumentKind;
137
+ type: string;
138
+ locale: string;
139
+ title: string;
140
+ headRev: number;
141
+ publishedRev: number | null;
142
+ deletedAt: string | null;
143
+ updatedAt: string;
144
+ }
145
+ export interface RevisionMeta {
146
+ id: number;
147
+ createdAt: string;
148
+ authorId: string | null;
149
+ authorName: string;
150
+ source: RevisionSource;
151
+ message: string | null;
152
+ }
153
+ /** One thing that happened lately, for the dashboard. */
154
+ export type Activity = {
155
+ kind: 'edit';
156
+ at: string;
157
+ authorName: string;
158
+ source: RevisionSource;
159
+ document: DocumentSummary;
160
+ revisionId: number;
161
+ count: number;
162
+ } | {
163
+ kind: 'publish' | 'unpublish';
164
+ at: string;
165
+ authorName: string;
166
+ source: RevisionSource;
167
+ documents: DocumentSummary[];
168
+ };
169
+ export interface DocumentView extends DocumentSummary {
170
+ state: 'head' | 'published';
171
+ revision: RevisionMeta;
172
+ data: DocumentData;
173
+ }
174
+ /** One readable change between two versions of a document. */
175
+ export interface DiffEntry {
176
+ path: PathSegment[];
177
+ labels: string[];
178
+ change: 'added' | 'removed' | 'changed';
179
+ before?: unknown;
180
+ after?: unknown;
181
+ }
182
+ /** Which content the live site shows: published revisions, or head revisions (drafts included) for preview. */
183
+ export type LiveState = 'published' | 'preview';
184
+ /** A document as the live site shows it in a requested locale. */
185
+ export interface LiveDocument {
186
+ documentId: string;
187
+ groupId: string;
188
+ kind: DocumentKind;
189
+ type: string;
190
+ /** The requested locale. */
191
+ locale: string;
192
+ /** The locale whose content is shown. */
193
+ contentLocale: string;
194
+ fallback: boolean;
195
+ /** Decoded, locale-prefixed site path; `null` for globals, data entries and path-less singletons. */
196
+ path: string | null;
197
+ title: string;
198
+ slug: string | null;
199
+ revisionId: number;
200
+ /** The shown revision's `created_at`. */
201
+ updatedAt: string;
202
+ data: DocumentData;
203
+ }
204
+ /** What a request path resolves to. A redirect's `location` is already encoded. */
205
+ export type RouteMatch = {
206
+ kind: 'page';
207
+ document: LiveDocument;
208
+ } | {
209
+ kind: 'redirect';
210
+ location: string;
211
+ status: 301 | 302;
212
+ }
213
+ /** `loop` lists the `from` of redirect rules that were skipped because they would go round in a loop. */
214
+ | {
215
+ kind: 'not_found';
216
+ locale: string;
217
+ loop?: string[];
218
+ };
219
+ export type RedirectSource = 'manual' | 'auto' | 'import';
220
+ /** A redirect rule. `from` is a decoded site path; `:name` segments make it a pattern. */
221
+ export interface Redirect {
222
+ id: number;
223
+ from: string;
224
+ /** A site path (which may use the `:name` params of `from`), or a document's translation group. */
225
+ to: {
226
+ path: string;
227
+ } | {
228
+ document: string;
229
+ };
230
+ status: 301 | 302;
231
+ source: RedirectSource;
232
+ note: string | null;
233
+ createdBy: string;
234
+ createdAt: string;
235
+ }
236
+ export interface RedirectInput {
237
+ /** A site path, or a full http(s) URL whose origin is dropped. */
238
+ from: string;
239
+ /** A site path, or a document's translation group. */
240
+ to: string | {
241
+ document: string;
242
+ };
243
+ status?: 301 | 302;
244
+ note?: string;
245
+ }
246
+ export type ThemeColor = 'base-100' | 'base-200' | 'base-300' | 'base-content' | 'primary' | 'primary-content' | 'secondary' | 'secondary-content' | 'accent' | 'accent-content' | 'neutral' | 'neutral-content' | 'info' | 'info-content' | 'success' | 'success-content' | 'warning' | 'warning-content' | 'error' | 'error-content';
247
+ export interface CustomTheme {
248
+ base?: string;
249
+ scheme?: 'light' | 'dark';
250
+ colors: Partial<Record<ThemeColor, string>>;
251
+ }
252
+ /** A built-in daisyUI theme name, or colors laid over a base theme. */
253
+ export type AdminTheme = string | CustomTheme;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare function inlayVersion(): string;
@@ -0,0 +1,5 @@
1
+ import { readFileSync } from 'node:fs';
2
+ export function inlayVersion() {
3
+ const url = new URL('../../package.json', import.meta.url);
4
+ return JSON.parse(readFileSync(url, 'utf8')).version;
5
+ }
@@ -0,0 +1,53 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { type BackupInfo } from '../core/backup/backup.js';
3
+ import { type ShippedReport } from '../core/content/shipped.js';
4
+ import type { Database } from '../core/db/schema.js';
5
+ import { type LoadedRelease } from '../core/release/read.js';
6
+ import type { ActivationSummary } from './ipc.js';
7
+ import { type ReleaseRow } from './store.js';
8
+ export interface ActivationResult {
9
+ /** The release, now current. */
10
+ release: ReleaseRow;
11
+ /** The release that was current before, now previous; null on the first activation or a no-op. */
12
+ previous: ReleaseRow | null;
13
+ shipped: ShippedReport;
14
+ /** The migration functions run, in order. */
15
+ migrations: string[];
16
+ backup: BackupInfo | null;
17
+ /** True when the release was already current and nothing was done. */
18
+ noop: boolean;
19
+ /**
20
+ * Why `current.json` couldn't be written after the commit, or null. The release is current all the same: a
21
+ * worker that starts repairs the pointer from the database.
22
+ */
23
+ pointerError: string | null;
24
+ }
25
+ export interface ActivationDeps {
26
+ db: Kysely<Database>;
27
+ /** The release being activated, loaded from its folder in `releasesDir`. */
28
+ loaded: LoadedRelease;
29
+ releasesDir: string;
30
+ backupsDir: string;
31
+ mediaDir: string;
32
+ /** The secrets set on the host, by name, for the names given. An empty value is set. */
33
+ secretsEnv: (names: readonly string[]) => Record<string, string>;
34
+ now: () => Date;
35
+ }
36
+ /** An activation's result as counts, for the worker that asked for it. */
37
+ export declare function summarize(result: ActivationResult): ActivationSummary;
38
+ /**
39
+ * Makes a stored release the current one (spec §7). Checks it suits this version of Inlay; already current, it
40
+ * does nothing else and says so. Otherwise: checks the secrets it declares are set, takes a `pre-activation` backup
41
+ * (unless the database has no documents yet), stores the media files its shipped content names, then in one
42
+ * transaction, which takes the write lock before it reads, applies its shipped content by edition, runs its
43
+ * migration functions not yet run and marks it current and the old current release previous; a throw rolls all of
44
+ * it back and removes the media files it stored that nothing names. Writes `current.json` after the commit; a
45
+ * failure there is returned as `pointerError`, not thrown. `deps.loaded` must be the release `releaseId` names, and
46
+ * `deps.db` must not be a transaction (`error.transactionWrite`).
47
+ *
48
+ * The transaction holds the database's write lock from start to end, and the live worker's saves wait at most 5
49
+ * seconds for it before they fail. Files are stored before it opens for that reason, but the shipped content is
50
+ * still planned (its files read) and the release's migration functions run inside it: a release whose functions
51
+ * take long makes editors' saves fail meanwhile.
52
+ */
53
+ export declare function activateRelease(deps: ActivationDeps, releaseId: string): Promise<ActivationResult>;
@@ -0,0 +1,162 @@
1
+ import { systemCtx } from '../core/auth/roles.js';
2
+ import { createBackup } from '../core/backup/backup.js';
3
+ import { withTransaction } from '../core/content/dry-run.js';
4
+ import { runReleaseMigrations } from '../core/content/release-migrations.js';
5
+ import { planShippedContent, storeShippedFiles, writeShippedContent } from '../core/content/shipped.js';
6
+ import { InlayError } from '../core/errors.js';
7
+ import { DEFAULT_MAX_BYTES, DEFAULT_UPLOAD_TYPES } from '../core/media/detect.js';
8
+ import { fileMediaStore } from '../core/media/store.js';
9
+ import { buildRegistry } from '../core/registry/registry.js';
10
+ import { checkInlayVersion } from '../core/release/read.js';
11
+ import { currentRelease, getRelease, readCurrentPointer, writeCurrentPointer } from './store.js';
12
+ const noShipped = () => ({ created: [], replaced: [], skipped: [], deletedRefs: [], warnings: [] });
13
+ /** An activation's result as counts, for the worker that asked for it. */
14
+ export function summarize(result) {
15
+ return {
16
+ shipped: {
17
+ created: result.shipped.created.length,
18
+ replaced: result.shipped.replaced.length,
19
+ skipped: result.shipped.skipped.length,
20
+ },
21
+ migrations: result.migrations,
22
+ backup: result.backup?.path ?? null,
23
+ noop: result.noop,
24
+ warnings: result.shipped.warnings.length,
25
+ };
26
+ }
27
+ function contentDeps(deps) {
28
+ return {
29
+ db: deps.db,
30
+ registry: buildRegistry(deps.loaded.site),
31
+ now: deps.now,
32
+ media: fileMediaStore(deps.mediaDir),
33
+ backups: deps.backupsDir,
34
+ uploads: { maxBytes: DEFAULT_MAX_BYTES, types: DEFAULT_UPLOAD_TYPES },
35
+ shippedFiles: deps.loaded.shippedFiles,
36
+ };
37
+ }
38
+ /** Runs the migration functions, turning a failure into an error that names the function that failed. */
39
+ async function runMigrations(tx, releaseId, migrations, ctx) {
40
+ let running = null;
41
+ const tracked = migrations.map((m) => ({
42
+ name: m.name,
43
+ run: async (api) => {
44
+ running = m.name;
45
+ await m.run(api);
46
+ // What fails after the function returned (recording it) isn't the function's fault.
47
+ running = null;
48
+ },
49
+ }));
50
+ try {
51
+ return await runReleaseMigrations(tx, releaseId, tracked, ctx);
52
+ }
53
+ catch (e) {
54
+ if (running === null)
55
+ throw e;
56
+ const problem = e instanceof Error ? e.message : String(e);
57
+ throw new InlayError('release', 'error.releaseMigration', { name: running, problem });
58
+ }
59
+ }
60
+ /** Writes `current.json`, returning why it failed instead of throwing: the database already says what's current. */
61
+ async function updatePointer(releasesDir, row, now) {
62
+ try {
63
+ await writeCurrentPointer(releasesDir, { id: row.id, name: row.name, activatedAt: row.activated_at ?? now().toISOString() });
64
+ return null;
65
+ }
66
+ catch (e) {
67
+ return e instanceof Error ? e.message : String(e);
68
+ }
69
+ }
70
+ /** Removes the files an activation stored that no `media` row names now that it was rolled back. Best effort. */
71
+ async function removeOrphans(deps, stored) {
72
+ const media = fileMediaStore(deps.mediaDir);
73
+ for (const id of stored) {
74
+ try {
75
+ const row = await deps.db.selectFrom('media').select('id').where('id', '=', id).executeTakeFirst();
76
+ if (row === undefined)
77
+ await media.remove(id);
78
+ }
79
+ catch {
80
+ // A file left behind takes space but harms nothing; the activation's own error matters more.
81
+ }
82
+ }
83
+ }
84
+ async function hasDocuments(db) {
85
+ return (await db.selectFrom('documents').select('id').limit(1).executeTakeFirst()) !== undefined;
86
+ }
87
+ /**
88
+ * Makes a stored release the current one (spec §7). Checks it suits this version of Inlay; already current, it
89
+ * does nothing else and says so. Otherwise: checks the secrets it declares are set, takes a `pre-activation` backup
90
+ * (unless the database has no documents yet), stores the media files its shipped content names, then in one
91
+ * transaction, which takes the write lock before it reads, applies its shipped content by edition, runs its
92
+ * migration functions not yet run and marks it current and the old current release previous; a throw rolls all of
93
+ * it back and removes the media files it stored that nothing names. Writes `current.json` after the commit; a
94
+ * failure there is returned as `pointerError`, not thrown. `deps.loaded` must be the release `releaseId` names, and
95
+ * `deps.db` must not be a transaction (`error.transactionWrite`).
96
+ *
97
+ * The transaction holds the database's write lock from start to end, and the live worker's saves wait at most 5
98
+ * seconds for it before they fail. Files are stored before it opens for that reason, but the shipped content is
99
+ * still planned (its files read) and the release's migration functions run inside it: a release whose functions
100
+ * take long makes editors' saves fail meanwhile.
101
+ */
102
+ export async function activateRelease(deps, releaseId) {
103
+ const row = await getRelease(deps.db, releaseId);
104
+ if (row === null)
105
+ throw new InlayError('not_found', 'error.releaseUnknown', { id: releaseId });
106
+ if (row.state === 'deleted')
107
+ throw new InlayError('release', 'error.releaseDeleted', { name: row.name });
108
+ checkInlayVersion(row.inlay_range);
109
+ if (row.state === 'current') {
110
+ // A retry after a commit whose pointer write was lost: the database already says it's current.
111
+ const pointer = await readCurrentPointer(deps.releasesDir).catch(() => null);
112
+ const pointerError = pointer?.id === row.id ? null : await updatePointer(deps.releasesDir, row, deps.now);
113
+ return { release: row, previous: null, shipped: noShipped(), migrations: [], backup: null, noop: true, pointerError };
114
+ }
115
+ const present = deps.secretsEnv(row.secrets);
116
+ const missing = row.secrets.find((name) => !Object.hasOwn(present, name));
117
+ if (missing !== undefined)
118
+ throw new InlayError('release', 'error.releaseSecret', { name: missing });
119
+ const ctx = { ...systemCtx('release'), releaseId };
120
+ const backup = (await hasDocuments(deps.db))
121
+ ? await createBackup({
122
+ db: deps.db,
123
+ backups: deps.backupsDir,
124
+ media: deps.mediaDir,
125
+ releases: deps.releasesDir,
126
+ reason: 'pre-activation',
127
+ ctx,
128
+ now: deps.now,
129
+ })
130
+ : null;
131
+ const stored = new Set();
132
+ const content = contentDeps(deps);
133
+ let done;
134
+ try {
135
+ // Outside the transaction, so it doesn't hold the write lock while files are written. The plan is made again
136
+ // inside it; a file only that one names is stored there.
137
+ await storeShippedFiles(content, await planShippedContent(content), (id) => stored.add(id));
138
+ done = await withTransaction(content, async (tx) => {
139
+ const plan = await planShippedContent(tx);
140
+ const shipped = await writeShippedContent(tx, plan, { ctx, onFileStored: (id) => stored.add(id) });
141
+ const migrations = await runMigrations(tx, releaseId, deps.loaded.site.migrations, ctx);
142
+ const at = deps.now().toISOString();
143
+ const old = await currentRelease(tx.db);
144
+ if (old) {
145
+ await tx.db.updateTable('releases').set({ state: 'previous', deactivated_at: at }).where('id', '=', old.id).execute();
146
+ }
147
+ await tx.db.updateTable('releases').set({ state: 'current', activated_at: at }).where('id', '=', releaseId).execute();
148
+ return {
149
+ shipped,
150
+ migrations,
151
+ release: (await getRelease(tx.db, releaseId)),
152
+ previous: old ? await getRelease(tx.db, old.id) : null,
153
+ };
154
+ }, { write: true });
155
+ }
156
+ catch (e) {
157
+ await removeOrphans(deps, stored);
158
+ throw e;
159
+ }
160
+ const pointerError = await updatePointer(deps.releasesDir, done.release, deps.now);
161
+ return { ...done, backup, noop: false, pointerError };
162
+ }
@@ -0,0 +1,46 @@
1
+ import { type FastifyInstance } from 'fastify';
2
+ import { type HostApi } from '../adapters/site/plugin.js';
3
+ import type { Core } from '../core/core.js';
4
+ import { type SiteDefinition } from '../core/registry/define.js';
5
+ import type { HostConfig } from './config.js';
6
+ import { type ContentDiff } from './push.js';
7
+ /** The site a host serves before it has a release: one locale, no types, only the admin. */
8
+ export declare const EMPTY_SITE: SiteDefinition;
9
+ /** What a site app serves: a loaded release, or a site `inlaycms dev` built from source. */
10
+ export interface SiteSource {
11
+ site: SiteDefinition;
12
+ publicDir: string | null;
13
+ /** Each shipped file's source as the site names it, to the file to read. */
14
+ shippedFiles?: ReadonlyMap<string, string>;
15
+ }
16
+ /**
17
+ * The Fastify app for one site on the host, ready but not listening. With no `source` it serves the admin and, for
18
+ * every content page, the `noSite` page: "no site yet" (`'empty'`, the default) for a host that has no release, or
19
+ * "temporarily unavailable" (`'unavailable'`, status 503) for a site that is down. `host` is what the site may ask
20
+ * of `inlaycms serve`; with it the app also serves the push API (`/_inlay/releases`, see `registerPushRoutes`) and
21
+ * sends requests whose preview cookie names a staged release to that release's preview (`registerPreviewProxy`).
22
+ *
23
+ * A staged release's preview passes `readOnly`, `preview: 'forced'`, `release`, `backupSchedule: false` and `diff`:
24
+ * it then refuses a request the proxy forwarded for another release (421), and serves `GET /_inlay/internal/diff`
25
+ * (what `diff` gives) to requests that didn't come through the proxy.
26
+ */
27
+ export declare function createSiteApp(config: HostConfig, source: SiteSource | null, opts: {
28
+ content: 'apply' | 'none';
29
+ logger?: boolean;
30
+ now?: () => Date;
31
+ noSite?: 'empty' | 'unavailable';
32
+ host?: HostApi;
33
+ readOnly?: boolean;
34
+ preview?: 'forced';
35
+ release?: {
36
+ id: string;
37
+ name: string;
38
+ };
39
+ backupSchedule?: false;
40
+ diff?: (core: Core) => Promise<ContentDiff>;
41
+ /** The largest release file a push may send (`PUSH_MAX_BYTES` by default); for tests. */
42
+ pushMaxBytes?: number;
43
+ }): Promise<{
44
+ app: FastifyInstance;
45
+ core: Core;
46
+ }>;
@@ -0,0 +1,129 @@
1
+ import Fastify from 'fastify';
2
+ import { AUTH, inlay } from '../adapters/site/plugin.js';
3
+ import { catalogPage } from '../adapters/site/render.js';
4
+ import { openDatabase } from '../core/db/connection.js';
5
+ import { InlayError } from '../core/errors.js';
6
+ import { t } from '../core/messages/index.js';
7
+ import { defineSite } from '../core/registry/define.js';
8
+ import { PREVIEW_RELEASE_HEADER, registerPreviewProxy } from './preview-proxy.js';
9
+ import { adminHostHooks } from './hooks.js';
10
+ import { registerPushRoutes } from './push.js';
11
+ import { getRelease } from './store.js';
12
+ /** The site a host serves before it has a release: one locale, no types, only the admin. */
13
+ export const EMPTY_SITE = defineSite({
14
+ locales: ['en'],
15
+ defaultLocale: 'en',
16
+ admin: { name: t('admin.title') },
17
+ });
18
+ /**
19
+ * The Fastify app for one site on the host, ready but not listening. With no `source` it serves the admin and, for
20
+ * every content page, the `noSite` page: "no site yet" (`'empty'`, the default) for a host that has no release, or
21
+ * "temporarily unavailable" (`'unavailable'`, status 503) for a site that is down. `host` is what the site may ask
22
+ * of `inlaycms serve`; with it the app also serves the push API (`/_inlay/releases`, see `registerPushRoutes`) and
23
+ * sends requests whose preview cookie names a staged release to that release's preview (`registerPreviewProxy`).
24
+ *
25
+ * A staged release's preview passes `readOnly`, `preview: 'forced'`, `release`, `backupSchedule: false` and `diff`:
26
+ * it then refuses a request the proxy forwarded for another release (421), and serves `GET /_inlay/internal/diff`
27
+ * (what `diff` gives) to requests that didn't come through the proxy.
28
+ */
29
+ export async function createSiteApp(config, source, opts) {
30
+ const app = Fastify({ logger: opts.logger ?? false, trustProxy: config.trustProxy });
31
+ const now = opts.now ?? (() => new Date());
32
+ // Opened once the site has booted (which creates and migrates the database), for the push API, admin and proxy.
33
+ let db = null;
34
+ try {
35
+ if (opts.host?.startPreview) {
36
+ // Before the site's own hooks (the site lock among them): the preview answers for the release it shows.
37
+ registerPreviewProxy(app, {
38
+ host: opts.host,
39
+ secret: config.secret,
40
+ baseUrl: config.baseUrl,
41
+ now,
42
+ isStaged: async (id) => db !== null && (await getRelease(db, id))?.state === 'staged',
43
+ });
44
+ }
45
+ const release = opts.release;
46
+ if (opts.preview === 'forced' && release) {
47
+ app.addHook('onRequest', async (request, reply) => {
48
+ const forwarded = request.headers[PREVIEW_RELEASE_HEADER];
49
+ if (forwarded === undefined || forwarded === release.id)
50
+ return;
51
+ return reply
52
+ .code(421)
53
+ .header('cache-control', 'no-store')
54
+ .type('text/html; charset=utf-8')
55
+ .send(catalogPage('preview.misdirected.title', 'preview.misdirected'));
56
+ });
57
+ }
58
+ // What the push API and the admin's Releases screen work with; read only once the site has booted.
59
+ const push = opts.host
60
+ ? {
61
+ get db() {
62
+ if (db === null)
63
+ throw new InlayError('invalid_operation', 'error.hostNotReady');
64
+ return db;
65
+ },
66
+ get registry() {
67
+ return source === null ? null : app.inlay.core.registry;
68
+ },
69
+ config,
70
+ now,
71
+ host: opts.host,
72
+ log: (e) => app.log.warn({ err: e }, 'content diff'),
73
+ }
74
+ : null;
75
+ await app.register(inlay, {
76
+ site: source?.site ?? EMPTY_SITE,
77
+ ...(source === null && { noSite: opts.noSite ?? 'empty' }),
78
+ db: config.paths.db,
79
+ media: config.paths.media,
80
+ backups: config.paths.backups,
81
+ secret: config.secret,
82
+ baseUrl: config.baseUrl,
83
+ ...(config.uploads && { uploads: config.uploads }),
84
+ rateLimit: config.rateLimit,
85
+ backupSchedule: opts.backupSchedule ?? { keep: config.backupKeep },
86
+ cdn: config.cdn,
87
+ publicMaxAge: config.publicMaxAge,
88
+ ...(source?.publicDir != null && { publicDir: source.publicDir }),
89
+ secrets: config.secrets(source?.site.secrets ?? []),
90
+ content: opts.content,
91
+ ...(source?.shippedFiles && { shippedFiles: source.shippedFiles }),
92
+ ...(opts.now && { now: opts.now }),
93
+ ...(opts.host && { host: opts.host }),
94
+ ...(opts.readOnly && { readOnly: true }),
95
+ ...(opts.preview && { preview: opts.preview }),
96
+ ...(opts.release && { release: opts.release }),
97
+ releasesDir: config.paths.releases,
98
+ trustedKeys: config.trustedKeys,
99
+ ...(push && { adminHost: adminHostHooks(push) }),
100
+ });
101
+ if (push) {
102
+ // Its own connection, so a push never waits behind the site's queries.
103
+ const own = openDatabase(config.paths.db);
104
+ db = own;
105
+ app.addHook('onClose', async () => own.destroy());
106
+ registerPushRoutes(app, {
107
+ ...push,
108
+ db: own,
109
+ service: app.inlay[AUTH],
110
+ ...(opts.pushMaxBytes !== undefined && { maxBytes: opts.pushMaxBytes }),
111
+ });
112
+ }
113
+ const { diff } = opts;
114
+ if (opts.preview === 'forced' && diff) {
115
+ app.get('/_inlay/internal/diff', async (request, reply) => {
116
+ // Only on the preview's own socket: not for a visitor's request the proxy forwarded.
117
+ if (request.headers[PREVIEW_RELEASE_HEADER] !== undefined)
118
+ return reply.callNotFound();
119
+ return reply.header('cache-control', 'no-store').send(await diff(app.inlay.core));
120
+ });
121
+ }
122
+ await app.ready();
123
+ }
124
+ catch (e) {
125
+ await app.close();
126
+ throw e;
127
+ }
128
+ return { app, core: app.inlay.core };
129
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The `inlaycms` command's own file. `serve` runs it for each worker and `dev` for its child, so they start the same
3
+ * code however the command was started (a symlinked bin, a wrapper script).
4
+ */
5
+ export declare const INLAY_BIN: string;
@@ -0,0 +1,8 @@
1
+ import { fileURLToPath } from 'node:url';
2
+ /** `.ts` when running from `src/` (tsx, vitest), `.js` from `dist/`. */
3
+ const EXT = import.meta.url.endsWith('.ts') ? '.ts' : '.js';
4
+ /**
5
+ * The `inlaycms` command's own file. `serve` runs it for each worker and `dev` for its child, so they start the same
6
+ * code however the command was started (a symlinked bin, a wrapper script).
7
+ */
8
+ export const INLAY_BIN = fileURLToPath(new URL(`../adapters/cli/bin${EXT}`, import.meta.url));