turbine-orm 0.93.1 → 0.94.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 (619) hide show
  1. package/README.md +49 -23
  2. package/dist/adapters/cockroachdb.d.ts +3 -3
  3. package/dist/adapters/cockroachdb.js +7 -11
  4. package/dist/adapters/index.d.ts +1 -1
  5. package/dist/adapters/yugabytedb.js +1 -1
  6. package/dist/better-sqlite3.d.ts +132 -0
  7. package/dist/better-sqlite3.js +303 -0
  8. package/dist/catalog-metadata.d.ts +250 -0
  9. package/dist/catalog-metadata.js +730 -0
  10. package/dist/cjs/adapters/cockroachdb.d.ts +3 -3
  11. package/dist/cjs/adapters/cockroachdb.js +7 -11
  12. package/dist/cjs/adapters/index.d.ts +1 -1
  13. package/dist/cjs/adapters/yugabytedb.js +1 -1
  14. package/dist/cjs/better-sqlite3.d.ts +132 -0
  15. package/dist/cjs/better-sqlite3.js +311 -0
  16. package/dist/cjs/catalog-metadata.d.ts +250 -0
  17. package/dist/cjs/catalog-metadata.js +747 -0
  18. package/dist/cjs/cli/compile-query.d.ts +6 -3
  19. package/dist/cjs/cli/compile-query.js +24 -3
  20. package/dist/cjs/cli/config.d.ts +35 -10
  21. package/dist/cjs/cli/config.js +173 -42
  22. package/dist/cjs/cli/d1-config.d.ts +14 -0
  23. package/dist/cjs/cli/d1-config.js +9 -0
  24. package/dist/cjs/cli/d1-local.d.ts +31 -0
  25. package/dist/cjs/cli/d1-local.js +298 -0
  26. package/dist/cjs/cli/d1-migrations.d.ts +16 -0
  27. package/dist/cjs/cli/d1-migrations.js +156 -0
  28. package/dist/cjs/cli/d1-project.d.ts +23 -0
  29. package/dist/cjs/cli/d1-project.js +314 -0
  30. package/dist/cjs/cli/d1-seed.d.ts +35 -0
  31. package/dist/cjs/cli/d1-seed.js +220 -0
  32. package/dist/cjs/cli/destructive.js +1 -2
  33. package/dist/cjs/cli/error-catalog.d.ts +3 -3
  34. package/dist/cjs/cli/error-catalog.js +21 -3
  35. package/dist/cjs/cli/index.d.ts +13 -8
  36. package/dist/cjs/cli/index.js +503 -71
  37. package/dist/cjs/cli/libsql-migrate-command.d.ts +5 -0
  38. package/dist/cjs/cli/libsql-migrate-command.js +82 -0
  39. package/dist/cjs/cli/libsql-migrate-status.d.ts +33 -0
  40. package/dist/cjs/cli/libsql-migrate-status.js +189 -0
  41. package/dist/cjs/cli/libsql-migrate.d.ts +14 -0
  42. package/dist/cjs/cli/libsql-migrate.js +522 -0
  43. package/dist/cjs/cli/libsql-project-config.d.ts +11 -0
  44. package/dist/cjs/cli/libsql-project-config.js +59 -0
  45. package/dist/cjs/cli/libsql-project.d.ts +52 -0
  46. package/dist/cjs/cli/libsql-project.js +409 -0
  47. package/dist/cjs/cli/libsql-seed-command.d.ts +29 -0
  48. package/dist/cjs/cli/libsql-seed-command.js +93 -0
  49. package/dist/cjs/cli/loader.d.ts +6 -5
  50. package/dist/cjs/cli/loader.js +53 -9
  51. package/dist/cjs/cli/mcp.d.ts +16 -1
  52. package/dist/cjs/cli/mcp.js +219 -125
  53. package/dist/cjs/cli/migrate.d.ts +2 -2
  54. package/dist/cjs/cli/migrate.js +29 -14
  55. package/dist/cjs/cli/mssql-doctor.d.ts +44 -0
  56. package/dist/cjs/cli/mssql-doctor.js +277 -0
  57. package/dist/cjs/cli/mssql-migrate-command.d.ts +9 -0
  58. package/dist/cjs/cli/mssql-migrate-command.js +230 -0
  59. package/dist/cjs/cli/mssql-migrate-connection.d.ts +51 -0
  60. package/dist/cjs/cli/mssql-migrate-connection.js +255 -0
  61. package/dist/cjs/cli/mssql-migrate-sql.d.ts +12 -0
  62. package/dist/cjs/cli/mssql-migrate-sql.js +282 -0
  63. package/dist/cjs/cli/mssql-migrate.d.ts +45 -0
  64. package/dist/cjs/cli/mssql-migrate.js +296 -0
  65. package/dist/cjs/cli/mssql-project.d.ts +34 -0
  66. package/dist/cjs/cli/mssql-project.js +171 -0
  67. package/dist/cjs/cli/mssql-seed.d.ts +7 -0
  68. package/dist/cjs/cli/mssql-seed.js +78 -0
  69. package/dist/cjs/cli/mssql-tools.d.ts +37 -0
  70. package/dist/cjs/cli/mssql-tools.js +354 -0
  71. package/dist/cjs/cli/mysql-doctor.d.ts +48 -0
  72. package/dist/cjs/cli/mysql-doctor.js +323 -0
  73. package/dist/cjs/cli/mysql-migrate-command.d.ts +7 -0
  74. package/dist/cjs/cli/mysql-migrate-command.js +290 -0
  75. package/dist/cjs/cli/mysql-migrate-sql.d.ts +18 -0
  76. package/dist/cjs/cli/mysql-migrate-sql.js +166 -0
  77. package/dist/cjs/cli/mysql-migrate.d.ts +77 -0
  78. package/dist/cjs/cli/mysql-migrate.js +619 -0
  79. package/dist/cjs/cli/mysql-project.d.ts +49 -0
  80. package/dist/cjs/cli/mysql-project.js +284 -0
  81. package/dist/cjs/cli/mysql-push-command.d.ts +7 -0
  82. package/dist/cjs/cli/mysql-push-command.js +94 -0
  83. package/dist/cjs/cli/mysql-push.d.ts +15 -0
  84. package/dist/cjs/cli/mysql-push.js +98 -0
  85. package/dist/cjs/cli/mysql-schema-command.d.ts +5 -0
  86. package/dist/cjs/cli/mysql-schema-command.js +58 -0
  87. package/dist/cjs/cli/mysql-schema-ddl.d.ts +37 -0
  88. package/dist/cjs/cli/mysql-schema-ddl.js +234 -0
  89. package/dist/cjs/cli/mysql-schema-snapshot.d.ts +21 -0
  90. package/dist/cjs/cli/mysql-schema-snapshot.js +127 -0
  91. package/dist/cjs/cli/mysql-schema.d.ts +27 -0
  92. package/dist/cjs/cli/mysql-schema.js +206 -0
  93. package/dist/cjs/cli/mysql-seed-loader.cjs +58 -0
  94. package/dist/cjs/cli/mysql-seed-loader.d.cts +3 -0
  95. package/dist/cjs/cli/mysql-seed.d.ts +6 -0
  96. package/dist/cjs/cli/mysql-seed.js +83 -0
  97. package/dist/cjs/cli/mysql-tools.d.ts +44 -0
  98. package/dist/cjs/cli/mysql-tools.js +336 -0
  99. package/dist/cjs/cli/no-follow.d.ts +29 -0
  100. package/dist/cjs/cli/no-follow.js +73 -0
  101. package/dist/cjs/cli/pii-predicate-guard.d.ts +1 -1
  102. package/dist/cjs/cli/pii-predicate-guard.js +2 -2
  103. package/dist/cjs/cli/pii-tags.d.ts +2 -2
  104. package/dist/cjs/cli/pii-tags.js +1 -1
  105. package/dist/cjs/cli/prisma-schema.js +2 -2
  106. package/dist/cjs/cli/sql-statements.d.ts +1 -1
  107. package/dist/cjs/cli/sql-statements.js +1 -1
  108. package/dist/cjs/cli/sqlite-doctor.d.ts +35 -0
  109. package/dist/cjs/cli/sqlite-doctor.js +400 -0
  110. package/dist/cjs/cli/sqlite-migrate-command.d.ts +4 -0
  111. package/dist/cjs/cli/sqlite-migrate-command.js +175 -0
  112. package/dist/cjs/cli/sqlite-migrate.d.ts +61 -0
  113. package/dist/cjs/cli/sqlite-migrate.js +692 -0
  114. package/dist/cjs/cli/sqlite-project.d.ts +42 -0
  115. package/dist/cjs/cli/sqlite-project.js +254 -0
  116. package/dist/cjs/cli/sqlite-schema-command.d.ts +4 -0
  117. package/dist/cjs/cli/sqlite-schema-command.js +82 -0
  118. package/dist/cjs/cli/sqlite-schema-ddl.d.ts +25 -0
  119. package/dist/cjs/cli/sqlite-schema-ddl.js +252 -0
  120. package/dist/cjs/cli/sqlite-schema.d.ts +25 -0
  121. package/dist/cjs/cli/sqlite-schema.js +334 -0
  122. package/dist/cjs/cli/sqlite-seed.d.ts +4 -0
  123. package/dist/cjs/cli/sqlite-seed.js +94 -0
  124. package/dist/cjs/cli/sqlite-tools.d.ts +24 -0
  125. package/dist/cjs/cli/sqlite-tools.js +169 -0
  126. package/dist/cjs/cli/studio.js +9 -9
  127. package/dist/cjs/cli/tool-capabilities.d.ts +72 -0
  128. package/dist/cjs/cli/tool-capabilities.js +120 -0
  129. package/dist/cjs/cli/tool-command.d.ts +11 -0
  130. package/dist/cjs/cli/tool-command.js +49 -0
  131. package/dist/cjs/cli/ui.d.ts +1 -1
  132. package/dist/cjs/cli/ui.js +1 -1
  133. package/dist/cjs/client.d.ts +20 -20
  134. package/dist/cjs/client.js +65 -344
  135. package/dist/cjs/connection-url.d.ts +1 -1
  136. package/dist/cjs/connection-url.js +1 -1
  137. package/dist/cjs/core.d.ts +58 -0
  138. package/dist/cjs/core.js +225 -0
  139. package/dist/cjs/d1/catalog-metadata.d.ts +5 -0
  140. package/dist/cjs/d1/catalog-metadata.js +230 -0
  141. package/dist/cjs/d1/catalog.d.ts +15 -0
  142. package/dist/cjs/d1/catalog.js +88 -0
  143. package/dist/cjs/d1/generate.d.ts +8 -0
  144. package/dist/cjs/d1/generate.js +163 -0
  145. package/dist/cjs/d1/introspect.d.ts +21 -0
  146. package/dist/cjs/d1/introspect.js +74 -0
  147. package/dist/cjs/d1/migrate.d.ts +29 -0
  148. package/dist/cjs/d1/migrate.js +222 -0
  149. package/dist/cjs/d1/migrations/sql.d.ts +2 -0
  150. package/dist/cjs/d1/migrations/sql.js +109 -0
  151. package/dist/cjs/d1/pool.d.ts +14 -0
  152. package/dist/cjs/d1/pool.js +90 -0
  153. package/dist/cjs/d1/sql.d.ts +5 -0
  154. package/dist/cjs/d1/sql.js +140 -0
  155. package/dist/cjs/d1/sqlite-dialect.d.ts +16 -0
  156. package/dist/cjs/d1/sqlite-dialect.js +579 -0
  157. package/dist/cjs/d1/types.d.ts +29 -0
  158. package/dist/cjs/d1/types.js +2 -0
  159. package/dist/cjs/d1.d.ts +53 -0
  160. package/dist/cjs/d1.js +220 -0
  161. package/dist/cjs/dialect.d.ts +33 -5
  162. package/dist/cjs/dialect.js +8 -6
  163. package/dist/cjs/errors.d.ts +38 -1
  164. package/dist/cjs/errors.js +72 -18
  165. package/dist/cjs/generate.d.ts +19 -3
  166. package/dist/cjs/generate.js +330 -97
  167. package/dist/cjs/global-filters-config.js +4 -4
  168. package/dist/cjs/index-advisor.js +6 -6
  169. package/dist/cjs/index.d.ts +1 -1
  170. package/dist/cjs/index.js +3 -2
  171. package/dist/cjs/introspect.d.ts +59 -356
  172. package/dist/cjs/introspect.js +158 -984
  173. package/dist/cjs/libsql/bindings.d.ts +2 -0
  174. package/dist/cjs/libsql/bindings.js +78 -0
  175. package/dist/cjs/libsql/dialect.d.ts +3 -0
  176. package/dist/cjs/libsql/dialect.js +48 -0
  177. package/dist/cjs/libsql/generate.d.ts +4 -0
  178. package/dist/cjs/libsql/generate.js +56 -0
  179. package/dist/cjs/libsql/introspect.d.ts +16 -0
  180. package/dist/cjs/libsql/introspect.js +295 -0
  181. package/dist/cjs/libsql/pool.d.ts +42 -0
  182. package/dist/cjs/libsql/pool.js +275 -0
  183. package/dist/cjs/libsql/seed-cleanup.d.ts +2 -0
  184. package/dist/cjs/libsql/seed-cleanup.js +19 -0
  185. package/dist/cjs/libsql/values.d.ts +20 -0
  186. package/dist/cjs/libsql/values.js +75 -0
  187. package/dist/cjs/libsql-seed.d.ts +19 -0
  188. package/dist/cjs/libsql-seed.js +50 -0
  189. package/dist/cjs/libsql.d.ts +28 -0
  190. package/dist/cjs/libsql.js +88 -0
  191. package/dist/cjs/live-query.d.ts +33 -0
  192. package/dist/cjs/live-query.js +172 -0
  193. package/dist/cjs/log-codes.d.ts +1 -1
  194. package/dist/cjs/log-codes.js +4 -0
  195. package/dist/cjs/mssql-seed.d.ts +27 -0
  196. package/dist/cjs/mssql-seed.js +118 -0
  197. package/dist/cjs/mssql.d.ts +7 -7
  198. package/dist/cjs/mssql.js +365 -53
  199. package/dist/cjs/mysql-seed.d.ts +25 -0
  200. package/dist/cjs/mysql-seed.js +169 -0
  201. package/dist/cjs/mysql.d.ts +18 -6
  202. package/dist/cjs/mysql.js +602 -94
  203. package/dist/cjs/neon-http/client.d.ts +95 -0
  204. package/dist/cjs/neon-http/client.js +291 -0
  205. package/dist/cjs/neon-http/sql.d.ts +3 -0
  206. package/dist/cjs/neon-http/sql.js +116 -0
  207. package/dist/cjs/neon-http.d.ts +5 -0
  208. package/dist/cjs/neon-http.js +8 -0
  209. package/dist/cjs/neon-ws/load-driver.cjs +44 -0
  210. package/dist/cjs/neon-ws/load-driver.d.cts +9 -0
  211. package/dist/cjs/neon-ws/recovery.d.ts +14 -0
  212. package/dist/cjs/neon-ws/recovery.js +69 -0
  213. package/dist/cjs/neon-ws/snapshot.d.ts +3 -0
  214. package/dist/cjs/neon-ws/snapshot.js +17 -0
  215. package/dist/cjs/neon-ws/transport.d.ts +112 -0
  216. package/dist/cjs/neon-ws/transport.js +290 -0
  217. package/dist/cjs/neon-ws.d.ts +26 -0
  218. package/dist/cjs/neon-ws.js +189 -0
  219. package/dist/cjs/nested-write.d.ts +34 -3
  220. package/dist/cjs/nested-write.js +117 -24
  221. package/dist/cjs/notification-hub/consumer.d.ts +22 -0
  222. package/dist/cjs/notification-hub/consumer.js +111 -0
  223. package/dist/cjs/notification-hub.d.ts +41 -0
  224. package/dist/cjs/notification-hub.js +373 -0
  225. package/dist/cjs/pg-catalog-text.d.ts +96 -0
  226. package/dist/cjs/pg-catalog-text.js +213 -0
  227. package/dist/cjs/pg-types.d.ts +46 -2
  228. package/dist/cjs/pipeline-submittable.d.ts +15 -5
  229. package/dist/cjs/pipeline-submittable.js +103 -48
  230. package/dist/cjs/pipeline.d.ts +5 -2
  231. package/dist/cjs/pipeline.js +111 -41
  232. package/dist/cjs/plan-divergence.d.ts +1 -1
  233. package/dist/cjs/plan-divergence.js +1 -1
  234. package/dist/cjs/powdb-introspect.d.ts +1 -1
  235. package/dist/cjs/powdb-introspect.js +5 -5
  236. package/dist/cjs/powdb-shared.d.ts +5 -5
  237. package/dist/cjs/powdb-shared.js +6 -5
  238. package/dist/cjs/powdb.d.ts +28 -10
  239. package/dist/cjs/powdb.js +80 -28
  240. package/dist/cjs/powql.d.ts +50 -28
  241. package/dist/cjs/powql.js +47 -33
  242. package/dist/cjs/prisma-compat.js +4 -5
  243. package/dist/cjs/prisma-schema-fingerprint.d.ts +1 -1
  244. package/dist/cjs/prisma-schema-fingerprint.js +1 -1
  245. package/dist/cjs/query/aggregates.d.ts +0 -13
  246. package/dist/cjs/query/aggregates.js +105 -238
  247. package/dist/cjs/query/batched-loader.d.ts +1 -1
  248. package/dist/cjs/query/batched-loader.js +18 -20
  249. package/dist/cjs/query/builder.d.ts +108 -144
  250. package/dist/cjs/query/builder.js +592 -893
  251. package/dist/cjs/query/compound-unique.d.ts +18 -3
  252. package/dist/cjs/query/compound-unique.js +110 -43
  253. package/dist/cjs/query/cursor-tuple.d.ts +17 -0
  254. package/dist/cjs/query/cursor-tuple.js +121 -0
  255. package/dist/cjs/query/expr.d.ts +2 -0
  256. package/dist/cjs/query/expr.js +40 -23
  257. package/dist/cjs/query/filters.d.ts +39 -7
  258. package/dist/cjs/query/filters.js +77 -19
  259. package/dist/cjs/query/normalize-args.d.ts +1 -1
  260. package/dist/cjs/query/normalize-args.js +7 -5
  261. package/dist/cjs/query/option-surface.d.ts +1 -1
  262. package/dist/cjs/query/option-surface.js +5 -3
  263. package/dist/cjs/query/pg-type-parsers.d.ts +126 -0
  264. package/dist/cjs/query/pg-type-parsers.js +306 -0
  265. package/dist/cjs/query/relation-names.d.ts +4 -2
  266. package/dist/cjs/query/relation-names.js +21 -12
  267. package/dist/cjs/query/relations.d.ts +19 -7
  268. package/dist/cjs/query/relations.js +329 -260
  269. package/dist/cjs/query/row-lock.js +3 -3
  270. package/dist/cjs/query/sql-comment.js +3 -3
  271. package/dist/cjs/query/stream-idle.d.ts +11 -1
  272. package/dist/cjs/query/stream-idle.js +53 -13
  273. package/dist/cjs/query/stream-signal.d.ts +21 -0
  274. package/dist/cjs/query/stream-signal.js +132 -0
  275. package/dist/cjs/query/temporal-parsers.d.ts +101 -0
  276. package/dist/cjs/query/temporal-parsers.js +362 -0
  277. package/dist/cjs/query/types.d.ts +67 -20
  278. package/dist/cjs/query/utils.d.ts +2 -878
  279. package/dist/cjs/query/utils.js +25 -2058
  280. package/dist/cjs/query/warn-registry.d.ts +1 -1
  281. package/dist/cjs/query/warn-registry.js +1 -1
  282. package/dist/cjs/query/where-compile.d.ts +4 -1
  283. package/dist/cjs/query/where-compile.js +18 -14
  284. package/dist/cjs/query/where.d.ts +14 -7
  285. package/dist/cjs/query/where.js +244 -436
  286. package/dist/cjs/query/writes.d.ts +33 -2
  287. package/dist/cjs/query/writes.js +104 -77
  288. package/dist/cjs/query-utils.d.ts +687 -0
  289. package/dist/cjs/query-utils.js +1444 -0
  290. package/dist/cjs/realtime.d.ts +1 -1
  291. package/dist/cjs/realtime.js +3 -3
  292. package/dist/cjs/schema-builder.js +2 -2
  293. package/dist/cjs/schema-metadata.d.ts +13 -3
  294. package/dist/cjs/schema-metadata.js +33 -5
  295. package/dist/cjs/schema-sql.d.ts +15 -24
  296. package/dist/cjs/schema-sql.js +53 -63
  297. package/dist/cjs/schema.d.ts +37 -2
  298. package/dist/cjs/schema.js +29 -2
  299. package/dist/cjs/seed.js +5 -5
  300. package/dist/cjs/serverless.d.ts +24 -71
  301. package/dist/cjs/serverless.js +24 -71
  302. package/dist/cjs/sql.d.ts +111 -0
  303. package/dist/cjs/sql.js +335 -0
  304. package/dist/cjs/sqlite-seed.d.ts +17 -0
  305. package/dist/cjs/sqlite-seed.js +31 -0
  306. package/dist/cjs/sqlite.d.ts +32 -19
  307. package/dist/cjs/sqlite.js +865 -652
  308. package/dist/cjs/supplied-pool-types.js +10 -9
  309. package/dist/cjs/transaction-control.js +6 -1
  310. package/dist/cjs/transaction-outcome.d.ts +61 -0
  311. package/dist/cjs/transaction-outcome.js +239 -0
  312. package/dist/cjs/transaction-state.d.ts +82 -13
  313. package/dist/cjs/transaction-state.js +222 -56
  314. package/dist/cjs/transaction-transport.d.ts +38 -0
  315. package/dist/cjs/transaction-transport.js +157 -0
  316. package/dist/cjs/typed-sql.d.ts +1 -1
  317. package/dist/cjs/typed-sql.js +1 -1
  318. package/dist/cli/compile-query.d.ts +6 -3
  319. package/dist/cli/compile-query.js +25 -4
  320. package/dist/cli/config.d.ts +35 -10
  321. package/dist/cli/config.js +170 -43
  322. package/dist/cli/d1-config.d.ts +14 -0
  323. package/dist/cli/d1-config.js +6 -0
  324. package/dist/cli/d1-local.d.ts +31 -0
  325. package/dist/cli/d1-local.js +285 -0
  326. package/dist/cli/d1-migrations.d.ts +16 -0
  327. package/dist/cli/d1-migrations.js +151 -0
  328. package/dist/cli/d1-project.d.ts +23 -0
  329. package/dist/cli/d1-project.js +304 -0
  330. package/dist/cli/d1-seed.d.ts +35 -0
  331. package/dist/cli/d1-seed.js +213 -0
  332. package/dist/cli/destructive.js +1 -2
  333. package/dist/cli/error-catalog.d.ts +3 -3
  334. package/dist/cli/error-catalog.js +21 -3
  335. package/dist/cli/index.d.ts +13 -8
  336. package/dist/cli/index.js +500 -71
  337. package/dist/cli/libsql-migrate-command.d.ts +5 -0
  338. package/dist/cli/libsql-migrate-command.js +77 -0
  339. package/dist/cli/libsql-migrate-status.d.ts +33 -0
  340. package/dist/cli/libsql-migrate-status.js +182 -0
  341. package/dist/cli/libsql-migrate.d.ts +14 -0
  342. package/dist/cli/libsql-migrate.js +516 -0
  343. package/dist/cli/libsql-project-config.d.ts +11 -0
  344. package/dist/cli/libsql-project-config.js +55 -0
  345. package/dist/cli/libsql-project.d.ts +52 -0
  346. package/dist/cli/libsql-project.js +391 -0
  347. package/dist/cli/libsql-seed-command.d.ts +29 -0
  348. package/dist/cli/libsql-seed-command.js +85 -0
  349. package/dist/cli/loader.d.ts +6 -5
  350. package/dist/cli/loader.js +50 -9
  351. package/dist/cli/mcp.d.ts +16 -1
  352. package/dist/cli/mcp.js +220 -127
  353. package/dist/cli/migrate.d.ts +2 -2
  354. package/dist/cli/migrate.js +29 -14
  355. package/dist/cli/mssql-doctor.d.ts +44 -0
  356. package/dist/cli/mssql-doctor.js +237 -0
  357. package/dist/cli/mssql-migrate-command.d.ts +9 -0
  358. package/dist/cli/mssql-migrate-command.js +192 -0
  359. package/dist/cli/mssql-migrate-connection.d.ts +51 -0
  360. package/dist/cli/mssql-migrate-connection.js +245 -0
  361. package/dist/cli/mssql-migrate-sql.d.ts +12 -0
  362. package/dist/cli/mssql-migrate-sql.js +275 -0
  363. package/dist/cli/mssql-migrate.d.ts +45 -0
  364. package/dist/cli/mssql-migrate.js +290 -0
  365. package/dist/cli/mssql-project.d.ts +34 -0
  366. package/dist/cli/mssql-project.js +160 -0
  367. package/dist/cli/mssql-seed.d.ts +7 -0
  368. package/dist/cli/mssql-seed.js +73 -0
  369. package/dist/cli/mssql-tools.d.ts +37 -0
  370. package/dist/cli/mssql-tools.js +341 -0
  371. package/dist/cli/mysql-doctor.d.ts +48 -0
  372. package/dist/cli/mysql-doctor.js +316 -0
  373. package/dist/cli/mysql-migrate-command.d.ts +7 -0
  374. package/dist/cli/mysql-migrate-command.js +285 -0
  375. package/dist/cli/mysql-migrate-sql.d.ts +18 -0
  376. package/dist/cli/mysql-migrate-sql.js +162 -0
  377. package/dist/cli/mysql-migrate.d.ts +77 -0
  378. package/dist/cli/mysql-migrate.js +606 -0
  379. package/dist/cli/mysql-project.d.ts +49 -0
  380. package/dist/cli/mysql-project.js +272 -0
  381. package/dist/cli/mysql-push-command.d.ts +7 -0
  382. package/dist/cli/mysql-push-command.js +89 -0
  383. package/dist/cli/mysql-push.d.ts +15 -0
  384. package/dist/cli/mysql-push.js +95 -0
  385. package/dist/cli/mysql-schema-command.d.ts +5 -0
  386. package/dist/cli/mysql-schema-command.js +54 -0
  387. package/dist/cli/mysql-schema-ddl.d.ts +37 -0
  388. package/dist/cli/mysql-schema-ddl.js +227 -0
  389. package/dist/cli/mysql-schema-snapshot.d.ts +21 -0
  390. package/dist/cli/mysql-schema-snapshot.js +119 -0
  391. package/dist/cli/mysql-schema.d.ts +27 -0
  392. package/dist/cli/mysql-schema.js +200 -0
  393. package/dist/cli/mysql-seed-loader.cjs +25 -0
  394. package/dist/cli/mysql-seed-loader.d.cts +3 -0
  395. package/dist/cli/mysql-seed.d.ts +6 -0
  396. package/dist/cli/mysql-seed.js +75 -0
  397. package/dist/cli/mysql-tools.d.ts +44 -0
  398. package/dist/cli/mysql-tools.js +290 -0
  399. package/dist/cli/no-follow.d.ts +29 -0
  400. package/dist/cli/no-follow.js +67 -0
  401. package/dist/cli/pii-predicate-guard.d.ts +1 -1
  402. package/dist/cli/pii-predicate-guard.js +2 -2
  403. package/dist/cli/pii-tags.d.ts +2 -2
  404. package/dist/cli/pii-tags.js +1 -1
  405. package/dist/cli/prisma-schema.js +2 -2
  406. package/dist/cli/sql-statements.d.ts +1 -1
  407. package/dist/cli/sql-statements.js +1 -1
  408. package/dist/cli/sqlite-doctor.d.ts +35 -0
  409. package/dist/cli/sqlite-doctor.js +392 -0
  410. package/dist/cli/sqlite-migrate-command.d.ts +4 -0
  411. package/dist/cli/sqlite-migrate-command.js +171 -0
  412. package/dist/cli/sqlite-migrate.d.ts +61 -0
  413. package/dist/cli/sqlite-migrate.js +681 -0
  414. package/dist/cli/sqlite-project.d.ts +42 -0
  415. package/dist/cli/sqlite-project.js +244 -0
  416. package/dist/cli/sqlite-schema-command.d.ts +4 -0
  417. package/dist/cli/sqlite-schema-command.js +79 -0
  418. package/dist/cli/sqlite-schema-ddl.d.ts +25 -0
  419. package/dist/cli/sqlite-schema-ddl.js +248 -0
  420. package/dist/cli/sqlite-schema.d.ts +25 -0
  421. package/dist/cli/sqlite-schema.js +330 -0
  422. package/dist/cli/sqlite-seed.d.ts +4 -0
  423. package/dist/cli/sqlite-seed.js +57 -0
  424. package/dist/cli/sqlite-tools.d.ts +24 -0
  425. package/dist/cli/sqlite-tools.js +163 -0
  426. package/dist/cli/studio.js +9 -9
  427. package/dist/cli/tool-capabilities.d.ts +72 -0
  428. package/dist/cli/tool-capabilities.js +114 -0
  429. package/dist/cli/tool-command.d.ts +11 -0
  430. package/dist/cli/tool-command.js +45 -0
  431. package/dist/cli/ui.d.ts +1 -1
  432. package/dist/cli/ui.js +1 -1
  433. package/dist/client.d.ts +20 -20
  434. package/dist/client.js +62 -341
  435. package/dist/connection-url.d.ts +1 -1
  436. package/dist/connection-url.js +1 -1
  437. package/dist/core.d.ts +58 -0
  438. package/dist/core.js +220 -0
  439. package/dist/d1/catalog-metadata.d.ts +5 -0
  440. package/dist/d1/catalog-metadata.js +227 -0
  441. package/dist/d1/catalog.d.ts +15 -0
  442. package/dist/d1/catalog.js +82 -0
  443. package/dist/d1/generate.d.ts +8 -0
  444. package/dist/d1/generate.js +160 -0
  445. package/dist/d1/introspect.d.ts +21 -0
  446. package/dist/d1/introspect.js +71 -0
  447. package/dist/d1/migrate.d.ts +29 -0
  448. package/dist/d1/migrate.js +217 -0
  449. package/dist/d1/migrations/sql.d.ts +2 -0
  450. package/dist/d1/migrations/sql.js +106 -0
  451. package/dist/d1/pool.d.ts +14 -0
  452. package/dist/d1/pool.js +86 -0
  453. package/dist/d1/sql.d.ts +5 -0
  454. package/dist/d1/sql.js +135 -0
  455. package/dist/d1/sqlite-dialect.d.ts +16 -0
  456. package/dist/d1/sqlite-dialect.js +572 -0
  457. package/dist/d1/types.d.ts +29 -0
  458. package/dist/d1/types.js +1 -0
  459. package/dist/d1.d.ts +53 -0
  460. package/dist/d1.js +215 -0
  461. package/dist/dialect.d.ts +33 -5
  462. package/dist/dialect.js +6 -4
  463. package/dist/errors.d.ts +38 -1
  464. package/dist/errors.js +68 -17
  465. package/dist/generate.d.ts +19 -3
  466. package/dist/generate.js +330 -97
  467. package/dist/global-filters-config.js +2 -2
  468. package/dist/index-advisor.js +1 -1
  469. package/dist/index.d.ts +1 -1
  470. package/dist/index.js +1 -1
  471. package/dist/introspect.d.ts +59 -356
  472. package/dist/introspect.js +116 -943
  473. package/dist/libsql/bindings.d.ts +2 -0
  474. package/dist/libsql/bindings.js +75 -0
  475. package/dist/libsql/dialect.d.ts +3 -0
  476. package/dist/libsql/dialect.js +45 -0
  477. package/dist/libsql/generate.d.ts +4 -0
  478. package/dist/libsql/generate.js +53 -0
  479. package/dist/libsql/introspect.d.ts +16 -0
  480. package/dist/libsql/introspect.js +289 -0
  481. package/dist/libsql/pool.d.ts +42 -0
  482. package/dist/libsql/pool.js +270 -0
  483. package/dist/libsql/seed-cleanup.d.ts +2 -0
  484. package/dist/libsql/seed-cleanup.js +15 -0
  485. package/dist/libsql/values.d.ts +20 -0
  486. package/dist/libsql/values.js +68 -0
  487. package/dist/libsql-seed.d.ts +19 -0
  488. package/dist/libsql-seed.js +46 -0
  489. package/dist/libsql.d.ts +28 -0
  490. package/dist/libsql.js +79 -0
  491. package/dist/live-query.d.ts +33 -0
  492. package/dist/live-query.js +169 -0
  493. package/dist/log-codes.d.ts +1 -1
  494. package/dist/log-codes.js +4 -0
  495. package/dist/mssql-seed.d.ts +27 -0
  496. package/dist/mssql-seed.js +114 -0
  497. package/dist/mssql.d.ts +7 -7
  498. package/dist/mssql.js +366 -54
  499. package/dist/mysql-seed.d.ts +25 -0
  500. package/dist/mysql-seed.js +165 -0
  501. package/dist/mysql.d.ts +18 -6
  502. package/dist/mysql.js +603 -95
  503. package/dist/neon-http/client.d.ts +95 -0
  504. package/dist/neon-http/client.js +286 -0
  505. package/dist/neon-http/sql.d.ts +3 -0
  506. package/dist/neon-http/sql.js +112 -0
  507. package/dist/neon-http.d.ts +5 -0
  508. package/dist/neon-http.js +2 -0
  509. package/dist/neon-ws/load-driver.cjs +11 -0
  510. package/dist/neon-ws/load-driver.d.cts +9 -0
  511. package/dist/neon-ws/recovery.d.ts +14 -0
  512. package/dist/neon-ws/recovery.js +66 -0
  513. package/dist/neon-ws/snapshot.d.ts +3 -0
  514. package/dist/neon-ws/snapshot.js +15 -0
  515. package/dist/neon-ws/transport.d.ts +112 -0
  516. package/dist/neon-ws/transport.js +286 -0
  517. package/dist/neon-ws.d.ts +26 -0
  518. package/dist/neon-ws.js +182 -0
  519. package/dist/nested-write.d.ts +34 -3
  520. package/dist/nested-write.js +114 -22
  521. package/dist/notification-hub/consumer.d.ts +22 -0
  522. package/dist/notification-hub/consumer.js +106 -0
  523. package/dist/notification-hub.d.ts +41 -0
  524. package/dist/notification-hub.js +370 -0
  525. package/dist/pg-catalog-text.d.ts +96 -0
  526. package/dist/pg-catalog-text.js +208 -0
  527. package/dist/pg-types.d.ts +46 -2
  528. package/dist/pipeline-submittable.d.ts +15 -5
  529. package/dist/pipeline-submittable.js +105 -50
  530. package/dist/pipeline.d.ts +5 -2
  531. package/dist/pipeline.js +113 -43
  532. package/dist/plan-divergence.d.ts +1 -1
  533. package/dist/plan-divergence.js +1 -1
  534. package/dist/powdb-introspect.d.ts +1 -1
  535. package/dist/powdb-introspect.js +5 -5
  536. package/dist/powdb-shared.d.ts +5 -5
  537. package/dist/powdb-shared.js +6 -5
  538. package/dist/powdb.d.ts +28 -10
  539. package/dist/powdb.js +80 -28
  540. package/dist/powql.d.ts +50 -28
  541. package/dist/powql.js +49 -35
  542. package/dist/prisma-compat.js +4 -5
  543. package/dist/prisma-schema-fingerprint.d.ts +1 -1
  544. package/dist/prisma-schema-fingerprint.js +1 -1
  545. package/dist/query/aggregates.d.ts +0 -13
  546. package/dist/query/aggregates.js +97 -230
  547. package/dist/query/batched-loader.d.ts +1 -1
  548. package/dist/query/batched-loader.js +5 -7
  549. package/dist/query/builder.d.ts +108 -144
  550. package/dist/query/builder.js +563 -864
  551. package/dist/query/compound-unique.d.ts +18 -3
  552. package/dist/query/compound-unique.js +99 -33
  553. package/dist/query/cursor-tuple.d.ts +17 -0
  554. package/dist/query/cursor-tuple.js +114 -0
  555. package/dist/query/expr.d.ts +2 -0
  556. package/dist/query/expr.js +32 -16
  557. package/dist/query/filters.d.ts +39 -7
  558. package/dist/query/filters.js +69 -14
  559. package/dist/query/normalize-args.d.ts +1 -1
  560. package/dist/query/normalize-args.js +4 -2
  561. package/dist/query/option-surface.d.ts +1 -1
  562. package/dist/query/option-surface.js +4 -2
  563. package/dist/query/pg-type-parsers.d.ts +126 -0
  564. package/dist/query/pg-type-parsers.js +296 -0
  565. package/dist/query/relation-names.d.ts +4 -2
  566. package/dist/query/relation-names.js +15 -7
  567. package/dist/query/relations.d.ts +19 -7
  568. package/dist/query/relations.js +293 -227
  569. package/dist/query/row-lock.js +1 -1
  570. package/dist/query/sql-comment.js +1 -1
  571. package/dist/query/stream-idle.d.ts +11 -1
  572. package/dist/query/stream-idle.js +51 -13
  573. package/dist/query/stream-signal.d.ts +21 -0
  574. package/dist/query/stream-signal.js +125 -0
  575. package/dist/query/temporal-parsers.d.ts +101 -0
  576. package/dist/query/temporal-parsers.js +354 -0
  577. package/dist/query/types.d.ts +67 -20
  578. package/dist/query/utils.d.ts +2 -878
  579. package/dist/query/utils.js +5 -2003
  580. package/dist/query/warn-registry.d.ts +1 -1
  581. package/dist/query/warn-registry.js +1 -1
  582. package/dist/query/where-compile.d.ts +4 -1
  583. package/dist/query/where-compile.js +14 -10
  584. package/dist/query/where.d.ts +14 -7
  585. package/dist/query/where.js +236 -430
  586. package/dist/query/writes.d.ts +33 -2
  587. package/dist/query/writes.js +90 -65
  588. package/dist/query-utils.d.ts +687 -0
  589. package/dist/query-utils.js +1390 -0
  590. package/dist/realtime.d.ts +1 -1
  591. package/dist/realtime.js +3 -3
  592. package/dist/schema-builder.js +2 -2
  593. package/dist/schema-metadata.d.ts +13 -3
  594. package/dist/schema-metadata.js +33 -5
  595. package/dist/schema-sql.d.ts +15 -24
  596. package/dist/schema-sql.js +50 -60
  597. package/dist/schema.d.ts +37 -2
  598. package/dist/schema.js +29 -2
  599. package/dist/seed.js +5 -5
  600. package/dist/serverless.d.ts +24 -71
  601. package/dist/serverless.js +24 -71
  602. package/dist/sql.d.ts +111 -0
  603. package/dist/sql.js +321 -0
  604. package/dist/sqlite-seed.d.ts +17 -0
  605. package/dist/sqlite-seed.js +27 -0
  606. package/dist/sqlite.d.ts +32 -19
  607. package/dist/sqlite.js +859 -648
  608. package/dist/supplied-pool-types.js +2 -1
  609. package/dist/transaction-control.js +6 -1
  610. package/dist/transaction-outcome.d.ts +61 -0
  611. package/dist/transaction-outcome.js +234 -0
  612. package/dist/transaction-state.d.ts +82 -13
  613. package/dist/transaction-state.js +220 -57
  614. package/dist/transaction-transport.d.ts +38 -0
  615. package/dist/transaction-transport.js +153 -0
  616. package/dist/typed-sql.d.ts +1 -1
  617. package/dist/typed-sql.js +1 -1
  618. package/package.json +239 -13
  619. package/skills/turbine-orm/SKILL.md +6 -5
