everything-dev 1.53.2 → 2.0.0-rc.1

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 (713) hide show
  1. package/README.md +2 -11
  2. package/dist/_virtual/_rolldown/runtime.cjs +17 -2
  3. package/dist/_virtual/_rolldown/runtime.mjs +36 -0
  4. package/dist/api/auth-middleware.cjs +161 -0
  5. package/dist/api/auth-middleware.cjs.map +1 -0
  6. package/dist/api/auth-middleware.d.cts +69 -0
  7. package/dist/api/auth-middleware.d.mts +69 -0
  8. package/dist/api/auth-middleware.mjs +160 -0
  9. package/dist/api/auth-middleware.mjs.map +1 -0
  10. package/dist/api-contract.cjs +250 -62
  11. package/dist/api-contract.cjs.map +1 -1
  12. package/dist/api-contract.mjs +246 -65
  13. package/dist/api-contract.mjs.map +1 -1
  14. package/dist/app.cjs +99 -26
  15. package/dist/app.cjs.map +1 -1
  16. package/dist/app.d.cts +3 -0
  17. package/dist/app.d.mts +3 -0
  18. package/dist/app.mjs +100 -27
  19. package/dist/app.mjs.map +1 -1
  20. package/dist/auth-login.cjs +163 -0
  21. package/dist/auth-login.cjs.map +1 -0
  22. package/dist/auth-login.mjs +162 -0
  23. package/dist/auth-login.mjs.map +1 -0
  24. package/dist/auth-session.cjs +64 -0
  25. package/dist/auth-session.cjs.map +1 -0
  26. package/dist/auth-session.mjs +58 -0
  27. package/dist/auth-session.mjs.map +1 -0
  28. package/dist/auth-types-gen.cjs +0 -1
  29. package/dist/auth-types-gen.cjs.map +1 -1
  30. package/dist/build.cjs +37 -173
  31. package/dist/build.cjs.map +1 -1
  32. package/dist/build.mjs +37 -171
  33. package/dist/build.mjs.map +1 -1
  34. package/dist/bundle-cache.cjs +74 -0
  35. package/dist/bundle-cache.cjs.map +1 -0
  36. package/dist/bundle-cache.d.cts +27 -0
  37. package/dist/bundle-cache.d.mts +27 -0
  38. package/dist/bundle-cache.mjs +68 -0
  39. package/dist/bundle-cache.mjs.map +1 -0
  40. package/dist/bundle-fs-resolve.cjs +209 -0
  41. package/dist/bundle-fs-resolve.cjs.map +1 -0
  42. package/dist/bundle-fs-resolve.d.cts +76 -0
  43. package/dist/bundle-fs-resolve.d.mts +76 -0
  44. package/dist/bundle-fs-resolve.mjs +202 -0
  45. package/dist/bundle-fs-resolve.mjs.map +1 -0
  46. package/dist/cdn-deploy.cjs +126 -0
  47. package/dist/cdn-deploy.cjs.map +1 -0
  48. package/dist/cdn-deploy.mjs +124 -0
  49. package/dist/cdn-deploy.mjs.map +1 -0
  50. package/dist/cli/db-doctor.cjs +19 -19
  51. package/dist/cli/db-doctor.cjs.map +1 -1
  52. package/dist/cli/db-doctor.mjs +18 -18
  53. package/dist/cli/db-doctor.mjs.map +1 -1
  54. package/dist/cli/db-repair.cjs +9 -32
  55. package/dist/cli/db-repair.cjs.map +1 -1
  56. package/dist/cli/db-repair.mjs +9 -32
  57. package/dist/cli/db-repair.mjs.map +1 -1
  58. package/dist/cli/framework-version.cjs +7 -3
  59. package/dist/cli/framework-version.cjs.map +1 -1
  60. package/dist/cli/framework-version.mjs +7 -3
  61. package/dist/cli/framework-version.mjs.map +1 -1
  62. package/dist/cli/infra.cjs +159 -251
  63. package/dist/cli/infra.cjs.map +1 -1
  64. package/dist/cli/infra.mjs +154 -242
  65. package/dist/cli/infra.mjs.map +1 -1
  66. package/dist/cli/init.cjs +627 -199
  67. package/dist/cli/init.cjs.map +1 -1
  68. package/dist/cli/init.d.cts +61 -8
  69. package/dist/cli/init.d.mts +61 -8
  70. package/dist/cli/init.mjs +616 -197
  71. package/dist/cli/init.mjs.map +1 -1
  72. package/dist/cli/parse.cjs +8 -7
  73. package/dist/cli/parse.cjs.map +1 -1
  74. package/dist/cli/parse.mjs +9 -7
  75. package/dist/cli/parse.mjs.map +1 -1
  76. package/dist/cli/prompts.cjs +14 -1
  77. package/dist/cli/prompts.cjs.map +1 -1
  78. package/dist/cli/prompts.mjs +14 -1
  79. package/dist/cli/prompts.mjs.map +1 -1
  80. package/dist/cli/prune.cjs +220 -0
  81. package/dist/cli/prune.cjs.map +1 -0
  82. package/dist/cli/prune.mjs +220 -0
  83. package/dist/cli/prune.mjs.map +1 -0
  84. package/dist/cli/snapshot.cjs +2 -1
  85. package/dist/cli/snapshot.cjs.map +1 -1
  86. package/dist/cli/snapshot.mjs +2 -1
  87. package/dist/cli/snapshot.mjs.map +1 -1
  88. package/dist/cli/status.cjs +5 -4
  89. package/dist/cli/status.cjs.map +1 -1
  90. package/dist/cli/status.mjs +6 -5
  91. package/dist/cli/status.mjs.map +1 -1
  92. package/dist/cli/sync.cjs +156 -58
  93. package/dist/cli/sync.cjs.map +1 -1
  94. package/dist/cli/sync.mjs +158 -63
  95. package/dist/cli/sync.mjs.map +1 -1
  96. package/dist/cli/timing.cjs +0 -1
  97. package/dist/cli/timing.cjs.map +1 -1
  98. package/dist/cli/upgrade.cjs +95 -69
  99. package/dist/cli/upgrade.cjs.map +1 -1
  100. package/dist/cli/upgrade.mjs +97 -72
  101. package/dist/cli/upgrade.mjs.map +1 -1
  102. package/dist/cli/utils/helpers.cjs.map +1 -1
  103. package/dist/cli.cjs +320 -72
  104. package/dist/cli.cjs.map +1 -1
  105. package/dist/cli.mjs +316 -68
  106. package/dist/cli.mjs.map +1 -1
  107. package/dist/code-artifacts.cjs +76 -8
  108. package/dist/code-artifacts.cjs.map +1 -1
  109. package/dist/code-artifacts.mjs +76 -10
  110. package/dist/code-artifacts.mjs.map +1 -1
  111. package/dist/commands/build.cjs +65 -0
  112. package/dist/commands/build.cjs.map +1 -0
  113. package/dist/commands/build.mjs +65 -0
  114. package/dist/commands/build.mjs.map +1 -0
  115. package/dist/commands/config.cjs +77 -0
  116. package/dist/commands/config.cjs.map +1 -0
  117. package/dist/commands/config.d.cts +8 -0
  118. package/dist/commands/config.d.mts +8 -0
  119. package/dist/commands/config.mjs +74 -0
  120. package/dist/commands/config.mjs.map +1 -0
  121. package/dist/commands/db.cjs +107 -0
  122. package/dist/commands/db.cjs.map +1 -0
  123. package/dist/commands/db.mjs +107 -0
  124. package/dist/commands/db.mjs.map +1 -0
  125. package/dist/commands/deploy.cjs +336 -0
  126. package/dist/commands/deploy.cjs.map +1 -0
  127. package/dist/commands/deploy.mjs +334 -0
  128. package/dist/commands/deploy.mjs.map +1 -0
  129. package/dist/commands/dev.cjs +75 -0
  130. package/dist/commands/dev.cjs.map +1 -0
  131. package/dist/commands/dev.mjs +73 -0
  132. package/dist/commands/dev.mjs.map +1 -0
  133. package/dist/commands/init.cjs +234 -0
  134. package/dist/commands/init.cjs.map +1 -0
  135. package/dist/commands/init.mjs +231 -0
  136. package/dist/commands/init.mjs.map +1 -0
  137. package/dist/commands/keys.cjs +255 -0
  138. package/dist/commands/keys.cjs.map +1 -0
  139. package/dist/commands/keys.mjs +253 -0
  140. package/dist/commands/keys.mjs.map +1 -0
  141. package/dist/commands/ops.cjs +199 -0
  142. package/dist/commands/ops.cjs.map +1 -0
  143. package/dist/commands/ops.mjs +197 -0
  144. package/dist/commands/ops.mjs.map +1 -0
  145. package/dist/commands/plugins.cjs +211 -0
  146. package/dist/commands/plugins.cjs.map +1 -0
  147. package/dist/commands/plugins.mjs +211 -0
  148. package/dist/commands/plugins.mjs.map +1 -0
  149. package/dist/commands/shared.cjs +8 -0
  150. package/dist/commands/shared.cjs.map +1 -0
  151. package/dist/commands/shared.d.cts +6 -0
  152. package/dist/commands/shared.d.mts +6 -0
  153. package/dist/commands/shared.mjs +8 -0
  154. package/dist/commands/shared.mjs.map +1 -0
  155. package/dist/commands/upgrade.cjs +325 -0
  156. package/dist/commands/upgrade.cjs.map +1 -0
  157. package/dist/commands/upgrade.mjs +323 -0
  158. package/dist/commands/upgrade.mjs.map +1 -0
  159. package/dist/components/dev-render.cjs +340 -0
  160. package/dist/components/dev-render.cjs.map +1 -0
  161. package/dist/components/dev-render.mjs +332 -0
  162. package/dist/components/dev-render.mjs.map +1 -0
  163. package/dist/config.cjs +460 -221
  164. package/dist/config.cjs.map +1 -1
  165. package/dist/config.d.cts +491 -48
  166. package/dist/config.d.mts +491 -48
  167. package/dist/config.mjs +439 -212
  168. package/dist/config.mjs.map +1 -1
  169. package/dist/contract.cjs +327 -50
  170. package/dist/contract.cjs.map +1 -1
  171. package/dist/contract.d.cts +1951 -1062
  172. package/dist/contract.d.mts +1951 -1062
  173. package/dist/contract.meta.cjs +107 -12
  174. package/dist/contract.meta.cjs.map +1 -1
  175. package/dist/contract.meta.d.cts +166 -8
  176. package/dist/contract.meta.d.mts +166 -8
  177. package/dist/contract.meta.mjs +107 -11
  178. package/dist/contract.meta.mjs.map +1 -1
  179. package/dist/contract.mjs +580 -327
  180. package/dist/contract.mjs.map +1 -1
  181. package/dist/dag.cjs +5 -3
  182. package/dist/dag.cjs.map +1 -1
  183. package/dist/dag.mjs +6 -3
  184. package/dist/dag.mjs.map +1 -1
  185. package/dist/db/binding.cjs +80 -0
  186. package/dist/db/binding.cjs.map +1 -0
  187. package/dist/db/binding.d.cts +39 -0
  188. package/dist/db/binding.d.mts +39 -0
  189. package/dist/db/binding.mjs +78 -0
  190. package/dist/db/binding.mjs.map +1 -0
  191. package/dist/db/bindings.cjs +78 -0
  192. package/dist/db/bindings.cjs.map +1 -0
  193. package/dist/db/bindings.d.cts +34 -0
  194. package/dist/db/bindings.d.mts +34 -0
  195. package/dist/db/bindings.mjs +76 -0
  196. package/dist/db/bindings.mjs.map +1 -0
  197. package/dist/db/core.cjs +204 -0
  198. package/dist/db/core.cjs.map +1 -0
  199. package/dist/db/core.d.cts +69 -0
  200. package/dist/db/core.d.mts +69 -0
  201. package/dist/db/core.mjs +192 -0
  202. package/dist/db/core.mjs.map +1 -0
  203. package/dist/db/driver.cjs +167 -0
  204. package/dist/db/driver.cjs.map +1 -0
  205. package/dist/db/driver.d.cts +50 -0
  206. package/dist/db/driver.d.mts +50 -0
  207. package/dist/db/driver.mjs +165 -0
  208. package/dist/db/driver.mjs.map +1 -0
  209. package/dist/db/drizzle-kit.cjs +177 -0
  210. package/dist/db/drizzle-kit.cjs.map +1 -0
  211. package/dist/db/drizzle-kit.d.cts +25 -0
  212. package/dist/db/drizzle-kit.d.mts +25 -0
  213. package/dist/db/drizzle-kit.mjs +175 -0
  214. package/dist/db/drizzle-kit.mjs.map +1 -0
  215. package/dist/db/errors.cjs +27 -0
  216. package/dist/db/errors.cjs.map +1 -0
  217. package/dist/db/errors.d.cts +16 -0
  218. package/dist/db/errors.d.mts +16 -0
  219. package/dist/db/errors.mjs +26 -0
  220. package/dist/db/errors.mjs.map +1 -0
  221. package/dist/db/identity.cjs +55 -0
  222. package/dist/db/identity.cjs.map +1 -0
  223. package/dist/db/identity.d.cts +40 -0
  224. package/dist/db/identity.d.mts +40 -0
  225. package/dist/db/identity.mjs +53 -0
  226. package/dist/db/identity.mjs.map +1 -0
  227. package/dist/db/index.cjs +43 -0
  228. package/dist/db/index.d.cts +9 -0
  229. package/dist/db/index.d.mts +9 -0
  230. package/dist/db/index.mjs +10 -0
  231. package/dist/db/run-migrations.cjs +343 -0
  232. package/dist/db/run-migrations.cjs.map +1 -0
  233. package/dist/db/run-migrations.d.cts +87 -0
  234. package/dist/db/run-migrations.d.mts +87 -0
  235. package/dist/db/run-migrations.mjs +341 -0
  236. package/dist/db/run-migrations.mjs.map +1 -0
  237. package/dist/delegate-signer.cjs +85 -0
  238. package/dist/delegate-signer.cjs.map +1 -0
  239. package/dist/delegate-signer.mjs +84 -0
  240. package/dist/delegate-signer.mjs.map +1 -0
  241. package/dist/deploy-diff.cjs +119 -0
  242. package/dist/deploy-diff.cjs.map +1 -0
  243. package/dist/deploy-diff.mjs +109 -0
  244. package/dist/deploy-diff.mjs.map +1 -0
  245. package/dist/descriptor/constructors.cjs +49 -0
  246. package/dist/descriptor/constructors.cjs.map +1 -0
  247. package/dist/descriptor/constructors.d.cts +27 -0
  248. package/dist/descriptor/constructors.d.mts +27 -0
  249. package/dist/descriptor/constructors.mjs +45 -0
  250. package/dist/descriptor/constructors.mjs.map +1 -0
  251. package/dist/descriptor/index.cjs +24 -0
  252. package/dist/descriptor/index.d.cts +5 -0
  253. package/dist/descriptor/index.d.mts +5 -0
  254. package/dist/descriptor/index.mjs +6 -0
  255. package/dist/descriptor/resolve.cjs +258 -0
  256. package/dist/descriptor/resolve.cjs.map +1 -0
  257. package/dist/descriptor/resolve.d.cts +50 -0
  258. package/dist/descriptor/resolve.d.mts +50 -0
  259. package/dist/descriptor/resolve.mjs +252 -0
  260. package/dist/descriptor/resolve.mjs.map +1 -0
  261. package/dist/descriptor/schema.cjs +109 -0
  262. package/dist/descriptor/schema.cjs.map +1 -0
  263. package/dist/descriptor/schema.d.cts +217 -0
  264. package/dist/descriptor/schema.d.mts +217 -0
  265. package/dist/descriptor/schema.mjs +102 -0
  266. package/dist/descriptor/schema.mjs.map +1 -0
  267. package/dist/descriptor/serialize.cjs +45 -0
  268. package/dist/descriptor/serialize.cjs.map +1 -0
  269. package/dist/descriptor/serialize.d.cts +7 -0
  270. package/dist/descriptor/serialize.d.mts +7 -0
  271. package/dist/descriptor/serialize.mjs +45 -0
  272. package/dist/descriptor/serialize.mjs.map +1 -0
  273. package/dist/dev-log-pipeline.cjs +273 -0
  274. package/dist/dev-log-pipeline.cjs.map +1 -0
  275. package/dist/dev-log-pipeline.mjs +267 -0
  276. package/dist/dev-log-pipeline.mjs.map +1 -0
  277. package/dist/dev-logs.cjs +39 -8
  278. package/dist/dev-logs.cjs.map +1 -1
  279. package/dist/dev-logs.mjs +37 -9
  280. package/dist/dev-logs.mjs.map +1 -1
  281. package/dist/dev-program.cjs +405 -0
  282. package/dist/dev-program.cjs.map +1 -0
  283. package/dist/dev-program.d.cts +10 -0
  284. package/dist/dev-program.d.mts +10 -0
  285. package/dist/dev-program.mjs +395 -0
  286. package/dist/dev-program.mjs.map +1 -0
  287. package/dist/dev-session-data.d.cts +27 -0
  288. package/dist/dev-session-data.d.mts +27 -0
  289. package/dist/dev-session.cjs +178 -105
  290. package/dist/dev-session.cjs.map +1 -1
  291. package/dist/dev-session.mjs +180 -105
  292. package/dist/dev-session.mjs.map +1 -1
  293. package/dist/env/process-env.cjs +16 -0
  294. package/dist/env/process-env.cjs.map +1 -0
  295. package/dist/env/process-env.mjs +13 -0
  296. package/dist/env/process-env.mjs.map +1 -0
  297. package/dist/env/project-env.cjs +144 -0
  298. package/dist/env/project-env.cjs.map +1 -0
  299. package/dist/env/project-env.d.cts +1 -0
  300. package/dist/env/project-env.d.mts +1 -0
  301. package/dist/env/project-env.mjs +132 -0
  302. package/dist/env/project-env.mjs.map +1 -0
  303. package/dist/fastkv.cjs +59 -12
  304. package/dist/fastkv.cjs.map +1 -1
  305. package/dist/fastkv.d.cts +42 -6
  306. package/dist/fastkv.d.mts +42 -6
  307. package/dist/fastkv.mjs +58 -13
  308. package/dist/fastkv.mjs.map +1 -1
  309. package/dist/fingerprint.cjs +57 -0
  310. package/dist/fingerprint.cjs.map +1 -0
  311. package/dist/fingerprint.d.cts +14 -0
  312. package/dist/fingerprint.d.mts +14 -0
  313. package/dist/fingerprint.mjs +55 -0
  314. package/dist/fingerprint.mjs.map +1 -0
  315. package/dist/http-client.cjs +17 -17
  316. package/dist/http-client.cjs.map +1 -1
  317. package/dist/http-client.mjs +17 -17
  318. package/dist/http-client.mjs.map +1 -1
  319. package/dist/image-deploy.cjs +186 -0
  320. package/dist/image-deploy.cjs.map +1 -0
  321. package/dist/image-deploy.mjs +182 -0
  322. package/dist/image-deploy.mjs.map +1 -0
  323. package/dist/index.cjs +66 -18
  324. package/dist/index.d.cts +8 -7
  325. package/dist/index.d.mts +8 -7
  326. package/dist/index.mjs +6 -5
  327. package/dist/infra/docker.cjs +77 -0
  328. package/dist/infra/docker.cjs.map +1 -0
  329. package/dist/infra/docker.d.cts +10 -0
  330. package/dist/infra/docker.d.mts +10 -0
  331. package/dist/infra/docker.mjs +69 -0
  332. package/dist/infra/docker.mjs.map +1 -0
  333. package/dist/infra/materializer.cjs +74 -0
  334. package/dist/infra/materializer.cjs.map +1 -0
  335. package/dist/infra/materializer.mjs +70 -0
  336. package/dist/infra/materializer.mjs.map +1 -0
  337. package/dist/infra/planner.cjs +135 -103
  338. package/dist/infra/planner.cjs.map +1 -1
  339. package/dist/infra/planner.mjs +137 -104
  340. package/dist/infra/planner.mjs.map +1 -1
  341. package/dist/infra/port-ownership.cjs +57 -0
  342. package/dist/infra/port-ownership.cjs.map +1 -0
  343. package/dist/infra/port-ownership.mjs +57 -0
  344. package/dist/infra/port-ownership.mjs.map +1 -0
  345. package/dist/infra/preflight.cjs +45 -33
  346. package/dist/infra/preflight.cjs.map +1 -1
  347. package/dist/infra/preflight.d.cts +1 -0
  348. package/dist/infra/preflight.d.mts +1 -0
  349. package/dist/infra/preflight.mjs +46 -34
  350. package/dist/infra/preflight.mjs.map +1 -1
  351. package/dist/infra/types.cjs.map +1 -1
  352. package/dist/infra/types.d.cts +2 -0
  353. package/dist/infra/types.d.mts +2 -0
  354. package/dist/infra/types.mjs.map +1 -1
  355. package/dist/integrity.cjs +50 -61
  356. package/dist/integrity.cjs.map +1 -1
  357. package/dist/integrity.d.cts +16 -10
  358. package/dist/integrity.d.mts +16 -10
  359. package/dist/integrity.mjs +50 -59
  360. package/dist/integrity.mjs.map +1 -1
  361. package/dist/internal/manifest-normalizer.cjs +8 -2
  362. package/dist/internal/manifest-normalizer.cjs.map +1 -1
  363. package/dist/internal/manifest-normalizer.mjs +9 -3
  364. package/dist/internal/manifest-normalizer.mjs.map +1 -1
  365. package/dist/merge.cjs +19 -1
  366. package/dist/merge.cjs.map +1 -1
  367. package/dist/merge.d.cts +1 -1
  368. package/dist/merge.d.mts +1 -1
  369. package/dist/merge.mjs +19 -2
  370. package/dist/merge.mjs.map +1 -1
  371. package/dist/mf.cjs +190 -3
  372. package/dist/mf.cjs.map +1 -1
  373. package/dist/mf.d.cts +24 -2
  374. package/dist/mf.d.mts +24 -2
  375. package/dist/mf.mjs +189 -4
  376. package/dist/mf.mjs.map +1 -1
  377. package/dist/near-cli.cjs +59 -91
  378. package/dist/near-cli.cjs.map +1 -1
  379. package/dist/near-cli.mjs +58 -90
  380. package/dist/near-cli.mjs.map +1 -1
  381. package/dist/near-signer.cjs +73 -0
  382. package/dist/near-signer.cjs.map +1 -0
  383. package/dist/near-signer.mjs +70 -0
  384. package/dist/near-signer.mjs.map +1 -0
  385. package/dist/network.cjs +0 -1
  386. package/dist/network.cjs.map +1 -1
  387. package/dist/orchestrator.cjs +256 -87
  388. package/dist/orchestrator.cjs.map +1 -1
  389. package/dist/orchestrator.mjs +248 -87
  390. package/dist/orchestrator.mjs.map +1 -1
  391. package/dist/platform-deploy.cjs +81 -0
  392. package/dist/platform-deploy.cjs.map +1 -0
  393. package/dist/platform-deploy.mjs +80 -0
  394. package/dist/platform-deploy.mjs.map +1 -0
  395. package/dist/plugin.cjs +54 -1389
  396. package/dist/plugin.cjs.map +1 -1
  397. package/dist/plugin.d.cts +6 -896
  398. package/dist/plugin.d.mts +6 -896
  399. package/dist/plugin.mjs +53 -1387
  400. package/dist/plugin.mjs.map +1 -1
  401. package/dist/process-kill.cjs +44 -0
  402. package/dist/process-kill.cjs.map +1 -0
  403. package/dist/process-kill.mjs +43 -0
  404. package/dist/process-kill.mjs.map +1 -0
  405. package/dist/process-registry.cjs +64 -9
  406. package/dist/process-registry.cjs.map +1 -1
  407. package/dist/process-registry.mjs +61 -10
  408. package/dist/process-registry.mjs.map +1 -1
  409. package/dist/progress.cjs +45 -0
  410. package/dist/progress.cjs.map +1 -0
  411. package/dist/progress.d.cts +13 -0
  412. package/dist/progress.d.mts +13 -0
  413. package/dist/progress.mjs +42 -0
  414. package/dist/progress.mjs.map +1 -0
  415. package/dist/publish.cjs +513 -79
  416. package/dist/publish.cjs.map +1 -1
  417. package/dist/publish.mjs +515 -82
  418. package/dist/publish.mjs.map +1 -1
  419. package/dist/registry-use.cjs +41 -0
  420. package/dist/registry-use.cjs.map +1 -0
  421. package/dist/registry-use.mjs +40 -0
  422. package/dist/registry-use.mjs.map +1 -0
  423. package/dist/resolution/session.cjs +335 -0
  424. package/dist/resolution/session.cjs.map +1 -0
  425. package/dist/resolution/session.d.cts +105 -0
  426. package/dist/resolution/session.d.mts +105 -0
  427. package/dist/resolution/session.mjs +331 -0
  428. package/dist/resolution/session.mjs.map +1 -0
  429. package/dist/rollback.cjs +131 -0
  430. package/dist/rollback.cjs.map +1 -0
  431. package/dist/rollback.mjs +128 -0
  432. package/dist/rollback.mjs.map +1 -0
  433. package/dist/sdk.cjs +7 -7
  434. package/dist/sdk.d.cts +3 -3
  435. package/dist/sdk.d.mts +3 -3
  436. package/dist/sdk.mjs +2 -2
  437. package/dist/service-descriptor.cjs +67 -34
  438. package/dist/service-descriptor.cjs.map +1 -1
  439. package/dist/service-descriptor.d.cts +4 -1
  440. package/dist/service-descriptor.d.mts +3 -0
  441. package/dist/service-descriptor.mjs +63 -35
  442. package/dist/service-descriptor.mjs.map +1 -1
  443. package/dist/shared-deps.cjs +17 -16
  444. package/dist/shared-deps.cjs.map +1 -1
  445. package/dist/shared-deps.mjs +17 -16
  446. package/dist/shared-deps.mjs.map +1 -1
  447. package/dist/start-config-source.cjs +24 -0
  448. package/dist/start-config-source.cjs.map +1 -0
  449. package/dist/start-config-source.d.cts +29 -0
  450. package/dist/start-config-source.d.mts +29 -0
  451. package/dist/start-config-source.mjs +22 -0
  452. package/dist/start-config-source.mjs.map +1 -0
  453. package/dist/storage-upload.cjs +145 -0
  454. package/dist/storage-upload.cjs.map +1 -0
  455. package/dist/storage-upload.mjs +143 -0
  456. package/dist/storage-upload.mjs.map +1 -0
  457. package/dist/types.cjs +126 -20
  458. package/dist/types.cjs.map +1 -1
  459. package/dist/types.d.cts +867 -585
  460. package/dist/types.d.mts +867 -585
  461. package/dist/types.mjs +307 -208
  462. package/dist/types.mjs.map +1 -1
  463. package/dist/ui/api.cjs +105 -0
  464. package/dist/ui/api.cjs.map +1 -0
  465. package/dist/ui/api.d.cts +31 -0
  466. package/dist/ui/api.d.mts +31 -0
  467. package/dist/ui/api.mjs +99 -0
  468. package/dist/ui/api.mjs.map +1 -0
  469. package/dist/ui/auth-guards.cjs +50 -0
  470. package/dist/ui/auth-guards.cjs.map +1 -0
  471. package/dist/ui/auth-guards.d.cts +39 -0
  472. package/dist/ui/auth-guards.d.mts +39 -0
  473. package/dist/ui/auth-guards.mjs +48 -0
  474. package/dist/ui/auth-guards.mjs.map +1 -0
  475. package/dist/ui/auth.cjs +197 -0
  476. package/dist/ui/auth.cjs.map +1 -0
  477. package/dist/ui/auth.d.cts +56 -0
  478. package/dist/ui/auth.d.mts +56 -0
  479. package/dist/ui/auth.mjs +179 -0
  480. package/dist/ui/auth.mjs.map +1 -0
  481. package/dist/ui/entry.cjs +16 -0
  482. package/dist/ui/entry.cjs.map +1 -0
  483. package/dist/ui/entry.d.cts +12 -0
  484. package/dist/ui/entry.d.mts +12 -0
  485. package/dist/ui/entry.mjs +15 -0
  486. package/dist/ui/entry.mjs.map +1 -0
  487. package/dist/ui/head.cjs +14 -7
  488. package/dist/ui/head.cjs.map +1 -1
  489. package/dist/ui/head.mjs +15 -7
  490. package/dist/ui/head.mjs.map +1 -1
  491. package/dist/ui/hydrate.cjs +265 -0
  492. package/dist/ui/hydrate.cjs.map +1 -0
  493. package/dist/ui/hydrate.d.cts +48 -0
  494. package/dist/ui/hydrate.d.mts +48 -0
  495. package/dist/ui/hydrate.mjs +263 -0
  496. package/dist/ui/hydrate.mjs.map +1 -0
  497. package/dist/ui/i18n.cjs +153 -0
  498. package/dist/ui/i18n.cjs.map +1 -0
  499. package/dist/ui/i18n.d.cts +29 -0
  500. package/dist/ui/i18n.d.mts +29 -0
  501. package/dist/ui/i18n.mjs +140 -0
  502. package/dist/ui/i18n.mjs.map +1 -0
  503. package/dist/ui/index.cjs +19 -1
  504. package/dist/ui/index.d.cts +6 -3
  505. package/dist/ui/index.d.mts +6 -3
  506. package/dist/ui/index.mjs +5 -2
  507. package/dist/ui/locale.cjs +53 -0
  508. package/dist/ui/locale.cjs.map +1 -0
  509. package/dist/ui/locale.d.cts +18 -0
  510. package/dist/ui/locale.d.mts +18 -0
  511. package/dist/ui/locale.mjs +49 -0
  512. package/dist/ui/locale.mjs.map +1 -0
  513. package/dist/ui/manifest/index.cjs +25 -0
  514. package/dist/ui/manifest/index.cjs.map +1 -0
  515. package/dist/ui/manifest/index.d.cts +9 -0
  516. package/dist/ui/manifest/index.d.mts +9 -0
  517. package/dist/ui/manifest/index.mjs +13 -0
  518. package/dist/ui/manifest/index.mjs.map +1 -0
  519. package/dist/ui/manifest-generator.cjs +8 -0
  520. package/dist/ui/manifest-generator.d.cts +1 -0
  521. package/dist/ui/manifest-generator.d.mts +1 -0
  522. package/dist/ui/manifest-generator.mjs +3 -0
  523. package/dist/ui/message-catalogs.cjs +8 -0
  524. package/dist/ui/message-catalogs.cjs.map +1 -0
  525. package/dist/ui/message-catalogs.d.cts +5 -0
  526. package/dist/ui/message-catalogs.d.mts +5 -0
  527. package/dist/ui/message-catalogs.mjs +8 -0
  528. package/dist/ui/message-catalogs.mjs.map +1 -0
  529. package/dist/ui/metadata.cjs +0 -1
  530. package/dist/ui/metadata.cjs.map +1 -1
  531. package/dist/ui/metadata.d.cts +1 -1
  532. package/dist/ui/metadata.d.mts +1 -1
  533. package/dist/ui/plugin-path.cjs +37 -0
  534. package/dist/ui/plugin-path.cjs.map +1 -0
  535. package/dist/ui/plugin-path.d.cts +25 -0
  536. package/dist/ui/plugin-path.d.mts +25 -0
  537. package/dist/ui/plugin-path.mjs +35 -0
  538. package/dist/ui/plugin-path.mjs.map +1 -0
  539. package/dist/ui/router-client.cjs +61 -0
  540. package/dist/ui/router-client.cjs.map +1 -0
  541. package/dist/ui/router-client.d.cts +20 -0
  542. package/dist/ui/router-client.d.mts +20 -0
  543. package/dist/ui/router-client.mjs +60 -0
  544. package/dist/ui/router-client.mjs.map +1 -0
  545. package/dist/ui/router-defaults.cjs +48 -0
  546. package/dist/ui/router-defaults.cjs.map +1 -0
  547. package/dist/ui/router-defaults.d.cts +8 -0
  548. package/dist/ui/router-defaults.d.mts +8 -0
  549. package/dist/ui/router-defaults.mjs +45 -0
  550. package/dist/ui/router-defaults.mjs.map +1 -0
  551. package/dist/ui/router-error.cjs +70 -0
  552. package/dist/ui/router-error.cjs.map +1 -0
  553. package/dist/ui/router-error.d.cts +19 -0
  554. package/dist/ui/router-error.d.mts +19 -0
  555. package/dist/ui/router-error.mjs +69 -0
  556. package/dist/ui/router-error.mjs.map +1 -0
  557. package/dist/ui/router-server.cjs +153 -0
  558. package/dist/ui/router-server.cjs.map +1 -0
  559. package/dist/ui/router-server.d.cts +38 -0
  560. package/dist/ui/router-server.d.mts +38 -0
  561. package/dist/ui/router-server.mjs +152 -0
  562. package/dist/ui/router-server.mjs.map +1 -0
  563. package/dist/ui/router.cjs +4 -16
  564. package/dist/ui/router.cjs.map +1 -1
  565. package/dist/ui/router.mjs +4 -15
  566. package/dist/ui/router.mjs.map +1 -1
  567. package/dist/ui/runtime.cjs +5 -1
  568. package/dist/ui/runtime.cjs.map +1 -1
  569. package/dist/ui/runtime.d.cts +2 -1
  570. package/dist/ui/runtime.d.mts +2 -1
  571. package/dist/ui/runtime.mjs +5 -1
  572. package/dist/ui/runtime.mjs.map +1 -1
  573. package/dist/ui/slot.cjs +34 -0
  574. package/dist/ui/slot.cjs.map +1 -0
  575. package/dist/ui/slot.d.cts +43 -0
  576. package/dist/ui/slot.d.mts +43 -0
  577. package/dist/ui/slot.mjs +34 -0
  578. package/dist/ui/slot.mjs.map +1 -0
  579. package/dist/ui/tenant.cjs +300 -0
  580. package/dist/ui/tenant.cjs.map +1 -0
  581. package/dist/ui/tenant.d.cts +122 -0
  582. package/dist/ui/tenant.d.mts +122 -0
  583. package/dist/ui/tenant.mjs +279 -0
  584. package/dist/ui/tenant.mjs.map +1 -0
  585. package/dist/ui/types.d.cts +32 -2
  586. package/dist/ui/types.d.mts +32 -2
  587. package/dist/ui/version-check.cjs +47 -0
  588. package/dist/ui/version-check.cjs.map +1 -0
  589. package/dist/ui/version-check.d.cts +23 -0
  590. package/dist/ui/version-check.d.mts +23 -0
  591. package/dist/ui/version-check.mjs +46 -0
  592. package/dist/ui/version-check.mjs.map +1 -0
  593. package/dist/utils/banner.cjs +2 -2
  594. package/dist/utils/banner.cjs.map +1 -1
  595. package/dist/utils/banner.mjs +2 -2
  596. package/dist/utils/banner.mjs.map +1 -1
  597. package/dist/utils/linkify.cjs +1 -1
  598. package/dist/utils/linkify.cjs.map +1 -1
  599. package/dist/utils/linkify.mjs +1 -0
  600. package/dist/utils/linkify.mjs.map +1 -1
  601. package/dist/utils/run.cjs +6 -6
  602. package/dist/utils/run.cjs.map +1 -1
  603. package/dist/utils/run.mjs +6 -6
  604. package/dist/utils/run.mjs.map +1 -1
  605. package/dist/utils/save-config.cjs +12 -0
  606. package/dist/utils/save-config.cjs.map +1 -1
  607. package/dist/utils/save-config.mjs +12 -0
  608. package/dist/utils/save-config.mjs.map +1 -1
  609. package/dist/utils/snapshot-hash.cjs +10 -0
  610. package/dist/utils/snapshot-hash.cjs.map +1 -0
  611. package/dist/utils/snapshot-hash.mjs +10 -0
  612. package/dist/utils/snapshot-hash.mjs.map +1 -0
  613. package/dist/utils/string.cjs +0 -1
  614. package/dist/utils/string.cjs.map +1 -1
  615. package/dist/utils/theme.cjs +30 -12
  616. package/dist/utils/theme.cjs.map +1 -1
  617. package/dist/utils/theme.mjs +30 -11
  618. package/dist/utils/theme.mjs.map +1 -1
  619. package/dist/version-manifest-deploy.cjs +50 -0
  620. package/dist/version-manifest-deploy.cjs.map +1 -0
  621. package/dist/version-manifest-deploy.mjs +49 -0
  622. package/dist/version-manifest-deploy.mjs.map +1 -0
  623. package/dist/version-manifest-resolve.cjs +42 -0
  624. package/dist/version-manifest-resolve.cjs.map +1 -0
  625. package/dist/version-manifest-resolve.d.cts +38 -0
  626. package/dist/version-manifest-resolve.d.mts +38 -0
  627. package/dist/version-manifest-resolve.mjs +40 -0
  628. package/dist/version-manifest-resolve.mjs.map +1 -0
  629. package/dist/version-status.cjs +18 -0
  630. package/dist/version-status.cjs.map +1 -0
  631. package/dist/version-status.d.cts +22 -0
  632. package/dist/version-status.d.mts +22 -0
  633. package/dist/version-status.mjs +17 -0
  634. package/dist/version-status.mjs.map +1 -0
  635. package/dist/workspace-catalog.cjs +53 -0
  636. package/dist/workspace-catalog.cjs.map +1 -0
  637. package/dist/workspace-catalog.mjs +51 -0
  638. package/dist/workspace-catalog.mjs.map +1 -0
  639. package/dist/workspace.cjs +237 -0
  640. package/dist/workspace.cjs.map +1 -0
  641. package/dist/workspace.mjs +233 -0
  642. package/dist/workspace.mjs.map +1 -0
  643. package/package.json +179 -27
  644. package/skills/add-a-route/SKILL.md +132 -0
  645. package/skills/api-and-auth/SKILL.md +87 -21
  646. package/skills/api-and-auth/references/middleware.md +1 -1
  647. package/skills/cli-reference/SKILL.md +48 -21
  648. package/skills/code-style/SKILL.md +8 -0
  649. package/skills/dev-workflow/SKILL.md +50 -26
  650. package/skills/extends-config/SKILL.md +31 -19
  651. package/skills/init-upgrade/SKILL.md +29 -16
  652. package/skills/plugin-development/SKILL.md +46 -112
  653. package/skills/plugin-development/references/database.md +82 -0
  654. package/skills/plugin-development/references/request-context.md +67 -0
  655. package/skills/publish-sync/SKILL.md +99 -22
  656. package/skills/registry/SKILL.md +82 -0
  657. package/skills/super-app/SKILL.md +25 -15
  658. package/skills/talk-to-the-app/SKILL.md +138 -0
  659. package/skills/ui-integration/SKILL.md +93 -11
  660. package/dist/cli/db-studio.cjs +0 -131
  661. package/dist/cli/db-studio.cjs.map +0 -1
  662. package/dist/cli/db-studio.mjs +0 -127
  663. package/dist/cli/db-studio.mjs.map +0 -1
  664. package/dist/cli/init.d.cts.map +0 -1
  665. package/dist/cli/init.d.mts.map +0 -1
  666. package/dist/components/dev-view.cjs +0 -309
  667. package/dist/components/dev-view.cjs.map +0 -1
  668. package/dist/components/dev-view.mjs +0 -309
  669. package/dist/components/dev-view.mjs.map +0 -1
  670. package/dist/components/streaming-view.cjs +0 -134
  671. package/dist/components/streaming-view.cjs.map +0 -1
  672. package/dist/components/streaming-view.mjs +0 -132
  673. package/dist/components/streaming-view.mjs.map +0 -1
  674. package/dist/config.d.cts.map +0 -1
  675. package/dist/config.d.mts.map +0 -1
  676. package/dist/contract.d.cts.map +0 -1
  677. package/dist/contract.d.mts.map +0 -1
  678. package/dist/contract.meta.d.cts.map +0 -1
  679. package/dist/contract.meta.d.mts.map +0 -1
  680. package/dist/dag.d.cts.map +0 -1
  681. package/dist/dag.d.mts.map +0 -1
  682. package/dist/db.cjs +0 -81
  683. package/dist/db.cjs.map +0 -1
  684. package/dist/db.d.cts +0 -30
  685. package/dist/db.d.cts.map +0 -1
  686. package/dist/db.d.mts +0 -30
  687. package/dist/db.d.mts.map +0 -1
  688. package/dist/db.mjs +0 -75
  689. package/dist/db.mjs.map +0 -1
  690. package/dist/fastkv.d.cts.map +0 -1
  691. package/dist/fastkv.d.mts.map +0 -1
  692. package/dist/integrity.d.cts.map +0 -1
  693. package/dist/integrity.d.mts.map +0 -1
  694. package/dist/merge.d.cts.map +0 -1
  695. package/dist/merge.d.mts.map +0 -1
  696. package/dist/mf.d.cts.map +0 -1
  697. package/dist/mf.d.mts.map +0 -1
  698. package/dist/plugin.d.cts.map +0 -1
  699. package/dist/plugin.d.mts.map +0 -1
  700. package/dist/service-descriptor.d.cts.map +0 -1
  701. package/dist/service-descriptor.d.mts.map +0 -1
  702. package/dist/types.d.cts.map +0 -1
  703. package/dist/types.d.mts.map +0 -1
  704. package/dist/ui/head.d.cts.map +0 -1
  705. package/dist/ui/head.d.mts.map +0 -1
  706. package/dist/ui/metadata.d.cts.map +0 -1
  707. package/dist/ui/metadata.d.mts.map +0 -1
  708. package/dist/ui/router.d.cts.map +0 -1
  709. package/dist/ui/router.d.mts.map +0 -1
  710. package/dist/ui/runtime.d.cts.map +0 -1
  711. package/dist/ui/runtime.d.mts.map +0 -1
  712. package/dist/ui/types.d.cts.map +0 -1
  713. package/dist/ui/types.d.mts.map +0 -1
