@heyo-sh/heyo-cms 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 (401) 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 +45 -0
  8. package/dist/adapters/astro.d.ts.map +1 -0
  9. package/dist/adapters/astro.js +1 -0
  10. package/dist/adapters/deliver.d.ts +26 -0
  11. package/dist/adapters/deliver.d.ts.map +1 -0
  12. package/dist/adapters/next.d.ts +45 -0
  13. package/dist/adapters/next.d.ts.map +1 -0
  14. package/dist/adapters/next.js +1 -0
  15. package/dist/adapters/nuxt.d.ts +51 -0
  16. package/dist/adapters/nuxt.d.ts.map +1 -0
  17. package/dist/adapters/nuxt.js +1 -0
  18. package/dist/adapters/react-router.d.ts +36 -0
  19. package/dist/adapters/react-router.d.ts.map +1 -0
  20. package/dist/adapters/react-router.js +1 -0
  21. package/dist/adapters/sveltekit.d.ts +41 -0
  22. package/dist/adapters/sveltekit.d.ts.map +1 -0
  23. package/dist/adapters/sveltekit.js +1 -0
  24. package/dist/ai/assistant/context.d.ts +64 -0
  25. package/dist/ai/assistant/context.d.ts.map +1 -0
  26. package/dist/ai/assistant/limits.d.ts +10 -0
  27. package/dist/ai/assistant/limits.d.ts.map +1 -0
  28. package/dist/ai/assistant/plans.d.ts +83 -0
  29. package/dist/ai/assistant/plans.d.ts.map +1 -0
  30. package/dist/ai/assistant/prompt.d.ts +22 -0
  31. package/dist/ai/assistant/prompt.d.ts.map +1 -0
  32. package/dist/ai/assistant/run.d.ts +59 -0
  33. package/dist/ai/assistant/run.d.ts.map +1 -0
  34. package/dist/ai/assistant/runtime.d.ts +35 -0
  35. package/dist/ai/assistant/runtime.d.ts.map +1 -0
  36. package/dist/ai/assistant/schema.d.ts +66 -0
  37. package/dist/ai/assistant/schema.d.ts.map +1 -0
  38. package/dist/ai/assistant/tools.d.ts +41 -0
  39. package/dist/ai/assistant/tools.d.ts.map +1 -0
  40. package/dist/ai/assistant/values.d.ts +33 -0
  41. package/dist/ai/assistant/values.d.ts.map +1 -0
  42. package/dist/ai/crypto.d.ts +12 -0
  43. package/dist/ai/crypto.d.ts.map +1 -0
  44. package/dist/ai/index.d.ts +19 -0
  45. package/dist/ai/index.d.ts.map +1 -0
  46. package/dist/ai/pi.d.ts +89 -0
  47. package/dist/ai/pi.d.ts.map +1 -0
  48. package/dist/ai/registry.d.ts +66 -0
  49. package/dist/ai/registry.d.ts.map +1 -0
  50. package/dist/ai/service.d.ts +31 -0
  51. package/dist/ai/service.d.ts.map +1 -0
  52. package/dist/ai/variant-translation.d.ts +6 -0
  53. package/dist/ai/variant-translation.d.ts.map +1 -0
  54. package/dist/ai.d.ts +12 -0
  55. package/dist/ai.d.ts.map +1 -0
  56. package/dist/ai.js +1 -0
  57. package/dist/auth/config.d.ts +65 -0
  58. package/dist/auth/config.d.ts.map +1 -0
  59. package/dist/auth/crypto.d.ts +44 -0
  60. package/dist/auth/crypto.d.ts.map +1 -0
  61. package/dist/auth/index.d.ts +15 -0
  62. package/dist/auth/index.d.ts.map +1 -0
  63. package/dist/auth/oauth.d.ts +93 -0
  64. package/dist/auth/oauth.d.ts.map +1 -0
  65. package/dist/auth/service.d.ts +38 -0
  66. package/dist/auth/service.d.ts.map +1 -0
  67. package/dist/auth/totp.d.ts +34 -0
  68. package/dist/auth/totp.d.ts.map +1 -0
  69. package/dist/auth.d.ts +9 -0
  70. package/dist/auth.d.ts.map +1 -0
  71. package/dist/auth.js +1 -0
  72. package/dist/cli.d.ts +3 -0
  73. package/dist/cli.d.ts.map +1 -0
  74. package/dist/cli.js +30 -0
  75. package/dist/client/index.d.ts +51 -0
  76. package/dist/client/index.d.ts.map +1 -0
  77. package/dist/client/types.d.ts +363 -0
  78. package/dist/client/types.d.ts.map +1 -0
  79. package/dist/client.d.ts +46 -0
  80. package/dist/client.d.ts.map +1 -0
  81. package/dist/client.js +1 -0
  82. package/dist/config.d.ts +31 -0
  83. package/dist/config.d.ts.map +1 -0
  84. package/dist/config.js +1 -0
  85. package/dist/content/export.d.ts +28 -0
  86. package/dist/content/export.d.ts.map +1 -0
  87. package/dist/content/import.d.ts +65 -0
  88. package/dist/content/import.d.ts.map +1 -0
  89. package/dist/content/records.d.ts +73 -0
  90. package/dist/content/records.d.ts.map +1 -0
  91. package/dist/content.d.ts +12 -0
  92. package/dist/content.d.ts.map +1 -0
  93. package/dist/content.js +1 -0
  94. package/dist/db/d1.d.ts +29 -0
  95. package/dist/db/d1.d.ts.map +1 -0
  96. package/dist/db/d1.js +1 -0
  97. package/dist/db/mongodb.d.ts +128 -0
  98. package/dist/db/mongodb.d.ts.map +1 -0
  99. package/dist/db/mongodb.js +2 -0
  100. package/dist/db/postgres.d.ts +37 -0
  101. package/dist/db/postgres.d.ts.map +1 -0
  102. package/dist/db/postgres.js +1 -0
  103. package/dist/db/sql/adapter.d.ts +57 -0
  104. package/dist/db/sql/adapter.d.ts.map +1 -0
  105. package/dist/db/sql/compile.d.ts +50 -0
  106. package/dist/db/sql/compile.d.ts.map +1 -0
  107. package/dist/db/sql/ddl.d.ts +34 -0
  108. package/dist/db/sql/ddl.d.ts.map +1 -0
  109. package/dist/db/sql/dialect.d.ts +37 -0
  110. package/dist/db/sql/dialect.d.ts.map +1 -0
  111. package/dist/db/sql/driver.d.ts +34 -0
  112. package/dist/db/sql/driver.d.ts.map +1 -0
  113. package/dist/db/sql/introspect.d.ts +15 -0
  114. package/dist/db/sql/introspect.d.ts.map +1 -0
  115. package/dist/db/sqlite.d.ts +50 -0
  116. package/dist/db/sqlite.d.ts.map +1 -0
  117. package/dist/db/sqlite.js +1 -0
  118. package/dist/defaults.d.ts +5 -0
  119. package/dist/defaults.d.ts.map +1 -0
  120. package/dist/duration.d.ts +12 -0
  121. package/dist/duration.d.ts.map +1 -0
  122. package/dist/editor/builtin.d.ts +45 -0
  123. package/dist/editor/builtin.d.ts.map +1 -0
  124. package/dist/editor/index.d.ts +14 -0
  125. package/dist/editor/index.d.ts.map +1 -0
  126. package/dist/editor/markdown.d.ts +19 -0
  127. package/dist/editor/markdown.d.ts.map +1 -0
  128. package/dist/editor/registry.d.ts +30 -0
  129. package/dist/editor/registry.d.ts.map +1 -0
  130. package/dist/editor/serialize.d.ts +41 -0
  131. package/dist/editor/serialize.d.ts.map +1 -0
  132. package/dist/editor.d.ts +10 -0
  133. package/dist/editor.d.ts.map +1 -0
  134. package/dist/editor.js +1 -0
  135. package/dist/engine/access.d.ts +33 -0
  136. package/dist/engine/access.d.ts.map +1 -0
  137. package/dist/engine/activity.d.ts +16 -0
  138. package/dist/engine/activity.d.ts.map +1 -0
  139. package/dist/engine/cursor.d.ts +19 -0
  140. package/dist/engine/cursor.d.ts.map +1 -0
  141. package/dist/engine/documents.d.ts +81 -0
  142. package/dist/engine/documents.d.ts.map +1 -0
  143. package/dist/engine/engine.d.ts +295 -0
  144. package/dist/engine/engine.d.ts.map +1 -0
  145. package/dist/engine/field-access.d.ts +21 -0
  146. package/dist/engine/field-access.d.ts.map +1 -0
  147. package/dist/engine/hooks.d.ts +58 -0
  148. package/dist/engine/hooks.d.ts.map +1 -0
  149. package/dist/engine/index.d.ts +20 -0
  150. package/dist/engine/index.d.ts.map +1 -0
  151. package/dist/engine/jobs.d.ts +63 -0
  152. package/dist/engine/jobs.d.ts.map +1 -0
  153. package/dist/engine/locales.d.ts +40 -0
  154. package/dist/engine/locales.d.ts.map +1 -0
  155. package/dist/engine/outbox.d.ts +81 -0
  156. package/dist/engine/outbox.d.ts.map +1 -0
  157. package/dist/engine/relations.d.ts +60 -0
  158. package/dist/engine/relations.d.ts.map +1 -0
  159. package/dist/engine/scoped-db.d.ts +13 -0
  160. package/dist/engine/scoped-db.d.ts.map +1 -0
  161. package/dist/engine/slugs.d.ts +124 -0
  162. package/dist/engine/slugs.d.ts.map +1 -0
  163. package/dist/engine/trash.d.ts +25 -0
  164. package/dist/engine/trash.d.ts.map +1 -0
  165. package/dist/errors.d.ts +42 -0
  166. package/dist/errors.d.ts.map +1 -0
  167. package/dist/fields/builtin.d.ts +169 -0
  168. package/dist/fields/builtin.d.ts.map +1 -0
  169. package/dist/fields/index.d.ts +3 -0
  170. package/dist/fields/index.d.ts.map +1 -0
  171. package/dist/fields/registry.d.ts +35 -0
  172. package/dist/fields/registry.d.ts.map +1 -0
  173. package/dist/fields.d.ts +9 -0
  174. package/dist/fields.d.ts.map +1 -0
  175. package/dist/fields.js +1 -0
  176. package/dist/http/guard.d.ts +45 -0
  177. package/dist/http/guard.d.ts.map +1 -0
  178. package/dist/http/handler.d.ts +31 -0
  179. package/dist/http/handler.d.ts.map +1 -0
  180. package/dist/http/index.d.ts +13 -0
  181. package/dist/http/index.d.ts.map +1 -0
  182. package/dist/http/openapi.d.ts +5 -0
  183. package/dist/http/openapi.d.ts.map +1 -0
  184. package/dist/http/params.d.ts +32 -0
  185. package/dist/http/params.d.ts.map +1 -0
  186. package/dist/http/request-db.d.ts +19 -0
  187. package/dist/http/request-db.d.ts.map +1 -0
  188. package/dist/http/respond.d.ts +48 -0
  189. package/dist/http/respond.d.ts.map +1 -0
  190. package/dist/http/rich-text.d.ts +41 -0
  191. package/dist/http/rich-text.d.ts.map +1 -0
  192. package/dist/http/router.d.ts +55 -0
  193. package/dist/http/router.d.ts.map +1 -0
  194. package/dist/http/routes/access.d.ts +13 -0
  195. package/dist/http/routes/access.d.ts.map +1 -0
  196. package/dist/http/routes/admin.d.ts +28 -0
  197. package/dist/http/routes/admin.d.ts.map +1 -0
  198. package/dist/http/routes/ai.d.ts +26 -0
  199. package/dist/http/routes/ai.d.ts.map +1 -0
  200. package/dist/http/routes/auth.d.ts +13 -0
  201. package/dist/http/routes/auth.d.ts.map +1 -0
  202. package/dist/http/routes/documents.d.ts +24 -0
  203. package/dist/http/routes/documents.d.ts.map +1 -0
  204. package/dist/http/routes/generate.d.ts +5 -0
  205. package/dist/http/routes/generate.d.ts.map +1 -0
  206. package/dist/http/routes/media.d.ts +58 -0
  207. package/dist/http/routes/media.d.ts.map +1 -0
  208. package/dist/http/routes/panel.d.ts +20 -0
  209. package/dist/http/routes/panel.d.ts.map +1 -0
  210. package/dist/http/routes/system.d.ts +25 -0
  211. package/dist/http/routes/system.d.ts.map +1 -0
  212. package/dist/http/routes/webhooks.d.ts +17 -0
  213. package/dist/http/routes/webhooks.d.ts.map +1 -0
  214. package/dist/http/spec.d.ts +28 -0
  215. package/dist/http/spec.d.ts.map +1 -0
  216. package/dist/http.d.ts +17 -0
  217. package/dist/http.d.ts.map +1 -0
  218. package/dist/http.js +1 -0
  219. package/dist/i18n/index.d.ts +12 -0
  220. package/dist/i18n/index.d.ts.map +1 -0
  221. package/dist/i18n/names.d.ts +25 -0
  222. package/dist/i18n/names.d.ts.map +1 -0
  223. package/dist/ids.d.ts +28 -0
  224. package/dist/ids.d.ts.map +1 -0
  225. package/dist/index-2ddk43me.js +2 -0
  226. package/dist/index-2prbs05k.js +2 -0
  227. package/dist/index-385ggnge.js +2 -0
  228. package/dist/index-466cwb0b.js +2 -0
  229. package/dist/index-4qrep5f0.js +26 -0
  230. package/dist/index-67e458ws.js +2 -0
  231. package/dist/index-6m1kjq9g.js +2 -0
  232. package/dist/index-6w10rch0.js +3 -0
  233. package/dist/index-761dec5z.js +2 -0
  234. package/dist/index-8nzmqy0f.js +2 -0
  235. package/dist/index-8x2em6c8.js +14 -0
  236. package/dist/index-91fa1gzf.js +2 -0
  237. package/dist/index-9g2n7xa6.js +2 -0
  238. package/dist/index-a8jcwqsf.js +2 -0
  239. package/dist/index-abfzb1ve.js +2 -0
  240. package/dist/index-cv0hpz3d.js +2 -0
  241. package/dist/index-ebtj6ebd.js +0 -0
  242. package/dist/index-g041kfa5.js +18 -0
  243. package/dist/index-g4crf47y.js +0 -0
  244. package/dist/index-hbx67b20.js +7 -0
  245. package/dist/index-hpast878.js +40 -0
  246. package/dist/index-kc1j3h6z.js +2 -0
  247. package/dist/index-p2cqsmvw.js +2 -0
  248. package/dist/index-rg9tpg3p.js +5 -0
  249. package/dist/index-rw0hze6x.js +2 -0
  250. package/dist/index-s9x07zb3.js +2 -0
  251. package/dist/index-sgdnp83t.js +2 -0
  252. package/dist/index-szaq03qq.js +2 -0
  253. package/dist/index-vkwzdfte.js +5 -0
  254. package/dist/index-vzhxn50e.js +2 -0
  255. package/dist/index-x72d1hzh.js +2 -0
  256. package/dist/index-y8kzzn94.js +2 -0
  257. package/dist/index-ypcmns0v.js +2 -0
  258. package/dist/index.d.ts +25 -0
  259. package/dist/index.d.ts.map +1 -0
  260. package/dist/index.js +1 -0
  261. package/dist/jobs/runner.d.ts +77 -0
  262. package/dist/jobs/runner.d.ts.map +1 -0
  263. package/dist/jobs.d.ts +11 -0
  264. package/dist/jobs.d.ts.map +1 -0
  265. package/dist/jobs.js +1 -0
  266. package/dist/media/cloudflare.d.ts +58 -0
  267. package/dist/media/cloudflare.d.ts.map +1 -0
  268. package/dist/media/document.d.ts +29 -0
  269. package/dist/media/document.d.ts.map +1 -0
  270. package/dist/media/gc.d.ts +46 -0
  271. package/dist/media/gc.d.ts.map +1 -0
  272. package/dist/media/index.d.ts +20 -0
  273. package/dist/media/index.d.ts.map +1 -0
  274. package/dist/media/pipeline.d.ts +55 -0
  275. package/dist/media/pipeline.d.ts.map +1 -0
  276. package/dist/media/probe.d.ts +6 -0
  277. package/dist/media/probe.d.ts.map +1 -0
  278. package/dist/media/service.d.ts +26 -0
  279. package/dist/media/service.d.ts.map +1 -0
  280. package/dist/media/sharp.d.ts +28 -0
  281. package/dist/media/sharp.d.ts.map +1 -0
  282. package/dist/media/strip.d.ts +16 -0
  283. package/dist/media/strip.d.ts.map +1 -0
  284. package/dist/media/urls.d.ts +77 -0
  285. package/dist/media/urls.d.ts.map +1 -0
  286. package/dist/media/usages.d.ts +77 -0
  287. package/dist/media/usages.d.ts.map +1 -0
  288. package/dist/media/variants.d.ts +61 -0
  289. package/dist/media/variants.d.ts.map +1 -0
  290. package/dist/migrations.d.ts +115 -0
  291. package/dist/migrations.d.ts.map +1 -0
  292. package/dist/migrations.js +1 -0
  293. package/dist/panel.d.ts +31 -0
  294. package/dist/panel.d.ts.map +1 -0
  295. package/dist/plugins/indexnow.d.ts +82 -0
  296. package/dist/plugins/indexnow.d.ts.map +1 -0
  297. package/dist/plugins.d.ts +9 -0
  298. package/dist/plugins.d.ts.map +1 -0
  299. package/dist/plugins.js +1 -0
  300. package/dist/query.d.ts +40 -0
  301. package/dist/query.d.ts.map +1 -0
  302. package/dist/query.js +1 -0
  303. package/dist/run-bjge3v8e.js +6 -0
  304. package/dist/schema/describe.d.ts +19 -0
  305. package/dist/schema/describe.d.ts.map +1 -0
  306. package/dist/schema/index.d.ts +5 -0
  307. package/dist/schema/index.d.ts.map +1 -0
  308. package/dist/schema/plan.d.ts +20 -0
  309. package/dist/schema/plan.d.ts.map +1 -0
  310. package/dist/schema/snapshot.d.ts +24 -0
  311. package/dist/schema/snapshot.d.ts.map +1 -0
  312. package/dist/schema/system.d.ts +31 -0
  313. package/dist/schema/system.d.ts.map +1 -0
  314. package/dist/schema.d.ts +7 -0
  315. package/dist/schema.d.ts.map +1 -0
  316. package/dist/schema.js +1 -0
  317. package/dist/slugify.d.ts +31 -0
  318. package/dist/slugify.d.ts.map +1 -0
  319. package/dist/storage/bytes.d.ts +17 -0
  320. package/dist/storage/bytes.d.ts.map +1 -0
  321. package/dist/storage/http.d.ts +43 -0
  322. package/dist/storage/http.d.ts.map +1 -0
  323. package/dist/storage/local.d.ts +31 -0
  324. package/dist/storage/local.d.ts.map +1 -0
  325. package/dist/storage/providers.d.ts +95 -0
  326. package/dist/storage/providers.d.ts.map +1 -0
  327. package/dist/storage/sign.d.ts +53 -0
  328. package/dist/storage/sign.d.ts.map +1 -0
  329. package/dist/strings.d.ts +13 -0
  330. package/dist/strings.d.ts.map +1 -0
  331. package/dist/telemetry.d.ts +137 -0
  332. package/dist/telemetry.d.ts.map +1 -0
  333. package/dist/telemetry.js +1 -0
  334. package/dist/types/activity.d.ts +68 -0
  335. package/dist/types/activity.d.ts.map +1 -0
  336. package/dist/types/actor.d.ts +26 -0
  337. package/dist/types/actor.d.ts.map +1 -0
  338. package/dist/types/ai.d.ts +357 -0
  339. package/dist/types/ai.d.ts.map +1 -0
  340. package/dist/types/api.d.ts +268 -0
  341. package/dist/types/api.d.ts.map +1 -0
  342. package/dist/types/auth.d.ts +310 -0
  343. package/dist/types/auth.d.ts.map +1 -0
  344. package/dist/types/config.d.ts +647 -0
  345. package/dist/types/config.d.ts.map +1 -0
  346. package/dist/types/database.d.ts +75 -0
  347. package/dist/types/database.d.ts.map +1 -0
  348. package/dist/types/editor.d.ts +166 -0
  349. package/dist/types/editor.d.ts.map +1 -0
  350. package/dist/types/events.d.ts +72 -0
  351. package/dist/types/events.d.ts.map +1 -0
  352. package/dist/types/fields.d.ts +142 -0
  353. package/dist/types/fields.d.ts.map +1 -0
  354. package/dist/types/hooks.d.ts +142 -0
  355. package/dist/types/hooks.d.ts.map +1 -0
  356. package/dist/types/index.d.ts +25 -0
  357. package/dist/types/index.d.ts.map +1 -0
  358. package/dist/types/instance.d.ts +263 -0
  359. package/dist/types/instance.d.ts.map +1 -0
  360. package/dist/types/jobs.d.ts +78 -0
  361. package/dist/types/jobs.d.ts.map +1 -0
  362. package/dist/types/json.d.ts +24 -0
  363. package/dist/types/json.d.ts.map +1 -0
  364. package/dist/types/locales.d.ts +30 -0
  365. package/dist/types/locales.d.ts.map +1 -0
  366. package/dist/types/media.d.ts +342 -0
  367. package/dist/types/media.d.ts.map +1 -0
  368. package/dist/types/panel.d.ts +249 -0
  369. package/dist/types/panel.d.ts.map +1 -0
  370. package/dist/types/plugin.d.ts +194 -0
  371. package/dist/types/plugin.d.ts.map +1 -0
  372. package/dist/types/query.d.ts +101 -0
  373. package/dist/types/query.d.ts.map +1 -0
  374. package/dist/types/schema.d.ts +203 -0
  375. package/dist/types/schema.d.ts.map +1 -0
  376. package/dist/types/storage.d.ts +61 -0
  377. package/dist/types/storage.d.ts.map +1 -0
  378. package/dist/types/telemetry.d.ts +14 -0
  379. package/dist/types/telemetry.d.ts.map +1 -0
  380. package/dist/types/trash.d.ts +42 -0
  381. package/dist/types/trash.d.ts.map +1 -0
  382. package/dist/types/webhooks.d.ts +133 -0
  383. package/dist/types/webhooks.d.ts.map +1 -0
  384. package/dist/types.d.ts +8 -0
  385. package/dist/types.d.ts.map +1 -0
  386. package/dist/types.js +1 -0
  387. package/dist/uploads.d.ts +22 -0
  388. package/dist/uploads.d.ts.map +1 -0
  389. package/dist/uploads.js +9 -0
  390. package/dist/webhooks/index.d.ts +10 -0
  391. package/dist/webhooks/index.d.ts.map +1 -0
  392. package/dist/webhooks/job.d.ts +17 -0
  393. package/dist/webhooks/job.d.ts.map +1 -0
  394. package/dist/webhooks/service.d.ts +53 -0
  395. package/dist/webhooks/service.d.ts.map +1 -0
  396. package/dist/webhooks/sign.d.ts +26 -0
  397. package/dist/webhooks/sign.d.ts.map +1 -0
  398. package/dist/webhooks.d.ts +10 -0
  399. package/dist/webhooks.d.ts.map +1 -0
  400. package/dist/webhooks.js +1 -0
  401. package/package.json +187 -4