@@ -59,6 +59,9 @@ var __importStar = (this && this.__importStar) || (function () {
59
59
  return result;
60
60
  };
61
61
  })();
62
+ var __importDefault = (this && this.__importDefault) || function (mod) {
63
+ return (mod && mod.__esModule) ? mod : { "default": mod };
64
+ };
62
65
  Object.defineProperty(exports, "__esModule", { value: true });
63
66
  exports.MIGRATE_POOLER_EXPLANATION = exports.DEFAULT_LOCK_WAIT_SECONDS = void 0;
64
67
  exports.canonicalCommand = canonicalCommand;
@@ -110,16 +113,41 @@ const schema_js_1 = require("../schema.js");
110
113
  const schema_sql_js_1 = require("../schema-sql.js");
111
114
  const code_first_tags_js_1 = require("./code-first-tags.js");
112
115
  const config_js_1 = require("./config.js");
116
+ const d1_config_js_1 = require("./d1-config.js");
117
+ const d1_project_js_1 = require("./d1-project.js");
113
118
  const destructive_js_1 = require("./destructive.js");
114
119
  const error_text_js_1 = require("./error-text.js");
120
+ const libsql_migrate_command_js_1 = require("./libsql-migrate-command.js");
121
+ const libsql_project_js_1 = require("./libsql-project.js");
122
+ const libsql_project_config_js_1 = require("./libsql-project-config.js");
123
+ const libsql_seed_command_js_1 = require("./libsql-seed-command.js");
115
124
  const loader_js_1 = require("./loader.js");