@@ -0,0 +1,78 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { parse } from "dotenv";
4
+
5
+ //#region src/db/binding.ts
6
+ /**
7
+ * drizzle-kit subcommands that open a database connection. For everything
8
+ * else (generate, check) the connection string is parsed but never used, so a
9
+ * placeholder is safe.
10
+ */
11
+ const DB_REQUIRING_COMMANDS = /* @__PURE__ */ new Set([
12
+ "push",
13
+ "pull",
14
+ "migrate",
15
+ "studio",
16
+ "up"
17
+ ]);
18
+ /**
19
+ * Whether the current process is a drizzle-kit invocation whose command needs
20
+ * a live database. Mirrors drizzle-kit's CLI layout: `drizzle-kit <command> …`.
21
+ */
22
+ function requiresDatabaseConnection(argv = process.argv) {
23
+ if (!(typeof argv[1] === "string" && argv[1].includes("drizzle-kit"))) return false;
24
+ const command = argv[2];
25
+ return typeof command === "string" && DB_REQUIRING_COMMANDS.has(command);
26
+ }
27
+ /**
28
+ * Materialize the environment a spawned tool needs to reach the binding's
29
+ * database: the canonical secret name mapped to the resolved URL. The process
30
+ * that resolves bindings (the CLI composition root) pushes this into spawned
31
+ * children so they never re-derive secrets from ambient state.
32
+ */
33
+ function bindingEnv(binding) {
34
+ return { [binding.secretName]: binding.url };
35
+ }
36
+ function findEnvFile(startDir) {
37
+ if (!startDir) return void 0;
38
+ let current = startDir;
39
+ for (let i = 0; i < 15; i++) {
40
+ const candidate = join(current, ".env");
41
+ if (existsSync(candidate)) return candidate;
42
+ const parent = dirname(current);
43
+ if (parent === current) return void 0;
44
+ current = parent;
45
+ }
46
+ }
47
+ /**
48
+ * Resolve the connection URL for a workspace identity.
49
+ *
50
+ * Resolution order:
51
+ * 1. the canonical secret in the provided environment
52
+ * 2. the canonical secret in the nearest `.env` walked up from the
53
+ * workspace directory (existing environment wins — values are not
54
+ * overridden, matching dotenv semantics)
55
+ * 3. loud failure when the drizzle-kit command needs a database
56
+ * 4. an in-memory pglite placeholder for commands that never connect
57
+ * (generate, check) and for non-drizzle-kit consumers
58
+ *
59
+ * This replaces the previous silent `pglite:` fallback that masked missing
60
+ * configuration as cryptic driver errors downstream.
61
+ */
62
+ function resolveDatabaseUrl(identity, options = {}) {
63
+ const env = options.env ?? process.env;
64
+ const argv = options.argv ?? process.argv;
65
+ const direct = env[identity.secretName];
66
+ if (direct) return direct;
67
+ const envFile = findEnvFile(identity.workspaceDir);
68
+ if (envFile) try {
69
+ const fromFile = parse(readFileSync(envFile, "utf-8"))[identity.secretName];
70
+ if (fromFile) return fromFile;
71
+ } catch {}
72
+ if (requiresDatabaseConnection(argv)) throw new Error(`Missing ${identity.secretName} for workspace "${identity.slug}" — required for "drizzle-kit ${argv[2]}". Add ${identity.secretName} to your .env (see .env.example) or run via \`bos db\`.`);
73
+ return `pglite:.bos/${identity.slug}/:memory:`;
74
+ }
75
+
76
+ //#endregion
77
+ export { bindingEnv, requiresDatabaseConnection, resolveDatabaseUrl };
78
+ //# sourceMappingURL=binding.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binding.mjs","names":["parseDotenv"],"sources":["../../src/db/binding.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { parse as parseDotenv } from \"dotenv\";\nimport type { WorkspaceIdentity } from \"./identity\";\n\n/**\n * drizzle-kit subcommands that open a database connection. For everything\n * else (generate, check) the connection string is parsed but never used, so a\n * placeholder is safe.\n */\nconst DB_REQUIRING_COMMANDS: ReadonlySet<string> = new Set([\n \"push\",\n \"pull\",\n \"migrate\",\n \"studio\",\n \"up\",\n]);\n\n/**\n * Whether the current process is a drizzle-kit invocation whose command needs\n * a live database. Mirrors drizzle-kit's CLI layout: `drizzle-kit <command> …`.\n */\nexport function requiresDatabaseConnection(argv: readonly string[] = process.argv): boolean {\n const isDrizzleKit = typeof argv[1] === \"string\" && argv[1].includes(\"drizzle-kit\");\n if (!isDrizzleKit) return false;\n const command = argv[2];\n return typeof command === \"string\" && DB_REQUIRING_COMMANDS.has(command);\n}\n\n/**\n * Materialize the environment a spawned tool needs to reach the binding's\n * database: the canonical secret name mapped to the resolved URL. The process\n * that resolves bindings (the CLI composition root) pushes this into spawned\n * children so they never re-derive secrets from ambient state.\n */\nexport function bindingEnv(binding: { secretName: string; url: string }): Record<string, string> {\n return { [binding.secretName]: binding.url };\n}\n\nfunction findEnvFile(startDir: string | undefined): string | undefined {\n if (!startDir) return undefined;\n let current = startDir;\n for (let i = 0; i < 15; i++) {\n const candidate = join(current, \".env\");\n if (existsSync(candidate)) return candidate;\n const parent = dirname(current);\n if (parent === current) return undefined;\n current = parent;\n }\n return undefined;\n}\n\n/**\n * Resolve the connection URL for a workspace identity.\n *\n * Resolution order:\n * 1. the canonical secret in the provided environment\n * 2. the canonical secret in the nearest `.env` walked up from the\n * workspace directory (existing environment wins — values are not\n * overridden, matching dotenv semantics)\n * 3. loud failure when the drizzle-kit command needs a database\n * 4. an in-memory pglite placeholder for commands that never connect\n * (generate, check) and for non-drizzle-kit consumers\n *\n * This replaces the previous silent `pglite:` fallback that masked missing\n * configuration as cryptic driver errors downstream.\n */\nexport function resolveDatabaseUrl(\n identity: WorkspaceIdentity,\n options: {\n env?: Record<string, string | undefined>;\n argv?: readonly string[];\n } = {},\n): string {\n const env = options.env ?? process.env;\n const argv = options.argv ?? process.argv;\n\n const direct = env[identity.secretName];\n if (direct) return direct;\n\n const envFile = findEnvFile(identity.workspaceDir);\n if (envFile) {\n try {\n const parsed = parseDotenv(readFileSync(envFile, \"utf-8\"));\n const fromFile = parsed[identity.secretName];\n if (fromFile) return fromFile;\n } catch {\n // unreadable .env — fall through to loud failure / placeholder\n }\n }\n\n if (requiresDatabaseConnection(argv)) {\n throw new Error(\n `Missing ${identity.secretName} for workspace \"${identity.slug}\" — ` +\n `required for \"drizzle-kit ${argv[2]}\". ` +\n `Add ${identity.secretName} to your .env (see .env.example) or run via \\`bos db\\`.`,\n );\n }\n\n return `pglite:.bos/${identity.slug}/:memory:`;\n}\n"],"mappings":";;;;;;;;;;AAUA,MAAM,wCAA6C,I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
3
+ let node_path = require("node:path");
4
+ let effect = require("effect");
5
+
6
+ //#region src/db/bindings.ts
7
+ var DatabaseBindingError = class extends effect.Data.TaggedError("DatabaseBindingError") {};
8
+ var DatabaseBindings = class extends effect.Context.Service()("everything-dev/DatabaseBindings") {};
9
+ function resolvePluginBinding(pluginKey, runtimeConfig, projectDir, env) {
10
+ if (!runtimeConfig) throw new Error("Runtime config not loaded — cannot resolve plugin database binding");
11
+ let source;
12
+ let section;
13
+ let secrets;
14
+ let localPath;
15
+ let key;
16
+ if (pluginKey === "api" && runtimeConfig.api) {
17
+ source = runtimeConfig.api.source;
18
+ section = "app.api";
19
+ secrets = runtimeConfig.api.secrets;
20
+ localPath = runtimeConfig.api.localPath;
21
+ key = "api";
22
+ } else if (pluginKey === "auth" && runtimeConfig.auth) {
23
+ source = runtimeConfig.auth.source;
24
+ section = "app.auth";
25
+ secrets = runtimeConfig.auth.secrets;
26
+ localPath = runtimeConfig.auth.localPath;
27
+ key = "auth";
28
+ } else if (runtimeConfig.plugins?.[pluginKey]) {
29
+ const plugin = runtimeConfig.plugins[pluginKey];
30
+ source = plugin.source;
31
+ section = "plugins";
32
+ secrets = plugin.secrets;
33
+ localPath = plugin.localPath;
34
+ key = pluginKey;
35
+ } else {
36
+ const available = [
37
+ "api",
38
+ ...runtimeConfig.auth ? ["auth"] : [],
39
+ ...Object.keys(runtimeConfig.plugins ?? {})
40
+ ].join(", ");
41
+ throw new Error(`Plugin "${pluginKey}" not found in app.api, app.auth, or plugins. Available: ${available}`);
42
+ }
43
+ const identity = localPath ? require_identity.workspaceIdentityFromWorkspaceDir((0, node_path.resolve)(projectDir, localPath)) : {
44
+ slug: require_core.pluginMigrationSlug(key),
45
+ secretName: require_core.getDatabaseUrlSecretName(require_core.pluginMigrationSlug(key)),
46
+ journal: require_core.getMigrationStorage(require_core.pluginMigrationSlug(key)),
47
+ workspaceDir: void 0
48
+ };
49
+ const url = env[identity.secretName];
50
+ if (!url) {
51
+ const declaredDatabaseSecrets = (secrets ?? []).filter((s) => s.endsWith("_DATABASE_URL"));
52
+ const mismatch = declaredDatabaseSecrets.length > 0 && !declaredDatabaseSecrets.includes(identity.secretName) ? ` Config declares ${declaredDatabaseSecrets.join(", ")} — the workspace package name and the declared secret disagree.` : "";
53
+ throw new Error(`.env missing ${identity.secretName} for plugin "${key}".` + mismatch + ` Add it to your .env file (see .env.example).`);
54
+ }
55
+ return {
56
+ key,
57
+ source: source ?? "remote",
58
+ section,
59
+ identity,
60
+ url
61
+ };
62
+ }
63
+ const makeDatabaseBindings = (options) => effect.Layer.succeed(DatabaseBindings, { forPluginKey: (pluginKey) => effect.Effect.tryPromise({
64
+ try: async () => {
65
+ await options.loadEnv?.();
66
+ return resolvePluginBinding(pluginKey, await options.loadRuntimeConfig(), options.projectDir, options.env ?? process.env);
67
+ },
68
+ catch: (error) => new DatabaseBindingError({
69
+ pluginKey,
70
+ message: error instanceof Error ? error.message : String(error)
71
+ })
72
+ }) });
73
+
74
+ //#endregion
75
+ exports.DatabaseBindingError = DatabaseBindingError;
76
+ exports.DatabaseBindings = DatabaseBindings;
77
+ exports.makeDatabaseBindings = makeDatabaseBindings;
78
+ //# sourceMappingURL=bindings.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bindings.cjs","names":["Data","Context","workspaceIdentityFromWorkspaceDir","resolve","pluginMigrationSlug","getDatabaseUrlSecretName","getMigrationStorage","Layer","Effect"],"sources":["../../src/db/bindings.ts"],"sourcesContent":["import { resolve } from \"node:path\";\nimport { Context, Data, Effect, Layer } from \"effect\";\nimport type { RuntimeConfig } from \"../types\";\nimport { getDatabaseUrlSecretName, getMigrationStorage, pluginMigrationSlug } from \"./core\";\nimport { type WorkspaceIdentity, workspaceIdentityFromWorkspaceDir } from \"./identity\";\n\nexport interface DatabaseBinding {\n readonly key: string;\n readonly source: \"local\" | \"remote\";\n readonly section: \"app.api\" | \"app.auth\" | \"plugins\";\n readonly identity: WorkspaceIdentity;\n readonly url: string;\n}\n\nexport class DatabaseBindingError extends Data.TaggedError(\"DatabaseBindingError\")<{\n readonly pluginKey: string;\n readonly message: string;\n}> {}\n\nexport interface DatabaseBindingsService {\n readonly forPluginKey: (\n pluginKey: string,\n ) => Effect.Effect<DatabaseBinding, DatabaseBindingError>;\n}\n\nexport class DatabaseBindings extends Context.Service<DatabaseBindings, DatabaseBindingsService>()(\n \"everything-dev/DatabaseBindings\",\n) {}\n\ninterface RuntimePluginEntry {\n readonly source?: string;\n readonly secrets?: string[];\n readonly localPath?: string;\n}\n\nfunction resolvePluginBinding(\n pluginKey: string,\n runtimeConfig: RuntimeConfig | null,\n projectDir: string,\n env: Record<string, string | undefined>,\n): DatabaseBinding {\n if (!runtimeConfig) {\n throw new Error(\"Runtime config not loaded — cannot resolve plugin database binding\");\n }\n\n let source: \"local\" | \"remote\" | undefined;\n let section: DatabaseBinding[\"section\"];\n let secrets: string[] | undefined;\n let localPath: string | undefined;\n let key: string;\n\n if (pluginKey === \"api\" && runtimeConfig.api) {\n source = runtimeConfig.api.source as \"local\" | \"remote\";\n section = \"app.api\";\n secrets = runtimeConfig.api.secrets;\n localPath = runtimeConfig.api.localPath;\n key = \"api\";\n } else if (pluginKey === \"auth\" && runtimeConfig.auth) {\n source = runtimeConfig.auth.source as \"local\" | \"remote\";\n section = \"app.auth\";\n secrets = runtimeConfig.auth.secrets;\n localPath = runtimeConfig.auth.localPath;\n key = \"auth\";\n } else if (runtimeConfig.plugins?.[pluginKey]) {\n const plugin = runtimeConfig.plugins[pluginKey] as RuntimePluginEntry;\n source = plugin.source as \"local\" | \"remote\";\n section = \"plugins\";\n secrets = plugin.secrets;\n localPath = plugin.localPath;\n key = pluginKey;\n } else {\n const available = [\n \"api\",\n ...(runtimeConfig.auth ? [\"auth\"] : []),\n ...Object.keys(runtimeConfig.plugins ?? {}),\n ].join(\", \");\n throw new Error(\n `Plugin \"${pluginKey}\" not found in app.api, app.auth, or plugins. Available: ${available}`,\n );\n }\n\n const identity: WorkspaceIdentity = localPath\n ? workspaceIdentityFromWorkspaceDir(resolve(projectDir, localPath))\n : {\n slug: pluginMigrationSlug(key),\n secretName: getDatabaseUrlSecretName(pluginMigrationSlug(key)),\n journal: getMigrationStorage(pluginMigrationSlug(key)),\n workspaceDir: undefined,\n };\n\n const url = env[identity.secretName];\n if (!url) {\n const declaredDatabaseSecrets = (secrets ?? []).filter((s) => s.endsWith(\"_DATABASE_URL\"));\n const mismatch =\n declaredDatabaseSecrets.length > 0 && !declaredDatabaseSecrets.includes(identity.secretName)\n ? ` Config declares ${declaredDatabaseSecrets.join(\", \")} — the workspace package name and the declared secret disagree.`\n : \"\";\n throw new Error(\n `.env missing ${identity.secretName} for plugin \"${key}\".` +\n mismatch +\n ` Add it to your .env file (see .env.example).`,\n );\n }\n\n return {\n key,\n source: source ?? \"remote\",\n section,\n identity,\n url,\n };\n}\n\nexport interface DatabaseBindingsOptions {\n readonly projectDir: string;\n readonly loadRuntimeConfig: () => Promise<RuntimeConfig | null>;\n /** May return a promise — a rejection propagates into the binding error instead of silently proceeding with an unloaded .env. */\n readonly loadEnv?: () => void | Promise<void>;\n readonly env?: Record<string, string | undefined>;\n}\n\nexport const makeDatabaseBindings = (\n options: DatabaseBindingsOptions,\n): Layer.Layer<DatabaseBindings> =>\n Layer.succeed(DatabaseBindings, {\n forPluginKey: (pluginKey) =>\n Effect.tryPromise({\n try: async () => {\n await options.loadEnv?.();\n const runtimeConfig = await options.loadRuntimeConfig();\n return resolvePluginBinding(\n pluginKey,\n runtimeConfig,\n options.projectDir,\n options.env ?? process.env,\n );\n },\n catch: (error) =>\n new DatabaseBindingError({\n pluginKey,\n message: error instanceof Error ? error.message : String(error),\n }),\n }),\n });\n"],"mappings":";;;;;;AAcA,IAAa,uBAAb,cAA0CA,YAAK,YAAY,sBAAsB,CAAC,CAG/E,CAAC;AAQJ,IAAa,mBAAb,cAAsCC,eAAQ,QAAmD,CAAC,CAChG,iCACF,CAAC,CAAC,CAAC;AAQH,SAAS,qBACP,WACA,eACA,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,gBAAgB,SAAS,WAAW,eAAe,IAAI,MACrD,WACA,+CACJ;CACF;CAEA,OAAO;EACL;EACA,QAAQ,UAAU;EAClB;EACA;EACA;CACF;AACF;AAUA,MAAa,wBACX,YAEAG,aAAM,QAAQ,kBAAkB,EAC9B,eAAe,cACbC,cAAO,WAAW;CAChB,KAAK,YAAY;EACf,MAAM,QAAQ,UAAU;EAExB,OAAO,qBACL,WACA,MAH0B,QAAQ,kBAAkB,GAIpD,QAAQ,YACR,QAAQ,OAAO,QAAQ,GACzB;CACF;CACA,QAAQ,UACN,IAAI,qBAAqB;EACvB;EACA,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CAChE,CAAC;AACL,CAAC,EACL,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { RuntimeConfig } from "../types.cjs";
2
+ import { WorkspaceIdentity } from "./identity.cjs";
3
+ import { Context, Effect, Layer } from "effect";
4
+ //#region src/db/bindings.d.ts
5
+ interface DatabaseBinding {
6
+ readonly key: string;
7
+ readonly source: "local" | "remote";
8
+ readonly section: "app.api" | "app.auth" | "plugins";
9
+ readonly identity: WorkspaceIdentity;
10
+ readonly url: string;
11
+ }
12
+ declare const DatabaseBindingError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
13
+ readonly _tag: "DatabaseBindingError";
14
+ } & Readonly<A>;
15
+ declare class DatabaseBindingError extends DatabaseBindingError_base<{
16
+ readonly pluginKey: string;
17
+ readonly message: string;
18
+ }> {}
19
+ interface DatabaseBindingsService {
20
+ readonly forPluginKey: (pluginKey: string) => Effect.Effect<DatabaseBinding, DatabaseBindingError>;
21
+ }
22
+ declare const DatabaseBindings_base: Context.ServiceClass<DatabaseBindings, "everything-dev/DatabaseBindings", DatabaseBindingsService>;
23
+ declare class DatabaseBindings extends DatabaseBindings_base {}
24
+ interface DatabaseBindingsOptions {
25
+ readonly projectDir: string;
26
+ readonly loadRuntimeConfig: () => Promise<RuntimeConfig | null>;
27
+ /** May return a promise — a rejection propagates into the binding error instead of silently proceeding with an unloaded .env. */
28
+ readonly loadEnv?: () => void | Promise<void>;
29
+ readonly env?: Record<string, string | undefined>;
30
+ }
31
+ declare const makeDatabaseBindings: (options: DatabaseBindingsOptions) => Layer.Layer<DatabaseBindings>;
32
+ //#endregion
33
+ export { DatabaseBinding, DatabaseBindingError, DatabaseBindings, DatabaseBindingsOptions, DatabaseBindingsService, makeDatabaseBindings };
34
+ //# sourceMappingURL=bindings.d.cts.map
@@ -0,0 +1,34 @@
1
+ import { RuntimeConfig } from "../types.mjs";
2
+ import { WorkspaceIdentity } from "./identity.mjs";
3
+ import { Context, Effect, Layer } from "effect";
4
+ //#region src/db/bindings.d.ts
5
+ interface DatabaseBinding {
6
+ readonly key: string;
7
+ readonly source: "local" | "remote";
8
+ readonly section: "app.api" | "app.auth" | "plugins";
9
+ readonly identity: WorkspaceIdentity;
10
+ readonly url: string;
11
+ }
12
+ declare const DatabaseBindingError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
13
+ readonly _tag: "DatabaseBindingError";
14
+ } & Readonly<A>;
15
+ declare class DatabaseBindingError extends DatabaseBindingError_base<{
16
+ readonly pluginKey: string;
17
+ readonly message: string;
18
+ }> {}
19
+ interface DatabaseBindingsService {
20
+ readonly forPluginKey: (pluginKey: string) => Effect.Effect<DatabaseBinding, DatabaseBindingError>;
21
+ }
22
+ declare const DatabaseBindings_base: Context.ServiceClass<DatabaseBindings, "everything-dev/DatabaseBindings", DatabaseBindingsService>;
23
+ declare class DatabaseBindings extends DatabaseBindings_base {}
24
+ interface DatabaseBindingsOptions {
25
+ readonly projectDir: string;
26
+ readonly loadRuntimeConfig: () => Promise<RuntimeConfig | null>;
27
+ /** May return a promise — a rejection propagates into the binding error instead of silently proceeding with an unloaded .env. */
28
+ readonly loadEnv?: () => void | Promise<void>;
29
+ readonly env?: Record<string, string | undefined>;
30
+ }
31
+ declare const makeDatabaseBindings: (options: DatabaseBindingsOptions) => Layer.Layer<DatabaseBindings>;
32
+ //#endregion
33
+ export { DatabaseBinding, DatabaseBindingError, DatabaseBindings, DatabaseBindingsOptions, DatabaseBindingsService, makeDatabaseBindings };
34
+ //# sourceMappingURL=bindings.d.mts.map
@@ -0,0 +1,76 @@
1
+ import { getDatabaseUrlSecretName, getMigrationStorage, pluginMigrationSlug } from "./core.mjs";
2
+ import { workspaceIdentityFromWorkspaceDir } from "./identity.mjs";
3
+ import { resolve } from "node:path";
4
+ import { Context, Data, Effect, Layer } from "effect";
5
+
6
+ //#region src/db/bindings.ts
7
+ var DatabaseBindingError = class extends Data.TaggedError("DatabaseBindingError") {};
8
+ var DatabaseBindings = class extends Context.Service()("everything-dev/DatabaseBindings") {};
9
+ function resolvePluginBinding(pluginKey, runtimeConfig, projectDir, env) {
10
+ if (!runtimeConfig) throw new Error("Runtime config not loaded — cannot resolve plugin database binding");
11
+ let source;
12
+ let section;
13
+ let secrets;
14
+ let localPath;
15
+ let key;
16
+ if (pluginKey === "api" && runtimeConfig.api) {
17
+ source = runtimeConfig.api.source;
18
+ section = "app.api";
19
+ secrets = runtimeConfig.api.secrets;
20
+ localPath = runtimeConfig.api.localPath;
21
+ key = "api";
22
+ } else if (pluginKey === "auth" && runtimeConfig.auth) {
23
+ source = runtimeConfig.auth.source;
24
+ section = "app.auth";
25
+ secrets = runtimeConfig.auth.secrets;
26
+ localPath = runtimeConfig.auth.localPath;
27
+ key = "auth";
28
+ } else if (runtimeConfig.plugins?.[pluginKey]) {
29
+ const plugin = runtimeConfig.plugins[pluginKey];
30
+ source = plugin.source;
31
+ section = "plugins";
32
+ secrets = plugin.secrets;
33
+ localPath = plugin.localPath;
34
+ key = pluginKey;
35
+ } else {
36
+ const available = [
37
+ "api",
38
+ ...runtimeConfig.auth ? ["auth"] : [],
39
+ ...Object.keys(runtimeConfig.plugins ?? {})
40
+ ].join(", ");
41
+ throw new Error(`Plugin "${pluginKey}" not found in app.api, app.auth, or plugins. Available: ${available}`);
42
+ }
43
+ const identity = localPath ? workspaceIdentityFromWorkspaceDir(resolve(projectDir, localPath)) : {
44
+ slug: pluginMigrationSlug(key),
45
+ secretName: getDatabaseUrlSecretName(pluginMigrationSlug(key)),
46
+ journal: getMigrationStorage(pluginMigrationSlug(key)),
47
+ workspaceDir: void 0
48
+ };
49
+ const url = env[identity.secretName];
50
+ if (!url) {
51
+ const declaredDatabaseSecrets = (secrets ?? []).filter((s) => s.endsWith("_DATABASE_URL"));
52
+ const mismatch = declaredDatabaseSecrets.length > 0 && !declaredDatabaseSecrets.includes(identity.secretName) ? ` Config declares ${declaredDatabaseSecrets.join(", ")} — the workspace package name and the declared secret disagree.` : "";
53
+ throw new Error(`.env missing ${identity.secretName} for plugin "${key}".` + mismatch + ` Add it to your .env file (see .env.example).`);
54
+ }
55
+ return {
56
+ key,
57
+ source: source ?? "remote",
58
+ section,
59
+ identity,
60
+ url
61
+ };
62
+ }
63
+ const makeDatabaseBindings = (options) => Layer.succeed(DatabaseBindings, { forPluginKey: (pluginKey) => Effect.tryPromise({
64
+ try: async () => {
65
+ await options.loadEnv?.();
66
+ return resolvePluginBinding(pluginKey, await options.loadRuntimeConfig(), options.projectDir, options.env ?? process.env);
67
+ },
68
+ catch: (error) => new DatabaseBindingError({
69
+ pluginKey,
70
+ message: error instanceof Error ? error.message : String(error)
71
+ })
72
+ }) });
73
+
74
+ //#endregion
75
+ export { DatabaseBindingError, DatabaseBindings, makeDatabaseBindings };
76
+ //# sourceMappingURL=bindings.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bindings.mjs","names":[],"sources":["../../src/db/bindings.ts"],"sourcesContent":["import { resolve } from \"node:path\";\nimport { Context, Data, Effect, Layer } from \"effect\";\nimport type { RuntimeConfig } from \"../types\";\nimport { getDatabaseUrlSecretName, getMigrationStorage, pluginMigrationSlug } from \"./core\";\nimport { type WorkspaceIdentity, workspaceIdentityFromWorkspaceDir } from \"./identity\";\n\nexport interface DatabaseBinding {\n readonly key: string;\n readonly source: \"local\" | \"remote\";\n readonly section: \"app.api\" | \"app.auth\" | \"plugins\";\n readonly identity: WorkspaceIdentity;\n readonly url: string;\n}\n\nexport class DatabaseBindingError extends Data.TaggedError(\"DatabaseBindingError\")<{\n readonly pluginKey: string;\n readonly message: string;\n}> {}\n\nexport interface DatabaseBindingsService {\n readonly forPluginKey: (\n pluginKey: string,\n ) => Effect.Effect<DatabaseBinding, DatabaseBindingError>;\n}\n\nexport class DatabaseBindings extends Context.Service<DatabaseBindings, DatabaseBindingsService>()(\n \"everything-dev/DatabaseBindings\",\n) {}\n\ninterface RuntimePluginEntry {\n readonly source?: string;\n readonly secrets?: string[];\n readonly localPath?: string;\n}\n\nfunction resolvePluginBinding(\n pluginKey: string,\n runtimeConfig: RuntimeConfig | null,\n projectDir: string,\n env: Record<string, string | undefined>,\n): DatabaseBinding {\n if (!runtimeConfig) {\n throw new Error(\"Runtime config not loaded — cannot resolve plugin database binding\");\n }\n\n let source: \"local\" | \"remote\" | undefined;\n let section: DatabaseBinding[\"section\"];\n let secrets: string[] | undefined;\n let localPath: string | undefined;\n let key: string;\n\n if (pluginKey === \"api\" && runtimeConfig.api) {\n source = runtimeConfig.api.source as \"local\" | \"remote\";\n section = \"app.api\";\n secrets = runtimeConfig.api.secrets;\n localPath = runtimeConfig.api.localPath;\n key = \"api\";\n } else if (pluginKey === \"auth\" && runtimeConfig.auth) {\n source = runtimeConfig.auth.source as \"local\" | \"remote\";\n section = \"app.auth\";\n secrets = runtimeConfig.auth.secrets;\n localPath = runtimeConfig.auth.localPath;\n key = \"auth\";\n } else if (runtimeConfig.plugins?.[pluginKey]) {\n const plugin = runtimeConfig.plugins[pluginKey] as RuntimePluginEntry;\n source = plugin.source as \"local\" | \"remote\";\n section = \"plugins\";\n secrets = plugin.secrets;\n localPath = plugin.localPath;\n key = pluginKey;\n } else {\n const available = [\n \"api\",\n ...(runtimeConfig.auth ? [\"auth\"] : []),\n ...Object.keys(runtimeConfig.plugins ?? {}),\n ].join(\", \");\n throw new Error(\n `Plugin \"${pluginKey}\" not found in app.api, app.auth, or plugins. Available: ${available}`,\n );\n }\n\n const identity: WorkspaceIdentity = localPath\n ? workspaceIdentityFromWorkspaceDir(resolve(projectDir, localPath))\n : {\n slug: pluginMigrationSlug(key),\n secretName: getDatabaseUrlSecretName(pluginMigrationSlug(key)),\n journal: getMigrationStorage(pluginMigrationSlug(key)),\n workspaceDir: undefined,\n };\n\n const url = env[identity.secretName];\n if (!url) {\n const declaredDatabaseSecrets = (secrets ?? []).filter((s) => s.endsWith(\"_DATABASE_URL\"));\n const mismatch =\n declaredDatabaseSecrets.length > 0 && !declaredDatabaseSecrets.includes(identity.secretName)\n ? ` Config declares ${declaredDatabaseSecrets.join(\", \")} — the workspace package name and the declared secret disagree.`\n : \"\";\n throw new Error(\n `.env missing ${identity.secretName} for plugin \"${key}\".` +\n mismatch +\n ` Add it to your .env file (see .env.example).`,\n );\n }\n\n return {\n key,\n source: source ?? \"remote\",\n section,\n identity,\n url,\n };\n}\n\nexport interface DatabaseBindingsOptions {\n readonly projectDir: string;\n readonly loadRuntimeConfig: () => Promise<RuntimeConfig | null>;\n /** May return a promise — a rejection propagates into the binding error instead of silently proceeding with an unloaded .env. */\n readonly loadEnv?: () => void | Promise<void>;\n readonly env?: Record<string, string | undefined>;\n}\n\nexport const makeDatabaseBindings = (\n options: DatabaseBindingsOptions,\n): Layer.Layer<DatabaseBindings> =>\n Layer.succeed(DatabaseBindings, {\n forPluginKey: (pluginKey) =>\n Effect.tryPromise({\n try: async () => {\n await options.loadEnv?.();\n const runtimeConfig = await options.loadRuntimeConfig();\n return resolvePluginBinding(\n pluginKey,\n runtimeConfig,\n options.projectDir,\n options.env ?? process.env,\n );\n },\n catch: (error) =>\n new DatabaseBindingError({\n pluginKey,\n message: error instanceof Error ? error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B,WAAW,CAAC,EAAC,CAAE,QAAQ,MAAM,EAAE,SAAS,eAAe,CAAC;EACzF,MAAM,WACJ,wBAAwB,SAAS,KAAK,CAAC,wBAAwB,SAAS,SAAS,UAAU,IACvF,oBAAoB,wBAAwB,KAAK,IAAI,EAAE,mEACvD;EACN,MAAM,IAAI,MACR,gBAAgB,SAAS,WAAW,eAAe,IAAI,MACrD,WACA,+CACJ;CACF;CAEA,OAAO;EACL;EACA,QAAQ,UAAU;EAClB;EACA;EACA;CACF;AACF;AAUA,MAAa,wBACX,YAEA,MAAM,QAAQ,kBAAkB,EAC9B,eAAe,cACb,OAAO,WAAW;CAChB,KAAK,YAAY;EACf,MAAM,QAAQ,UAAU;EAExB,OAAO,qBACL,WACA,MAH0B,QAAQ,kBAAkB,GAIpD,QAAQ,YACR,QAAQ,OAAO,QAAQ,GACzB;CACF;CACA,QAAQ,UACN,IAAI,qBAAqB;EACvB;EACA,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CAChE,CAAC;AACL,CAAC,EACL,CAAC"}
@@ -0,0 +1,204 @@
1
+ let node_fs = require("node:fs");
2
+ let node_path = require("node:path");
3
+
4
+ //#region src/db/core.ts
5
+ const DEFAULT_MIGRATION_JOURNAL = {
6
+ schema: "drizzle",
7
+ table: "__drizzle_migrations"
8
+ };
9
+ const PER_PLUGIN_ISOLATION = false;
10
+ function normalizeSlug(name) {
11
+ return (name.split("/").pop() ?? name).replace(/^@/, "").replace(/[^a-zA-Z0-9_-]/g, "_").replace(/-plugin$/i, "").replace(/-/g, "_").toLowerCase();
12
+ }
13
+ function getMigrationSlug(dir) {
14
+ if (!dir) return normalizeSlug(process.env.npm_package_name ?? "unknown");
15
+ let current = dir;
16
+ for (let i = 0; i < 10; i++) {
17
+ const pkgPath = (0, node_path.join)(current, "package.json");
18
+ if ((0, node_fs.existsSync)(pkgPath)) try {
19
+ return normalizeSlug(JSON.parse((0, node_fs.readFileSync)(pkgPath, "utf-8")).name ?? current);
20
+ } catch {
21
+ return normalizeSlug(current);
22
+ }
23
+ const parent = (0, node_path.dirname)(current);
24
+ if (parent === current) break;
25
+ current = parent;
26
+ }
27
+ return normalizeSlug(dir);
28
+ }
29
+ function getMigrationStorage(slug, options) {
30
+ const s = normalizeSlug(slug ?? getMigrationSlug());
31
+ if (options?.isolated ?? PER_PLUGIN_ISOLATION) return {
32
+ schema: DEFAULT_MIGRATION_JOURNAL.schema,
33
+ table: `__drizzle_migrations_${s}`,
34
+ slug: s
35
+ };
36
+ return {
37
+ schema: DEFAULT_MIGRATION_JOURNAL.schema,
38
+ table: DEFAULT_MIGRATION_JOURNAL.table,
39
+ slug: s
40
+ };
41
+ }
42
+ /**
43
+ * Format a JavaScript string array as a PostgreSQL text array literal for use
44
+ * with Drizzle's `sql` tag. Example return:
45
+ * `'{"h1","h2"}'::text[]`
46
+ *
47
+ * Usage: sql`WHERE col = ANY(${toSqlArray(values)})`
48
+ *
49
+ * Drizzle's default parameter binding does not handle array types correctly
50
+ * with the pg driver (it emits `ANY(($1))` with a single string, which
51
+ * Postgres rejects as a malformed array literal).
52
+ */
53
+ function toSqlArray(arr) {
54
+ if (arr.length === 0) return `'{}'::text[]`;
55
+ return `'{${arr.map((v) => v.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")).map((v) => `"${v}"`).join(",")}}'::text[]`;
56
+ }
57
+ function pluginMigrationSlug(key) {
58
+ return normalizeSlug(key);
59
+ }
60
+ function getDatabaseUrlSecretName(slug) {
61
+ return `${slug.toUpperCase().replace(/-/g, "_")}_DATABASE_URL`;
62
+ }
63
+ const DUPLICATE_OBJECT_SQLSTATES = [
64
+ "42710",
65
+ "42701",
66
+ "42P07"
67
+ ];
68
+ /**
69
+ * Walk `error` and its `cause` chain (bounded), invoking `visit` on each link.
70
+ * Postgres driver errors arrive wrapped by drizzle/Effect at varying depths,
71
+ * so every error-shape predicate below shares this traversal.
72
+ */
73
+ function visitCauses(error, depth, visit) {
74
+ let current = error;
75
+ for (let i = 0; i < depth && current; i++) {
76
+ if (typeof current === "object" && current !== null && visit(current)) return true;
77
+ current = current?.cause;
78
+ }
79
+ return false;
80
+ }
81
+ /**
82
+ * pg_catalog unique indexes that can surface a concurrent-DDL race as SQLSTATE
83
+ * 23505 instead of a duplicate-object class. When two connections run
84
+ * `CREATE TABLE <name>` at the same time, the loser fails its insert into
85
+ * `pg_type` ("duplicate key value violates unique constraint
86
+ * `pg_type_typname_nsp_index`") rather than seeing 42P07, because the winner's
87
+ * table is not yet committed. The same shape exists for schemas and other
88
+ * relations.
89
+ */
90
+ const CONCURRENT_DDL_CONSTRAINTS = /* @__PURE__ */ new Set([
91
+ "pg_type_typname_nsp_index",
92
+ "pg_namespace_nspname_index",
93
+ "pg_class_relname_nsp_index"
94
+ ]);
95
+ /**
96
+ * Whether a SQLSTATE 23505 unique violation is the concurrent-DDL catalog
97
+ * collision signature rather than a data-level constraint on a user table.
98
+ * Data-level violations must keep failing loudly; only the pg_catalog indexes
99
+ * above are treated as duplicate-DDL tolerance candidates.
100
+ */
101
+ function isConcurrentDdlUniqueViolation(error) {
102
+ return visitCauses(error, 6, (link) => {
103
+ const { code, constraint, message } = link;
104
+ if (code !== "23505") return false;
105
+ if (typeof constraint === "string" && CONCURRENT_DDL_CONSTRAINTS.has(constraint)) return true;
106
+ if (typeof message !== "string") return false;
107
+ for (const name of CONCURRENT_DDL_CONSTRAINTS) if (message.includes(name)) return true;
108
+ return false;
109
+ });
110
+ }
111
+ const RETRYABLE_SQLSTATES = /* @__PURE__ */ new Set([
112
+ "42P06",
113
+ "42710",
114
+ "42701",
115
+ "42P07",
116
+ "23505",
117
+ "40001",
118
+ "40P01",
119
+ "55P03"
120
+ ]);
121
+ const RETRYABLE_DRIVER_CODES = /* @__PURE__ */ new Set([
122
+ "ECONNREFUSED",
123
+ "ECONNRESET",
124
+ "EPIPE",
125
+ "ETIMEDOUT",
126
+ "ENOTFOUND",
127
+ "EAI_AGAIN"
128
+ ]);
129
+ function matchesRetryableStates(error, states) {
130
+ return visitCauses(error, 6, (link) => {
131
+ const code = link.code;
132
+ if (typeof code !== "string") return false;
133
+ return states.has(code) || code.startsWith("08") || RETRYABLE_DRIVER_CODES.has(code);
134
+ });
135
+ }
136
+ /**
137
+ * Decide whether a failed migration-init statement (schema/journal creation)
138
+ * is worth retrying. Covers the concurrent `CREATE SCHEMA IF NOT EXISTS`
139
+ * race (unique violation on `pg_namespace`, duplicate-object errors),
140
+ * serialization/deadlock errors, and transient connection failures.
141
+ */
142
+ function isRetryableMigrationError(error) {
143
+ return matchesRetryableStates(error, RETRYABLE_SQLSTATES);
144
+ }
145
+ const RETRYABLE_STATEMENT_SQLSTATES = /* @__PURE__ */ new Set([
146
+ "40001",
147
+ "40P01",
148
+ "55P03"
149
+ ]);
150
+ /**
151
+ * Decide whether a failed migration *statement* (inside its transaction) is
152
+ * worth retrying. Deliberately narrower than `isRetryableMigrationError`:
153
+ * duplicate-object classes are tolerated at the SAVEPOINT level, and a 23505
154
+ * is either the concurrent-DDL catalog collision (also tolerated) or a
155
+ * deterministic data-level violation (retrying is pointless) — so only
156
+ * lock/serialization/transient-connection states justify re-running the
157
+ * transaction.
158
+ */
159
+ function isRetryableMigrationExecutionError(error) {
160
+ return matchesRetryableStates(error, RETRYABLE_STATEMENT_SQLSTATES);
161
+ }
162
+ const PG_QUERY_QUEUE_DEPRECATION = "client.query() when the client is already executing a query";
163
+ let pgWarningFilterInstalled = false;
164
+ /**
165
+ * Silence pg's query-queue deprecation warning (fires once per process from
166
+ * pg-pool's internal dispatch under concurrent boot load — node-postgres#3612,
167
+ * #3617). Node's default warning handler prints even when user listeners are
168
+ * attached, so it is removed first; every other warning is re-printed here.
169
+ */
170
+ function suppressPgQueryQueueDeprecation() {
171
+ if (pgWarningFilterInstalled) return;
172
+ if (typeof process === "undefined" || typeof process.on !== "function") return;
173
+ pgWarningFilterInstalled = true;
174
+ process.removeAllListeners("warning");
175
+ process.on("warning", (warning) => {
176
+ if (warning.name === "DeprecationWarning" && warning.message.includes(PG_QUERY_QUEUE_DEPRECATION)) return;
177
+ console.error(warning.stack || `${warning.name}: ${warning.message}`);
178
+ });
179
+ }
180
+ function extractExpectedTables(migrations) {
181
+ const tables = /* @__PURE__ */ new Set();
182
+ const re = /CREATE\s+TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?(?:"([^"]+)"\.)?"([^"]+)"/gi;
183
+ for (const migration of migrations) for (const stmt of migration.sql) for (const match of stmt.matchAll(re)) {
184
+ const tableName = match[2];
185
+ if (tableName) tables.add(tableName);
186
+ }
187
+ return [...tables];
188
+ }
189
+
190
+ //#endregion
191
+ exports.DUPLICATE_OBJECT_SQLSTATES = DUPLICATE_OBJECT_SQLSTATES;
192
+ exports.extractExpectedTables = extractExpectedTables;
193
+ exports.getDatabaseUrlSecretName = getDatabaseUrlSecretName;
194
+ exports.getMigrationSlug = getMigrationSlug;
195
+ exports.getMigrationStorage = getMigrationStorage;
196
+ exports.isConcurrentDdlUniqueViolation = isConcurrentDdlUniqueViolation;
197
+ exports.isRetryableMigrationError = isRetryableMigrationError;
198
+ exports.isRetryableMigrationExecutionError = isRetryableMigrationExecutionError;
199
+ exports.normalizeSlug = normalizeSlug;
200
+ exports.pluginMigrationSlug = pluginMigrationSlug;
201
+ exports.suppressPgQueryQueueDeprecation = suppressPgQueryQueueDeprecation;
202
+ exports.toSqlArray = toSqlArray;
203
+ exports.visitCauses = visitCauses;
204
+ //# sourceMappingURL=core.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.cjs","names":["join","existsSync","readFileSync","dirname"],"sources":["../../src/db/core.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\n\nexport interface MigrationStorage {\n schema: string;\n table: string;\n slug: string;\n}\n\nconst DEFAULT_MIGRATION_JOURNAL = {\n schema: \"drizzle\",\n table: \"__drizzle_migrations\",\n} as const;\n\nconst PER_PLUGIN_ISOLATION = false;\n\nexport function normalizeSlug(name: string): string {\n const basename = name.split(\"/\").pop() ?? name;\n return basename\n .replace(/^@/, \"\")\n .replace(/[^a-zA-Z0-9_-]/g, \"_\")\n .replace(/-plugin$/i, \"\")\n .replace(/-/g, \"_\")\n .toLowerCase();\n}\n\nexport function getMigrationSlug(dir?: string): string {\n if (!dir) return normalizeSlug(process.env.npm_package_name ?? \"unknown\");\n let current = dir;\n for (let i = 0; i < 10; i++) {\n const pkgPath = join(current, \"package.json\");\n if (existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, \"utf-8\")) as { name?: string };\n return normalizeSlug(pkg.name ?? current);\n } catch {\n return normalizeSlug(current);\n }\n }\n const parent = dirname(current);\n if (parent === current) break;\n current = parent;\n }\n return normalizeSlug(dir);\n}\n\nexport function getMigrationStorage(\n slug?: string,\n options?: { isolated?: boolean },\n): MigrationStorage {\n const s = normalizeSlug(slug ?? getMigrationSlug());\n const isolated = options?.isolated ?? PER_PLUGIN_ISOLATION;\n if (isolated) {\n return {\n schema: DEFAULT_MIGRATION_JOURNAL.schema,\n table: `__drizzle_migrations_${s}`,\n slug: s,\n };\n }\n return {\n schema: DEFAULT_MIGRATION_JOURNAL.schema,\n table: DEFAULT_MIGRATION_JOURNAL.table,\n slug: s,\n };\n}\n\n/**\n * Format a JavaScript string array as a PostgreSQL text array literal for use\n * with Drizzle's `sql` tag. Example return:\n * `'{\"h1\",\"h2\"}'::text[]`\n *\n * Usage: sql`WHERE col = ANY(${toSqlArray(values)})`\n *\n * Drizzle's default parameter binding does not handle array types correctly\n * with the pg driver (it emits `ANY(($1))` with a single string, which\n * Postgres rejects as a malformed array literal).\n */\nexport function toSqlArray(arr: string[]): string {\n if (arr.length === 0) return `'{}'::text[]`;\n const escaped = arr.map((v) => v.replace(/\\\\/g, \"\\\\\\\\\").replace(/\"/g, '\\\\\"'));\n return `'{${escaped.map((v) => `\"${v}\"`).join(\",\")}}'::text[]`;\n}\n\nexport function pluginMigrationSlug(key: string): string {\n return normalizeSlug(key);\n}\n\nexport function getDatabaseUrlSecretName(slug: string): string {\n return `${slug.toUpperCase().replace(/-/g, \"_\")}_DATABASE_URL`;\n}\n\nexport const DUPLICATE_OBJECT_SQLSTATES: readonly string[] = [\"42710\", \"42701\", \"42P07\"];\n\n/**\n * Walk `error` and its `cause` chain (bounded), invoking `visit` on each link.\n * Postgres driver errors arrive wrapped by drizzle/Effect at varying depths,\n * so every error-shape predicate below shares this traversal.\n */\nexport function visitCauses(\n error: unknown,\n depth: number,\n visit: (link: object) => boolean,\n): boolean {\n let current: unknown = error;\n for (let i = 0; i < depth && current; i++) {\n if (typeof current === \"object\" && current !== null && visit(current)) return true;\n current = (current as { cause?: unknown })?.cause;\n }\n return false;\n}\n\n/**\n * pg_catalog unique indexes that can surface a concurrent-DDL race as SQLSTATE\n * 23505 instead of a duplicate-object class. When two connections run\n * `CREATE TABLE <name>` at the same time, the loser fails its insert into\n * `pg_type` (\"duplicate key value violates unique constraint\n * `pg_type_typname_nsp_index`\") rather than seeing 42P07, because the winner's\n * table is not yet committed. The same shape exists for schemas and other\n * relations.\n */\nconst CONCURRENT_DDL_CONSTRAINTS: ReadonlySet<string> = new Set([\n \"pg_type_typname_nsp_index\",\n \"pg_namespace_nspname_index\",\n \"pg_class_relname_nsp_index\",\n]);\n\n/**\n * Whether a SQLSTATE 23505 unique violation is the concurrent-DDL catalog\n * collision signature rather than a data-level constraint on a user table.\n * Data-level violations must keep failing loudly; only the pg_catalog indexes\n * above are treated as duplicate-DDL tolerance candidates.\n */\nexport function isConcurrentDdlUniqueViolation(error: unknown): boolean {\n return visitCauses(error, 6, (link) => {\n const { code, constraint, message } = link as {\n code?: unknown;\n constraint?: unknown;\n message?: unknown;\n };\n if (code !== \"23505\") return false;\n if (typeof constraint === \"string\" && CONCURRENT_DDL_CONSTRAINTS.has(constraint)) return true;\n if (typeof message !== \"string\") return false;\n for (const name of CONCURRENT_DDL_CONSTRAINTS) {\n if (message.includes(name)) return true;\n }\n return false;\n });\n}\n\nconst RETRYABLE_SQLSTATES: ReadonlySet<string> = new Set([\n \"42P06\",\n \"42710\",\n \"42701\",\n \"42P07\",\n \"23505\",\n \"40001\",\n \"40P01\",\n \"55P03\",\n]);\n\nconst RETRYABLE_DRIVER_CODES: ReadonlySet<string> = new Set([\n \"ECONNREFUSED\",\n \"ECONNRESET\",\n \"EPIPE\",\n \"ETIMEDOUT\",\n \"ENOTFOUND\",\n \"EAI_AGAIN\",\n]);\n\nfunction matchesRetryableStates(error: unknown, states: ReadonlySet<string>): boolean {\n return visitCauses(error, 6, (link) => {\n const code = (link as { code?: unknown }).code;\n if (typeof code !== \"string\") return false;\n return states.has(code) || code.startsWith(\"08\") || RETRYABLE_DRIVER_CODES.has(code);\n });\n}\n\n/**\n * Decide whether a failed migration-init statement (schema/journal creation)\n * is worth retrying. Covers the concurrent `CREATE SCHEMA IF NOT EXISTS`\n * race (unique violation on `pg_namespace`, duplicate-object errors),\n * serialization/deadlock errors, and transient connection failures.\n */\nexport function isRetryableMigrationError(error: unknown): boolean {\n return matchesRetryableStates(error, RETRYABLE_SQLSTATES);\n}\n\nconst RETRYABLE_STATEMENT_SQLSTATES: ReadonlySet<string> = new Set([\n \"40001\", // serialization_failure\n \"40P01\", // deadlock_detected\n \"55P03\", // lock_not_available\n]);\n\n/**\n * Decide whether a failed migration *statement* (inside its transaction) is\n * worth retrying. Deliberately narrower than `isRetryableMigrationError`:\n * duplicate-object classes are tolerated at the SAVEPOINT level, and a 23505\n * is either the concurrent-DDL catalog collision (also tolerated) or a\n * deterministic data-level violation (retrying is pointless) — so only\n * lock/serialization/transient-connection states justify re-running the\n * transaction.\n */\nexport function isRetryableMigrationExecutionError(error: unknown): boolean {\n return matchesRetryableStates(error, RETRYABLE_STATEMENT_SQLSTATES);\n}\n\nconst PG_QUERY_QUEUE_DEPRECATION = \"client.query() when the client is already executing a query\";\n\nlet pgWarningFilterInstalled = false;\n\n/**\n * Silence pg's query-queue deprecation warning (fires once per process from\n * pg-pool's internal dispatch under concurrent boot load — node-postgres#3612,\n * #3617). Node's default warning handler prints even when user listeners are\n * attached, so it is removed first; every other warning is re-printed here.\n */\nexport function suppressPgQueryQueueDeprecation(): void {\n if (pgWarningFilterInstalled) return;\n if (typeof process === \"undefined\" || typeof process.on !== \"function\") return;\n pgWarningFilterInstalled = true;\n process.removeAllListeners(\"warning\");\n process.on(\"warning\", (warning) => {\n if (\n warning.name === \"DeprecationWarning\" &&\n warning.message.includes(PG_QUERY_QUEUE_DEPRECATION)\n ) {\n return;\n }\n console.error(warning.stack || `${warning.name}: ${warning.message}`);\n });\n}\n\nexport function extractExpectedTables(migrations: { sql: string[] }[]): string[] {\n const tables = new Set<string>();\n const re = /CREATE\\s+TABLE\\s+(?:IF\\s+NOT\\s+EXISTS\\s+)?(?:\"([^\"]+)\"\\.)?\"([^\"]+)\"/gi;\n for (const migration of migrations) {\n for (const stmt of migration.sql) {\n for (const match of stmt.matchAll(re)) {\n const tableName = match[2];\n if (tableName) {\n tables.add(tableName);\n }\n }\n }\n }\n return [...tables];\n}\n"],"mappings":";;;;AASA,MAAM,4BAA4B;CAChC,QAAQ;CACR,OAAO;AACT;AAEA,MAAM,uBAAuB;AAE7B,SAAgB,cAAc,MAAsB;CAElD,QADiB,KAAK,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK,KAC3B,CACZ,QAAQ,MAAM,EAAE,CAAC,CACjB,QAAQ,mBAAmB,GAAG,CAAC,CAC/B,QAAQ,aAAa,EAAE,CAAC,CACxB,QAAQ,MAAM,GAAG,CAAC,CAClB,YAAY;AACjB;AAEA,SAAgB,iBAAiB,KAAsB;CACrD,IAAI,CAAC,KAAK,OAAO,cAAc,QAAQ,IAAI,oBAAoB,SAAS;CACxE,IAAI,UAAU;CACd,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KAAK;EAC3B,MAAM,cAAUA,gBAAK,SAAS,cAAc;EAC5C,QAAIC,oBAAW,OAAO,GACpB,IAAI;GAEF,OAAO,cADK,KAAK,UAAMC,sBAAa,SAAS,O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QAAQ,KAAK,IAAI,QAAQ,SAAS;CACtE,CAAC;AACH;AAEA,SAAgB,sBAAsB,YAA2C;CAC/E,MAAM,yBAAS,IAAI,IAAY;CAC/B,MAAM,KAAK;CACX,KAAK,MAAM,aAAa,YACtB,KAAK,MAAM,QAAQ,UAAU,KAC3B,KAAK,MAAM,SAAS,KAAK,SAAS,EAAE,GAAG;EACrC,MAAM,YAAY,MAAM;EACxB,IAAI,WACF,OAAO,IAAI,SAAS;CAExB;CAGJ,OAAO,CAAC,GAAG,MAAM;AACnB"}
@@ -0,0 +1,69 @@
1
+ //#region src/db/core.d.ts
2
+ interface MigrationStorage {
3
+ schema: string;
4
+ table: string;
5
+ slug: string;
6
+ }
7
+ declare function normalizeSlug(name: string): string;
8
+ declare function getMigrationSlug(dir?: string): string;
9
+ declare function getMigrationStorage(slug?: string, options?: {
10
+ isolated?: boolean;
11
+ }): MigrationStorage;
12
+ /**
13
+ * Format a JavaScript string array as a PostgreSQL text array literal for use
14
+ * with Drizzle's `sql` tag. Example return:
15
+ * `'{"h1","h2"}'::text[]`
16
+ *
17
+ * Usage: sql`WHERE col = ANY(${toSqlArray(values)})`
18
+ *
19
+ * Drizzle's default parameter binding does not handle array types correctly
20
+ * with the pg driver (it emits `ANY(($1))` with a single string, which
21
+ * Postgres rejects as a malformed array literal).
22
+ */
23
+ declare function toSqlArray(arr: string[]): string;
24
+ declare function pluginMigrationSlug(key: string): string;
25
+ declare function getDatabaseUrlSecretName(slug: string): string;
26
+ declare const DUPLICATE_OBJECT_SQLSTATES: readonly string[];
27
+ /**
28
+ * Walk `error` and its `cause` chain (bounded), invoking `visit` on each link.
29
+ * Postgres driver errors arrive wrapped by drizzle/Effect at varying depths,
30
+ * so every error-shape predicate below shares this traversal.
31
+ */
32
+ declare function visitCauses(error: unknown, depth: number, visit: (link: object) => boolean): boolean;
33
+ /**
34
+ * Whether a SQLSTATE 23505 unique violation is the concurrent-DDL catalog
35
+ * collision signature rather than a data-level constraint on a user table.
36
+ * Data-level violations must keep failing loudly; only the pg_catalog indexes
37
+ * above are treated as duplicate-DDL tolerance candidates.
38
+ */
39
+ declare function isConcurrentDdlUniqueViolation(error: unknown): boolean;
40
+ /**
41
+ * Decide whether a failed migration-init statement (schema/journal creation)
42
+ * is worth retrying. Covers the concurrent `CREATE SCHEMA IF NOT EXISTS`
43
+ * race (unique violation on `pg_namespace`, duplicate-object errors),
44
+ * serialization/deadlock errors, and transient connection failures.
45
+ */
46
+ declare function isRetryableMigrationError(error: unknown): boolean;
47
+ /**
48
+ * Decide whether a failed migration *statement* (inside its transaction) is
49
+ * worth retrying. Deliberately narrower than `isRetryableMigrationError`:
50
+ * duplicate-object classes are tolerated at the SAVEPOINT level, and a 23505
51
+ * is either the concurrent-DDL catalog collision (also tolerated) or a
52
+ * deterministic data-level violation (retrying is pointless) — so only
53
+ * lock/serialization/transient-connection states justify re-running the
54
+ * transaction.
55
+ */
56
+ declare function isRetryableMigrationExecutionError(error: unknown): boolean;
57
+ /**
58
+ * Silence pg's query-queue deprecation warning (fires once per process from
59
+ * pg-pool's internal dispatch under concurrent boot load — node-postgres#3612,
60
+ * #3617). Node's default warning handler prints even when user listeners are
61
+ * attached, so it is removed first; every other warning is re-printed here.
62
+ */
63
+ declare function suppressPgQueryQueueDeprecation(): void;
64
+ declare function extractExpectedTables(migrations: {
65
+ sql: string[];
66
+ }[]): string[];
67
+ //#endregion
68
+ export { DUPLICATE_OBJECT_SQLSTATES, MigrationStorage, extractExpectedTables, getDatabaseUrlSecretName, getMigrationSlug, getMigrationStorage, isConcurrentDdlUniqueViolation, isRetryableMigrationError, isRetryableMigrationExecutionError, normalizeSlug, pluginMigrationSlug, suppressPgQueryQueueDeprecation, toSqlArray, visitCauses };
69
+ //# sourceMappingURL=core.d.cts.map