@heyo-sh/heyo-cms 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 (382) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +44 -2
  3. package/dist/access/index.d.ts +9 -0
  4. package/dist/access/index.d.ts.map +1 -0
  5. package/dist/access/permissions.d.ts +54 -0
  6. package/dist/access/permissions.d.ts.map +1 -0
  7. package/dist/adapters/astro.d.ts +38 -0
  8. package/dist/adapters/astro.d.ts.map +1 -0
  9. package/dist/adapters/astro.js +1 -0
  10. package/dist/adapters/next.d.ts +31 -0
  11. package/dist/adapters/next.d.ts.map +1 -0
  12. package/dist/adapters/next.js +1 -0
  13. package/dist/adapters/nuxt.d.ts +47 -0
  14. package/dist/adapters/nuxt.d.ts.map +1 -0
  15. package/dist/adapters/nuxt.js +1 -0
  16. package/dist/adapters/react-router.d.ts +29 -0
  17. package/dist/adapters/react-router.d.ts.map +1 -0
  18. package/dist/adapters/react-router.js +1 -0
  19. package/dist/adapters/sveltekit.d.ts +37 -0
  20. package/dist/adapters/sveltekit.d.ts.map +1 -0
  21. package/dist/adapters/sveltekit.js +1 -0
  22. package/dist/ai/assistant/context.d.ts +64 -0
  23. package/dist/ai/assistant/context.d.ts.map +1 -0
  24. package/dist/ai/assistant/limits.d.ts +10 -0
  25. package/dist/ai/assistant/limits.d.ts.map +1 -0
  26. package/dist/ai/assistant/plans.d.ts +83 -0
  27. package/dist/ai/assistant/plans.d.ts.map +1 -0
  28. package/dist/ai/assistant/prompt.d.ts +22 -0
  29. package/dist/ai/assistant/prompt.d.ts.map +1 -0
  30. package/dist/ai/assistant/run.d.ts +59 -0
  31. package/dist/ai/assistant/run.d.ts.map +1 -0
  32. package/dist/ai/assistant/runtime.d.ts +35 -0
  33. package/dist/ai/assistant/runtime.d.ts.map +1 -0
  34. package/dist/ai/assistant/schema.d.ts +66 -0
  35. package/dist/ai/assistant/schema.d.ts.map +1 -0
  36. package/dist/ai/assistant/tools.d.ts +41 -0
  37. package/dist/ai/assistant/tools.d.ts.map +1 -0
  38. package/dist/ai/assistant/values.d.ts +33 -0
  39. package/dist/ai/assistant/values.d.ts.map +1 -0
  40. package/dist/ai/crypto.d.ts +12 -0
  41. package/dist/ai/crypto.d.ts.map +1 -0
  42. package/dist/ai/index.d.ts +19 -0
  43. package/dist/ai/index.d.ts.map +1 -0
  44. package/dist/ai/pi.d.ts +89 -0
  45. package/dist/ai/pi.d.ts.map +1 -0
  46. package/dist/ai/registry.d.ts +66 -0
  47. package/dist/ai/registry.d.ts.map +1 -0
  48. package/dist/ai/service.d.ts +31 -0
  49. package/dist/ai/service.d.ts.map +1 -0
  50. package/dist/ai/variant-translation.d.ts +6 -0
  51. package/dist/ai/variant-translation.d.ts.map +1 -0
  52. package/dist/ai.d.ts +12 -0
  53. package/dist/ai.d.ts.map +1 -0
  54. package/dist/ai.js +1 -0
  55. package/dist/auth/config.d.ts +65 -0
  56. package/dist/auth/config.d.ts.map +1 -0
  57. package/dist/auth/crypto.d.ts +44 -0
  58. package/dist/auth/crypto.d.ts.map +1 -0
  59. package/dist/auth/index.d.ts +15 -0
  60. package/dist/auth/index.d.ts.map +1 -0
  61. package/dist/auth/oauth.d.ts +93 -0
  62. package/dist/auth/oauth.d.ts.map +1 -0
  63. package/dist/auth/service.d.ts +38 -0
  64. package/dist/auth/service.d.ts.map +1 -0
  65. package/dist/auth/totp.d.ts +34 -0
  66. package/dist/auth/totp.d.ts.map +1 -0
  67. package/dist/auth.d.ts +9 -0
  68. package/dist/auth.d.ts.map +1 -0
  69. package/dist/auth.js +1 -0
  70. package/dist/cli.d.ts +3 -0
  71. package/dist/cli.d.ts.map +1 -0
  72. package/dist/cli.js +30 -0
  73. package/dist/client/index.d.ts +51 -0
  74. package/dist/client/index.d.ts.map +1 -0
  75. package/dist/client/types.d.ts +340 -0
  76. package/dist/client/types.d.ts.map +1 -0
  77. package/dist/client.d.ts +46 -0
  78. package/dist/client.d.ts.map +1 -0
  79. package/dist/client.js +1 -0
  80. package/dist/config.d.ts +31 -0
  81. package/dist/config.d.ts.map +1 -0
  82. package/dist/config.js +1 -0
  83. package/dist/content/export.d.ts +28 -0
  84. package/dist/content/export.d.ts.map +1 -0
  85. package/dist/content/import.d.ts +65 -0
  86. package/dist/content/import.d.ts.map +1 -0
  87. package/dist/content/records.d.ts +73 -0
  88. package/dist/content/records.d.ts.map +1 -0
  89. package/dist/content.d.ts +12 -0
  90. package/dist/content.d.ts.map +1 -0
  91. package/dist/content.js +1 -0
  92. package/dist/db/d1.d.ts +29 -0
  93. package/dist/db/d1.d.ts.map +1 -0
  94. package/dist/db/d1.js +1 -0
  95. package/dist/db/mongodb.d.ts +128 -0
  96. package/dist/db/mongodb.d.ts.map +1 -0
  97. package/dist/db/mongodb.js +2 -0
  98. package/dist/db/postgres.d.ts +37 -0
  99. package/dist/db/postgres.d.ts.map +1 -0
  100. package/dist/db/postgres.js +1 -0
  101. package/dist/db/sql/adapter.d.ts +57 -0
  102. package/dist/db/sql/adapter.d.ts.map +1 -0
  103. package/dist/db/sql/compile.d.ts +50 -0
  104. package/dist/db/sql/compile.d.ts.map +1 -0
  105. package/dist/db/sql/ddl.d.ts +34 -0
  106. package/dist/db/sql/ddl.d.ts.map +1 -0
  107. package/dist/db/sql/dialect.d.ts +35 -0
  108. package/dist/db/sql/dialect.d.ts.map +1 -0
  109. package/dist/db/sql/driver.d.ts +34 -0
  110. package/dist/db/sql/driver.d.ts.map +1 -0
  111. package/dist/db/sql/introspect.d.ts +15 -0
  112. package/dist/db/sql/introspect.d.ts.map +1 -0
  113. package/dist/db/sqlite.d.ts +39 -0
  114. package/dist/db/sqlite.d.ts.map +1 -0
  115. package/dist/db/sqlite.js +1 -0
  116. package/dist/defaults.d.ts +5 -0
  117. package/dist/defaults.d.ts.map +1 -0
  118. package/dist/duration.d.ts +12 -0
  119. package/dist/duration.d.ts.map +1 -0
  120. package/dist/editor/builtin.d.ts +45 -0
  121. package/dist/editor/builtin.d.ts.map +1 -0
  122. package/dist/editor/index.d.ts +14 -0
  123. package/dist/editor/index.d.ts.map +1 -0
  124. package/dist/editor/markdown.d.ts +19 -0
  125. package/dist/editor/markdown.d.ts.map +1 -0
  126. package/dist/editor/registry.d.ts +30 -0
  127. package/dist/editor/registry.d.ts.map +1 -0
  128. package/dist/editor/serialize.d.ts +41 -0
  129. package/dist/editor/serialize.d.ts.map +1 -0
  130. package/dist/editor.d.ts +10 -0
  131. package/dist/editor.d.ts.map +1 -0
  132. package/dist/editor.js +1 -0
  133. package/dist/engine/access.d.ts +33 -0
  134. package/dist/engine/access.d.ts.map +1 -0
  135. package/dist/engine/activity.d.ts +16 -0
  136. package/dist/engine/activity.d.ts.map +1 -0
  137. package/dist/engine/cursor.d.ts +19 -0
  138. package/dist/engine/cursor.d.ts.map +1 -0
  139. package/dist/engine/documents.d.ts +81 -0
  140. package/dist/engine/documents.d.ts.map +1 -0
  141. package/dist/engine/engine.d.ts +276 -0
  142. package/dist/engine/engine.d.ts.map +1 -0
  143. package/dist/engine/field-access.d.ts +21 -0
  144. package/dist/engine/field-access.d.ts.map +1 -0
  145. package/dist/engine/hooks.d.ts +58 -0
  146. package/dist/engine/hooks.d.ts.map +1 -0
  147. package/dist/engine/index.d.ts +20 -0
  148. package/dist/engine/index.d.ts.map +1 -0
  149. package/dist/engine/jobs.d.ts +63 -0
  150. package/dist/engine/jobs.d.ts.map +1 -0
  151. package/dist/engine/locales.d.ts +40 -0
  152. package/dist/engine/locales.d.ts.map +1 -0
  153. package/dist/engine/outbox.d.ts +81 -0
  154. package/dist/engine/outbox.d.ts.map +1 -0
  155. package/dist/engine/relations.d.ts +60 -0
  156. package/dist/engine/relations.d.ts.map +1 -0
  157. package/dist/engine/scoped-db.d.ts +13 -0
  158. package/dist/engine/scoped-db.d.ts.map +1 -0
  159. package/dist/engine/trash.d.ts +25 -0
  160. package/dist/engine/trash.d.ts.map +1 -0
  161. package/dist/errors.d.ts +42 -0
  162. package/dist/errors.d.ts.map +1 -0
  163. package/dist/fields/builtin.d.ts +142 -0
  164. package/dist/fields/builtin.d.ts.map +1 -0
  165. package/dist/fields/index.d.ts +3 -0
  166. package/dist/fields/index.d.ts.map +1 -0
  167. package/dist/fields/registry.d.ts +35 -0
  168. package/dist/fields/registry.d.ts.map +1 -0
  169. package/dist/fields.d.ts +8 -0
  170. package/dist/fields.d.ts.map +1 -0
  171. package/dist/fields.js +1 -0
  172. package/dist/http/guard.d.ts +45 -0
  173. package/dist/http/guard.d.ts.map +1 -0
  174. package/dist/http/handler.d.ts +31 -0
  175. package/dist/http/handler.d.ts.map +1 -0
  176. package/dist/http/index.d.ts +13 -0
  177. package/dist/http/index.d.ts.map +1 -0
  178. package/dist/http/openapi.d.ts +5 -0
  179. package/dist/http/openapi.d.ts.map +1 -0
  180. package/dist/http/params.d.ts +32 -0
  181. package/dist/http/params.d.ts.map +1 -0
  182. package/dist/http/request-db.d.ts +19 -0
  183. package/dist/http/request-db.d.ts.map +1 -0
  184. package/dist/http/respond.d.ts +48 -0
  185. package/dist/http/respond.d.ts.map +1 -0
  186. package/dist/http/rich-text.d.ts +30 -0
  187. package/dist/http/rich-text.d.ts.map +1 -0
  188. package/dist/http/router.d.ts +55 -0
  189. package/dist/http/router.d.ts.map +1 -0
  190. package/dist/http/routes/access.d.ts +13 -0
  191. package/dist/http/routes/access.d.ts.map +1 -0
  192. package/dist/http/routes/admin.d.ts +28 -0
  193. package/dist/http/routes/admin.d.ts.map +1 -0
  194. package/dist/http/routes/ai.d.ts +26 -0
  195. package/dist/http/routes/ai.d.ts.map +1 -0
  196. package/dist/http/routes/auth.d.ts +13 -0
  197. package/dist/http/routes/auth.d.ts.map +1 -0
  198. package/dist/http/routes/documents.d.ts +24 -0
  199. package/dist/http/routes/documents.d.ts.map +1 -0
  200. package/dist/http/routes/generate.d.ts +5 -0
  201. package/dist/http/routes/generate.d.ts.map +1 -0
  202. package/dist/http/routes/media.d.ts +28 -0
  203. package/dist/http/routes/media.d.ts.map +1 -0
  204. package/dist/http/routes/panel.d.ts +20 -0
  205. package/dist/http/routes/panel.d.ts.map +1 -0
  206. package/dist/http/routes/system.d.ts +25 -0
  207. package/dist/http/routes/system.d.ts.map +1 -0
  208. package/dist/http/routes/webhooks.d.ts +17 -0
  209. package/dist/http/routes/webhooks.d.ts.map +1 -0
  210. package/dist/http/spec.d.ts +28 -0
  211. package/dist/http/spec.d.ts.map +1 -0
  212. package/dist/http.d.ts +17 -0
  213. package/dist/http.d.ts.map +1 -0
  214. package/dist/http.js +1 -0
  215. package/dist/i18n/index.d.ts +12 -0
  216. package/dist/i18n/index.d.ts.map +1 -0
  217. package/dist/i18n/names.d.ts +25 -0
  218. package/dist/i18n/names.d.ts.map +1 -0
  219. package/dist/ids.d.ts +28 -0
  220. package/dist/ids.d.ts.map +1 -0
  221. package/dist/index-2757kej5.js +2 -0
  222. package/dist/index-2kb5nbxx.js +2 -0
  223. package/dist/index-2z1qe5mw.js +2 -0
  224. package/dist/index-34s342fz.js +2 -0
  225. package/dist/index-5ngtc7gy.js +2 -0
  226. package/dist/index-7a231xfp.js +2 -0
  227. package/dist/index-7k091gpe.js +2 -0
  228. package/dist/index-9g2n7xa6.js +2 -0
  229. package/dist/index-9x1z3b85.js +5 -0
  230. package/dist/index-9zqnf6gx.js +23 -0
  231. package/dist/index-b2ecggck.js +26 -0
  232. package/dist/index-cbwwtcm4.js +2 -0
  233. package/dist/index-ebtj6ebd.js +0 -0
  234. package/dist/index-g4crf47y.js +0 -0
  235. package/dist/index-gpwcmmvr.js +2 -0
  236. package/dist/index-hq05mc1n.js +3 -0
  237. package/dist/index-hy1x46nf.js +2 -0
  238. package/dist/index-k8wbg1dw.js +2 -0
  239. package/dist/index-kbsgt44t.js +2 -0
  240. package/dist/index-m82a0shw.js +2 -0
  241. package/dist/index-md79xr6h.js +5 -0
  242. package/dist/index-nvgwyykk.js +40 -0
  243. package/dist/index-ty698y02.js +2 -0
  244. package/dist/index-vq2978e7.js +14 -0
  245. package/dist/index-vxw0a03g.js +2 -0
  246. package/dist/index-wj8y1xcj.js +2 -0
  247. package/dist/index-x72d1hzh.js +2 -0
  248. package/dist/index-y5mwknr9.js +2 -0
  249. package/dist/index-ymq6jsar.js +2 -0
  250. package/dist/index.d.ts +25 -0
  251. package/dist/index.d.ts.map +1 -0
  252. package/dist/index.js +1 -0
  253. package/dist/jobs/runner.d.ts +77 -0
  254. package/dist/jobs/runner.d.ts.map +1 -0
  255. package/dist/jobs.d.ts +11 -0
  256. package/dist/jobs.d.ts.map +1 -0
  257. package/dist/jobs.js +1 -0
  258. package/dist/media/document.d.ts +28 -0
  259. package/dist/media/document.d.ts.map +1 -0
  260. package/dist/media/gc.d.ts +46 -0
  261. package/dist/media/gc.d.ts.map +1 -0
  262. package/dist/media/index.d.ts +20 -0
  263. package/dist/media/index.d.ts.map +1 -0
  264. package/dist/media/pipeline.d.ts +36 -0
  265. package/dist/media/pipeline.d.ts.map +1 -0
  266. package/dist/media/probe.d.ts +6 -0
  267. package/dist/media/probe.d.ts.map +1 -0
  268. package/dist/media/service.d.ts +26 -0
  269. package/dist/media/service.d.ts.map +1 -0
  270. package/dist/media/sharp.d.ts +28 -0
  271. package/dist/media/sharp.d.ts.map +1 -0
  272. package/dist/media/strip.d.ts +16 -0
  273. package/dist/media/strip.d.ts.map +1 -0
  274. package/dist/media/usages.d.ts +69 -0
  275. package/dist/media/usages.d.ts.map +1 -0
  276. package/dist/media/variants.d.ts +50 -0
  277. package/dist/media/variants.d.ts.map +1 -0
  278. package/dist/migrations.d.ts +115 -0
  279. package/dist/migrations.d.ts.map +1 -0
  280. package/dist/migrations.js +1 -0
  281. package/dist/panel.d.ts +31 -0
  282. package/dist/panel.d.ts.map +1 -0
  283. package/dist/query.d.ts +40 -0
  284. package/dist/query.d.ts.map +1 -0
  285. package/dist/query.js +1 -0
  286. package/dist/run-3r72dwhs.js +6 -0
  287. package/dist/schema/describe.d.ts +19 -0
  288. package/dist/schema/describe.d.ts.map +1 -0
  289. package/dist/schema/index.d.ts +5 -0
  290. package/dist/schema/index.d.ts.map +1 -0
  291. package/dist/schema/plan.d.ts +20 -0
  292. package/dist/schema/plan.d.ts.map +1 -0
  293. package/dist/schema/snapshot.d.ts +22 -0
  294. package/dist/schema/snapshot.d.ts.map +1 -0
  295. package/dist/schema/system.d.ts +22 -0
  296. package/dist/schema/system.d.ts.map +1 -0
  297. package/dist/schema.d.ts +7 -0
  298. package/dist/schema.d.ts.map +1 -0
  299. package/dist/schema.js +1 -0
  300. package/dist/storage/bytes.d.ts +17 -0
  301. package/dist/storage/bytes.d.ts.map +1 -0
  302. package/dist/storage/http.d.ts +43 -0
  303. package/dist/storage/http.d.ts.map +1 -0
  304. package/dist/storage/local.d.ts +31 -0
  305. package/dist/storage/local.d.ts.map +1 -0
  306. package/dist/storage/providers.d.ts +95 -0
  307. package/dist/storage/providers.d.ts.map +1 -0
  308. package/dist/storage/sign.d.ts +53 -0
  309. package/dist/storage/sign.d.ts.map +1 -0
  310. package/dist/strings.d.ts +13 -0
  311. package/dist/strings.d.ts.map +1 -0
  312. package/dist/telemetry.d.ts +137 -0
  313. package/dist/telemetry.d.ts.map +1 -0
  314. package/dist/telemetry.js +1 -0
  315. package/dist/types/activity.d.ts +68 -0
  316. package/dist/types/activity.d.ts.map +1 -0
  317. package/dist/types/actor.d.ts +26 -0
  318. package/dist/types/actor.d.ts.map +1 -0
  319. package/dist/types/ai.d.ts +357 -0
  320. package/dist/types/ai.d.ts.map +1 -0
  321. package/dist/types/api.d.ts +212 -0
  322. package/dist/types/api.d.ts.map +1 -0
  323. package/dist/types/auth.d.ts +310 -0
  324. package/dist/types/auth.d.ts.map +1 -0
  325. package/dist/types/config.d.ts +632 -0
  326. package/dist/types/config.d.ts.map +1 -0
  327. package/dist/types/database.d.ts +75 -0
  328. package/dist/types/database.d.ts.map +1 -0
  329. package/dist/types/editor.d.ts +140 -0
  330. package/dist/types/editor.d.ts.map +1 -0
  331. package/dist/types/events.d.ts +72 -0
  332. package/dist/types/events.d.ts.map +1 -0
  333. package/dist/types/fields.d.ts +142 -0
  334. package/dist/types/fields.d.ts.map +1 -0
  335. package/dist/types/hooks.d.ts +142 -0
  336. package/dist/types/hooks.d.ts.map +1 -0
  337. package/dist/types/index.d.ts +25 -0
  338. package/dist/types/index.d.ts.map +1 -0
  339. package/dist/types/instance.d.ts +263 -0
  340. package/dist/types/instance.d.ts.map +1 -0
  341. package/dist/types/jobs.d.ts +78 -0
  342. package/dist/types/jobs.d.ts.map +1 -0
  343. package/dist/types/json.d.ts +24 -0
  344. package/dist/types/json.d.ts.map +1 -0
  345. package/dist/types/locales.d.ts +30 -0
  346. package/dist/types/locales.d.ts.map +1 -0
  347. package/dist/types/media.d.ts +245 -0
  348. package/dist/types/media.d.ts.map +1 -0
  349. package/dist/types/panel.d.ts +249 -0
  350. package/dist/types/panel.d.ts.map +1 -0
  351. package/dist/types/plugin.d.ts +172 -0
  352. package/dist/types/plugin.d.ts.map +1 -0
  353. package/dist/types/query.d.ts +101 -0
  354. package/dist/types/query.d.ts.map +1 -0
  355. package/dist/types/schema.d.ts +203 -0
  356. package/dist/types/schema.d.ts.map +1 -0
  357. package/dist/types/storage.d.ts +61 -0
  358. package/dist/types/storage.d.ts.map +1 -0
  359. package/dist/types/telemetry.d.ts +14 -0
  360. package/dist/types/telemetry.d.ts.map +1 -0
  361. package/dist/types/trash.d.ts +42 -0
  362. package/dist/types/trash.d.ts.map +1 -0
  363. package/dist/types/webhooks.d.ts +133 -0
  364. package/dist/types/webhooks.d.ts.map +1 -0
  365. package/dist/types.d.ts +8 -0
  366. package/dist/types.d.ts.map +1 -0
  367. package/dist/types.js +1 -0
  368. package/dist/uploads.d.ts +21 -0
  369. package/dist/uploads.d.ts.map +1 -0
  370. package/dist/uploads.js +9 -0
  371. package/dist/webhooks/index.d.ts +10 -0
  372. package/dist/webhooks/index.d.ts.map +1 -0
  373. package/dist/webhooks/job.d.ts +17 -0
  374. package/dist/webhooks/job.d.ts.map +1 -0
  375. package/dist/webhooks/service.d.ts +53 -0
  376. package/dist/webhooks/service.d.ts.map +1 -0
  377. package/dist/webhooks/sign.d.ts +26 -0
  378. package/dist/webhooks/sign.d.ts.map +1 -0
  379. package/dist/webhooks.d.ts +10 -0
  380. package/dist/webhooks.d.ts.map +1 -0
  381. package/dist/webhooks.js +1 -0
  382. package/package.json +183 -4