116
125
  const mcp_js_1 = require("./mcp.js");
117
126
  const migrate_js_1 = require("./migrate.js");
127
+ const mssql_doctor_js_1 = require("./mssql-doctor.js");
128
+ const mssql_migrate_command_js_1 = require("./mssql-migrate-command.js");
129
+ const mssql_project_js_1 = require("./mssql-project.js");
130
+ const mssql_seed_js_1 = require("./mssql-seed.js");
131
+ const mysql_doctor_js_1 = require("./mysql-doctor.js");
132
+ const mysql_migrate_command_js_1 = require("./mysql-migrate-command.js");
133
+ const mysql_project_js_1 = require("./mysql-project.js");
134
+ const mysql_push_command_js_1 = require("./mysql-push-command.js");
135
+ const mysql_schema_command_js_1 = require("./mysql-schema-command.js");
136
+ const mysql_seed_js_1 = require("./mysql-seed.js");
137
+ const mysql_seed_loader_cjs_1 = __importDefault(require("./mysql-seed-loader.cjs"));
138
+ const mysql_tools_js_1 = require("./mysql-tools.js");
118
139
  const observe_js_1 = require("./observe.js");
119
140
  const prisma_report_js_1 = require("./prisma-report.js");
120
141
  const prisma_resolve_js_1 = require("./prisma-resolve.js");