@@ -0,0 +1,73 @@
1
+ import type { JsonObject, JsonValue } from "../types/json";
2
+ /**
3
+ * The on-disk format of an export: newline-delimited JSON.
4
+ *
5
+ * One record per line, header first. The choice is not cosmetic: a content
6
+ * dump is the one file in a CMS that routinely outgrows memory, and NDJSON is
7
+ * the only JSON shape that can be written and read a record at a time. It also
8
+ * diffs, greps and `tail`s, which a single array wrapped in two brackets does
9
+ * not.
10
+ */
11
+ export declare const exportFormat = "heyo-cms/export";
12
+ export declare const exportVersion = 1;
13
+ /**
14
+ * The first line of every file.
15
+ *
16
+ * It carries what the importer has to check before it writes anything — the
17
+ * format and its version — and what a human has to know a year later: when it
18
+ * was taken, from which engine, and what is in it.
19
+ */
20
+ export interface ExportHeader {
21
+ kind: "header";
22
+ format: typeof exportFormat;
23
+ version: number;
24
+ exportedAt: string;
25
+ /** `postgres`, `sqlite`, `d1`, `mongodb`. Informational. */
26
+ database: string;
27
+ /** The default locale at the time of export; the importer writes into it. */
28
+ defaultLocale: string;
29
+ collections: string[];
30
+ globals: string[];
31
+ }
32
+ /**
33
+ * One document, in storage shape.
34
+ *
35
+ * `data` is what the row holds, not what a read returns: a localized field is
36
+ * a `{ [locale]: value }` map here, because an export that resolved one
37
+ * language would silently drop every translation. The importer takes the maps
38
+ * apart again and writes each locale through the ordinary API.
39
+ */
40
+ export interface DocumentRecord {
41
+ kind: "document";
42
+ collection: string;
43
+ id: string;
44
+ data: JsonObject;
45
+ createdAt: string | null;
46
+ updatedAt: string | null;
47
+ /** Set only on an export that asked for the trash. */
48
+ deletedAt?: string | null;
49
+ scheduledAt?: string | null;
50
+ scheduledPatch?: JsonValue;
51
+ }
52
+ /** A singleton. Same shape, no id: its row id is derived from the slug. */
53
+ export interface GlobalRecord {
54
+ kind: "global";
55
+ global: string;
56
+ data: JsonObject;
57
+ updatedAt: string | null;
58
+ }
59
+ export type ContentRecord = ExportHeader | DocumentRecord | GlobalRecord;
60
+ /** Parses one line. Throws with the line number, which is what a reader needs. */
61
+ export declare function parseRecord(line: string, lineNumber: number): ContentRecord;
62
+ /**
63
+ * Reads an NDJSON stream into records.
64
+ *
65
+ * Blank lines are skipped rather than refused: a file that was concatenated,
66
+ * edited or produced by a shell redirect is still a valid export, and failing
67
+ * on a trailing newline would be a rule nobody could guess.
68
+ */
69
+ export declare function readRecords(lines: AsyncIterable<string>): AsyncGenerator<ContentRecord>;
70
+ /** Splits a chunked stream into lines, so a reader never buffers the file. */
71
+ export declare function toLines(chunks: AsyncIterable<string>): AsyncGenerator<string>;
72
+ export declare function serializeRecord(record: ContentRecord): string;
73
+ //# sourceMappingURL=records.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"records.d.ts","sourceRoot":"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AAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,aAAa,CAuC3E;AAED;;;;;;GAMG;AACH,wBAAuB,WAAW,CAChC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,GAC3B,cAAc,CAAC,aAAa,CAAC,CAQ/B;AAED,8EAA8E;AAC9E,wBAAuB,OAAO,CAC5B,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,GAC5B,cAAc,CAAC,MAAM,CAAC,CAYxB;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAE7D"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * `@heyo-sh/heyo-cms/content` — content import and export.
3
+ *
4
+ * The CLI spells this as `heyo-cms export` and `heyo-cms import`; the module
5
+ * exists because the interesting uses are not interactive: seeding a preview
6
+ * deployment from production, moving a site between databases, or writing the
7
+ * importer's input from a converter for somebody else's CMS.
8
+ */
9
+ export { exportContent, type ExportOptions } from "./content/export";
10
+ export { importContent, splitLocales, type ImportOptions, type ImportReport, } from "./content/import";
11
+ export { exportFormat, exportVersion, parseRecord, readRecords, serializeRecord, toLines, type ContentRecord, type DocumentRecord, type ExportHeader, type GlobalRecord, } from "./content/records";
12
+ //# sourceMappingURL=content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../src/content.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EACL,aAAa,EACb,YAAY,EACZ,KAAK,aAAa,EAClB,KAAK,YAAY,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,aAAa,EACb,WAAW,EACX,WAAW,EACX,eAAe,EACf,OAAO,EACP,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,YAAY,GAClB,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1 @@
1
+ import"./index-sgdnp83t.js";import"./index-6m1kjq9g.js";import"./index-abfzb1ve.js";import"./index-cv0hpz3d.js";import"./index-g041kfa5.js";import"./index-8x2em6c8.js";import"./index-hpast878.js";import"./index-kc1j3h6z.js";import{at,ze,Bn,Dt,qt,Lt,Ft,Nt,gn}from"./index-rg9tpg3p.js";import"./index-6w10rch0.js";import"./index-91fa1gzf.js";import"./index-2prbs05k.js";export{Ft as exportContent,at as exportFormat,ze as exportVersion,Nt as importContent,Bn as parseRecord,Dt as readRecords,Lt as serializeRecord,gn as splitLocales,qt as toLines};
@@ -0,0 +1,29 @@
1
+ import type { DatabaseAdapter } from "../types/database";
2
+ /** The Cloudflare D1 binding, typed structurally so no SDK is imported. */
3
+ export interface D1Database {
4
+ prepare(sql: string): D1PreparedStatement;
5
+ exec?(sql: string): Promise<unknown>;
6
+ batch?(statements: D1PreparedStatement[]): Promise<unknown>;
7
+ }
8
+ export interface D1PreparedStatement {
9
+ bind(...values: unknown[]): D1PreparedStatement;
10
+ all<T = Record<string, unknown>>(): Promise<{
11
+ results?: T[];
12
+ }>;
13
+ run(): Promise<{
14
+ meta?: {
15
+ changes?: number;
16
+ };
17
+ }>;
18
+ }
19
+ /**
20
+ * Creates the D1 adapter.
21
+ *
22
+ * D1 has no interactive transactions — only batches — so the adapter declares
23
+ * `transactions: false` and the engine switches to the compensating path:
24
+ * the outbox row is written with the document in one statement, and the
25
+ * worker that delivers it is idempotent (section 12). Pretending otherwise
26
+ * would mean a rollback that silently did not roll back.
27
+ */
28
+ export declare function d1(binding: D1Database): DatabaseAdapter;
29
+ //# sourceMappingURL=d1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"d1.d.ts","sourceRoot":"","sources":["../../src/db/d1.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAKzD,2EAA2E;AAC3E,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,mBAAmB,CAAC;IAC1C,IAAI,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACrC,KAAK,CAAC,CAAC,UAAU,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7D;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,mBAAmB,CAAC;IAChD,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC;QAAE,OAAO,CAAC,EAAE,CAAC,EAAE,CAAA;KAAE,CAAC,CAAC;IAC/D,GAAG,IAAI,OAAO,CAAC;QAAE,IAAI,CAAC,EAAE;YAAE,OAAO,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC,CAAC;CACjD;AAkCD;;;;;;;;GAQG;AACH,wBAAgB,EAAE,CAAC,OAAO,EAAE,UAAU,GAAG,eAAe,CAIvD"}
package/dist/db/d1.js ADDED
@@ -0,0 +1 @@
1
+ import{Mt,ce,st}from"../index-4qrep5f0.js";class n{binding;id="d1";constructor(e){this.binding=e}async all(e,t){return(await this.bind(e,t).all()).results??[]}async run(e,t){return{rowsAffected:(await this.bind(e,t).run()).meta?.changes??0}}async exec(e){for(let t of Mt(e))await this.binding.prepare(t).run()}bind(e,t){let r=this.binding.prepare(e);return t.length>0?r.bind(...t):r}}function o(e){return new ce(new n(e),st,{capabilities:{transactions:!1}})}export{o as d1};
@@ -0,0 +1,128 @@
1
+ import type { AppliedMigration, DatabaseAdapter, DatabaseAdapterFactory, DatabaseCapabilities } from "../types/database";
2
+ import type { Mutation, MutationResult, Query, Row, Tx } from "../types/query";
3
+ import type { MigrationArtifact, MigrationStep, SchemaSnapshot } from "../types/schema";
4
+ export type MongoDocument = Record<string, unknown>;
5
+ export type MongoFilter = Record<string, unknown>;
6
+ export interface MongoCursor<T> {
7
+ toArray(): Promise<T[]>;
8
+ }
9
+ export interface MongoIndexInfo {
10
+ name: string;
11
+ key: Record<string, number>;
12
+ unique?: boolean;
13
+ }
14
+ export interface MongoLikeCollection {
15
+ find(filter: MongoFilter, options?: {
16
+ sort?: Record<string, 1 | -1>;
17
+ limit?: number;
18
+ skip?: number;
19
+ projection?: Record<string, 1>;
20
+ }): MongoCursor<MongoDocument>;
21
+ countDocuments(filter: MongoFilter): Promise<number>;
22
+ insertOne(document: MongoDocument): Promise<unknown>;
23
+ updateMany(filter: MongoFilter, update: Record<string, unknown>): Promise<{
24
+ modifiedCount?: number;
25
+ matchedCount?: number;
26
+ }>;
27
+ deleteMany(filter: MongoFilter): Promise<{
28
+ deletedCount?: number;
29
+ }>;
30
+ createIndex(keys: Record<string, 1 | -1>, options?: {
31
+ name?: string;
32
+ unique?: boolean;
33
+ partialFilterExpression?: MongoFilter;
34
+ }): Promise<unknown>;
35
+ dropIndex(name: string): Promise<unknown>;
36
+ listIndexes(): MongoCursor<MongoIndexInfo>;
37
+ }
38
+ /** The subset of a `Db` the adapter uses. The official driver satisfies it. */
39
+ export interface MongoLikeDatabase {
40
+ collection(name: string): MongoLikeCollection;
41
+ listCollections(): MongoCursor<{
42
+ name: string;
43
+ }>;
44
+ createCollection(name: string): Promise<unknown>;
45
+ dropCollection(name: string): Promise<unknown>;
46
+ }
47
+ export interface MongoOptions {
48
+ /**
49
+ * Transactions need a replica set. Left unset, the adapter reports `false`
50
+ * and the engine uses the compensating path — which is the correct answer
51
+ * for a standalone `mongod`, and a stated one rather than a surprise.
52
+ */
53
+ transactions?: boolean;
54
+ /** Database name, when it is not part of the connection string. */
55
+ database?: string;
56
+ }
57
+ /**
58
+ * MongoDB behind the same contract as Postgres.
59
+ *
60
+ * Everything that would normally leak — DDL, SQL, column types — was already
61
+ * removed from the engine by the neutral `Query`/`Mutation` AST and the
62
+ * neutral migration steps, so this adapter is a translator rather than a
63
+ * second implementation of the CMS.
64
+ */
65
+ export declare class MongoDatabaseAdapter implements DatabaseAdapter {
66
+ private readonly database;
67
+ readonly id = "mongodb";
68
+ readonly capabilities: DatabaseCapabilities;
69
+ private schema;
70
+ private documentColumns;
71
+ private columnNames;
72
+ constructor(database: MongoLikeDatabase, options?: MongoOptions);
73
+ useSchema(schema: SchemaSnapshot): void;
74
+ /**
75
+ * Lists collections and their indexes.
76
+ *
77
+ * A document database has no columns to report, so the snapshot carries
78
+ * tables without them. That is enough for drift detection — a missing
79
+ * collection or a missing index is what breaks a deployment.
80
+ */
81
+ introspect(): Promise<SchemaSnapshot>;
82
+ plan(from: SchemaSnapshot, to: SchemaSnapshot): MigrationStep[];
83
+ /**
84
+ * Renders the steps themselves.
85
+ *
86
+ * There is no SQL to write, and a hand-written script would not survive a
87
+ * review as well as the step list the planner already produced. The file is
88
+ * numbered, committed and applied exactly like a `.sql` one; only its
89
+ * contents differ.
90
+ */
91
+ render(steps: MigrationStep[], id: string): MigrationArtifact;
92
+ applyMigration(artifact: MigrationArtifact): Promise<void>;
93
+ listAppliedMigrations(): Promise<AppliedMigration[]>;
94
+ recordMigration(id: string, checksum: string): Promise<void>;
95
+ /**
96
+ * Transactions exist only on a replica set.
97
+ *
98
+ * Rather than emulate them, the adapter reports the capability honestly and
99
+ * runs the function without one. The engine is written to that flag: the
100
+ * outbox row goes in with the document, and delivery is idempotent.
101
+ */
102
+ transaction<T>(fn: (tx: Tx) => Promise<T>): Promise<T>;
103
+ query(_tx: Tx, query: Query): Promise<Row[]>;
104
+ mutate(_tx: Tx, mutation: Mutation): Promise<MutationResult>;
105
+ private applyStep;
106
+ private filter;
107
+ private condition;
108
+ /**
109
+ * `title` means `data.title` on a table that stores a document body.
110
+ *
111
+ * Identical to the SQL compiler's rule, which is what keeps a query written
112
+ * against one engine working against another.
113
+ */
114
+ private path;
115
+ /** `id` is the primary key, so it is `_id` in storage and nowhere else. */
116
+ private encode;
117
+ private decode;
118
+ }
119
+ /**
120
+ * Creates the MongoDB adapter.
121
+ *
122
+ * A connection string is accepted as well as a `Db`, and loads the official
123
+ * driver on demand: it is a peer dependency, because a project on Postgres
124
+ * must not ship a MongoDB client.
125
+ */
126
+ export declare function mongodb(url: string, options?: MongoOptions): DatabaseAdapterFactory;
127
+ export declare function mongodb(database: MongoLikeDatabase, options?: MongoOptions): DatabaseAdapter;
128
+ //# sourceMappingURL=mongodb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongodb.d.ts","sourceRoot":"","sources":["../../src/db/mongodb.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAGV,QAAQ,EACR,cAAc,EACd,KAAK,EACL,GAAG,EACH,EAAE,EAEH,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EACV,iBAAiB,EACjB,aAAa,EACb,cAAc,EAEf,MAAM,iBAAiB,CAAC;AAMzB,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACpD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAElD,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,OAAO,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,CACF,MAAM,EAAE,WAAW,EACnB,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CA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EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CA4BjD;IAEK,MAAM,CAAC,GAAG,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC,CA0DjE;YAMa,SAAS;IAyFvB,OAAO,CAAC,MAAM;IAiCd,OAAO,CAAC,SAAS;IAoCjB;;;;;OAKG;IACH,OAAO,CAAC,IAAI;IAiBZ,2EAA2E;IAC3E,OAAO,CAAC,MAAM;IAQd,OAAO,CAAC,MAAM;CAsBf;AAkCD;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,sBAAsB,CAAC;AACrF,wBAAgB,OAAO,CAAC,QAAQ,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,eAAe,CAAC"}
@@ -0,0 +1,2 @@
1
+ import{Ce,Oe}from"../index-vzhxn50e.js";import{z}from"../index-761dec5z.js";import{e,n}from"../index-x72d1hzh.js";class b{id;real;constructor(o,t){this.id=o;this.real=t}}class h{database;id="mongodb";capabilities;schema={version:1,tables:[],collections:[]};documentColumns=new Map;columnNames=new Map;constructor(o,t={}){this.database=o;this.capabilities={transactions:t.transactions===!0,sqlMigrations:!1,jsonQuery:!0}}useSchema(o){this.schema=o,this.documentColumns=new Map(o.tables.filter((t)=>t.documentColumn!==void 0).map((t)=>[t.name,t.documentColumn])),this.columnNames=new Map(o.tables.map((t)=>[t.name,new Set(t.columns.map((i)=>i.name))]))}async introspect(){let o=(await this.database.listCollections().toArray()).map((i)=>i.name).filter((i)=>i!==z).sort(),t=[];for(let i of o){let r=await this.database.collection(i).listIndexes().toArray();t.push({name:i,columns:[],primaryKey:["id"],indexes:r.filter((a)=>a.name!=="_id_").map((a)=>({name:a.name,table:i,targets:Object.keys(a.key).map((c)=>({kind:"column",column:c})),unique:a.unique===!0})).sort((a,c)=>a.name.localeCompare(c.name))})}return{version:1,tables:t,collections:[]}}plan(o,t){return Ce(o,t)}render(o,t){let i=o.map(Oe);return{id:t,extension:"json",content:`${JSON.stringify({id:t,summary:i,steps:o},null,2)}
2
+ `,summary:i}}async applyMigration(o){let t=JSON.parse(o.content);for(let i of t.steps)await this.applyStep(i)}async listAppliedMigrations(){return(await this.database.collection(z).find({},{sort:{_id:1}}).toArray()).map((t)=>({id:String(t._id),checksum:String(t.checksum),appliedAt:new Date(String(t.applied_at))}))}async recordMigration(o,t){await this.database.collection(z).insertOne({_id:o,checksum:t,applied_at:new Date().toISOString()})}async transaction(o){return o(new b(x(),this.capabilities.transactions))}async query(o,t){let i=this.database.collection(t.table),r=this.filter(t.table,t.where);if(t.count===!0)return[{count:await i.countDocuments(r)}];let a={};if(t.orderBy&&t.orderBy.length>0)a.sort=Object.fromEntries(t.orderBy.map((s)=>[this.path(t.table,s.path),s.direction==="desc"?-1:1]));if(t.limit!==void 0)a.limit=t.limit;if(t.offset!==void 0)a.skip=t.offset;return(await i.find(r,a).toArray()).map((s)=>this.decode(t.table,s,t.select,t.table))}async mutate(o,t){let i=this.database.collection(t.table);if(t.kind==="insert"){let s=this.encode(t.values);return await i.insertOne(s),{rows:t.returning===!1?[]:[this.decode(t.table,s)],count:1}}if(t.kind==="update"){let s=this.filter(t.table,t.where),l=this.encode(t.set),u=t.returning===!1?[]:await i.find(s,{projection:{_id:1}}).toArray(),m=await i.updateMany(s,{$set:l}),p=m.modifiedCount??m.matchedCount??0;if(t.returning===!1)return{rows:[],count:p};let g=u.length===0?[]:await i.find({_id:{$in:u.map((d)=>d._id)}}).toArray();return{rows:g.map((d)=>this.decode(t.table,d)),count:Math.max(p,g.length)}}let r=this.filter(t.table,t.where),a=t.returning===!0?await i.find(r).toArray():[],c=await i.deleteMany(r);return{rows:a.map((s)=>this.decode(t.table,s)),count:c.deletedCount??a.length}}async applyStep(o){switch(o.kind){case"create_table":{if(!(await this.database.listCollections().toArray()).map((i)=>i.name).includes(o.table.name))await this.database.createCollection(o.table.name);return}case"drop_table":await this.database.dropCollection(o.table).catch(()=>{return});return;case"add_column":{if(o.column.default===void 0)return;await this.database.collection(o.table).updateMany({[o.column.name]:{$exists:!1}},{$set:{[o.column.name]:o.column.default}});return}case"drop_column":await this.database.collection(o.table).updateMany({},{$unset:{[o.column]:""}});return;case"alter_column":return;case"create_index":{let t={};for(let i of o.index.targets)t[i.kind==="column"?i.column:[i.column,...i.path].join(".")]=1;await this.database.collection(o.index.table).createIndex(t,{name:o.index.name,unique:o.index.unique,...o.index.where?{partialFilterExpression:{[o.index.where.column]:o.index.where.equals}}:{}});return}case"drop_index":await this.database.collection(o.table).dropIndex(o.index).catch(()=>{return});return;case"set_document_field":{let t=[o.documentColumn,...o.path].join(".");await this.database.collection(o.table).updateMany({collection:o.collection,[t]:{$exists:!1}},{$set:{[t]:o.value}});return}case"unset_document_field":{let t=[o.documentColumn,...o.path].join(".");await this.database.collection(o.table).updateMany({collection:o.collection},{$unset:{[t]:""}});return}}}filter(o,t){if(!t)return{};if(t.kind==="and"){if(t.conditions.length===0)return{};return{$and:t.conditions.map((c)=>this.filter(o,c))}}if(t.kind==="or"){if(t.conditions.length===0)return{_id:{$exists:!1}};return{$or:t.conditions.map((c)=>this.filter(o,c))}}if(t.kind==="not")return{$nor:[this.filter(o,t.condition)]};let i=this.path(o,t.path),r=this.documentColumns.get(o),a=r!==void 0&&i.startsWith(`${r}.`)?w(t.value):t.value;return{[i]:this.condition(t.operator,a)}}condition(o,t){switch(o){case"eq":return{$eq:t};case"ne":return{$ne:t};case"gt":return{$gt:t};case"gte":return{$gte:t};case"lt":return{$lt:t};case"lte":return{$lte:t};case"in":return{$in:Array.isArray(t)?t:[t]};case"nin":return{$nin:Array.isArray(t)?t:[t]};case"like":case"ilike":return{$regex:y(String(t)),...o==="ilike"?{$options:"i"}:{}};case"contains":return{$eq:t};case"exists":return t===!1?{$in:[null]}:{$nin:[null]}}}path(o,t){let[i,...r]=t.split("."),a=i;if(this.columnNames.get(o)?.has(a))return[a==="id"?"_id":a,...r].join(".");let c=this.documentColumns.get(o);if(!c)throw new e(`Unknown column ${o}.${t}`,{status:400,code:"unknown_column"});return[c,...t.split(".")].join(".")}encode(o){let t={};for(let[i,r]of Object.entries(o))t[i==="id"?"_id":i]=r;return t}decode(o,t,i,r){let a={};for(let[s,l]of Object.entries(t))a[s==="_id"?"id":s]=l;if(!i||i.length===0||r===void 0)return a;let c={};for(let s of i){let l=this.path(r,s).replace(/^_id\b/,"id");c[s]=M(a,l.split("."))}return c}}function M(o,t){let i=o;for(let r of t){if(i===null||typeof i!=="object")return null;i=i[r]}return i??null}function w(o){if(o instanceof Date)return o.toISOString();return Array.isArray(o)?o.map((t)=>t instanceof Date?t.toISOString():t):o}function y(o){return`^${o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replaceAll("%",".*").replaceAll("_",".")}$`}var f=0;function x(){return f+=1,`mongo_tx_${f}`}function k(o,t={}){if(typeof o==="string")return async()=>k(await C(o,t),t);return new h(o,t)}async function C(o,t){let r;try{r=await import("mongodb")}catch{throw new n("database",'mongodb(url) needs the "mongodb" package; install it, or pass a Db you built yourself')}let a=new r.MongoClient(o);return await a.connect(),t.database?a.db(t.database):a.db()}export{h as MongoDatabaseAdapter,k as mongodb};
@@ -0,0 +1,37 @@
1
+ import type { DatabaseAdapter, DatabaseAdapterFactory } from "../types/database";
2
+ /**
3
+ * The shape `pg`, Neon, Supabase and PGlite all already have.
4
+ *
5
+ * No driver is bundled: the dependency belongs to the application, which knows
6
+ * whether it is deploying to a Node server with a pool, a serverless function
7
+ * with an HTTP driver, or a test with Postgres compiled to WebAssembly.
8
+ */
9
+ export interface PostgresClient {
10
+ query<T extends Record<string, unknown> = Record<string, unknown>>(text: string, values?: unknown[]): Promise<{
11
+ rows: T[];
12
+ rowCount?: number | null;
13
+ }>;
14
+ /** Pools expose this; a single connection does not. */
15
+ connect?(): Promise<PostgresConnection>;
16
+ end?(): Promise<void>;
17
+ }
18
+ export interface PostgresConnection extends PostgresClient {
19
+ release?(): void;
20
+ }
21
+ export interface PostgresOptions {
22
+ /** Overrides the adapter id reported by `cms.inspect()`. */
23
+ id?: string;
24
+ }
25
+ /**
26
+ * Creates the Postgres adapter.
27
+ *
28
+ * A connection string is accepted as well as a client, because
29
+ * `postgres(env.DATABASE_URL)` is what a developer wants to write. It returns
30
+ * a factory in that case: the pool is built on first use, so a module that is
31
+ * merely imported — by the CLI, by a page that never queries — does not open
32
+ * a connection, and a missing secret surfaces as a request error rather than
33
+ * an unhandled module error.
34
+ */
35
+ export declare function postgres(url: string, options?: PostgresOptions): DatabaseAdapterFactory;
36
+ export declare function postgres(client: PostgresClient, options?: PostgresOptions): DatabaseAdapter;
37
+ //# sourceMappingURL=postgres.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../src/db/postgres.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAK3B;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/D,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,OAAO,EAAE,GACjB,OAAO,CAAC;QAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;IACpD,uDAAuD;IACvD,OAAO,CAAC,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACxC,GAAG,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AAED,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,OAAO,CAAC,IAAI,IAAI,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,4DAA4D;IAC5D,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AA6CD;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,sBAAsB,CAAC;AACzF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,eAAe,CAAC"}
@@ -0,0 +1 @@
1
+ import{ce,Hn}from"../index-4qrep5f0.js";import{n}from"../index-x72d1hzh.js";class a{client;id;constructor(t,e="postgres"){this.client=t;this.id=e}async all(t,e){return(await this.client.query(t,e)).rows}async run(t,e){return{rowsAffected:(await this.client.query(t,e)).rowCount??0}}async exec(t){await this.client.query(t)}async close(){await this.client.end?.()}}function u(t,e={}){if(typeof t==="string")return async()=>u(await g(t),e);let r=t,o=new a(r,e.id??"postgres");if(r.connect){let l=r.connect.bind(r);o.transaction=async(p)=>{let c=await l(),s=new a(c,o.id);try{await s.exec("BEGIN");let i=await p(s);return await s.exec("COMMIT"),i}catch(i){throw await s.exec("ROLLBACK").catch(()=>{return}),i}finally{c.release?.()}}}return new ce(o,Hn)}async function g(t){let r;try{r=await import("pg")}catch{throw new n("database",'postgres(url) needs the "pg" package; install it, or pass a client you built yourself')}return new r.Pool({connectionString:t})}export{u as postgres};
@@ -0,0 +1,57 @@
1
+ import type { AppliedMigration, DatabaseAdapter, DatabaseCapabilities } from "../../types/database";
2
+ import type { Mutation, MutationResult, Query, Row, Tx } from "../../types/query";
3
+ import type { MigrationArtifact, MigrationStep, SchemaSnapshot } from "../../types/schema";
4
+ import type { SqlDialect } from "./dialect";
5
+ import { type SqlDriver } from "./driver";
6
+ export interface SqlAdapterOptions {
7
+ /** Overrides, for engines that are SQL but not fully featured (D1). */
8
+ capabilities?: Partial<DatabaseCapabilities>;
9
+ schema?: SchemaSnapshot;
10
+ }
11
+ /**
12
+ * One adapter for every SQL engine.
13
+ *
14
+ * Postgres, SQLite and D1 differ in a dialect object and a driver, not in a
15
+ * repository: a bug fixed for one is fixed for all three, and the contract
16
+ * suite that proves it runs against each.
17
+ */
18
+ export declare class SqlDatabaseAdapter implements DatabaseAdapter {
19
+ private readonly driver;
20
+ private readonly dialect;
21
+ readonly id: string;
22
+ readonly capabilities: DatabaseCapabilities;
23
+ private readonly catalog;
24
+ private readonly compiler;
25
+ private readonly renderer;
26
+ private schema;
27
+ private journalReady;
28
+ private transactionDepth;
29
+ constructor(driver: SqlDriver, dialect: SqlDialect, options?: SqlAdapterOptions);
30
+ useSchema(schema: SchemaSnapshot): void;
31
+ introspect(): Promise<SchemaSnapshot>;
32
+ plan(from: SchemaSnapshot, to: SchemaSnapshot): MigrationStep[];
33
+ render(steps: MigrationStep[], id: string): MigrationArtifact;
34
+ applyMigration(artifact: MigrationArtifact): Promise<void>;
35
+ listAppliedMigrations(): Promise<AppliedMigration[]>;
36
+ recordMigration(id: string, sum: string): Promise<void>;
37
+ /**
38
+ * Runs a function inside a transaction, or inside nothing at all when the
39
+ * engine has none.
40
+ *
41
+ * The nesting counter keeps a hook that calls back into the engine from
42
+ * issuing a second `BEGIN`, which Postgres warns about and SQLite refuses.
43
+ */
44
+ transaction<T>(fn: (tx: Tx) => Promise<T>): Promise<T>;
45
+ query(tx: Tx, query: Query): Promise<Row[]>;
46
+ mutate(tx: Tx, mutation: Mutation): Promise<MutationResult>;
47
+ close(): Promise<void>;
48
+ /**
49
+ * Creates the journal.
50
+ *
51
+ * It cannot be part of the generated schema: `migrate` has to know what has
52
+ * already run before it runs anything, so the table that answers that
53
+ * question must predate the first migration.
54
+ */
55
+ private ensureJournal;
56
+ }
57
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/db/sql/adapter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,E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,cAAc,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAK/D;IAEK,qBAAqB,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAWzD;IAEK,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAM5D;IAED;;;;;;OAMG;IACG,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CA2B3D;IAEK,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAYhD;IAEK,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC,CAehE;IAEK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;IAED;;;;;;OAMG;YACW,aAAa;CAW5B"}
@@ -0,0 +1,50 @@
1
+ import type { Mutation, Query, Row } from "../../types/query";
2
+ import type { ColumnType, SchemaSnapshot } from "../../types/schema";
3
+ import type { SqlDialect } from "./dialect";
4
+ export interface CompiledStatement {
5
+ text: string;
6
+ values: unknown[];
7
+ }
8
+ /**
9
+ * Knows what every column holds.
10
+ *
11
+ * Built from the snapshot the engine hands the adapter. Without it a row
12
+ * would come back with a JSON string where the caller expects an object, and
13
+ * a timestamp as whatever the driver felt like returning.
14
+ */
15
+ export declare class SchemaCatalog {
16
+ private readonly columns;
17
+ private readonly documentColumns;
18
+ constructor(schema?: SchemaSnapshot);
19
+ use(schema: SchemaSnapshot): void;
20
+ columnType(table: string, column: string): ColumnType | undefined;
21
+ /** The JSON column a table stores its document body in, if it has one. */
22
+ documentColumn(table: string): string | undefined;
23
+ tableColumns(table: string): string[];
24
+ knows(table: string): boolean;
25
+ }
26
+ export declare class SqlCompiler {
27
+ private readonly dialect;
28
+ private readonly catalog;
29
+ constructor(dialect: SqlDialect, catalog: SchemaCatalog);
30
+ compileQuery(query: Query): CompiledStatement;
31
+ compileMutation(mutation: Mutation): CompiledStatement;
32
+ /** Turns driver output back into the values the engine declared. */
33
+ decodeRow(table: string, row: Record<string, unknown>): Row;
34
+ private compileSelect;
35
+ private compileWhere;
36
+ /**
37
+ * A comparison decides the type of its own expression.
38
+ *
39
+ * The document body is untyped, so `views > 5` has to extract a number and
40
+ * `slug > "a"` has to extract text out of the very same column. Postgres
41
+ * refuses to compare the two, which is a feature: the cast belongs to the
42
+ * comparison, not to the column.
43
+ */
44
+ private comparisonExpression;
45
+ private compileComparison;
46
+ private expression;
47
+ private resolve;
48
+ private encodeColumn;
49
+ }
50
+ //# sourceMappingURL=compile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/db/sql/compile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,QAAQ,EACR,KAAK,EACL,GAAG,EAEJ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,EAAE,CAAC;CACnB;AAED;;;;;;GAMG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8C;IACtE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA6B;IAE7D,YAAY,MAAM,CAAC,EAAE,cAAc,EAElC;IAED,GAAG,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAYhC;IAED,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAEhE;IAED,0EAA0E;IAC1E,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEhD;IAED,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAEpC;IAED,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE5B;CACF;AAeD,qBAAa,WAAW;IAEpB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAF1B,YACmB,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,aAAa,EACrC;IAEJ,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,iBAAiB,CA+B5C;IAED,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,iBAAiB,CAsDrD;IAED,oEAAoE;IACpE,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,GAAG,CAU1D;IAED,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,YAAY;IAqBpB;;;;;;;OAOG;IACH,OAAO,CAAC,oBAAoB;IAQ5B,OAAO,CAAC,iBAAiB;IA0DzB,OAAO,CAAC,UAAU;IASlB,OAAO,CAAC,OAAO;IAuBf,OAAO,CAAC,YAAY;CAcrB"}
@@ -0,0 +1,34 @@
1
+ import type { MigrationStep, SchemaSnapshot } from "../../types/schema";
2
+ import type { SqlDialect } from "./dialect";
3
+ /**
4
+ * Turns neutral steps into the SQL that lands in the repository.
5
+ *
6
+ * The output is a file a reviewer reads in a pull request, so it carries the
7
+ * step summaries as comments and keeps one statement per line. Nothing here
8
+ * runs against a database: rendering and applying are separate on purpose, or
9
+ * "review the migration" would mean "review what already happened".
10
+ */
11
+ export declare class SqlDdlRenderer {
12
+ private readonly dialect;
13
+ private readonly target;
14
+ constructor(dialect: SqlDialect, target: () => SchemaSnapshot);
15
+ render(steps: MigrationStep[]): string;
16
+ private renderStep;
17
+ private createTable;
18
+ private columnClause;
19
+ private addColumn;
20
+ /**
21
+ * SQLite cannot alter a column, so the table is rebuilt.
22
+ *
23
+ * The twelve-step rebuild from the SQLite documentation, minus the steps
24
+ * that only matter for legacy schemas: create the new shape, copy the
25
+ * columns both shapes share, swap the names, recreate the indexes.
26
+ */
27
+ private alterColumn;
28
+ private createIndex;
29
+ private setDocumentField;
30
+ private unsetDocumentField;
31
+ private literal;
32
+ private q;
33
+ }
34
+ //# sourceMappingURL=ddl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ddl.d.ts","sourceRoot":"","sources":["../../../src/db/sql/ddl.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,aAAa,EACb,cAAc,EAEf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C;;;;;;;GAOG;AACH,qBAAa,cAAc;IAEvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFzB,YACmB,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,MAAM,cAAc,EAC3C;IAEJ,MAAM,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,MAAM,CAMrC;IAED,OAAO,CAAC,UAAU;IAwClB,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,SAAS;IAcjB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAsCnB,OAAO,CAAC,WAAW;IAenB,OAAO,CAAC,gBAAgB;IAmBxB,OAAO,CAAC,kBAAkB;IAc1B,OAAO,CAAC,OAAO;IAUf,OAAO,CAAC,CAAC;CAGV"}
@@ -0,0 +1,37 @@
1
+ import type { ColumnValue } from "../../types/query";
2
+ import type { ColumnSnapshot, ColumnType } from "../../types/schema";
3
+ /**
4
+ * Everything two SQL engines disagree about.
5
+ *
6
+ * The compiler and the DDL renderer are shared; only this table differs. A
7
+ * third SQL engine is a new object here, not a new adapter.
8
+ */
9
+ export interface SqlDialect {
10
+ readonly id: "postgres" | "sqlite";
11
+ /** `$1` on Postgres, `?` on SQLite. */
12
+ placeholder(index: number): string;
13
+ quote(identifier: string): string;
14
+ columnType(column: Pick<ColumnSnapshot, "type" | "array">): string;
15
+ /** Extracts a JSON path as a comparable value. */
16
+ jsonExtract(column: string, path: string[], type: ColumnType): string;
17
+ /** Extracts a JSON path as JSON, for array membership tests. */
18
+ jsonArrayMembership(column: string, path: string[], placeholder: string): string;
19
+ /** Case-insensitive LIKE, when the engine distinguishes the two. */
20
+ likeOperator(caseInsensitive: boolean): string;
21
+ encode(value: ColumnValue | undefined, type: ColumnType): unknown;
22
+ decode(value: unknown, type: ColumnType): ColumnValue;
23
+ /** True when `ALTER TABLE ... ALTER COLUMN` exists. */
24
+ readonly supportsAlterColumn: boolean;
25
+ /** The statement that opens a transaction; `BEGIN` when absent. */
26
+ readonly beginTransaction?: string;
27
+ }
28
+ export declare const postgresDialect: SqlDialect;
29
+ /**
30
+ * SQLite stores timestamps as epoch milliseconds and JSON as text.
31
+ *
32
+ * Milliseconds rather than ISO strings: comparisons and ordering are then
33
+ * plain integer work, and no row can carry a different time zone from its
34
+ * neighbour.
35
+ */
36
+ export declare const sqliteDialect: SqlDialect;
37
+ //# sourceMappingURL=dialect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialect.d.ts","sourceRoot":"","sources":["../../../src/db/sql/dialect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErE;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,EAAE,UAAU,GAAG,QAAQ,CAAC;IACnC,uCAAuC;IACvC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACnC,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,MAAM,CAAC;IACnE,kDAAkD;IAClD,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,CAAC;IACtE,gEAAgE;IAChE,mBAAmB,CACjB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAAE,EACd,WAAW,EAAE,MAAM,GAClB,MAAM,CAAC;IACV,oEAAoE;IACpE,YAAY,CAAC,eAAe,EAAE,OAAO,GAAG,MAAM,CAAC;IAC/C,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC;IAClE,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,GAAG,WAAW,CAAC;IACtD,uDAAuD;IACvD,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC;IACtC,mEAAmE;IACnE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACpC;AAiCD,eAAO,MAAM,eAAe,EAAE,UAgD7B,CAAC;AAyBF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,EAAE,UAwD3B,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The narrow surface every SQL engine has to provide.
3
+ *
4
+ * Four methods, no driver bundled: `pg`, Neon, PGlite, `bun:sqlite`,
5
+ * `node:sqlite` and a D1 binding all fit behind it, and the adapter never
6
+ * learns which one it is talking to.
7
+ */
8
+ export interface SqlDriver {
9
+ readonly id: string;
10
+ all(sql: string, values: unknown[]): Promise<Record<string, unknown>[]>;
11
+ run(sql: string, values: unknown[]): Promise<{
12
+ rowsAffected: number;
13
+ }>;
14
+ /** Multi-statement DDL. Migrations are the only caller. */
15
+ exec(sql: string): Promise<void>;
16
+ /**
17
+ * Runs a function against a connection pinned for the transaction.
18
+ *
19
+ * Optional: a pooled client would otherwise send `BEGIN` on one connection
20
+ * and the write on another. Engines without interactive transactions (D1)
21
+ * leave it out and declare `transactions: false`.
22
+ */
23
+ transaction?<T>(run: (driver: SqlDriver) => Promise<T>): Promise<T>;
24
+ close?(): Promise<void>;
25
+ }
26
+ /**
27
+ * Splits a migration file into statements.
28
+ *
29
+ * Quote-aware rather than a plain `split(";")`: a default value or a backfill
30
+ * literal can contain a semicolon, and cutting a statement in half there
31
+ * would corrupt a migration in the one place nobody tests twice.
32
+ */
33
+ export declare function splitStatements(sql: string): string[];
34
+ //# sourceMappingURL=driver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../../src/db/sql/driver.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;IACxE,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvE,2DAA2D;IAC3D,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC;;;;;;OAMG;IACH,WAAW,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACpE,KAAK,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAqCrD"}
@@ -0,0 +1,15 @@
1
+ import type { SchemaSnapshot } from "../../types/schema";
2
+ import type { SqlDriver } from "./driver";
3
+ /**
4
+ * Reads the physical schema back out of a live database.
5
+ *
6
+ * Only tables and indexes: a database cannot tell which collection a document
7
+ * belongs to any more than a filesystem can tell which project a file belongs
8
+ * to. The logical layer lives in the committed snapshot, and `generate` diffs
9
+ * against that. This is for drift detection — "the database is not what the
10
+ * migrations say it should be" — which is a different question from "what
11
+ * changed in the configuration".
12
+ */
13
+ export declare function introspectPostgres(driver: SqlDriver): Promise<SchemaSnapshot>;
14
+ export declare function introspectSqlite(driver: SqlDriver): Promise<SchemaSnapshot>;
15
+ //# sourceMappingURL=introspect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"introspect.d.ts","sourceRoot":"","sources":["../../../src/db/sql/introspect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,cAAc,EAEf,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;;;;GASG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,SAAS,GAChB,OAAO,CAAC,cAAc,CAAC,CAsDzB;AAED,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,SAAS,GAChB,OAAO,CAAC,cAAc,CAAC,CAkCzB"}