@@ -0,0 +1,2 @@
1
+ class e extends Error{status;code;details;constructor(t,r={}){super(t,r.cause===void 0?void 0:{cause:r.cause});if(this.name="CmsError",this.status=r.status??400,this.code=r.code??"cms_error",r.details!==void 0)this.details=r.details}static notFound(t="Not found"){return new e(t,{status:404,code:"not_found"})}static forbidden(t="Forbidden"){return new e(t,{status:403,code:"forbidden"})}static unauthorized(t="Unauthorized"){return new e(t,{status:401,code:"unauthorized"})}static conflict(t){return new e(t,{status:409,code:"conflict"})}static validation(t,r){return new e(t,{status:422,code:"validation_failed",...r===void 0?{}:{details:r}})}}class n extends Error{path;constructor(t,r){super(t?`${t}: ${r}`:r);this.name="CmsConfigError",this.path=t}}
2
+ export{e,n};
@@ -0,0 +1,2 @@
1
+ var N="cms_migrations";function e(u,i,a={}){return{name:u,type:i,nullable:a.default!==void 0?!1:a.nullable??!0,storage:"column",...a.default===void 0?{}:{default:a.default},...a.unique===void 0?{}:{unique:a.unique},...a.index===void 0?{}:{index:a.index},...a.array===void 0?{}:{array:a.array},...a.references===void 0?{}:{references:a.references}}}var l=()=>e("id","text",{nullable:!1,unique:!0}),n=()=>e("created_at","timestamp",{nullable:!1}),o=()=>e("updated_at","timestamp",{nullable:!1});function t(u,i,a={}){let d=i.map((c)=>({kind:"column",column:c})),r=a.unique===!0?"uniq":"idx";return{name:a.name??`${r}_${u}_${i.join("_")}`,table:u,targets:d,unique:a.unique===!0}}function s(u,i,a=[],d){return{name:u,columns:[...i].sort((r,c)=>r.name.localeCompare(c.name)),primaryKey:["id"],indexes:[...a].sort((r,c)=>r.name.localeCompare(c.name)),...d===void 0?{}:{documentColumn:d}}}function ze(){return[m(),_(),b(),f(),p(),x(),h(),y(),T(),g(),v(),k(),q(),S(),j(),w(),C()].sort((u,i)=>u.name.localeCompare(i.name))}function Ve(){return["cms_migrations",...ze().map((u)=>u.name)].sort()}function m(){return s("documents",[l(),e("collection","text",{nullable:!1}),e("data","json",{nullable:!1}),e("revision","integer",{nullable:!1,default:1}),e("scheduled_at","timestamp"),e("scheduled_patch","json"),e("deleted_at","timestamp"),e("purge_after","timestamp"),n(),o(),e("updated_by","text")],[t("documents",["collection"]),t("documents",["collection","deleted_at"]),t("documents",["collection","updated_at"]),t("documents",["scheduled_at"]),t("documents",["purge_after"])],"data")}function _(){return s("cms_users",[l(),e("email","text",{nullable:!1,unique:!0}),e("name","text"),e("password_hash","text"),e("two_factor_secret","text"),e("two_factor_enabled","boolean",{default:!1}),e("status","text",{nullable:!1,default:"active"}),e("roles","json",{nullable:!1,array:!0}),e("avatar_url","text"),e("locale","text"),e("last_login_at","timestamp"),n(),o()],[t("cms_users",["email"],{unique:!0})])}function b(){return s("cms_sessions",[l(),e("user_id","text",{nullable:!1,references:{table:"cms_users",column:"id",onDelete:"cascade"}}),e("token_hash","text",{nullable:!1,unique:!0}),e("ip","text"),e("user_agent","text"),e("expires_at","timestamp",{nullable:!1}),n()],[t("cms_sessions",["token_hash"],{unique:!0}),t("cms_sessions",["user_id"]),t("cms_sessions",["expires_at"])])}function f(){return s("cms_accounts",[l(),e("user_id","text",{nullable:!1,references:{table:"cms_users",column:"id",onDelete:"cascade"}}),e("provider","text",{nullable:!1}),e("provider_account_id","text",{nullable:!1}),e("email","text"),n(),o()],[t("cms_accounts",["provider","provider_account_id"],{unique:!0,name:"uniq_cms_accounts_provider_account"}),t("cms_accounts",["user_id"])])}function p(){return s("cms_tokens",[l(),e("type","text",{nullable:!1}),e("user_id","text",{references:{table:"cms_users",column:"id",onDelete:"cascade"}}),e("email","text"),e("token_hash","text",{nullable:!1,unique:!0}),e("data","json"),e("expires_at","timestamp",{nullable:!1}),e("consumed_at","timestamp"),n()],[t("cms_tokens",["token_hash"],{unique:!0}),t("cms_tokens",["user_id"]),t("cms_tokens",["type","expires_at"])])}function x(){return s("cms_api_keys",[l(),e("name","text",{nullable:!1}),e("user_id","text",{references:{table:"cms_users",column:"id",onDelete:"cascade"}}),e("key_hash","text",{nullable:!1,unique:!0}),e("prefix","text",{nullable:!1}),e("scopes","json",{nullable:!1,array:!0}),e("last_used_at","timestamp"),e("expires_at","timestamp"),e("revoked_at","timestamp"),n()],[t("cms_api_keys",["key_hash"],{unique:!0}),t("cms_api_keys",["user_id"])])}function h(){return s("cms_roles",[l(),e("name","text",{nullable:!1,unique:!0}),e("label","text"),e("permissions","json",{nullable:!1,array:!0}),n(),o()],[t("cms_roles",["name"],{unique:!0})])}function y(){return s("cms_ai_credentials",[l(),e("provider","text",{nullable:!1,unique:!0}),e("auth_type","text",{nullable:!1,default:"api-key"}),e("secret","text",{nullable:!1}),e("hint","text"),n(),o()],[t("cms_ai_credentials",["provider"],{unique:!0})])}function T(){return s("cms_ai_mutations",[l(),e("idempotency_key","text",{nullable:!1,unique:!0}),e("run_id","text",{nullable:!1}),e("collection","text"),e("document_id","text"),e("result","json"),n()],[t("cms_ai_mutations",["idempotency_key"],{unique:!0}),t("cms_ai_mutations",["run_id"])])}function g(){return s("cms_ai_plans",[l(),e("run_id","text",{nullable:!1}),e("actor_id","text"),e("kind","text",{nullable:!1}),e("summary","text",{nullable:!1}),e("operations","json",{nullable:!1}),e("status","text",{nullable:!1,default:"pending"}),e("result","json"),e("expires_at","timestamp",{nullable:!1}),e("approved_at","timestamp"),n()],[t("cms_ai_plans",["run_id"]),t("cms_ai_plans",["status","expires_at"])])}function v(){return s("media",[l(),e("filename","text",{nullable:!1}),e("mime_type","text",{nullable:!1}),e("size","bigint",{nullable:!1}),e("width","integer"),e("height","integer"),e("storage_key","text",{nullable:!1,unique:!0}),e("checksum","text"),e("alt","json"),e("focal_x","real"),e("focal_y","real"),e("status","text",{nullable:!1,default:"active"}),e("orphaned_at","timestamp"),e("purge_after","timestamp"),e("purge_error","text"),e("metadata","json"),e("created_by","text"),n(),o()],[t("media",["storage_key"],{unique:!0}),t("media",["status"]),t("media",["status","purge_after"])])}function k(){return s("media_usages",[l(),e("media_id","text",{nullable:!1,references:{table:"media",column:"id",onDelete:"cascade"}}),e("collection","text",{nullable:!1}),e("document_id","text",{nullable:!1}),e("field","text",{nullable:!1}),e("locale","text",{nullable:!1,default:""}),n()],[t("media_usages",["media_id"]),t("media_usages",["document_id"]),t("media_usages",["media_id","document_id","field","locale"],{unique:!0,name:"uniq_media_usages_reference"})])}function q(){return s("webhooks",[l(),e("url","text",{nullable:!1}),e("events","json",{nullable:!1,array:!0}),e("filters","json"),e("headers","json"),e("secret","text"),e("active","boolean",{nullable:!1,default:!0}),n(),o()],[t("webhooks",["active"])])}function S(){return s("webhook_deliveries",[l(),e("webhook_id","text",{nullable:!1,references:{table:"webhooks",column:"id",onDelete:"cascade"}}),e("event_id","text",{nullable:!1}),e("event_type","text",{nullable:!1}),e("status","text",{nullable:!1,default:"pending"}),e("attempt","integer",{nullable:!1,default:0}),e("request_body","json"),e("response_status","integer"),e("response_body","text"),e("error","text"),e("next_attempt_at","timestamp"),e("delivered_at","timestamp"),n()],[t("webhook_deliveries",["webhook_id","created_at"]),t("webhook_deliveries",["status","next_attempt_at"]),t("webhook_deliveries",["event_id"])])}function j(){return s("outbox",[l(),e("event_id","text",{nullable:!1,unique:!0}),e("type","text",{nullable:!1}),e("payload","json",{nullable:!1}),e("previous","json"),e("actor","json"),e("collection","text"),e("document_id","text"),e("status","text",{nullable:!1,default:"pending"}),e("attempts","integer",{nullable:!1,default:0}),e("available_at","timestamp",{nullable:!1}),e("processed_at","timestamp"),e("error","text"),n()],[t("outbox",["event_id"],{unique:!0}),t("outbox",["status","available_at"]),t("outbox",["document_id","created_at"])])}function w(){return s("activity",[l(),e("actor_id","text"),e("actor_source","text"),e("action","text",{nullable:!1}),e("source","text"),e("collection","text"),e("document_id","text"),e("locale","text"),e("changes","json"),e("ip","text"),n()],[t("activity",["collection","document_id"]),t("activity",["actor_id"]),t("activity",["created_at"])])}function C(){return s("jobs",[l(),e("type","text",{nullable:!1}),e("payload","json"),e("status","text",{nullable:!1,default:"pending"}),e("run_at","timestamp",{nullable:!1}),e("attempts","integer",{nullable:!1,default:0}),e("locked_at","timestamp"),e("locked_by","text"),e("completed_at","timestamp"),e("error","text"),n()],[t("jobs",["status","run_at"]),t("jobs",["type"])])}
2
+ export{N,ze,Ve};
@@ -0,0 +1,2 @@
1
+ import{ze}from"./index-y5mwknr9.js";var g="documents",Qt="data";function At(n){let e=[...Object.values(n.collections),...Object.values(n.globals)].sort((t,a)=>t.name.localeCompare(a.name)),o=e.flatMap(r),s=ze().map((t)=>t.name===g?{...t,indexes:[...t.indexes,...o].sort((a,l)=>a.name.localeCompare(l.name))}:t);for(let t of n.pluginTables??[])s.push(u(t));return{version:1,tables:s.sort((t,a)=>t.name.localeCompare(a.name)),collections:e.map(c)}}function xt(){return{version:1,tables:[],collections:[]}}function u(n){return{...n,columns:[...n.columns].sort((e,o)=>e.name.localeCompare(o.name)),indexes:[...n.indexes].sort((e,o)=>e.name.localeCompare(o.name))}}function c(n){return{name:n.name,slug:n.slug,kind:n.kind,table:g,documentColumn:Qt,fields:Object.entries(n.fields).map(([e,o])=>i(e,o)).sort((e,o)=>e.name.localeCompare(o.name))}}function i(n,e){let o=e.defaultValue??e.column.default;return{name:n,type:e.type,localized:e.localized,required:e.required,unique:e.column.unique===!0,index:e.column.index===!0||e.column.unique===!0,...o===void 0?{}:{default:o},...e.relationTo===void 0?{}:{relationTo:e.relationTo},column:e.column}}function r(n){let e=[];for(let[o,s]of Object.entries(n.fields)){let t=s.column.unique===!0;if(!(t||s.column.index===!0)||s.localized)continue;e.push({name:m(n.slug,o,t),table:g,targets:[{kind:"json",column:Qt,path:[o],type:s.column.type}],unique:t,where:{column:"collection",equals:n.slug}})}return e.sort((o,s)=>o.name.localeCompare(s.name))}function m(n,e,o){return`${o?"uniq":"idx"}_documents_${n}_${e}`}
2
+ export{g,Qt,At,xt};
@@ -0,0 +1,25 @@
1
+ /**
2
+ * `@heyo-sh/heyo-cms`.
3
+ *
4
+ * The configuration surface and the contracts. Databases, fields and storage
5
+ * come from their own entry points so a Worker bundle only carries what it
6
+ * uses.
7
+ */
8
+ export { defaultAdminPath, defaultBasePath, defaultMigrationsDirectory, defineCollection, defineGlobal, heyoCms, systemActor, } from "./config";
9
+ export { aiActionsFor, createAi, defineAiAction, getAiAction, piCompletion, registeredAiActions, } from "./ai/index";
10
+ export { defineEditorMark, defineEditorNode, describeEditorSchema, getEditorMark, getEditorNode, registeredEditorMarks, registeredEditorNodes, renderRichText, richTextFromMarkdown, richTextFromText, richTextToHtml, richTextToMarkdown, richTextToPlainText, } from "./editor/index";
11
+ export { createWebhooks, signatureHeader, signPayload, verifySignature, webhookRetryJob, } from "./webhooks/index";
12
+ export { cmsScheduled, runDueJobs, startJobRunner, type JobRunnerHandle, type JobRunnerOptions, } from "./jobs/runner";
13
+ export { expandRoles, grants, intersectPermissions, isValidScope, permissionFor, permits, scopePermissions, } from "./access/index";
14
+ export { CmsConfigError, CmsError } from "./errors";
15
+ export { isRtlLocale, localeName, localeRecords, LOCALE_NAMES, } from "./i18n/index";
16
+ export { createId, createOrderedId } from "./ids";
17
+ export { createCmsHttp, Router, type CmsHttp, type RouteRecord, } from "./http/index";
18
+ export { applyFieldReadAccess, assertFieldWriteAccess, buildHookPipeline, cursorWhere, encodeCursor, globalRowId, hookPipelineEntries, listTrashed, localeContext, resolveLocalized, rowToDocument, scheduledPatch, scopedDb, toStoredData, validateFields, CmsEngine, EventBuffer, JobRunner, Outbox, RelationLoader, relationTarget, runAfterHooks, runBeforeHooks, type CollectionHookPipeline, type EngineOptions, type EventDispatch, type JobDefinition, type JobHost, type ListTrashedOptions, type LocaleContext, type ScheduledPatch, type WriteIntent, } from "./engine/index";
19
+ export { collectMediaReferences, createMedia, mediaGcJob, prepareUpload, probeImage, referencesMedia, stripImageMetadata, syncMediaUsages, toMediaDocument, variantKey, variantTransform, type MediaGcContext, type MediaReference, type MediaServiceOptions, type PreparedUpload, } from "./media/index";
20
+ export { parseByteSize, parseDuration } from "./duration";
21
+ export { describePanel } from "./panel";
22
+ export { buildSchemaSnapshot, documentsDataColumn, documentsTableName, emptySnapshot, planMigration, systemTableNames, systemTables, } from "./schema/index";
23
+ export { defineField } from "./fields/registry";
24
+ export type * from "./types/index";
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,0BAA0B,EAC1B,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,WAAW,GACZ,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,WAAW,EACX,YAAY,EACZ,mBAAmB,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,cAAc,EACd,eAAe,EACf,WAAW,EACX,eAAe,EACf,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,UAAU,EACV,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,WAAW,EACX,MAAM,EACN,oBAAoB,EACpB,YAAY,EACZ,aAAa,EACb,OAAO,EACP,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EACL,WAAW,EACX,UAAU,EACV,aAAa,EACb,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EACL,aAAa,EACb,MAAM,EACN,KAAK,OAAO,EACZ,KAAK,WAAW,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,SAAS,EACT,WAAW,EACX,SAAS,EACT,MAAM,EACN,cAAc,EACd,cAAc,EACd,aAAa,EACb,cAAc,EACd,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,OAAO,EACZ,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,WAAW,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,sBAAsB,EACtB,WAAW,EACX,UAAU,EACV,aAAa,EACb,UAAU,EACV,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,mBAAmB,eAAe,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{x,Y,Ne,wt,Tn,Sn,de,ue,On,J,_n,pe,Pn}from"./index-9zqnf6gx.js";import{ae,z,$e,ce,le,_}from"./index-vq2978e7.js";import{Rt,Ln,P,Ge,Ct,Tt,Re,S,rn,A,Ce,Ie,Te}from"./index-2z1qe5mw.js";import"./index-vxw0a03g.js";import{Xe,Se,De,Dt,et,tt,nt,ot,un,Mt,rt,V,qt,Lt,Ft,pn,Jt,Nt,Wn,Hn,Bn,it}from"./index-ty698y02.js";import{_e,Cn,Pe}from"./index-nvgwyykk.js";import{Ut,Wt,Ht,W,q,L,st,mn,Me,Bt,ut,fn,zt}from"./index-wj8y1xcj.js";import"./index-g4crf47y.js";import{Qe,ln,dn}from"./index-hy1x46nf.js";import{Le,ht}from"./index-hq05mc1n.js";import{be,we,wn}from"./index-7k091gpe.js";import{d}from"./index-9g2n7xa6.js";import{me,He,Be}from"./index-2757kej5.js";import{T}from"./index-k8wbg1dw.js";import{Ae}from"./index-gpwcmmvr.js";import{g,Qt,At,xt}from"./index-ymq6jsar.js";import{ze,Ve}from"./index-y5mwknr9.js";import"./index-5ngtc7gy.js";import{b,ee}from"./index-cbwwtcm4.js";import{w,ge}from"./index-2kb5nbxx.js";import{e,n}from"./index-x72d1hzh.js";export{n as CmsConfigError,rt as CmsEngine,e as CmsError,tt as EventBuffer,et as JobRunner,qt as LOCALE_NAMES,nt as Outbox,ot as RelationLoader,_e as Router,$e as aiActionsFor,le as applyFieldReadAccess,_ as assertFieldWriteAccess,Xe as buildHookPipeline,At as buildSchemaSnapshot,dn as cmsScheduled,Wt as collectMediaReferences,ht as createAi,Pe as createCmsHttp,w as createId,zt as createMedia,ge as createOrderedId,Jt as createWebhooks,q as cursorWhere,He as defaultAdminPath,me as defaultBasePath,Be as defaultMigrationsDirectory,ae as defineAiAction,Wn as defineCollection,Y as defineEditorMark,x as defineEditorNode,T as defineField,Hn as defineGlobal,de as describeEditorSchema,Cn as describePanel,Qt as documentsDataColumn,g as documentsTableName,xt as emptySnapshot,W as encodeCursor,Ge as expandRoles,z as getAiAction,wt as getEditorMark,Ne as getEditorNode,V as globalRowId,Ln as grants,Bn as heyoCms,Dt as hookPipelineEntries,Ct as intersectPermissions,Ft as isRtlLocale,Re as isValidScope,Mt as listTrashed,S as localeContext,Lt as localeName,pn as localeRecords,Bt as mediaGcJob,ee as parseByteSize,b as parseDuration,Rt as permissionFor,P as permits,Le as piCompletion,Ae as planMigration,fn as prepareUpload,st as probeImage,Ut as referencesMedia,ce as registeredAiActions,Sn as registeredEditorMarks,Tn as registeredEditorNodes,un as relationTarget,ue as renderRichText,rn as resolveLocalized,pe as richTextFromMarkdown,Pn as richTextFromText,On as richTextToHtml,J as richTextToMarkdown,_n as richTextToPlainText,A as rowToDocument,De as runAfterHooks,Se as runBeforeHooks,Qe as runDueJobs,Te as scheduledPatch,Tt as scopePermissions,d as scopedDb,we as signPayload,be as signatureHeader,ln as startJobRunner,ut as stripImageMetadata,Ht as syncMediaUsages,it as systemActor,Ve as systemTableNames,ze as systemTables,L as toMediaDocument,Ce as toStoredData,Ie as validateFields,Me as variantKey,mn as variantTransform,wn as verifySignature,Nt as webhookRetryJob};
@@ -0,0 +1,77 @@
1
+ import type { Duration } from "../types/config";
2
+ import type { CmsInstance } from "../types/instance";
3
+ import type { JobRunArgs, JobRunReport } from "../types/jobs";
4
+ /**
5
+ * Something has to call `cms.jobs.run()`.
6
+ *
7
+ * The package deliberately starts no timer of its own (stage 5): it has to
8
+ * load on Workers and on Lambda, where a `setInterval` either does nothing
9
+ * or keeps an invocation alive and bills for it. So the sweeps are a
10
+ * function, and this file is the two ways a deployment calls it — a timer
11
+ * for a process that has one, and a handler for a platform that owns the
12
+ * clock.
13
+ *
14
+ * Both do the same two things in the same order: run what is due, then drain
15
+ * the outbox. The second part is not optional on serverless, where the
16
+ * process freezes the moment the handler returns and anything still in the
17
+ * outbox waits for the next cron.
18
+ */
19
+ export interface RunDueOptions extends JobRunArgs {
20
+ /** Delivers the events the sweep produced before returning. Default true. */
21
+ drainEvents?: boolean;
22
+ }
23
+ export declare function runDueJobs(cms: CmsInstance, options?: RunDueOptions): Promise<JobRunReport>;
24
+ export interface JobRunnerOptions extends RunDueOptions {
25
+ cms: CmsInstance;
26
+ /** How often to sweep. Defaults to one minute. */
27
+ interval?: Duration | number;
28
+ /** Runs one sweep immediately instead of waiting for the first tick. */
29
+ immediate?: boolean;
30
+ onReport?: (report: JobRunReport) => void;
31
+ /**
32
+ * Called when a sweep throws.
33
+ *
34
+ * A sweep that throws is a database that is unreachable, not a job that
35
+ * failed — individual failures are recorded and counted inside the report.
36
+ * Default: log to `console.error`, because a background loop that swallows
37
+ * its own outage is worse than a noisy one.
38
+ */
39
+ onError?: (error: unknown) => void;
40
+ /** Stops the loop. The same signal a server shutdown already has. */
41
+ signal?: AbortSignal;
42
+ }
43
+ export interface JobRunnerHandle {
44
+ /** Runs one sweep now, outside the schedule. */
45
+ runNow(): Promise<JobRunReport>;
46
+ /** Stops the loop and waits for a sweep in flight. */
47
+ stop(): Promise<void>;
48
+ readonly running: boolean;
49
+ }
50
+ /**
51
+ * The Node and Bun answer: a timer that never overlaps itself.
52
+ *
53
+ * Overlap is the failure that matters here. A sweep that takes longer than
54
+ * the interval — a backlog of scheduled changes, a slow webhook endpoint —
55
+ * would otherwise start a second pass over the same rows, and every job in
56
+ * the product claims its row before acting precisely because that must stay
57
+ * harmless. Not starting the second pass is cheaper than relying on it.
58
+ */
59
+ export declare function startJobRunner(options: JobRunnerOptions): JobRunnerHandle;
60
+ /**
61
+ * The Workers answer: the platform owns the clock.
62
+ *
63
+ * ```ts
64
+ * export default {
65
+ * fetch: (request) => cms.handler(request),
66
+ * scheduled: cmsScheduled(cms),
67
+ * };
68
+ * ```
69
+ *
70
+ * `waitUntil` is used when the platform provides it, so the outbox drain is
71
+ * allowed to outlive the handler rather than being killed halfway through a
72
+ * webhook.
73
+ */
74
+ export declare function cmsScheduled(cms: CmsInstance, options?: RunDueOptions): (event: unknown, env?: unknown, context?: {
75
+ waitUntil?: (promise: Promise<unknown>) => void;
76
+ }) => Promise<void>;
77
+ //# sourceMappingURL=runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/jobs/runner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE9D;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,aAAc,SAAQ,UAAU;IAC/C,6EAA6E;IAC7E,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wBAAsB,UAAU,CAC9B,GAAG,EAAE,WAAW,EAChB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,YAAY,CAAC,CAKvB;AAED,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,GAAG,EAAE,WAAW,CAAC;IACjB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC7B,wEAAwE;IACxE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAC1C;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,qEAAqE;IACrE,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,gDAAgD;IAChD,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IAChC,sDAAsD;IACtD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,eAAe,CAqEzE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,WAAW,EAChB,OAAO,GAAE,aAAkB,GAC1B,CACD,KAAK,EAAE,OAAO,EACd,GAAG,CAAC,EAAE,OAAO,EACb,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,IAAI,CAAA;CAAE,KAC1D,OAAO,CAAC,IAAI,CAAC,CAMjB"}
package/dist/jobs.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * `@heyo-sh/heyo-cms/jobs`.
3
+ *
4
+ * The scheduled-change sweep, the trash purge, `media-gc` and the webhook
5
+ * retries all run from `cms.jobs.run()`. This entry point is how something
6
+ * calls it on a schedule: a timer in a long-lived process, or the platform's
7
+ * own cron on Workers and Vercel.
8
+ */
9
+ export { cmsScheduled, runDueJobs, startJobRunner, type JobRunnerHandle, type JobRunnerOptions, type RunDueOptions, } from "./jobs/runner";
10
+ export type { CmsJobs, JobFailure, JobResult, JobRunArgs, JobRunReport, } from "./types/jobs";
11
+ //# sourceMappingURL=jobs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jobs.d.ts","sourceRoot":"","sources":["../src/jobs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,YAAY,EACZ,UAAU,EACV,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,aAAa,GACnB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,OAAO,EACP,UAAU,EACV,SAAS,EACT,UAAU,EACV,YAAY,GACb,MAAM,cAAc,CAAC"}
package/dist/jobs.js ADDED
@@ -0,0 +1 @@
1
+ import{Qe,ln,dn}from"./index-hy1x46nf.js";export{dn as cmsScheduled,Qe as runDueJobs,ln as startJobRunner};
@@ -0,0 +1,28 @@
1
+ import type { JsonObject } from "../types/json";
2
+ import type { MediaDocument } from "../types/media";
3
+ import type { Row } from "../types/query";
4
+ import type { StorageAdapter } from "../types/storage";
5
+ /**
6
+ * Metadata keys the engine owns.
7
+ *
8
+ * The crop rectangle and the list of rendered sizes live inside the `metadata`
9
+ * column because they are per-file facts no index ever has to answer about,
10
+ * and two more columns on a system table is two more migrations for every
11
+ * deployment that will ever exist. They are hidden from
12
+ * `MediaDocument.metadata` and refused on write, so "your metadata" stays
13
+ * yours.
14
+ */
15
+ export declare const reservedMetadata: readonly ["crop", "variants"];
16
+ /**
17
+ * A `media` row as the rest of the world sees it.
18
+ *
19
+ * `url` is the adapter's public URL rather than a signed one: signing is
20
+ * cryptography, and making this asynchronous would charge every list of
21
+ * twenty-five files twenty-five signatures for a feature most deployments do
22
+ * not use. A private bucket signs at the moment of serving instead, which is
23
+ * what `cms.media.variant()` returns.
24
+ */
25
+ export declare function toMediaDocument(row: Row, storage: StorageAdapter): MediaDocument;
26
+ /** The document as an event payload: plain JSON, no behaviour, no aliasing. */
27
+ export declare function mediaJson(media: MediaDocument): JsonObject;
28
+ //# sourceMappingURL=document.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/media/document.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,eAAe,CAAC;AAC3D,OAAO,KAAK,EAAwB,aAAa,EAAe,MAAM,gBAAgB,CAAC;AACvF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,YAAI,MAAM,EAAE,UAAU,CAAU,CAAC;AAE9D;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,cAAc,GACtB,aAAa,CA8Bf;AAED,+EAA+E;AAC/E,wBAAgB,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,UAAU,CAE1D"}
@@ -0,0 +1,46 @@
1
+ import type { JobDefinition } from "../engine/jobs";
2
+ import type { BufferedEvent, OutboxEntryMeta } from "../engine/outbox";
3
+ import type { ResolvedCmsConfig, UploadsConfig } from "../types/config";
4
+ import type { DatabaseAdapter } from "../types/database";
5
+ import type { MediaCollectArgs, MediaCollectReport, MediaDocument } from "../types/media";
6
+ import type { Row, Tx } from "../types/query";
7
+ import type { StorageAdapter } from "../types/storage";
8
+ export interface MediaGcContext {
9
+ config: ResolvedCmsConfig;
10
+ database: () => Promise<DatabaseAdapter>;
11
+ storage: () => Promise<StorageAdapter>;
12
+ emit: (tx: Tx, events: BufferedEvent[], meta: OutboxEntryMeta) => Promise<void>;
13
+ deliver: () => void;
14
+ }
15
+ /** Files whose grace period has run out, oldest obligation first. */
16
+ export declare function dueMedia(context: MediaGcContext, now: Date, limit: number): Promise<Row[]>;
17
+ export declare function collectMedia(context: MediaGcContext, args?: MediaCollectArgs): Promise<MediaCollectReport>;
18
+ export type CollectOutcome = "purged" | "reclaimed" | "taken";
19
+ /**
20
+ * Takes one file, or discovers it should not be taken.
21
+ *
22
+ * The status change is a conditional update — the same portable claim the
23
+ * outbox and the scheduler use — so two collectors running at once cannot
24
+ * both delete the same object, on any of the three engines and without a
25
+ * lock.
26
+ */
27
+ export declare function collectOne(context: MediaGcContext, row: Row, now: Date): Promise<CollectOutcome>;
28
+ /**
29
+ * The sweep, as the job registry sees it.
30
+ *
31
+ * Registered next to `scheduled-changes` and `trash-purge` rather than run on
32
+ * a timer of its own: the deployment decides what calls `cms.jobs.run()`,
33
+ * because the package does not know whether it is in a process that has
34
+ * timers (stage 5).
35
+ */
36
+ export declare function mediaGcJob(context: MediaGcContext): JobDefinition;
37
+ /**
38
+ * Every object this file owns: the original and every size rendered from it.
39
+ *
40
+ * The recorded list plus the declared one. A size removed from the
41
+ * configuration still has objects in the bucket, and a size added since the
42
+ * last render has none but costs nothing to ask about — and a leaked
43
+ * derivative is a file nobody will ever find again.
44
+ */
45
+ export declare function storageKeysOf(media: MediaDocument, uploads: UploadsConfig | undefined): string[];
46
+ //# sourceMappingURL=gc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gc.d.ts","sourceRoot":"","sources":["../../src/media/gc.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAmBvD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;IACzC,OAAO,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,CAAC;IACvC,IAAI,EAAE,CACJ,EAAE,EAAE,EAAE,EACN,MAAM,EAAE,aAAa,EAAE,EACvB,IAAI,EAAE,eAAe,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,qEAAqE;AACrE,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,cAAc,EACvB,GAAG,EAAE,IAAI,EACT,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,GAAG,EAAE,CAAC,CAqBhB;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,cAAc,EACvB,IAAI,GAAE,gBAAqB,GAC1B,OAAO,CAAC,kBAAkB,CAAC,CAyB7B;AAED,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,CAAC;AAE9D;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,cAAc,EACvB,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,IAAI,GACR,OAAO,CAAC,cAAc,CAAC,CAqDzB;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,aAAa,CAcjE;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,aAAa,GAAG,SAAS,GACjC,MAAM,EAAE,CASV"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Media: storage, processing and the lifecycle.
3
+ *
4
+ * Three separate concerns that only make sense together. Storage is where the
5
+ * bytes live; processing is what happens to them on the way in and on the way
6
+ * out; the lifecycle is the reference counting that lets a file be removed
7
+ * from a page without being destroyed (section 6).
8
+ *
9
+ * Nothing here is HTTP-aware. The routes in stage 7 and the library screen in
10
+ * stage 8 call exactly these functions.
11
+ */
12
+ export { mediaJson, reservedMetadata, toMediaDocument } from "./document";
13
+ export { collectMedia, collectOne, dueMedia, mediaGcJob, storageKeysOf, type CollectOutcome, type MediaGcContext, } from "./gc";
14
+ export { matchesMime, prepareUpload, sanitiseFilename, type PrepareUploadOptions, type PreparedUpload, } from "./pipeline";
15
+ export { extensionFor, imageContentType, probeImage } from "./probe";
16
+ export { createMedia, type MediaServiceOptions } from "./service";
17
+ export { stripImageMetadata } from "./strip";
18
+ export { collectMediaReferences, mediaTable, mediaUsagesTable, purgeDeadline, referencesMedia, richTextMediaAttribute, syncMediaUsages, type MediaReference, type SyncMediaUsagesOptions, type SyncMediaUsagesResult, } from "./usages";
19
+ export { renderVariant, variantContentType, variantKey, variantNames, variantQuery, variantSize, variantTransform, } from "./variants";
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/media/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EACL,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,UAAU,EACV,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,cAAc,GACpB,MAAM,MAAM,CAAC;AACd,OAAO,EACL,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,KAAK,oBAAoB,EACzB,KAAK,cAAc,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EACL,sBAAsB,EACtB,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,GAC3B,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { UploadsConfig } from "../types/config";
2
+ import type { ImageInfo } from "../types/media";
3
+ /**
4
+ * What happens between "here is a file" and "it is in the bucket".
5
+ *
6
+ * Validate, identify, shrink, strip, fingerprint — in that order, and all of
7
+ * it before a single byte reaches storage. Doing any of it afterwards would
8
+ * mean a rejected upload still costs a write, and a downscale that failed
9
+ * would leave the original in the bucket forever.
10
+ */
11
+ export interface PreparedUpload {
12
+ data: Uint8Array;
13
+ contentType: string;
14
+ filename: string;
15
+ /** Null for anything that is not an image we can read. */
16
+ info: ImageInfo | null;
17
+ checksum: string;
18
+ extension: string;
19
+ }
20
+ export interface PrepareUploadOptions {
21
+ bytes: Uint8Array;
22
+ filename: string;
23
+ /** What the client claimed. Overruled by the bytes when they disagree. */
24
+ contentType: string;
25
+ uploads: UploadsConfig;
26
+ }
27
+ export declare function prepareUpload(options: PrepareUploadOptions): Promise<PreparedUpload>;
28
+ export declare function matchesMime(contentType: string, pattern: string): boolean;
29
+ /**
30
+ * A filename that is safe to show, log and put in a header.
31
+ *
32
+ * It is never used to build a storage key — those are derived from the id —
33
+ * so this is about display and `content-disposition`, not about traversal.
34
+ */
35
+ export declare function sanitiseFilename(filename: string): string;
36
+ //# sourceMappingURL=pipeline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/media/pipeline.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAkB,MAAM,gBAAgB,CAAC;AAIhE;;;;;;;GAOG;AAEH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,wBAAsB,aAAa,CACjC,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,cAAc,CAAC,CA6DzB;AAwFD,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAMzE;AAWD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAOzD"}
@@ -0,0 +1,6 @@
1
+ import type { ImageFormat, ImageInfo } from "../types/media";
2
+ export declare function imageContentType(format: ImageFormat): string;
3
+ export declare function probeImage(bytes: Uint8Array): ImageInfo | null;
4
+ /** The extension a stored object should carry for a content type. */
5
+ export declare function extensionFor(contentType: string): string;
6
+ //# sourceMappingURL=probe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probe.d.ts","sourceRoot":"","sources":["../../src/media/probe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAyB7D,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAE5D;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,IAAI,CAS9D;AAED,qEAAqE;AACrE,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAuBxD"}
@@ -0,0 +1,26 @@
1
+ import type { BufferedEvent, OutboxEntryMeta } from "../engine/outbox";
2
+ import type { ResolvedCmsConfig } from "../types/config";
3
+ import type { DatabaseAdapter } from "../types/database";
4
+ import type { CmsMedia } from "../types/media";
5
+ import type { Tx } from "../types/query";
6
+ export interface MediaServiceOptions {
7
+ config: ResolvedCmsConfig;
8
+ database: () => Promise<DatabaseAdapter>;
9
+ /** Appends events to the outbox inside the caller's transaction. */
10
+ emit: (tx: Tx, events: BufferedEvent[], meta: OutboxEntryMeta) => Promise<void>;
11
+ /** Schedules delivery once the transaction has committed. */
12
+ deliver: () => void;
13
+ }
14
+ /**
15
+ * `cms.media`.
16
+ *
17
+ * Media is a high-level setting rather than a plugin (section 3), and a file
18
+ * is not a document: it has a lifecycle no document has — active, orphaned,
19
+ * collected — and a body that lives somewhere the database cannot see. Hence
20
+ * its own service, with the same rule as `cms.api`: everything is a method
21
+ * rather than a route, so the REST endpoints in stage 7, the panel in stage 8
22
+ * and a seed script all get identical behaviour, including the parts that are
23
+ * easy to get wrong.
24
+ */
25
+ export declare function createMedia(options: MediaServiceOptions): CmsMedia;
26
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/media/service.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAOvE,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,KAAK,EACV,QAAQ,EAcT,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAO,EAAE,EAAS,MAAM,gBAAgB,CAAC;AAmBrD,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;IACzC,oEAAoE;IACpE,IAAI,EAAE,CACJ,EAAE,EAAE,EAAE,EACN,MAAM,EAAE,aAAa,EAAE,EACvB,IAAI,EAAE,eAAe,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,6DAA6D;IAC7D,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,mBAAmB,GAAG,QAAQ,CA0iBlE"}
@@ -0,0 +1,28 @@
1
+ import type { ImageProcessor, ImageTransform } from "../types/media";
2
+ export interface SharpImagesOptions {
3
+ /**
4
+ * The decompression-bomb ceiling, in pixels.
5
+ *
6
+ * `sharp` defaults to roughly 268 megapixels. The upload pipeline already
7
+ * refuses anything over `uploads.limits.maxImageDimensions`, so this is the
8
+ * second fence rather than the first.
9
+ */
10
+ limitInputPixels?: number | false;
11
+ /**
12
+ * Honour the EXIF orientation flag before doing anything else.
13
+ *
14
+ * On by default, and it matters: a phone photograph is stored sideways with
15
+ * a flag saying so, and stripping metadata without applying the flag first
16
+ * turns every portrait into a landscape.
17
+ */
18
+ autoOrient?: boolean;
19
+ }
20
+ export declare function sharpImages(options?: SharpImagesOptions): ImageProcessor;
21
+ /** The rectangle of the source that a cover crop should keep. */
22
+ export declare function sourceRegion(width: number, height: number, transform: ImageTransform): {
23
+ left: number;
24
+ top: number;
25
+ width: number;
26
+ height: number;
27
+ } | null;
28
+ //# sourceMappingURL=sharp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sharp.d.ts","sourceRoot":"","sources":["../../src/media/sharp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,cAAc,EACd,cAAc,EAEf,MAAM,gBAAgB,CAAC;AAwBxB,MAAM,WAAW,kBAAkB;IACjC;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAClC;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AA8CD,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,cAAc,CA6D5E;AAED,iEAAiE;AACjE,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,cAAc,GACxB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CA0BrE"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Metadata removal, without a decoder.
3
+ *
4
+ * `stripMetadata` exists for one concrete reason: a photograph taken on a
5
+ * phone carries the coordinates of the place it was taken, and a CMS that
6
+ * publishes it publishes those too (section 6). That is a privacy obligation,
7
+ * not an optimisation, so it must not depend on whether an optional image
8
+ * processor happens to be installed — which is why it is implemented here, by
9
+ * dropping container chunks rather than by re-encoding pixels.
10
+ *
11
+ * ICC colour profiles are deliberately kept. Dropping them is what most tools
12
+ * do under "strip metadata", and it visibly shifts the colours of every
13
+ * wide-gamut photograph, which is not what anybody asking for privacy meant.
14
+ */
15
+ export declare function stripImageMetadata(bytes: Uint8Array, contentType: string): Uint8Array;
16
+ //# sourceMappingURL=strip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strip.d.ts","sourceRoot":"","sources":["../../src/media/strip.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,UAAU,EACjB,WAAW,EAAE,MAAM,GAClB,UAAU,CAaZ"}
@@ -0,0 +1,69 @@
1
+ import type { ResolvedCollection } from "../types/config";
2
+ import type { ScopedDb } from "../types/hooks";
3
+ import type { JsonObject } from "../types/json";
4
+ import type { RetentionConfig } from "../types/config";
5
+ export declare const mediaTable = "media";
6
+ export declare const mediaUsagesTable = "media_usages";
7
+ /**
8
+ * The attribute a rich-text node uses to point at a file.
9
+ *
10
+ * A convention rather than a node type, so a custom editor node registered in
11
+ * stage 9 participates in reference counting for free: if it carries
12
+ * `mediaId`, the file it shows is counted as used.
13
+ */
14
+ export declare const richTextMediaAttribute = "mediaId";
15
+ export interface MediaReference {
16
+ mediaId: string;
17
+ field: string;
18
+ /** Empty for a field that is not localized. */
19
+ locale: string;
20
+ }
21
+ /**
22
+ * Whether a collection can point at a file at all.
23
+ *
24
+ * Checked once per collection and cached by the caller: the alternative is
25
+ * three extra queries on every write to a collection that has no images,
26
+ * which is most of them.
27
+ */
28
+ export declare function referencesMedia(collection: ResolvedCollection): boolean;
29
+ /**
30
+ * Every file this document body points at.
31
+ *
32
+ * Read from the stored body rather than from the resolved document, because
33
+ * references exist per locale: a German translation that drops an image has
34
+ * not stopped the English one from using it, and counting only the locale of
35
+ * the current request would orphan a file that is on a live page.
36
+ */
37
+ export declare function collectMediaReferences(collection: ResolvedCollection, stored: JsonObject): MediaReference[];
38
+ export interface SyncMediaUsagesOptions {
39
+ db: ScopedDb;
40
+ collection: string;
41
+ documentId: string;
42
+ /** `null` releases every reference this document held, for a purge. */
43
+ references: MediaReference[] | null;
44
+ /**
45
+ * Whether the orphan and reclaim rules apply.
46
+ *
47
+ * False when the configuration has no `uploads` section: the usage rows
48
+ * still have to be kept straight, because the trash and the purge depend on
49
+ * them, but there is no storage behind them to collect.
50
+ */
51
+ lifecycle: boolean;
52
+ retention: RetentionConfig | undefined;
53
+ now: Date;
54
+ }
55
+ export interface SyncMediaUsagesResult {
56
+ orphaned: string[];
57
+ reclaimed: string[];
58
+ }
59
+ /**
60
+ * Brings `media_usages` in line with what a document now contains.
61
+ *
62
+ * This is the mechanism the whole of section 6 rests on. Nothing counts
63
+ * references at read time or at delete time; the count is maintained at the
64
+ * one moment the truth changes, inside the transaction that changed it, so a
65
+ * rolled back save cannot leave a file looking unused.
66
+ */
67
+ export declare function syncMediaUsages(options: SyncMediaUsagesOptions): Promise<SyncMediaUsagesResult>;
68
+ export declare function purgeDeadline(retention: RetentionConfig | undefined, now: Date): Date | null;
69
+ //# sourceMappingURL=usages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usages.d.ts","sourceRoot":"","sources":["../../src/media/usages.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,eAAe,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGvD,eAAO,MAAM,UAAU,UAAU,CAAC;AAClC,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAE/C;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,YAAY,CAAC;AAEhD,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAOvE;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,kBAAkB,EAC9B,MAAM,EAAE,UAAU,GACjB,cAAc,EAAE,CAuBlB;AAED,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,QAAQ,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,UAAU,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IACpC;;;;;;OAMG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,eAAe,GAAG,SAAS,CAAC;IACvC,GAAG,EAAE,IAAI,CAAC;CACX;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,qBAAqB,CAAC,CA4ChC;AAqED,wBAAgB,aAAa,CAC3B,SAAS,EAAE,eAAe,GAAG,SAAS,EACtC,GAAG,EAAE,IAAI,GACR,IAAI,GAAG,IAAI,CAIb"}
@@ -0,0 +1,50 @@
1
+ import type { ImageSizeConfig, ImagesConfig } from "../types/config";
2
+ import type { ImageProcessor, ImageTransform, MediaDocument, ProcessedImage } from "../types/media";
3
+ /**
4
+ * Named sizes, and where they come from.
5
+ *
6
+ * Two strategies, one code path. `pregenerate` renders at upload time and
7
+ * `on-demand` renders at first request, but both write the result into storage
8
+ * under the same deterministic key — so a size added to the configuration next
9
+ * year applies to the whole archive either way, and the second request for it
10
+ * is a storage hit rather than a render (section 6).
11
+ */
12
+ export declare function variantNames(images: ImagesConfig | undefined): string[];
13
+ export declare function variantSize(images: ImagesConfig | undefined, name: string): ImageSizeConfig;
14
+ /**
15
+ * The rendering request for one named size on one file.
16
+ *
17
+ * The focal point and the crop come from the file, not from the size: a size
18
+ * says "320 square, cover", and which 320 square pixels that is, is a decision
19
+ * the editor made once in the panel and that every size inherits.
20
+ */
21
+ export declare function variantTransform(images: ImagesConfig | undefined, name: string, media: Pick<MediaDocument, "focalPoint" | "crop" | "mimeType">): ImageTransform;
22
+ /** The content type a variant will have, before anything is rendered. */
23
+ export declare function variantContentType(images: ImagesConfig | undefined, mimeType: string): string;
24
+ /**
25
+ * Where a variant lives.
26
+ *
27
+ * Derived from the original's key rather than recorded, so the collector can
28
+ * find every derivative of a file it is about to delete without a second
29
+ * table — and so two processes rendering the same variant at the same time
30
+ * write the same object instead of two.
31
+ */
32
+ export declare function variantKey(storageKey: string, name: string, contentType: string): string;
33
+ /**
34
+ * The query a CDN would need to do this itself.
35
+ *
36
+ * Appended to the original's URL when no processor is configured: that is the
37
+ * `cdn-worker` arrangement from section 6, where the CMS owns one original and
38
+ * the edge owns the resizing. The parameters are the ones every image CDN
39
+ * understands, so the same URL works behind Cloudflare, Vercel or a Worker of
40
+ * your own.
41
+ */
42
+ export declare function variantQuery(images: ImagesConfig | undefined, name: string): string;
43
+ /**
44
+ * Renders one variant, or explains why it cannot.
45
+ *
46
+ * A processor that does not handle this type is not an error — an SVG asked
47
+ * for at thumbnail size is simply served as it is, because it already scales.
48
+ */
49
+ export declare function renderVariant(processor: ImageProcessor | undefined, source: Uint8Array, transform: ImageTransform, media: Pick<MediaDocument, "mimeType" | "width" | "height">): Promise<ProcessedImage | null>;
50
+ //# sourceMappingURL=variants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../src/media/variants.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,aAAa,EACb,cAAc,EACf,MAAM,gBAAgB,CAAC;AAGxB;;;;;;;;GAQG;AAEH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,GAAG,MAAM,EAAE,CAEvE;AAED,wBAAgB,WAAW,CACzB,MAAM,EAAE,YAAY,GAAG,SAAS,EAChC,IAAI,EAAE,MAAM,GACX,eAAe,CAWjB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,YAAY,GAAG,SAAS,EAChC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,YAAY,GAAG,MAAM,GAAG,UAAU,CAAC,GAC7D,cAAc,CAqBhB;AAED,yEAAyE;AACzE,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,GAAG,SAAS,EAChC,QAAQ,EAAE,MAAM,GACf,MAAM,CAIR;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACxB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAClB,MAAM,CAKR;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,YAAY,GAAG,SAAS,EAChC,IAAI,EAAE,MAAM,GACX,MAAM,CAUR;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,SAAS,EAAE,cAAc,GAAG,SAAS,EACrC,MAAM,EAAE,UAAU,EAClB,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC,GAC1D,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAQhC"}