121
142
  const prisma_schema_js_1 = require("./prisma-schema.js");
143
+ const sqlite_doctor_js_1 = require("./sqlite-doctor.js");
144
+ const sqlite_migrate_command_js_1 = require("./sqlite-migrate-command.js");
145
+ const sqlite_project_js_1 = require("./sqlite-project.js");
146
+ const sqlite_schema_command_js_1 = require("./sqlite-schema-command.js");
147
+ const sqlite_seed_js_1 = require("./sqlite-seed.js");
122
148
  const studio_js_1 = require("./studio.js");
149
+ const tool_capabilities_js_1 = require("./tool-capabilities.js");
150
+ const tool_command_js_1 = require("./tool-command.js");
123
151
  const ui_js_1 = require("./ui.js");
124
152
  /** How long a bare `migrate deploy --wait` waits for a concurrent deploy to finish. */
125
153
  exports.DEFAULT_LOCK_WAIT_SECONDS = 300;
@@ -151,6 +179,7 @@ function failArg(message, ...hints) {
151
179
  * below.
152
180
  */
153
181
  const GLOBAL_FLAGS = [
182
+ '--engine',
154
183
  '--url',
155
184
  '--out',
156
185
  '--schema',
@@ -183,6 +212,7 @@ const COMMAND_FLAGS = {
183
212
  '--no-timestamp',
184
213
  '--import-ext',
185
214
  '--keep-column-names',
215
+ '--exact-native-integers',
186
216
  '--legacy-to-many-uniques',
187
217
  '--allow-empty',
188
218
  ],
@@ -198,6 +228,7 @@ const COMMAND_FLAGS = {
198
228
  '--exit-code',
199
229
  '--wait',
200
230
  '--allow-drift',
231
+ '--acknowledge-partial-ddl',
201
232
  '--allow-destructive',
202
233
  '--allow-pending',
203
234
  '--allow-pooler',
@@ -216,7 +247,11 @@ const COMMAND_FLAGS = {
216
247
  '--allow-pooler',
217
248
  ],
218
249
  studio: ['--port', '--host', '--no-open', '--allow-remote', '--write', '--show-pii', '--demo'],
219
- mcp: [],
250
+ mcp: ['--legacy-to-many-uniques'],
251
+ capabilities: [],
252
+ compile: [],
253
+ schema: [],
254
+ 'explain-error': [],
220
255
  observe: ['--port', '--host', '--no-open', '--allow-remote', '--metrics-url'],
221
256
  skill: ['--print', '--agents', '--dir'],
222
257
  help: [],
@@ -375,6 +410,10 @@ function parseArgs(argv = process.argv.slice(2)) {
375
410
  // in which case nothing here validates flags: main() reports the misspelled
376
411
  // command instead, which is the actual problem.
377
412
  const accepted = acceptedFlagTokens(result.command);
413
+ if (result.command === 'push' && argv.some((token, i) => token === '--engine' && argv[i + 1] === 'mysql')) {
414
+ accepted?.add('--yes');
415
+ accepted?.add('-y');
416
+ }
378
417
  const unknownFlags = [];
379
418
  /** The raw `--step` operand, judged after the loop. Absent means unset. */
380
419
  let stepRaw;
@@ -397,6 +436,18 @@ function parseArgs(argv = process.argv.slice(2)) {
397
436
  continue;
398
437
  }
399
438
  switch (arg) {
439
+ case '--engine':
440
+ if (next !== 'postgresql' &&
441
+ next !== 'sqlite' &&
442
+ next !== 'mysql' &&
443
+ next !== 'mssql' &&
444
+ next !== 'libsql' &&
445
+ next !== 'd1') {
446
+ failArg(`Unknown CLI engine ${JSON.stringify(next ?? '')}. Use --engine postgresql, --engine sqlite, --engine mysql, --engine mssql or --engine libsql or --engine d1.`);
447
+ }
448
+ result.engine = next;
449
+ i++;
450
+ break;
400
451
  case '--url':
401
452
  case '-u':
402
453
  result.url = next;
@@ -481,6 +532,9 @@ function parseArgs(argv = process.argv.slice(2)) {
481
532
  case '--skip-generate':
482
533
  result.skipGenerate = true;
483
534
  break;
535
+ case '--acknowledge-partial-ddl':
536
+ result.acknowledgePartialDdl = true;
537
+ break;
484
538
  case '--allow-drift':
485
539
  result.allowDrift = true;
486
540
  break;
@@ -544,6 +598,9 @@ function parseArgs(argv = process.argv.slice(2)) {
544
598
  result.importExtension = next;
545
599
  i++;
546
600
  break;
601
+ case '--exact-native-integers':
602
+ result.exactNativeIntegers = true;
603
+ break;
547
604
  case '--keep-column-names':
548
605
  result.keepColumnNames = true;
549
606
  break;
@@ -649,7 +706,7 @@ function parseArgs(argv = process.argv.slice(2)) {
649
706
  // ---------------------------------------------------------------------------
650
707
  /**
651
708
  * Print a friendly error explaining how to install tsx, then exit.
652
- * Called when we know we need to load a `.ts` file but the loader isn't available.
709
+ * Called when a `.ts` file must be loaded but the loader is unavailable.
653
710
  */
654
711
  function failMissingTsLoader(filePath, reason) {
655
712
  (0, ui_js_1.errorLine)();
@@ -701,6 +758,17 @@ function failMissingTsLoader(filePath, reason) {
701
758
  function usesProjectConfig(args) {
702
759
  return !(args.command === 'studio' && args.demo === true);
703
760
  }
761
+ /** Keep the public config helper independent of the runtime error graph. */
762
+ function resolveCommandConfig(file, overrides) {
763
+ try {
764
+ return (0, config_js_1.resolveConfig)(file, overrides);
765
+ }
766
+ catch (error) {
767
+ if (error instanceof TypeError)
768
+ throw new errors_js_1.ValidationError(error.message);
769
+ throw error;
770
+ }
771
+ }
704
772
  /**
705
773
  * Resolve the effective CLI config: register the tsx loader when the config file
706
774
  * is TypeScript, import it, then merge it with env vars and CLI flags. Exits with
@@ -711,10 +779,10 @@ function usesProjectConfig(args) {
711
779
  */
712
780
  async function bootstrapCliConfig(args, overrides) {
713
781
  if (!usesProjectConfig(args)) {
714
- return { config: (0, config_js_1.resolveConfig)({}, overrides), fileConfig: {}, skipped: true };
782
+ return { config: resolveCommandConfig({}, overrides), fileConfig: {}, skipped: true };
715
783
  }
716
784
  // If the user has a TypeScript config file, register the tsx ESM loader
717
- // before we attempt to import it. Otherwise Node throws
785
+ // before importing it. Otherwise Node throws
718
786
  // ERR_UNKNOWN_FILE_EXTENSION for `.ts`.
719
787
  const configPath = (0, config_js_1.findConfigFile)();
720
788
  if ((0, loader_js_1.needsTsLoader)(configPath)) {
@@ -723,8 +791,8 @@ async function bootstrapCliConfig(args, overrides) {
723
791
  failMissingTsLoader(configPath ?? 'turbine.config.ts', status);
724
792
  }
725
793
  }
726
- const { config: fileConfig, loadError } = await (0, config_js_1.loadConfigResult)();
727
- return { config: (0, config_js_1.resolveConfig)(fileConfig, overrides), fileConfig, loadError, skipped: false };
794
+ const { config: fileConfig, loadError } = await (0, config_js_1.loadConfigResult)(undefined, mysql_seed_loader_cjs_1.default);
795
+ return { config: resolveCommandConfig(fileConfig, overrides), fileConfig, loadError, skipped: false };
728
796
  }
729
797
  function requireUrl(config, options = {}) {
730
798
  if (!config.url) {
@@ -747,7 +815,7 @@ function requireUrl(config, options = {}) {
747
815
  }
748
816
  return config.url;
749
817
  }
750
- async function loadSchemaFile(schemaFile) {
818
+ async function loadSchemaFile(schemaFile, importer) {
751
819
  const absPath = (0, node_path_1.resolve)(schemaFile);
752
820
  if (!(0, node_fs_1.existsSync)(absPath)) {
753
821
  (0, ui_js_1.error)(`Schema file not found: ${schemaFile}`);
@@ -755,7 +823,7 @@ async function loadSchemaFile(schemaFile) {
755
823
  process.exit(1);
756
824
  }
757
825
  // If this is a TypeScript file, ensure the tsx ESM loader is registered
758
- // before we attempt the dynamic import. Without this, Node throws
826
+ // before the dynamic import. Without this, Node throws
759
827
  // ERR_UNKNOWN_FILE_EXTENSION for `.ts`.
760
828
  if ((0, loader_js_1.needsTsLoader)(absPath)) {
761
829
  const status = await (0, loader_js_1.registerTsLoader)();
@@ -765,7 +833,7 @@ async function loadSchemaFile(schemaFile) {
765
833
  }
766
834
  try {
767
835
  const fileUrl = (0, node_url_1.pathToFileURL)(absPath).href;
768
- const mod = await Promise.resolve(`${fileUrl}`).then(s => __importStar(require(s)));
836
+ const mod = await (importer ? importer(fileUrl) : Promise.resolve(`${fileUrl}`).then(s => __importStar(require(s))));
769
837
  // Unwrap the same CJS-interop double-wrapped default that bites config files
770
838
  // in a "type": "commonjs" project under the tsx loader (see
771
839
  // unwrapModuleDefault). Without this, `mod.default ?? mod` reads
@@ -874,7 +942,7 @@ function loadDotEnvForCli(deps = {}) {
874
942
  * differing, non-empty `url` in the config file. Pure so it is unit-testable.
875
943
  *
876
944
  * Precedence is unchanged (`.env` `DATABASE_URL` still wins), this only decides
877
- * whether that override is silent or loud. We warn ONLY when all hold:
945
+ * whether to emit a warning. Warn ONLY when all hold:
878
946
  * - no CLI `--url` override (an explicit override is the user's clear intent),
879
947
  * - `DATABASE_URL` came from `.env` (shell-exported stays silent, as before),
880
948
  * - the config file has a non-empty `url`, and
@@ -1236,8 +1304,8 @@ function planEnvScaffold(state) {
1236
1304
  return {
1237
1305
  env: !state.envExists ? 'created' : state.envHasDatabaseUrl ? 'unchanged' : 'appended',
1238
1306
  envExample: state.envExampleExists ? 'unchanged' : 'created',
1239
- // No `.gitignore` at all means nothing is ignored, so the `.env` we just
1240
- // wrote is committable. Create one rather than warn about it.
1307
+ // No `.gitignore` at all means nothing is ignored, so the `.env` created
1308
+ // above is committable. Create one rather than warn about it.
1241
1309
  gitignore: !state.gitignoreExists ? 'created' : state.gitignoreIgnoresEnv ? 'unchanged' : 'appended',
1242
1310
  };
1243
1311
  }
@@ -1499,6 +1567,7 @@ async function runInitGenerate(config, url) {
1499
1567
  const genSpinner = new ui_js_1.Spinner('Generating TypeScript client').start();
1500
1568
  const result = (0, generate_js_1.generate)({
1501
1569
  schema,
1570
+ exactNativeIntegers: config.exactNativeIntegers,
1502
1571
  outDir: config.out,
1503
1572
  connectionString: url,
1504
1573
  importExtension: config.importExtension,
@@ -1663,7 +1732,7 @@ async function cmdInit(args, config) {
1663
1732
  const hasEnvFile = (0, node_fs_1.existsSync)('.env');
1664
1733
  const hasEnvLocal = (0, node_fs_1.existsSync)('.env.local');
1665
1734
  // On Node < 20.12 (no process.loadEnvFile) main() could not auto-load .env, so
1666
- // we cannot claim it "has no DATABASE_URL"; we simply could not read it.
1735
+ // an unread `.env` cannot be described as lacking DATABASE_URL.
1667
1736
  const canAutoLoadEnv = typeof process.loadEnvFile === 'function';
1668
1737
  const envNotice = initEnvNotice({
1669
1738
  envUrl,
@@ -2042,7 +2111,7 @@ async function cmdGenerate(args, config) {
2042
2111
  const totalColumns = Object.values(schema.tables).reduce((sum, t) => sum + t.columns.length, 0);
2043
2112
  const totalRelations = Object.values(schema.tables).reduce((sum, t) => sum + Object.keys(t.relations).length, 0);
2044
2113
  spinner.succeed(`Found ${(0, ui_js_1.bold)(String(tableNames.length))} tables, ${(0, ui_js_1.bold)(String(totalColumns))} columns, ${(0, ui_js_1.bold)(String(totalRelations))} relations`);
2045
- // F12: make the default bookkeeping-table exclusions discoverable rather than
2114
+ // Make the default bookkeeping-table exclusions discoverable rather than
2046
2115
  // silent. `include` re-adds any of them byte-for-byte.
2047
2116
  for (const t of skippedInternalTables) {
2048
2117
  console.log(` ${(0, ui_js_1.dim)(`${ui_js_1.symbols.teeEnd} skipped internal table ${t} (add it to include to keep it)`)}`);
@@ -2086,6 +2155,7 @@ async function cmdGenerate(args, config) {
2086
2155
  const genSpinner = new ui_js_1.Spinner('Generating TypeScript client').start();
2087
2156
  const result = (0, generate_js_1.generate)({
2088
2157
  schema,
2158
+ exactNativeIntegers: config.exactNativeIntegers,
2089
2159
  outDir: config.out,
2090
2160
  connectionString: url,
2091
2161
  zod: args.zod,
@@ -2123,7 +2193,7 @@ async function cmdGenerate(args, config) {
2123
2193
  * `configUrl` is what {@link resolveConfig} already produced (`--url`, then
2124
2194
  * `DATABASE_URL`, then `turbine.config.ts`) and always wins: an explicit flag
2125
2195
  * must never be overridden by a value declared in someone else's schema file.
2126
- * Only when that is empty do we fall back to the `datasource` block, which
2196
+ * Only when that is empty does resolution fall back to the `datasource` block, which
2127
2197
  * removes the flag a project with a non-standard variable name would otherwise
2128
2198
  * pass on every run.
2129
2199
  */
@@ -2187,7 +2257,7 @@ async function cmdMigrateFromPrisma(args, config) {
2187
2257
  (0, ui_js_1.errorLine)();
2188
2258
  process.exit(1);
2189
2259
  }
2190
- // Parse (fatal only on a construct we must understand).
2260
+ // Parse (fatal only on a construct the importer must understand).
2191
2261
  let source;
2192
2262
  try {
2193
2263
  source = readPrismaSchemaSource(prismaPath);
@@ -2313,6 +2383,7 @@ async function cmdMigrateFromPrisma(args, config) {
2313
2383
  // client's field names match the name map (D).
2314
2384
  const gen = (0, generate_js_1.generate)({
2315
2385
  schema: schemaMeta,
2386
+ exactNativeIntegers: config.exactNativeIntegers,
2316
2387
  outDir: config.out,
2317
2388
  connectionString: url,
2318
2389
  noTimestamp: args.noTimestamp,
@@ -3045,7 +3116,7 @@ function reportRebaselined(rebaselined) {
3045
3116
  * never see, because their name is not `YYYYMMDDHHMMSS_<name>.sql`.
3046
3117
  *
3047
3118
  * They were skipped in silence by `status`, `up` and `deploy` alike, so a
3048
- * hand-named migration simply never ran and nothing said so.
3119
+ * hand-named migration never ran and nothing said so.
3049
3120
  */
3050
3121
  function warnIgnoredMigrationFiles(migrationsDir) {
3051
3122
  const ignored = (0, migrate_js_1.listIgnoredSqlFiles)(migrationsDir);
@@ -3483,7 +3554,7 @@ async function runSeedPlan(plan, config) {
3483
3554
  if (!(0, loader_js_1.canResolveTsx)()) {
3484
3555
  throw new Error('TypeScript seed files require tsx, install tsx or use seed.js/seed.sql.');
3485
3556
  }
3486
- // The seed runs in a child process, so we cannot observe its callback
3557
+ // The seed runs in a child process, so its callback cannot be observed here
3487
3558
  // directly. Hand it a sentinel path: `defineSeed`'s runner writes the file
3488
3559
  // only after a callback executes to completion. A non-zero exit is a
3489
3560
  // failure. A clean exit with no sentinel is a script that did its work at
@@ -4510,7 +4581,7 @@ async function cmdStudio(args, config) {
4510
4581
  }
4511
4582
  // Non-loopback binds require an explicit --allow-remote opt-in. Studio has
4512
4583
  // only a random session token, exposing it on a LAN interface is foot-gun
4513
- // territory, so we refuse rather than warn-and-proceed.
4584
+ // territory, so refuse rather than warn-and-proceed.
4514
4585
  if (!isLoopbackHost(host)) {
4515
4586
  if (!args.allowRemote) {
4516
4587
  (0, ui_js_1.error)(`Studio refuses to bind to ${(0, ui_js_1.yellow)(host)} without ${(0, ui_js_1.cyan)('--allow-remote')}.`);
@@ -4629,11 +4700,13 @@ async function cmdMcp(_args, config) {
4629
4700
  const url = requireUrl(config);
4630
4701
  await (0, mcp_js_1.runMcpServer)({
4631
4702
  url,
4703
+ engine: (0, tool_capabilities_js_1.toolEngine)(config.engine),
4632
4704
  schema: config.schema,
4633
4705
  migrationsDir: config.migrationsDir,
4634
4706
  metadataDir: config.out,
4635
4707
  include: config.include.length ? config.include : undefined,
4636
4708
  exclude: config.exclude.length ? config.exclude : undefined,
4709
+ legacyToManyUniques: config.legacyToManyUniques,
4637
4710
  });
4638
4711
  }
4639
4712
  // ---------------------------------------------------------------------------
@@ -4794,6 +4867,7 @@ function showGenerateHelp() {
4794
4867
  console.log(` ${(0, ui_js_1.cyan)('--import-ext')} ${(0, ui_js_1.dim)('<mode>')} Sibling-import extension: ${(0, ui_js_1.cyan)('js')} / ${(0, ui_js_1.cyan)('ts')} / ${(0, ui_js_1.cyan)('none')} / ${(0, ui_js_1.cyan)('auto')} ${(0, ui_js_1.dim)('(default: auto)')}`);
4795
4868
  console.log(` ${(0, ui_js_1.dim)('ts emits ./types.ts so')} ${(0, ui_js_1.cyan)('node app.ts')} ${(0, ui_js_1.dim)('can run the client with native type stripping')}`);
4796
4869
  console.log(` ${(0, ui_js_1.cyan)('--keep-column-names')} Keep raw DB column names as field names ${(0, ui_js_1.dim)('(snake_case, not camelCase)')}`);
4870
+ console.log(` ${(0, ui_js_1.cyan)('--exact-native-integers')} Native integer unions ${(0, ui_js_1.dim)('(sqlite/mysql/mssql only)')}`);
4797
4871
  console.log(` ${(0, ui_js_1.cyan)('--legacy-to-many-uniques')} Emit ${(0, ui_js_1.cyan)('hasMany')} for unique-FK children ${(0, ui_js_1.dim)('(pre-0.41 shape; default flips to hasOne)')}`);
4798
4872
  console.log(` ${(0, ui_js_1.cyan)('--allow-empty')} Generate even when introspection matches 0 tables`);
4799
4873
  (0, ui_js_1.newline)();
@@ -4932,6 +5006,7 @@ function showStatusHelp() {
4932
5006
  }
4933
5007
  function showDoctorHelp() {
4934
5008
  (0, ui_js_1.banner)();
5009
+ console.log(' SQL Server: turbine doctor --engine mssql [--json] (fixed catalog diagnostics only; no repairs/plans).');
4935
5010
  console.log(` ${(0, ui_js_1.bold)('turbine doctor')}, Index + cached-plan triage`);
4936
5011
  (0, ui_js_1.newline)();
4937
5012
  console.log(` ${(0, ui_js_1.bold)('Usage:')}`);
@@ -5020,16 +5095,21 @@ function showMcpHelp() {
5020
5095
  console.log(` ${(0, ui_js_1.bold)('Usage:')}`);
5021
5096
  console.log(` npx turbine mcp ${(0, ui_js_1.dim)('[options]')}`);
5022
5097
  (0, ui_js_1.newline)();
5023
- console.log(` Speaks newline-delimited JSON-RPC 2.0 on stdin/stdout and exposes eleven`);
5098
+ console.log(` Speaks newline-delimited JSON-RPC 2.0 on stdin/stdout and exposes twelve`);
5024
5099
  console.log(` read-only tools: schema overview, table detail, relation graph, join paths,`);
5025
5100
  console.log(` migration status, doctor, EXPLAIN, query compile, table stats, sample rows`);
5026
- console.log(` and error lookup.`);
5101
+ console.log(` error lookup and engine capability discovery.`);
5102
+ console.log(` SQLite and MySQL expose nine tools; SQL Server exposes eight catalog/compile/discovery tools.`);
5103
+ console.log(` SQL Server sample/explain/data execution is refused; no native read-only transaction is asserted.`);
5104
+ console.log(` Use capabilities, schema [table], compile '<json>', or explain-error <code> for one JSON result.`);
5027
5105
  (0, ui_js_1.newline)();
5028
5106
  console.log(` ${(0, ui_js_1.bold)('Options:')}`);
5029
- console.log(` ${(0, ui_js_1.cyan)('--url, -u')} ${(0, ui_js_1.dim)('<url>')} Postgres connection string`);
5107
+ console.log(` ${(0, ui_js_1.cyan)('--engine')} ${(0, ui_js_1.dim)('<name>')} postgresql (default), sqlite, mysql, mssql, libsql or d1`);
5108
+ console.log(` ${(0, ui_js_1.cyan)('--url, -u')} ${(0, ui_js_1.dim)('<url>')} Postgres/MySQL/SQL Server connection string or existing SQLite file`);
5030
5109
  console.log(` ${(0, ui_js_1.cyan)('--schema, -s')} ${(0, ui_js_1.dim)('<name>')} Postgres schema ${(0, ui_js_1.dim)('(default: public)')}`);
5031
5110
  console.log(` ${(0, ui_js_1.cyan)('--include')} ${(0, ui_js_1.dim)('<tables>')} Comma-separated tables to include`);
5032
5111
  console.log(` ${(0, ui_js_1.cyan)('--exclude')} ${(0, ui_js_1.dim)('<tables>')} Comma-separated tables to exclude`);
5112
+ console.log(` ${(0, ui_js_1.cyan)('--legacy-to-many-uniques')} Describe unique-FK children as ${(0, ui_js_1.cyan)('hasMany')}, as before 0.41 ${(0, ui_js_1.dim)('(match a client generated with the same flag)')}`);
5033
5113
  (0, ui_js_1.newline)();
5034
5114
  }
5035
5115
  function showObserveHelp() {
@@ -5102,10 +5182,16 @@ function showHelp() {
5102
5182
  console.log(` ${(0, ui_js_1.cyan)('doctor')} Index + cached-plan triage ${(0, ui_js_1.dim)('(--fix, --json, --unused, --audit)')}`);
5103
5183
  console.log(` ${(0, ui_js_1.cyan)('studio')} Launch local read-only web UI ${(0, ui_js_1.dim)('(--write for writes, --demo for a sample DB)')}`);
5104
5184
  console.log(` ${(0, ui_js_1.cyan)('mcp')} Start read-only MCP server over stdio`);
5185
+ console.log(` ${(0, ui_js_1.cyan)('capabilities')} JSON engine/runtime/tool transport facts (no connection)`);
5186
+ console.log(` ${(0, ui_js_1.cyan)('schema [table]')} JSON read-only schema overview or table detail`);
5187
+ console.log(` ${(0, ui_js_1.cyan)('compile <json>')} Compile {table, operation?, args?} without executing`);
5188
+ console.log(` ${(0, ui_js_1.cyan)('explain-error <code>')} Explain an error from the catalog (no connection)`);
5105
5189
  console.log(` ${(0, ui_js_1.cyan)('observe')} Launch metrics dashboard ${(0, ui_js_1.dim)('(requires TURBINE_OBSERVE_URL)')}`);
5106
5190
  console.log(` ${(0, ui_js_1.cyan)('skill')} Install the agent query skill ${(0, ui_js_1.dim)('(--print, --agents, --dir <path>)')}`);
5107
5191
  (0, ui_js_1.newline)();
5108
5192
  console.log(` ${(0, ui_js_1.bold)('Options:')}`);
5193
+ console.log(` ${(0, ui_js_1.cyan)('--engine')} ${(0, ui_js_1.dim)('<name>')} postgresql (default), sqlite, mysql, mssql, libsql or d1; use migrate --engine sqlite --help for its workflow; generate --engine mysql --help or generate --engine mssql --help`);
5194
+ console.log(` ${(0, ui_js_1.cyan)('--acknowledge-partial-ddl')} MySQL migrate recover only; manually reconcile partial DDL first`);
5109
5195
  console.log(` ${(0, ui_js_1.cyan)('--url, -u')} ${(0, ui_js_1.dim)('<url>')} Postgres connection string`);
5110
5196
  console.log(` ${(0, ui_js_1.cyan)('--out, -o')} ${(0, ui_js_1.dim)('<dir>')} Output directory ${(0, ui_js_1.dim)('(default: ./generated/turbine)')}`);
5111
5197
  console.log(` ${(0, ui_js_1.cyan)('--schema, -s')} ${(0, ui_js_1.dim)('<name>')} Postgres schema NAME to read ${(0, ui_js_1.dim)('(default: public)')}`);
@@ -5310,7 +5396,39 @@ function showVersion() {
5310
5396
  async function main() {
5311
5397
  let args;
5312
5398
  try {
5399
+ const preflightRaw = process.argv.slice(2);
5400
+ if (preflightRaw.some((token, i) => token === '--engine' && preflightRaw[i + 1] === 'd1'))
5401
+ (0, d1_project_js_1.assertD1Arguments)(preflightRaw);
5313
5402
  args = parseArgs();
5403
+ const rawArgs = process.argv.slice(2);
5404
+ if (args.engine === 'libsql' || rawArgs.some((token, i) => token === '--engine' && rawArgs[i + 1] === 'libsql')) {
5405
+ if (canonicalCommand(args.command) === 'migrate')
5406
+ (0, libsql_migrate_command_js_1.assertLibsqlMigrationArguments)(args, rawArgs);
5407
+ else if (canonicalCommand(args.command) === 'seed')
5408
+ (0, libsql_seed_command_js_1.assertLibsqlSeedArguments)(args, rawArgs);
5409
+ else
5410
+ (0, libsql_project_js_1.assertLibsqlProjectArguments)(args.command, rawArgs);
5411
+ }
5412
+ if (args.command === 'doctor' && args.engine === 'mysql')
5413
+ (0, mysql_doctor_js_1.assertMysqlDoctorArguments)(args, rawArgs);
5414
+ if (args.command === 'doctor' && args.engine === 'sqlite')
5415
+ (0, sqlite_doctor_js_1.assertSqliteDoctorArguments)(args, rawArgs);
5416
+ if (args.command === 'doctor' && args.engine === 'mssql')
5417
+ (0, mssql_doctor_js_1.assertMssqlDoctorArguments)(args, rawArgs);
5418
+ if (args.command === 'push' &&
5419
+ (args.engine === 'mysql' || rawArgs.some((token, i) => token === '--engine' && rawArgs[i + 1] === 'mysql'))) {
5420
+ (0, mysql_push_command_js_1.assertMysqlPushArguments)(args, rawArgs);
5421
+ }
5422
+ if (canonicalCommand(args.command) === 'seed' && args.engine === 'mssql') {
5423
+ (0, mssql_seed_js_1.assertMssqlSeedArguments)(args, rawArgs);
5424
+ }
5425
+ if (canonicalCommand(args.command) === 'seed' && args.engine === 'mysql') {
5426
+ (0, mysql_seed_js_1.assertMysqlSeedArguments)(args, rawArgs);
5427
+ }
5428
+ if (canonicalCommand(args.command) === 'migrate' &&
5429
+ (args.engine === 'mysql' || rawArgs.some((token, i) => token === '--engine' && rawArgs[i + 1] === 'mysql'))) {
5430
+ (0, mysql_migrate_command_js_1.assertMysqlMigrationArguments)(args, rawArgs);
5431
+ }
5314
5432
  }
5315
5433
  catch (err) {
5316
5434
  // A last-resort net. Every flag refusal parseArgs makes goes through
@@ -5328,7 +5446,78 @@ async function main() {
5328
5446
  return;
5329
5447
  }
5330
5448
  // Subcommand help: e.g. `turbine migrate --help`
5331
- if (args.help) {
5449
+ let libsqlConfigHelp = false;
5450
+ if (args.help && args.engine === undefined && (0, config_js_1.findConfigFile)()) {
5451
+ if ((0, loader_js_1.needsTsLoader)((0, config_js_1.findConfigFile)()))
5452
+ await (0, loader_js_1.registerTsLoader)();
5453
+ libsqlConfigHelp = ['libsql', 'd1'].includes((await (0, config_js_1.loadConfigResult)(undefined, mysql_seed_loader_cjs_1.default)).config.engine ?? '');
5454
+ }
5455
+ const configCommandHelp = args.help &&
5456
+ args.engine === undefined &&
5457
+ (canonicalCommand(args.command) === 'migrate' || canonicalCommand(args.command) === 'seed' || libsqlConfigHelp) &&
5458
+ !!(0, config_js_1.findConfigFile)();
5459
+ if (args.help && !configCommandHelp) {
5460
+ if (args.engine === 'd1') {
5461
+ (0, d1_project_js_1.showD1Help)();
5462
+ return;
5463
+ }
5464
+ if (args.engine === 'libsql') {
5465
+ if (canonicalCommand(args.command) === 'migrate')
5466
+ (0, libsql_migrate_command_js_1.showLibsqlMigrateHelp)();
5467
+ else if (canonicalCommand(args.command) === 'seed')
5468
+ (0, libsql_seed_command_js_1.showLibsqlSeedHelp)();
5469
+ else
5470
+ (0, libsql_project_js_1.showLibsqlProjectHelp)();
5471
+ return;
5472
+ }
5473
+ if (tool_command_js_1.TOOL_COMMANDS.includes(args.command) || args.command === 'mcp') {
5474
+ showMcpHelp();
5475
+ return;
5476
+ }
5477
+ if (args.engine === 'mysql') {
5478
+ if (args.command === 'doctor') {
5479
+ (0, mysql_doctor_js_1.showMysqlDoctorHelp)();
5480
+ return;
5481
+ }
5482
+ if (args.command === 'push') {
5483
+ (0, mysql_push_command_js_1.showMysqlPushHelp)();
5484
+ return;
5485
+ }
5486
+ if (canonicalCommand(args.command) === 'seed') {
5487
+ (0, mysql_seed_js_1.showMysqlSeedHelp)();
5488
+ return;
5489
+ }
5490
+ if (canonicalCommand(args.command) === 'migrate') {
5491
+ (0, mysql_migrate_command_js_1.showMysqlMigrateHelp)();
5492
+ return;
5493
+ }
5494
+ (0, mysql_project_js_1.showMysqlHelp)();
5495
+ return;
5496
+ }
5497
+ if (args.engine === 'mssql') {
5498
+ if (args.command === 'doctor') {
5499
+ (0, mssql_doctor_js_1.showMssqlDoctorHelp)();
5500
+ return;
5501
+ }
5502
+ if (canonicalCommand(args.command) === 'seed') {
5503
+ (0, mssql_seed_js_1.showMssqlSeedHelp)();
5504
+ return;
5505
+ }
5506
+ (0, mssql_project_js_1.showMssqlHelp)();
5507
+ return;
5508
+ }
5509
+ if (args.engine === 'sqlite') {
5510
+ if (args.command === 'doctor') {
5511
+ (0, sqlite_doctor_js_1.showSqliteDoctorHelp)();
5512
+ return;
5513
+ }
5514
+ if (canonicalCommand(args.command) === 'seed') {
5515
+ (0, sqlite_seed_js_1.showSqliteSeedHelp)();
5516
+ return;
5517
+ }
5518
+ (0, sqlite_migrate_command_js_1.showSqliteHelp)();
5519
+ return;
5520
+ }
5332
5521
  if (showSubcommandHelp(args.command))
5333
5522
  return;
5334
5523
  showHelp();
@@ -5338,55 +5527,298 @@ async function main() {
5338
5527
  showVersion();
5339
5528
  return;
5340
5529
  }
5341
- // Load a local `.env` so `DATABASE_URL` (and every other var it defines) is
5342
- // available to the config file, to `turbine()` in user scripts, and to command
5343
- // resolution: exactly what the quickstart promises. A pre-existing env var
5344
- // always wins. Surfaces the honest state when the file cannot be read.
5345
- const dotEnv = loadDotEnvForCli();
5346
- if (dotEnv.loadError) {
5347
- (0, ui_js_1.warn)(`Could not read ${(0, ui_js_1.cyan)('.env')}: ${dotEnv.loadError}. Continuing without it.`);
5348
- }
5349
- else if (dotEnv.fileExists && dotEnv.unsupported) {
5350
- (0, ui_js_1.warn)(`Found ${(0, ui_js_1.cyan)('.env')} but this Node version cannot auto-load it. ` +
5351
- `Upgrade to Node 20.12+ or export ${(0, ui_js_1.cyan)('DATABASE_URL')} yourself.`);
5352
- }
5353
- const overrides = {
5354
- url: args.url,
5355
- out: args.out,
5356
- schema: args.schema,
5357
- schemaFile: args.schemaFile,
5358
- include: args.include,
5359
- exclude: args.exclude,
5360
- importExtension: args.importExtension,
5361
- keepColumnNames: args.keepColumnNames,
5362
- legacyToManyUniques: args.legacyToManyUniques,
5363
- };
5364
- // Resolve the config file (skipped entirely for config-free invocations such
5365
- // as `studio --demo`). A config that exists but fails to import is surfaced
5366
- // loudly (with a name + the underlying error) instead of being swallowed and
5367
- // later misreported as a missing database URL.
5368
- const { config, fileConfig, loadError } = await bootstrapCliConfig(args, overrides);
5369
- if (loadError && args.command !== 'init') {
5370
- const underlying = loadError.error instanceof Error ? loadError.error.message : String(loadError.error);
5371
- (0, ui_js_1.warn)(`Could not load ${(0, ui_js_1.cyan)(loadError.filename)}: ${underlying}`);
5372
- if (loadError.error instanceof Error)
5373
- printCjsHintIfApplicable(loadError.error);
5374
- (0, ui_js_1.newline)();
5375
- }
5376
- // Warn (don't change precedence) when an .env-sourced DATABASE_URL is silently
5377
- // overriding a differing, non-empty url in the config file (a wrong-database
5378
- // hazard for push/migrate/seed). Shell-exported DATABASE_URL stays silent.
5379
- const urlConflict = dotEnvUrlConflictWarning({
5380
- provenance: dotEnv.databaseUrlProvenance,
5381
- envUrl: process.env.DATABASE_URL,
5382
- fileConfigUrl: fileConfig.url,
5383
- overrideUrl: overrides.url,
5384
- });
5385
- if (urlConflict && args.command !== 'init') {
5386
- (0, ui_js_1.warn)(urlConflict);
5387
- (0, ui_js_1.newline)();
5388
- }
5389
5530
  try {
5531
+ // Load a local `.env` so `DATABASE_URL` (and every other var it defines) is
5532
+ // available to the config file, to `turbine()` in user scripts, and to command
5533
+ // resolution: exactly what the quickstart promises. A pre-existing env var
5534
+ // always wins. Surfaces the honest state when the file cannot be read.
5535
+ const dotEnv = loadDotEnvForCli();
5536
+ if (dotEnv.loadError) {
5537
+ (0, ui_js_1.warn)(`Could not read ${(0, ui_js_1.cyan)('.env')}: ${dotEnv.loadError}. Continuing without it.`);
5538
+ }
5539
+ else if (dotEnv.fileExists && dotEnv.unsupported) {
5540
+ (0, ui_js_1.warn)(`Found ${(0, ui_js_1.cyan)('.env')} but this Node version cannot auto-load it. ` +
5541
+ `Upgrade to Node 20.12+ or export ${(0, ui_js_1.cyan)('DATABASE_URL')} yourself.`);
5542
+ }
5543
+ const overrides = {
5544
+ engine: args.engine,
5545
+ url: args.url,
5546
+ out: args.out,
5547
+ schema: args.schema,
5548
+ schemaFile: args.schemaFile,
5549
+ include: args.include,
5550
+ exclude: args.exclude,
5551
+ importExtension: args.importExtension,
5552
+ keepColumnNames: args.keepColumnNames,
5553
+ exactNativeIntegers: args.exactNativeIntegers,
5554
+ legacyToManyUniques: args.legacyToManyUniques,
5555
+ };
5556
+ // Resolve the config file (skipped entirely for config-free invocations such
5557
+ // as `studio --demo`). A config that exists but fails to import is surfaced
5558
+ // loudly (with a name + the underlying error) instead of being swallowed and
5559
+ // later misreported as a missing database URL.
5560
+ const { config, fileConfig, loadError } = await bootstrapCliConfig(args, overrides);
5561
+ if (loadError && args.engine === undefined) {
5562
+ throw new errors_js_1.ValidationError(`Could not load ${loadError.filename}: ${(0, error_text_js_1.errorText)(loadError.error)}. Refusing to select a database engine from an unreadable config. Fix the config or explicitly choose --engine.`);
5563
+ }
5564
+ if (loadError && args.command === 'doctor' && config.engine === 'mysql')
5565
+ throw new errors_js_1.ValidationError('Could not load MySQL doctor configuration.');
5566
+ if (loadError && args.command !== 'init') {
5567
+ const underlying = loadError.error instanceof Error ? loadError.error.message : String(loadError.error);
5568
+ (0, ui_js_1.warn)(`Could not load ${(0, ui_js_1.cyan)(loadError.filename)}: ${underlying}`);
5569
+ if (loadError.error instanceof Error)
5570
+ printCjsHintIfApplicable(loadError.error);
5571
+ (0, ui_js_1.newline)();
5572
+ }
5573
+ if (config.engine === 'd1') {
5574
+ if (loadError)
5575
+ throw new errors_js_1.ValidationError(`Could not load ${loadError.filename}: ${(0, error_text_js_1.errorText)(loadError.error)}`);
5576
+ (0, d1_config_js_1.assertD1Config)(fileConfig);
5577
+ if (args.command === 'init' && (0, config_js_1.findConfigFile)() && fileConfig.engine !== 'd1')
5578
+ throw new errors_js_1.ValidationError('Existing config selects a different database engine.');
5579
+ const d1Config = args.command === 'init' && !(0, config_js_1.findConfigFile)()
5580
+ ? { ...config, d1: { binding: 'DB', databaseId: 'turbine-local', persist: './.turbine/d1' } }
5581
+ : config;
5582
+ await (0, d1_project_js_1.cmdD1Project)(args.command, args, d1Config, process.argv.slice(2));
5583
+ return;
5584
+ }
5585
+ if (config.engine === 'libsql') {
5586
+ (0, libsql_project_config_js_1.assertLibsqlProjectConfigOptions)(fileConfig);
5587
+ const projectConfig = { ...config, url: config.url ? (0, libsql_project_config_js_1.libsqlProjectUrl)(config.url).url : config.url };
5588
+ if (loadError)
5589
+ throw new errors_js_1.ValidationError(`Could not load ${loadError.filename}: ${(0, error_text_js_1.errorText)(loadError.error)}`);
5590
+ if (args.command === 'init' && (0, config_js_1.findConfigFile)() && fileConfig.engine !== 'libsql')
5591
+ throw new errors_js_1.ValidationError('Existing config selects a different database engine.');
5592
+ if (canonicalCommand(args.command) === 'migrate')
5593
+ (0, libsql_migrate_command_js_1.assertLibsqlMigrationArguments)(args, process.argv.slice(2));
5594
+ else if (canonicalCommand(args.command) === 'seed')
5595
+ (0, libsql_seed_command_js_1.assertLibsqlSeedArguments)(args, process.argv.slice(2));
5596
+ else
5597
+ (0, libsql_project_js_1.assertLibsqlProjectArguments)(args.command, process.argv.slice(2));
5598
+ if (args.help) {
5599
+ if (canonicalCommand(args.command) === 'migrate')
5600
+ (0, libsql_migrate_command_js_1.showLibsqlMigrateHelp)();
5601
+ else if (canonicalCommand(args.command) === 'seed')
5602
+ (0, libsql_seed_command_js_1.showLibsqlSeedHelp)();
5603
+ else
5604
+ (0, libsql_project_js_1.showLibsqlProjectHelp)();
5605
+ return;
5606
+ }
5607
+ switch (canonicalCommand(args.command)) {
5608
+ case 'migrate':
5609
+ await (0, libsql_migrate_command_js_1.cmdLibsqlMigrate)(args, projectConfig);
5610
+ return;
5611
+ case 'seed': {
5612
+ const context = (0, libsql_project_js_1.resolveLibsqlProjectContext)(projectConfig);
5613
+ await (0, libsql_seed_command_js_1.cmdLibsqlSeed)(args, { ...projectConfig, url: context.url }, async () => ({
5614
+ url: context.url,
5615
+ schema: await (0, libsql_project_js_1.introspectLibsqlProject)(projectConfig),
5616
+ }));
5617
+ return;
5618
+ }
5619
+ case 'init':
5620
+ await (0, libsql_project_js_1.cmdLibsqlInit)(args, { ...projectConfig, url: projectConfig.url || 'file:./turbine/dev.sqlite' });
5621
+ return;
5622
+ case 'generate':
5623
+ await (0, libsql_project_js_1.cmdLibsqlGenerate)(args, projectConfig);
5624
+ return;
5625
+ case 'status':
5626
+ await (0, libsql_project_js_1.cmdLibsqlStatus)(args, projectConfig);
5627
+ return;
5628
+ }
5629
+ throw new errors_js_1.ValidationError('Unsupported local libSQL command.');
5630
+ }
5631
+ // Refuse before commands can replace reports, maps or generated output.
5632
+ if (config.exactNativeIntegers && config.engine === 'postgresql') {
5633
+ throw new errors_js_1.ValidationError('exactNativeIntegers requires an explicit target: sqlite, mysql or mssql.');
5634
+ }
5635
+ if (config.engine === 'mysql' && args.command === 'push') {
5636
+ (0, mysql_push_command_js_1.assertMysqlPushArguments)(args, process.argv.slice(2));
5637
+ }
5638
+ if (config.engine === 'mysql' && canonicalCommand(args.command) === 'migrate') {
5639
+ (0, mysql_migrate_command_js_1.assertMysqlMigrationArguments)(args, process.argv.slice(2));
5640
+ }
5641
+ if (config.engine === 'mysql' && canonicalCommand(args.command) === 'seed') {
5642
+ (0, mysql_seed_js_1.assertMysqlSeedArguments)(args, process.argv.slice(2));
5643
+ }
5644
+ if (config.engine === 'mssql' && canonicalCommand(args.command) === 'seed') {
5645
+ (0, mssql_seed_js_1.assertMssqlSeedArguments)(args, process.argv.slice(2));
5646
+ }
5647
+ if (configCommandHelp) {
5648
+ if (loadError)
5649
+ throw new errors_js_1.ValidationError(`Could not load ${loadError.filename}: ${(0, error_text_js_1.errorText)(loadError.error)}`);
5650
+ if (canonicalCommand(args.command) === 'seed') {
5651
+ if (config.engine === 'mysql')
5652
+ (0, mysql_seed_js_1.showMysqlSeedHelp)();
5653
+ else if (config.engine === 'sqlite')
5654
+ (0, sqlite_seed_js_1.showSqliteSeedHelp)();
5655
+ else if (config.engine === 'mssql')
5656
+ (0, mssql_seed_js_1.showMssqlSeedHelp)();
5657
+ else
5658
+ showSubcommandHelp(args.command);
5659
+ return;
5660
+ }
5661
+ if (config.engine === 'mysql')
5662
+ (0, mysql_migrate_command_js_1.showMysqlMigrateHelp)();
5663
+ else if (config.engine === 'sqlite')
5664
+ (0, sqlite_migrate_command_js_1.showSqliteHelp)();
5665
+ else if (config.engine === 'mssql')
5666
+ (0, mssql_project_js_1.showMssqlHelp)();
5667
+ else
5668
+ showSubcommandHelp(args.command);
5669
+ return;
5670
+ }
5671
+ // Warn (don't change precedence) when an .env-sourced DATABASE_URL is silently
5672
+ // overriding a differing, non-empty url in the config file (a wrong-database
5673
+ // hazard for push/migrate/seed). Shell-exported DATABASE_URL stays silent.
5674
+ const urlConflict = dotEnvUrlConflictWarning({
5675
+ provenance: dotEnv.databaseUrlProvenance,
5676
+ envUrl: process.env.DATABASE_URL,
5677
+ fileConfigUrl: fileConfig.url,
5678
+ overrideUrl: overrides.url,
5679
+ });
5680
+ if (urlConflict && args.command !== 'init') {
5681
+ (0, ui_js_1.warn)((config.engine === 'mssql' || config.engine === 'sqlite') &&
5682
+ (args.command === 'doctor' || args.command === 'mcp')
5683
+ ? 'DATABASE_URL from .env is overriding the url in your config file. Using the .env value. Remove DATABASE_URL from .env, or unset the config url, to silence this.'
5684
+ : urlConflict);
5685
+ (0, ui_js_1.newline)();
5686
+ }
5687
+ if (tool_command_js_1.TOOL_COMMANDS.includes(args.command)) {
5688
+ if (loadError)
5689
+ throw new errors_js_1.ValidationError(`Could not load ${loadError.filename}: ${(0, error_text_js_1.errorText)(loadError.error)}`);
5690
+ refuseSchemaFilePath(config);
5691
+ const result = await (0, tool_command_js_1.runToolCommand)(args, {
5692
+ engine: (0, tool_capabilities_js_1.toolEngine)(config.engine),
5693
+ url: config.url,
5694
+ schema: config.schema,
5695
+ migrationsDir: config.migrationsDir,
5696
+ legacyToManyUniques: config.legacyToManyUniques,
5697
+ metadataDir: config.out,
5698
+ include: config.include,
5699
+ exclude: config.exclude,
5700
+ });
5701
+ console.log(JSON.stringify(result, null, 2));
5702
+ return;
5703
+ }
5704
+ if (args.acknowledgePartialDdl && config.engine !== 'mysql') {
5705
+ throw new errors_js_1.ValidationError('--acknowledge-partial-ddl only applies to MySQL migrate recover.');
5706
+ }
5707
+ if (config.engine === 'mysql') {
5708
+ if (args.command === 'doctor') {
5709
+ (0, mysql_doctor_js_1.assertMysqlDoctorArguments)(args, process.argv.slice(2));
5710
+ if (loadError)
5711
+ throw new errors_js_1.ValidationError('Could not load MySQL doctor configuration.');
5712
+ await (0, mysql_doctor_js_1.cmdMysqlDoctor)(args, config, mysql_tools_js_1.mysqlToolDoctorReport);
5713
+ return;
5714
+ }
5715
+ if (loadError)
5716
+ throw new errors_js_1.ValidationError(`Could not load ${loadError.filename}: ${(0, error_text_js_1.errorText)(loadError.error)}`);
5717
+ if (args.command === 'init' && (0, config_js_1.findConfigFile)() && fileConfig.engine !== config.engine) {
5718
+ throw new errors_js_1.ValidationError('Existing config selects a different database engine. Set engine: "mysql" before initializing a MySQL project.');
5719
+ }
5720
+ if (args.command === 'mcp') {
5721
+ await cmdMcp(args, config);
5722
+ return;
5723
+ }
5724
+ if (args.command === 'diff') {
5725
+ await (0, mysql_schema_command_js_1.cmdMysqlSchema)(args, config, loadSchemaFile);
5726
+ return;
5727
+ }
5728
+ if (args.command === 'push') {
5729
+ await (0, mysql_push_command_js_1.cmdMysqlPush)(args, config, (path) => loadSchemaFile(path, mysql_seed_loader_cjs_1.default));
5730
+ return;
5731
+ }
5732
+ if (canonicalCommand(args.command) === 'seed') {
5733
+ await (0, mysql_seed_js_1.cmdMysqlSeed)(args, config);
5734
+ return;
5735
+ }
5736
+ (0, mysql_project_js_1.assertMysqlProjectCommand)(args.command);
5737
+ switch (canonicalCommand(args.command)) {
5738
+ case 'migrate':
5739
+ await (0, mysql_migrate_command_js_1.cmdMysqlMigrate)(args, config, loadSchemaFile);
5740
+ return;
5741
+ case 'init':
5742
+ await (0, mysql_project_js_1.cmdMysqlInit)(args, config);
5743
+ return;
5744
+ case 'generate':
5745
+ await (0, mysql_project_js_1.cmdMysqlGenerate)(args, config);
5746
+ return;
5747
+ case 'status':
5748
+ await (0, mysql_project_js_1.cmdMysqlStatus)(args, config);
5749
+ return;
5750
+ }
5751
+ }
5752
+ if (config.engine === 'mssql') {
5753
+ if (loadError)
5754
+ throw new errors_js_1.ValidationError(`Could not load ${loadError.filename}: ${(0, error_text_js_1.errorText)(loadError.error)}`);
5755
+ if (args.command === 'init' && (0, config_js_1.findConfigFile)() && fileConfig.engine !== config.engine) {
5756
+ throw new errors_js_1.ValidationError('Existing config selects a different database engine. Set engine: "mssql" before initializing a SQL Server project.');
5757
+ }
5758
+ if (args.command === 'mcp') {
5759
+ await cmdMcp(args, config);
5760
+ return;
5761
+ }
5762
+ if (canonicalCommand(args.command) === 'seed') {
5763
+ await (0, mssql_seed_js_1.cmdMssqlSeed)(args, config, mysql_seed_loader_cjs_1.default);
5764
+ return;
5765
+ }
5766
+ if (args.command === 'doctor') {
5767
+ await (0, mssql_doctor_js_1.cmdMssqlDoctor)(args, config, process.argv.slice(2));
5768
+ return;
5769
+ }
5770
+ (0, mssql_project_js_1.assertMssqlProjectCommand)(args.command);
5771
+ switch (canonicalCommand(args.command)) {
5772
+ case 'init':
5773
+ await (0, mssql_project_js_1.cmdMssqlInit)(args, config);
5774
+ return;
5775
+ case 'generate':
5776
+ await (0, mssql_project_js_1.cmdMssqlGenerate)(args, config);
5777
+ return;
5778
+ case 'status':
5779
+ await (0, mssql_project_js_1.cmdMssqlStatus)(args, config);
5780
+ return;
5781
+ case 'migrate':
5782
+ await (0, mssql_migrate_command_js_1.cmdMssqlMigrate)(args, config, confirmDestructive);
5783
+ return;
5784
+ }
5785
+ }
5786
+ if (config.engine === 'sqlite') {
5787
+ if (loadError)
5788
+ throw new errors_js_1.ValidationError(`Could not load ${loadError.filename}: ${(0, error_text_js_1.errorText)(loadError.error)}`);
5789
+ if (args.command === 'init' && (0, config_js_1.findConfigFile)() && fileConfig.engine !== config.engine) {
5790
+ throw new errors_js_1.ValidationError('Existing config selects a different database engine. Set engine: "sqlite" in that config before initializing a SQLite project.');
5791
+ }
5792
+ if (args.command === 'mcp') {
5793
+ await cmdMcp(args, config);
5794
+ return;
5795
+ }
5796
+ if (args.command === 'doctor') {
5797
+ await (0, sqlite_doctor_js_1.cmdSqliteDoctor)(args, config);
5798
+ return;
5799
+ }
5800
+ (0, sqlite_project_js_1.assertSqliteProjectCommand)(args.command);
5801
+ switch (canonicalCommand(args.command)) {
5802
+ case 'init':
5803
+ await (0, sqlite_project_js_1.cmdSqliteInit)(args, config);
5804
+ return;
5805
+ case 'generate':
5806
+ await (0, sqlite_project_js_1.cmdSqliteGenerate)(args, config);
5807
+ return;
5808
+ case 'status':
5809
+ await (0, sqlite_project_js_1.cmdSqliteStatus)(args, config);
5810
+ return;
5811
+ case 'seed':
5812
+ await (0, sqlite_seed_js_1.cmdSqliteSeed)(args, config);
5813
+ return;
5814
+ case 'migrate':
5815
+ await (0, sqlite_migrate_command_js_1.cmdSqliteMigrate)(args, config, confirmDestructive);
5816
+ return;
5817
+ case 'push':
5818
+ await (0, sqlite_schema_command_js_1.cmdSqliteSchema)(args, config, loadSchemaFile);
5819
+ return;
5820
+ }
5821
+ }
5390
5822
  switch (args.command) {
5391
5823
  case 'init':
5392
5824
  await cmdInit(args, config);