d1s 0.2.8 → 0.2.9

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 (310) hide show
  1. package/dist/.next/.next/BUILD_ID +1 -1
  2. package/dist/.next/.next/app-build-manifest.json +33 -26
  3. package/dist/.next/.next/app-path-routes-manifest.json +1 -1
  4. package/dist/.next/.next/build-manifest.json +2 -2
  5. package/dist/.next/.next/cache/.rscinfo +1 -1
  6. package/dist/.next/.next/cache/.tsbuildinfo +1 -1
  7. package/dist/.next/.next/cache/webpack/client-production/0.pack +0 -0
  8. package/dist/.next/.next/cache/webpack/client-production/1.pack +0 -0
  9. package/dist/.next/.next/cache/webpack/client-production/2.pack +0 -0
  10. package/dist/.next/.next/cache/webpack/client-production/index.pack +0 -0
  11. package/dist/.next/.next/cache/webpack/client-production/index.pack.old +0 -0
  12. package/dist/.next/.next/cache/webpack/edge-server-production/index.pack +0 -0
  13. package/dist/.next/.next/cache/webpack/server-production/0.pack +0 -0
  14. package/dist/.next/.next/cache/webpack/server-production/index.pack +0 -0
  15. package/dist/.next/.next/next-minimal-server.js.nft.json +1 -1
  16. package/dist/.next/.next/next-server.js.nft.json +1 -1
  17. package/dist/.next/.next/prerender-manifest.json +1 -1
  18. package/dist/.next/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  19. package/dist/.next/.next/server/app/_not-found.html +1 -1
  20. package/dist/.next/.next/server/app/_not-found.rsc +4 -4
  21. package/dist/.next/.next/server/app/api/cloudflare/route.js +1 -1
  22. package/dist/.next/.next/server/app/api/cloudflare/route_client-reference-manifest.js +1 -1
  23. package/dist/.next/.next/server/app/api/databases/route.js +1 -1
  24. package/dist/.next/.next/server/app/api/databases/route_client-reference-manifest.js +1 -1
  25. package/dist/.next/.next/server/app/api/migrations/sync/route.js +28 -3
  26. package/dist/.next/.next/server/app/api/migrations/sync/route.js.nft.json +1 -1
  27. package/dist/.next/.next/server/app/api/migrations/sync/route_client-reference-manifest.js +1 -1
  28. package/dist/.next/.next/server/app/api/migrations/sync-files/route.js +26 -1
  29. package/dist/.next/.next/server/app/api/migrations/sync-files/route.js.nft.json +1 -1
  30. package/dist/.next/.next/server/app/api/migrations/sync-files/route_client-reference-manifest.js +1 -1
  31. package/dist/.next/.next/server/app/api/pull-data/confirm/route.js +1 -0
  32. package/dist/.next/.next/server/app/api/pull-data/confirm/route.js.nft.json +1 -0
  33. package/dist/.next/.next/server/app/api/pull-data/confirm/route_client-reference-manifest.js +1 -0
  34. package/dist/.next/.next/server/app/api/pull-remote/confirm/route.js +26 -1
  35. package/dist/.next/.next/server/app/api/pull-remote/confirm/route.js.nft.json +1 -1
  36. package/dist/.next/.next/server/app/api/pull-remote/confirm/route_client-reference-manifest.js +1 -1
  37. package/dist/.next/.next/server/app/api/pull-remote/preview/route.js +26 -1
  38. package/dist/.next/.next/server/app/api/pull-remote/preview/route.js.nft.json +1 -1
  39. package/dist/.next/.next/server/app/api/pull-remote/preview/route_client-reference-manifest.js +1 -1
  40. package/dist/.next/.next/server/app/api/push-remote/confirm/route.js +28 -3
  41. package/dist/.next/.next/server/app/api/push-remote/confirm/route.js.nft.json +1 -1
  42. package/dist/.next/.next/server/app/api/push-remote/confirm/route_client-reference-manifest.js +1 -1
  43. package/dist/.next/.next/server/app/api/push-remote/preview/route.js +28 -3
  44. package/dist/.next/.next/server/app/api/push-remote/preview/route.js.nft.json +1 -1
  45. package/dist/.next/.next/server/app/api/push-remote/preview/route_client-reference-manifest.js +1 -1
  46. package/dist/.next/.next/server/app/api/query/route.js +27 -2
  47. package/dist/.next/.next/server/app/api/query/route.js.nft.json +1 -1
  48. package/dist/.next/.next/server/app/api/query/route_client-reference-manifest.js +1 -1
  49. package/dist/.next/.next/server/app/api/tables/[name]/route.js +4 -4
  50. package/dist/.next/.next/server/app/api/tables/[name]/route_client-reference-manifest.js +1 -1
  51. package/dist/.next/.next/server/app/api/tables/route.js +2 -2
  52. package/dist/.next/.next/server/app/api/tables/route_client-reference-manifest.js +1 -1
  53. package/dist/.next/.next/server/app/api/update/route.js +2 -2
  54. package/dist/.next/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
  55. package/dist/.next/.next/server/app/index.html +3 -3
  56. package/dist/.next/.next/server/app/index.rsc +5 -5
  57. package/dist/.next/.next/server/app/page.js +11 -11
  58. package/dist/.next/.next/server/app/page_client-reference-manifest.js +1 -1
  59. package/dist/.next/.next/server/app-paths-manifest.json +2 -1
  60. package/dist/.next/.next/server/chunks/226.js +30 -0
  61. package/dist/.next/.next/server/chunks/336.js +1 -1
  62. package/dist/.next/.next/server/pages/404.html +1 -1
  63. package/dist/.next/.next/server/pages/500.html +1 -1
  64. package/dist/.next/.next/server/pages-manifest.json +1 -1
  65. package/dist/.next/.next/server/server-reference-manifest.json +1 -1
  66. package/dist/.next/.next/static/7XBqETNmhSxMXhw8iUpEa/_buildManifest.js +1 -0
  67. package/dist/.next/.next/static/chunks/{958-98887928efebfdf7.js → 176-9146975ef8699719.js} +1 -1
  68. package/dist/.next/.next/static/chunks/{735-c9144179c6bd7d06.js → 735-b885dfec6353171d.js} +1 -1
  69. package/dist/.next/.next/static/chunks/app/api/cloudflare/route-b77846f372b01f38.js +1 -0
  70. package/dist/.next/.next/static/chunks/app/api/databases/route-407794f8145d9a0b.js +1 -0
  71. package/dist/.next/.next/static/chunks/app/api/migrations/sync/route-9f480f5590369a8f.js +1 -0
  72. package/dist/.next/.next/static/chunks/app/api/migrations/sync-files/route-92010db279b4dd8e.js +1 -0
  73. package/dist/.next/.next/static/chunks/app/api/pull-data/confirm/route-a02fe6d3cdd0a535.js +1 -0
  74. package/dist/.next/.next/static/chunks/app/api/pull-remote/confirm/route-f401a03507d1da50.js +1 -0
  75. package/dist/.next/.next/static/chunks/app/api/pull-remote/preview/route-3c53814b5cb8b6b0.js +1 -0
  76. package/dist/.next/.next/static/chunks/app/api/push-remote/confirm/route-8f359249e907c63b.js +1 -0
  77. package/dist/.next/.next/static/chunks/app/api/push-remote/preview/route-b51bf94f39c17a9d.js +1 -0
  78. package/dist/.next/.next/static/chunks/app/api/query/route-87bae2d4aebaf859.js +1 -0
  79. package/dist/.next/.next/static/chunks/app/api/tables/[name]/route-d20ca163b9c03e7c.js +1 -0
  80. package/dist/.next/.next/static/chunks/app/api/tables/route-0f46f911562abcdf.js +1 -0
  81. package/dist/.next/.next/static/chunks/app/api/update/route-14edc1917760bce0.js +1 -0
  82. package/dist/.next/.next/static/chunks/app/page-5990cb23b8bd27c4.js +1 -0
  83. package/dist/.next/.next/static/css/674bee6608c638e4.css +3 -0
  84. package/dist/.next/.next/trace +3 -3
  85. package/dist/.next/.next/types/app/api/pull-data/confirm/route.ts +347 -0
  86. package/dist/.next/BUILD_ID +1 -1
  87. package/dist/.next/app-build-manifest.json +35 -21
  88. package/dist/.next/app-path-routes-manifest.json +1 -1
  89. package/dist/.next/build-manifest.json +2 -2
  90. package/dist/.next/cache/.rscinfo +1 -1
  91. package/dist/.next/cache/.tsbuildinfo +1 -1
  92. package/dist/.next/cache/webpack/client-production/0.pack +0 -0
  93. package/dist/.next/cache/webpack/client-production/index.pack +0 -0
  94. package/dist/.next/cache/webpack/edge-server-production/index.pack +0 -0
  95. package/dist/.next/cache/webpack/server-production/0.pack +0 -0
  96. package/dist/.next/cache/webpack/server-production/index.pack +0 -0
  97. package/dist/.next/next-minimal-server.js.nft.json +1 -1
  98. package/dist/.next/next-server.js.nft.json +1 -1
  99. package/dist/.next/prerender-manifest.json +1 -1
  100. package/dist/.next/server/app/_not-found/page.js +1 -1
  101. package/dist/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  102. package/dist/.next/server/app/_not-found.html +1 -1
  103. package/dist/.next/server/app/_not-found.rsc +4 -4
  104. package/dist/.next/server/app/api/cloudflare/route.js +1 -1
  105. package/dist/.next/server/app/api/cloudflare/route.js.nft.json +1 -1
  106. package/dist/.next/server/app/api/cloudflare/route_client-reference-manifest.js +1 -1
  107. package/dist/.next/server/app/api/databases/route.js +1 -1
  108. package/dist/.next/server/app/api/databases/route.js.nft.json +1 -1
  109. package/dist/.next/server/app/api/databases/route_client-reference-manifest.js +1 -1
  110. package/dist/.next/server/app/api/migrations/sync/route.js +28 -3
  111. package/dist/.next/server/app/api/migrations/sync/route.js.nft.json +1 -1
  112. package/dist/.next/server/app/api/migrations/sync/route_client-reference-manifest.js +1 -1
  113. package/dist/.next/server/app/api/migrations/sync-files/route.js +26 -1
  114. package/dist/.next/server/app/api/migrations/sync-files/route.js.nft.json +1 -1
  115. package/dist/.next/server/app/api/migrations/sync-files/route_client-reference-manifest.js +1 -1
  116. package/dist/.next/server/app/api/pull-data/confirm/route.js +1 -0
  117. package/dist/.next/server/app/api/pull-data/confirm/route.js.nft.json +1 -0
  118. package/dist/.next/server/app/api/pull-data/confirm/route_client-reference-manifest.js +1 -0
  119. package/dist/.next/server/app/api/pull-remote/confirm/route.js +26 -1
  120. package/dist/.next/server/app/api/pull-remote/confirm/route.js.nft.json +1 -1
  121. package/dist/.next/server/app/api/pull-remote/confirm/route_client-reference-manifest.js +1 -1
  122. package/dist/.next/server/app/api/pull-remote/preview/route.js +26 -1
  123. package/dist/.next/server/app/api/pull-remote/preview/route.js.nft.json +1 -1
  124. package/dist/.next/server/app/api/pull-remote/preview/route_client-reference-manifest.js +1 -1
  125. package/dist/.next/server/app/api/push-remote/confirm/route.js +28 -3
  126. package/dist/.next/server/app/api/push-remote/confirm/route.js.nft.json +1 -1
  127. package/dist/.next/server/app/api/push-remote/confirm/route_client-reference-manifest.js +1 -1
  128. package/dist/.next/server/app/api/push-remote/preview/route.js +28 -3
  129. package/dist/.next/server/app/api/push-remote/preview/route.js.nft.json +1 -1
  130. package/dist/.next/server/app/api/push-remote/preview/route_client-reference-manifest.js +1 -1
  131. package/dist/.next/server/app/api/query/route.js +27 -2
  132. package/dist/.next/server/app/api/query/route.js.nft.json +1 -1
  133. package/dist/.next/server/app/api/query/route_client-reference-manifest.js +1 -1
  134. package/dist/.next/server/app/api/tables/[name]/route.js +3 -3
  135. package/dist/.next/server/app/api/tables/[name]/route.js.nft.json +1 -1
  136. package/dist/.next/server/app/api/tables/[name]/route_client-reference-manifest.js +1 -1
  137. package/dist/.next/server/app/api/tables/route.js +2 -2
  138. package/dist/.next/server/app/api/tables/route.js.nft.json +1 -1
  139. package/dist/.next/server/app/api/tables/route_client-reference-manifest.js +1 -1
  140. package/dist/.next/server/app/api/update/route.js +5 -0
  141. package/dist/.next/server/app/api/update/route.js.nft.json +1 -0
  142. package/dist/.next/server/app/api/update/route_client-reference-manifest.js +1 -0
  143. package/dist/.next/server/app/index.html +3 -3
  144. package/dist/.next/server/app/index.rsc +5 -5
  145. package/dist/.next/server/app/page.js +13 -11
  146. package/dist/.next/server/app/page_client-reference-manifest.js +1 -1
  147. package/dist/.next/server/app-paths-manifest.json +5 -3
  148. package/dist/.next/server/chunks/226.js +30 -0
  149. package/dist/.next/server/chunks/336.js +1 -1
  150. package/dist/.next/server/chunks/391.js +23 -0
  151. package/dist/.next/server/chunks/452.js +1 -0
  152. package/dist/.next/server/chunks/627.js +3 -3
  153. package/dist/.next/server/chunks/638.js +3 -3
  154. package/dist/.next/server/chunks/992.js +3 -3
  155. package/dist/.next/server/pages/404.html +1 -1
  156. package/dist/.next/server/pages/500.html +1 -1
  157. package/dist/.next/server/pages/_app.js +1 -1
  158. package/dist/.next/server/pages/_document.js +1 -1
  159. package/dist/.next/server/pages/_error.js +1 -1
  160. package/dist/.next/server/server-reference-manifest.json +1 -1
  161. package/dist/.next/static/MoZBULXFiTFzrY1JVK_Df/_buildManifest.js +1 -0
  162. package/dist/.next/static/chunks/176-9146975ef8699719.js +1 -0
  163. package/dist/.next/static/chunks/{735-c9144179c6bd7d06.js → 735-b885dfec6353171d.js} +1 -1
  164. package/dist/.next/static/chunks/app/api/cloudflare/route-b77846f372b01f38.js +1 -0
  165. package/dist/.next/static/chunks/app/api/databases/route-407794f8145d9a0b.js +1 -0
  166. package/dist/.next/static/chunks/app/api/migrations/sync/route-9f480f5590369a8f.js +1 -0
  167. package/dist/.next/static/chunks/app/api/migrations/sync-files/route-92010db279b4dd8e.js +1 -0
  168. package/dist/.next/static/chunks/app/api/pull-data/confirm/route-a02fe6d3cdd0a535.js +1 -0
  169. package/dist/.next/static/chunks/app/api/pull-remote/confirm/route-f401a03507d1da50.js +1 -0
  170. package/dist/.next/static/chunks/app/api/pull-remote/preview/route-3c53814b5cb8b6b0.js +1 -0
  171. package/dist/.next/static/chunks/app/api/push-remote/confirm/route-8f359249e907c63b.js +1 -0
  172. package/dist/.next/static/chunks/app/api/push-remote/preview/route-b51bf94f39c17a9d.js +1 -0
  173. package/dist/.next/static/chunks/app/api/query/route-87bae2d4aebaf859.js +1 -0
  174. package/dist/.next/static/chunks/app/api/tables/[name]/route-d20ca163b9c03e7c.js +1 -0
  175. package/dist/.next/static/chunks/app/api/tables/route-0f46f911562abcdf.js +1 -0
  176. package/dist/.next/static/chunks/app/api/update/route-14edc1917760bce0.js +1 -0
  177. package/dist/.next/static/chunks/app/page-5990cb23b8bd27c4.js +1 -0
  178. package/dist/.next/static/css/674bee6608c638e4.css +3 -0
  179. package/dist/.next/trace +17 -14
  180. package/dist/.next/types/app/api/pull-data/confirm/route.ts +347 -0
  181. package/dist/.next/types/app/api/update/route.ts +347 -0
  182. package/dist/app/api/pull-data/confirm/route.js +230 -0
  183. package/dist/app/api/update/route.js +36 -0
  184. package/dist/app/app/api/pull-data/confirm/route.js +230 -0
  185. package/dist/app/app/api/update/route.js +30 -5
  186. package/dist/app/app/page.jsx +21 -17
  187. package/dist/app/page.jsx +24 -14
  188. package/dist/d1-studio.js +8 -1
  189. package/dist/lib/logger.js +35 -5
  190. package/dist/lib/sql-operations.js +77 -0
  191. package/package.json +1 -1
  192. package/scripts/studio.js +8 -1
  193. package/src/app/api/pull-data/confirm/route.js +230 -0
  194. package/src/app/api/update/route.js +30 -5
  195. package/src/app/page.jsx +21 -17
  196. package/src/components/environment-handler.jsx +70 -16
  197. package/src/components/environment-select.jsx +6 -3
  198. package/src/components/pull-preview-toast.jsx +90 -63
  199. package/src/components/sidebar.jsx +25 -24
  200. package/src/components/update-banner.jsx +29 -31
  201. package/src/context/database-context.js +4 -4
  202. package/src/lib/logger.js +35 -5
  203. package/src/lib/sql-operations.js +77 -0
  204. package/dist/.next/.next/cache/webpack/client-development/0.pack.gz +0 -0
  205. package/dist/.next/.next/cache/webpack/client-development/1.pack.gz +0 -0
  206. package/dist/.next/.next/cache/webpack/client-development/2.pack.gz +0 -0
  207. package/dist/.next/.next/cache/webpack/client-development/3.pack.gz +0 -0
  208. package/dist/.next/.next/cache/webpack/client-development/4.pack.gz +0 -0
  209. package/dist/.next/.next/cache/webpack/client-development/index.pack.gz +0 -0
  210. package/dist/.next/.next/cache/webpack/client-development/index.pack.gz.old +0 -0
  211. package/dist/.next/.next/cache/webpack/client-production/10.pack +0 -0
  212. package/dist/.next/.next/cache/webpack/client-production/11.pack +0 -0
  213. package/dist/.next/.next/cache/webpack/client-production/12.pack +0 -0
  214. package/dist/.next/.next/cache/webpack/client-production/13.pack +0 -0
  215. package/dist/.next/.next/cache/webpack/client-production/14.pack +0 -0
  216. package/dist/.next/.next/cache/webpack/client-production/3.pack +0 -0
  217. package/dist/.next/.next/cache/webpack/client-production/4.pack +0 -0
  218. package/dist/.next/.next/cache/webpack/client-production/5.pack +0 -0
  219. package/dist/.next/.next/cache/webpack/client-production/6.pack +0 -0
  220. package/dist/.next/.next/cache/webpack/client-production/7.pack +0 -0
  221. package/dist/.next/.next/cache/webpack/client-production/8.pack +0 -0
  222. package/dist/.next/.next/cache/webpack/client-production/9.pack +0 -0
  223. package/dist/.next/.next/cache/webpack/server-development/0.pack.gz +0 -0
  224. package/dist/.next/.next/cache/webpack/server-development/1.pack.gz +0 -0
  225. package/dist/.next/.next/cache/webpack/server-development/2.pack.gz +0 -0
  226. package/dist/.next/.next/cache/webpack/server-development/3.pack.gz +0 -0
  227. package/dist/.next/.next/cache/webpack/server-development/4.pack.gz +0 -0
  228. package/dist/.next/.next/cache/webpack/server-development/index.pack.gz +0 -0
  229. package/dist/.next/.next/cache/webpack/server-development/index.pack.gz.old +0 -0
  230. package/dist/.next/.next/cache/webpack/server-production/1.pack +0 -0
  231. package/dist/.next/.next/cache/webpack/server-production/10.pack +0 -0
  232. package/dist/.next/.next/cache/webpack/server-production/11.pack +0 -0
  233. package/dist/.next/.next/cache/webpack/server-production/12.pack +0 -0
  234. package/dist/.next/.next/cache/webpack/server-production/13.pack +0 -0
  235. package/dist/.next/.next/cache/webpack/server-production/2.pack +0 -0
  236. package/dist/.next/.next/cache/webpack/server-production/3.pack +0 -0
  237. package/dist/.next/.next/cache/webpack/server-production/4.pack +0 -0
  238. package/dist/.next/.next/cache/webpack/server-production/5.pack +0 -0
  239. package/dist/.next/.next/cache/webpack/server-production/6.pack +0 -0
  240. package/dist/.next/.next/cache/webpack/server-production/7.pack +0 -0
  241. package/dist/.next/.next/cache/webpack/server-production/8.pack +0 -0
  242. package/dist/.next/.next/cache/webpack/server-production/9.pack +0 -0
  243. package/dist/.next/.next/cache/webpack/server-production/index.pack.old +0 -0
  244. package/dist/.next/.next/server/chunks/686.js +0 -23
  245. package/dist/.next/.next/server/chunks/801.js +0 -55
  246. package/dist/.next/.next/static/IWRJZhjf8U8mjzz4h0VNE/_buildManifest.js +0 -1
  247. package/dist/.next/.next/static/JrwgdSDcipr0Zh7k19Cj_/_buildManifest.js +0 -1
  248. package/dist/.next/.next/static/chunks/422-6fa3c14fc64ad67b.js +0 -1
  249. package/dist/.next/.next/static/chunks/app/api/cloudflare/route-3458d78022185d7f.js +0 -1
  250. package/dist/.next/.next/static/chunks/app/api/cloudflare/route-5133155a604f2719.js +0 -1
  251. package/dist/.next/.next/static/chunks/app/api/databases/route-63a31080b565794e.js +0 -1
  252. package/dist/.next/.next/static/chunks/app/api/databases/route-64255424877a9f72.js +0 -1
  253. package/dist/.next/.next/static/chunks/app/api/migrations/sync/route-03766b3afcf043ba.js +0 -1
  254. package/dist/.next/.next/static/chunks/app/api/migrations/sync/route-d97667565b4a59b6.js +0 -1
  255. package/dist/.next/.next/static/chunks/app/api/migrations/sync-files/route-02fa291c8000dadf.js +0 -1
  256. package/dist/.next/.next/static/chunks/app/api/migrations/sync-files/route-7089bcbfeb6b5260.js +0 -1
  257. package/dist/.next/.next/static/chunks/app/api/pull-remote/confirm/route-7e05bb8920127abe.js +0 -1
  258. package/dist/.next/.next/static/chunks/app/api/pull-remote/confirm/route-9143e6e4c3f05162.js +0 -1
  259. package/dist/.next/.next/static/chunks/app/api/pull-remote/preview/route-0fa15f783e8a306c.js +0 -1
  260. package/dist/.next/.next/static/chunks/app/api/pull-remote/preview/route-c963d143a51aed66.js +0 -1
  261. package/dist/.next/.next/static/chunks/app/api/push-remote/confirm/route-072132c0a6cb3df3.js +0 -1
  262. package/dist/.next/.next/static/chunks/app/api/push-remote/confirm/route-96691f1880e4ed14.js +0 -1
  263. package/dist/.next/.next/static/chunks/app/api/push-remote/preview/route-a798679c67374552.js +0 -1
  264. package/dist/.next/.next/static/chunks/app/api/push-remote/preview/route-ca6bf35aa72661ee.js +0 -1
  265. package/dist/.next/.next/static/chunks/app/api/query/route-1466f6b7ffd8b6c0.js +0 -1
  266. package/dist/.next/.next/static/chunks/app/api/query/route-e90d0030a5083e20.js +0 -1
  267. package/dist/.next/.next/static/chunks/app/api/tables/[name]/route-1efe63e73b480e58.js +0 -1
  268. package/dist/.next/.next/static/chunks/app/api/tables/[name]/route-898d3f85fc8544c4.js +0 -1
  269. package/dist/.next/.next/static/chunks/app/api/tables/route-3772b4f480c4b4a4.js +0 -1
  270. package/dist/.next/.next/static/chunks/app/api/tables/route-91650359fc3735cb.js +0 -1
  271. package/dist/.next/.next/static/chunks/app/api/update/route-504d663df9124f97.js +0 -1
  272. package/dist/.next/.next/static/chunks/app/page-2c28a255a4ecd8d4.js +0 -1
  273. package/dist/.next/.next/static/chunks/app/page-3db7feef57019055.js +0 -1
  274. package/dist/.next/.next/static/chunks/app/page-79049bfa6cc07e11.js +0 -1
  275. package/dist/.next/.next/static/css/4957328384ed5c42.css +0 -3
  276. package/dist/.next/.next/static/css/cf41da7a0d47f779.css +0 -3
  277. package/dist/.next/.next/static/gc8l1G6KXOeLLOM7VJip6/_buildManifest.js +0 -1
  278. package/dist/.next/.next/static/gc8l1G6KXOeLLOM7VJip6/_ssgManifest.js +0 -1
  279. package/dist/.next/.next/static/kYsJoni86CJWDuTkc1xU6/_buildManifest.js +0 -1
  280. package/dist/.next/.next/static/kYsJoni86CJWDuTkc1xU6/_ssgManifest.js +0 -1
  281. package/dist/.next/.next/static/scC5qwQC9H7rR1groM0Q-/_buildManifest.js +0 -1
  282. package/dist/.next/.next/static/scC5qwQC9H7rR1groM0Q-/_ssgManifest.js +0 -1
  283. package/dist/.next/.next/static/tEHOI_-t-iqfJClNzuo9m/_buildManifest.js +0 -1
  284. package/dist/.next/.next/static/tEHOI_-t-iqfJClNzuo9m/_ssgManifest.js +0 -1
  285. package/dist/.next/.next/static/vin2VQs5pM_dH2e2_I7AN/_buildManifest.js +0 -1
  286. package/dist/.next/.next/static/vin2VQs5pM_dH2e2_I7AN/_ssgManifest.js +0 -1
  287. package/dist/.next/.next/static/wHKwQhaxin5_i06GFVDHb/_buildManifest.js +0 -1
  288. package/dist/.next/.next/static/wHKwQhaxin5_i06GFVDHb/_ssgManifest.js +0 -1
  289. package/dist/.next/.next/static/xW4MspD8XibrhXDi_q2IO/_buildManifest.js +0 -1
  290. package/dist/.next/.next/static/xW4MspD8XibrhXDi_q2IO/_ssgManifest.js +0 -1
  291. package/dist/.next/server/chunks/686.js +0 -23
  292. package/dist/.next/server/chunks/801.js +0 -55
  293. package/dist/.next/static/ZwNOdZJ0LOtE0AJMNWwzY/_buildManifest.js +0 -1
  294. package/dist/.next/static/ZwNOdZJ0LOtE0AJMNWwzY/_ssgManifest.js +0 -1
  295. package/dist/.next/static/chunks/422-6fa3c14fc64ad67b.js +0 -1
  296. package/dist/.next/static/chunks/app/api/cloudflare/route-3458d78022185d7f.js +0 -1
  297. package/dist/.next/static/chunks/app/api/databases/route-64255424877a9f72.js +0 -1
  298. package/dist/.next/static/chunks/app/api/migrations/sync/route-03766b3afcf043ba.js +0 -1
  299. package/dist/.next/static/chunks/app/api/migrations/sync-files/route-02fa291c8000dadf.js +0 -1
  300. package/dist/.next/static/chunks/app/api/pull-remote/confirm/route-7e05bb8920127abe.js +0 -1
  301. package/dist/.next/static/chunks/app/api/pull-remote/preview/route-0fa15f783e8a306c.js +0 -1
  302. package/dist/.next/static/chunks/app/api/push-remote/confirm/route-96691f1880e4ed14.js +0 -1
  303. package/dist/.next/static/chunks/app/api/push-remote/preview/route-a798679c67374552.js +0 -1
  304. package/dist/.next/static/chunks/app/api/query/route-e90d0030a5083e20.js +0 -1
  305. package/dist/.next/static/chunks/app/api/tables/[name]/route-1efe63e73b480e58.js +0 -1
  306. package/dist/.next/static/chunks/app/api/tables/route-3772b4f480c4b4a4.js +0 -1
  307. package/dist/.next/static/chunks/app/page-79049bfa6cc07e11.js +0 -1
  308. package/dist/.next/static/css/cf41da7a0d47f779.css +0 -3
  309. /package/dist/.next/.next/static/{IWRJZhjf8U8mjzz4h0VNE → 7XBqETNmhSxMXhw8iUpEa}/_ssgManifest.js +0 -0
  310. /package/dist/.next/{.next/static/JrwgdSDcipr0Zh7k19Cj_ → static/MoZBULXFiTFzrY1JVK_Df}/_ssgManifest.js +0 -0
@@ -20,17 +20,20 @@ export function EnvironmentSelect({
20
20
  onValueChange={onValueChange}
21
21
  disabled={disabled || isLoading || showPreview}
22
22
  >
23
- <SelectTrigger className="w-[104px] bg-white border-neutral-200 font-medium">
23
+ <SelectTrigger className="w-full bg-white border-neutral-200 font-medium">
24
24
  <div className="flex items-center gap-1 text-sm">
25
25
  {isLoading || showPreview ? (
26
26
  <>
27
27
  <Loader2 className="h-4 w-4 animate-spin text-muted-foreground" />
28
28
  <span className="text-muted-foreground font-medium">
29
- {value === "pull" ? "Pulling..." : "Pushing..."}
29
+ {value === "pull" ? "Pulling..." :
30
+ value === "syncing" ? "Syncing..." :
31
+ value === "production" ? "Pushing..." :
32
+ "Loading..."}
30
33
  </span>
31
34
  </>
32
35
  ) : (
33
- <SelectValue placeholder="Environment" />
36
+ <SelectValue placeholder="Environment" className="w-full" />
34
37
  )}
35
38
  </div>
36
39
  </SelectTrigger>
@@ -1,26 +1,21 @@
1
- "use client";
1
+ // components/pull-preview-toast.jsx
2
2
 
3
3
  import React, { useEffect, useState } from "react";
4
4
  import { Button } from "@/components/ui/button";
5
5
  import { ScrollArea } from "@/components/ui/scroll-area";
6
- import {
7
- Table,
8
- TableBody,
9
- TableCell,
10
- TableHead,
11
- TableHeader,
12
- TableRow,
13
- } from "@/components/ui/table";
14
- import { FileText, Loader2 } from "lucide-react";
6
+ import { FileText, Loader2, X } from "lucide-react";
15
7
  import { cn } from "@/lib/utils";
16
8
 
17
9
  export function PullPreviewToast({
18
10
  preview = [],
19
11
  onConfirm,
20
12
  onCancel,
13
+ onDataPull,
21
14
  isConfirming,
15
+ isDataPulling,
22
16
  error,
23
17
  isLoading,
18
+ success,
24
19
  }) {
25
20
  console.log("PullPreviewToast rendered with:", {
26
21
  previewLength: preview.length,
@@ -66,7 +61,6 @@ export function PullPreviewToast({
66
61
  <div className="fixed bottom-4 right-4 z-50 w-[600px]">
67
62
  <div className="rounded-lg border bg-destructive/15 p-4">
68
63
  <div className="flex items-center gap-2">
69
- <FileText className="h-5 w-5 text-destructive" />
70
64
  <p className="text-sm font-medium text-destructive">
71
65
  No preview data available
72
66
  </p>
@@ -86,6 +80,10 @@ export function PullPreviewToast({
86
80
  const totalMigrations = sqlMigrations.length;
87
81
  console.log("Migration stats:", { totalMigrations });
88
82
 
83
+ // Determine if sync button should be enabled
84
+ // Only enable if pull was successful and not currently pulling data
85
+ const isSyncEnabled = success && !isDataPulling && !error;
86
+
89
87
  return (
90
88
  <div className="fixed bottom-4 right-4 z-50 font-sans w-[600px]">
91
89
  <div
@@ -94,28 +92,44 @@ export function PullPreviewToast({
94
92
  error ? "bg-destructive/15" : "bg-background"
95
93
  )}
96
94
  >
97
- <div className="flex items-start gap-3">
95
+ <div className="flex items-start gap-x-1">
98
96
  <div className="flex-1 space-y-3">
99
- {/* Header */}
97
+ {/* Header with Close Button */}
100
98
  <div className="space-y-1">
101
- <h5
102
- className={cn(
103
- "font-medium",
104
- error ? "text-destructive" : "text-neutral-900"
105
- )}
106
- >
107
- {error ? "Pull Migration Error" : "Pull Migration Preview"}
108
- </h5>
99
+ <div className="flex items-center justify-between">
100
+ <h5
101
+ className={cn(
102
+ "font-medium",
103
+ error ? "text-destructive" : "text-neutral-900"
104
+ )}
105
+ >
106
+ {error ? "Pull Migration Error" : "Pull Migration Preview"}
107
+ </h5>
108
+ <button
109
+ onClick={onCancel}
110
+ className="text-neutral-500 hover:text-neutral-900 p-1 rounded-md hover:bg-neutral-100"
111
+ >
112
+ <X className="h-4 w-4" />
113
+ </button>
114
+ </div>
109
115
  <p
110
116
  className={cn(
111
117
  "text-sm",
112
118
  error ? "text-destructive/80" : "text-neutral-700"
113
119
  )}
114
120
  >
115
- {error
116
- ? error.message
117
- : `${totalMigrations} migration(s) will be applied`}
121
+ {`${totalMigrations} migration(s) will be applied`}
118
122
  </p>
123
+ {error && (
124
+ <p className="text-sm text-destructive font-medium mt-1">
125
+ {error.message}
126
+ </p>
127
+ )}
128
+ {success && (
129
+ <p className="text-sm text-green-700 font-medium mt-1">
130
+ {success}
131
+ </p>
132
+ )}
119
133
  </div>
120
134
 
121
135
  {/* Migration Details */}
@@ -129,54 +143,67 @@ export function PullPreviewToast({
129
143
 
130
144
  {isDetailsOpen && (
131
145
  <ScrollArea className="h-[480px] mt-2 rounded border border-neutral-200">
132
- <Table>
133
- <TableHeader>
134
- <TableRow>
135
- <TableHead className="w-[30px]"></TableHead>
136
- <TableHead className="pl-0">Migration</TableHead>
137
- </TableRow>
138
- </TableHeader>
139
- <TableBody>
146
+ <div className="w-full">
147
+ <div className="bg-neutral-50 border-b px-4 py-2">
148
+ <div className="text-sm font-medium text-neutral-600">Migration</div>
149
+ </div>
150
+ <div>
140
151
  {sqlMigrations.map((item, index) => (
141
- <TableRow key={index}>
142
- <TableCell className="w-[30px] pr-1 pl-2">
143
- <FileText className="h-4 w-4" />
144
- </TableCell>
145
- <TableCell className="font-mono text-xs pr-5 pl-0.5">
152
+ <div
153
+ key={index}
154
+ className="px-4 py-2 border-b last:border-0"
155
+ >
156
+ <div className="font-mono text-xs">
146
157
  {item.migration || item.name}
147
- </TableCell>
148
- </TableRow>
158
+ </div>
159
+ </div>
149
160
  ))}
150
- </TableBody>
151
- </Table>
161
+ </div>
162
+ </div>
152
163
  </ScrollArea>
153
164
  )}
154
165
  </div>
155
166
 
156
167
  {/* Action Buttons */}
157
- <div className="flex gap-2 pt-1">
158
- <Button
159
- onClick={onConfirm}
160
- disabled={isConfirming}
161
- className="flex-1"
162
- >
163
- {isConfirming ? (
164
- <>
165
- <Loader2 className="mr-2 h-4 w-4 animate-spin" />
166
- Confirming...
167
- </>
168
- ) : (
169
- "Confirm Pull"
170
- )}
171
- </Button>
168
+ <div className="flex flex-col gap-2 pt-1">
169
+ <div className="flex gap-2">
172
170
  <Button
173
- variant="outline"
174
- onClick={onCancel}
175
- disabled={isConfirming}
176
- className="flex-1"
177
- >
178
- Cancel
179
- </Button>
171
+ onClick={onConfirm}
172
+ disabled={isConfirming}
173
+ className={`flex-1 ${isConfirming ? "cursor-not-allowed opacity-50" : ""}`}
174
+ >
175
+ {isConfirming ? (
176
+ <>
177
+ <Loader2 className="h-4 w-4 animate-spin" />
178
+ Confirming...
179
+ </>
180
+ ) : (
181
+ "Confirm Pull"
182
+ )}
183
+ </Button>
184
+
185
+ {/* Right column - Sync data and description */}
186
+ <div className="flex-1 flex flex-col gap-2">
187
+ <Button
188
+ onClick={onDataPull}
189
+ disabled={!isSyncEnabled}
190
+ variant="outline"
191
+ className={`w-full ${!isSyncEnabled ? "cursor-not-allowed opacity-50" : ""}`}
192
+ >
193
+ {isDataPulling ? (
194
+ <>
195
+ <Loader2 className="h-4 w-4 animate-spin" />
196
+ Syncing remote data...
197
+ </>
198
+ ) : (
199
+ "Sync remote data"
200
+ )}
201
+ </Button>
202
+ <p className="text-xs text-neutral-500 text-center">
203
+ 75 records per table
204
+ </p>
205
+ </div>
206
+ </div>
180
207
  </div>
181
208
  </div>
182
209
  </div>
@@ -136,24 +136,11 @@ export function AppSidebar({
136
136
  <aside className={`${className} w-64 fixed top-0 left-0 h-full bg-neutral-50 p-4`}>
137
137
  <div className="flex flex-col h-full font-sans">
138
138
  {/* Header */}
139
- <div className="flex items-center gap-2 mb-6">
139
+ <div className="flex items-center gap-2 mb-4">
140
140
  <Table2 className="h-5 w-5" />
141
141
  <span className="font-mono font-bold text-sm">d1-studio</span>
142
142
  </div>
143
143
 
144
- {/* SQL Editor Section */}
145
- <div className="mb-6">
146
- <button
147
- className={`w-full flex items-center gap-x-1 border rounded-md text-sm font-medium transition-colors px-2 py-2
148
- ${currentView === 'sql-editor' ? 'bg-neutral-900 text-white' : 'bg-white hover:bg-neutral-100'}`}
149
- onClick={() => onNavigate('sql-editor')}
150
- disabled={isTableLoading}
151
- >
152
- <TerminalSquare className="h-[16px] w-[16px]" />
153
- SQL editor
154
- </button>
155
- </div>
156
-
157
144
  {/* Error Message */}
158
145
  {error && (
159
146
  <Alert variant="destructive" className="mb-4">
@@ -162,16 +149,17 @@ export function AppSidebar({
162
149
  </Alert>
163
150
  )}
164
151
 
165
- {/* Database Section */}
166
- <div className="flex items-center justify-between mb-6">
167
- <div>
168
- <div className="text-xs text-muted-foreground mb-1">Database name</div>
169
- <div className="font-semibold text-sm">
170
- {databases[0]?.database_name || 'No database found'}
171
- </div>
152
+ {/* Database Section */}
153
+ <div className="mb-2">
154
+ <div className="text-xs text-muted-foreground mb-1">Database name</div>
155
+ <div className="font-semibold text-sm">
156
+ {databases[0]?.database_name || 'No database found'}
172
157
  </div>
173
-
174
- <EnvironmentSelect
158
+ </div>
159
+
160
+ {/* Environment Section - Full Width */}
161
+ <div className="mb-6">
162
+ <EnvironmentSelect className="w-full"
175
163
  value={environment}
176
164
  onValueChange={handleEnvironmentChange}
177
165
  isLoading={isPushing}
@@ -179,9 +167,22 @@ export function AppSidebar({
179
167
  showPreview={showPreview}
180
168
  />
181
169
  </div>
170
+
171
+ {/* SQL Editor Section */}
172
+ <div className="mb-3">
173
+ <button
174
+ className={`w-full flex items-center gap-x-1 border rounded-md text-sm font-medium transition-colors px-2 py-2
175
+ ${currentView === 'sql-editor' ? 'bg-neutral-900 text-white' : 'bg-white hover:bg-neutral-100'}`}
176
+ onClick={() => onNavigate('sql-editor')}
177
+ disabled={isTableLoading}
178
+ >
179
+ <TerminalSquare className="h-[16px] w-[16px]" />
180
+ SQL editor
181
+ </button>
182
+ </div>
182
183
 
183
184
  {/* Search Section */}
184
- <div className="relative mb-6 bg-white">
185
+ <div className="relative mb-3 bg-white">
185
186
  <Search className="absolute left-2 top-2.5 h-4 w-4 text-neutral-500" />
186
187
  <Input
187
188
  placeholder="Search tables"
@@ -1,64 +1,62 @@
1
1
  // components/update-banner.jsx
2
-
3
2
  'use client'
4
3
 
5
4
  import { useEffect, useState } from 'react';
5
+ import { Download } from 'lucide-react';
6
6
  import axios from 'axios';
7
7
 
8
8
  export default function UpdateBanner() {
9
9
  const [updateInfo, setUpdateInfo] = useState(null);
10
10
  const [visible, setVisible] = useState(true);
11
11
 
12
- // On component mount, check if the banner was previously dismissed
13
12
  useEffect(() => {
14
- const isDismissed = localStorage.getItem('updateBannerDismissed');
15
- if (isDismissed === 'true') {
13
+ const dismissedVersion = localStorage.getItem('updateBannerDismissedVersion');
14
+ if (dismissedVersion) {
16
15
  setVisible(false);
17
16
  }
18
17
  }, []);
19
18
 
20
- // Fetch update info from /api/update
21
19
  useEffect(() => {
22
- axios
23
- .get('/api/update')
24
- .then(({ data }) => {
25
- // If there's an update object returned
26
- if (data?.update) {
27
- setUpdateInfo(data.update);
28
- // If user has not dismissed the banner, ensure it's visible
29
- // so they see the new version if it differs from the old one
30
- setVisible(true);
31
- }
32
- })
33
- .catch(console.error);
20
+ const timer = setTimeout(() => {
21
+ axios
22
+ .get('/api/update')
23
+ .then(({ data }) => {
24
+ if (data?.update) {
25
+ const dismissedVersion = localStorage.getItem('updateBannerDismissedVersion');
26
+ if (dismissedVersion !== data.update.latest) {
27
+ setUpdateInfo(data.update);
28
+ setVisible(true);
29
+ }
30
+ }
31
+ })
32
+ .catch(console.error);
33
+ }, 1000);
34
+
35
+ return () => clearTimeout(timer);
34
36
  }, []);
35
37
 
36
- // If no update or the banner was dismissed, don't render
37
38
  if (!updateInfo || !visible) return null;
38
39
 
39
- // Close handler that writes to localStorage
40
40
  const handleClose = () => {
41
- localStorage.setItem('updateBannerDismissed', 'true');
41
+ localStorage.setItem('updateBannerDismissedVersion', updateInfo.latest);
42
42
  setVisible(false);
43
43
  };
44
44
 
45
45
  return (
46
- <div className="bg-gray-200 w-full px-3 py-3 flex items-center justify-between">
47
- <div className="text-gray-800">
48
- <strong>Update available!</strong> You are on version {updateInfo.current};
49
- version {updateInfo.latest} is available. Run{' '}
50
- <code className="bg-white text-sm px-1 py-0.5 rounded">
51
- npm install -g d1s@latest
52
- </code>{' '}
53
- to update.
46
+ <div className="w-full bg-neutral-100 border-b px-3 py-2 flex items-center justify-between">
47
+ <div className="flex items-center gap-2 text-sm">
48
+ <Download className="h-4 w-4 text-blue-500" />
49
+ <span>
50
+ Version {updateInfo.latest} is available — npm install -g d1s@latest
51
+ </span>
54
52
  </div>
55
53
  <button
56
54
  onClick={handleClose}
57
- className="ml-4 text-gray-500 hover:text-gray-700"
55
+ className="text-neutral-500 hover:text-neutral-700"
58
56
  aria-label="Close update banner"
59
57
  >
60
- &times;
58
+ ×
61
59
  </button>
62
60
  </div>
63
61
  );
64
- }
62
+ }
@@ -395,10 +395,10 @@ export function DatabaseProvider({ children }) {
395
395
  tableCache.clear();
396
396
  await refreshTables();
397
397
 
398
- toast({
399
- title: "Success",
400
- description: `Remote state applied successfully. Migrations applied: ${data.details.appliedMigrations.join(', ')}`,
401
- });
398
+ // toast({
399
+ // title: "Success",
400
+ // description: `Remote state applied successfully. Migrations applied: ${data.details.appliedMigrations.join(', ')}`,
401
+ // });
402
402
 
403
403
  return data;
404
404
  } catch (error) {
package/src/lib/logger.js CHANGED
@@ -4,14 +4,21 @@ const { combine, timestamp, printf, colorize } = winston.format;
4
4
 
5
5
  const isDevelopment = process.env.NODE_ENV === 'development' || process.env.NODE_ENV === undefined;
6
6
  const isProduction = process.env.NODE_ENV === 'production';
7
+ // Check for DEBUG env var which is set by --debug flag
7
8
  const isDebug = process.env.DEBUG === 'true';
8
9
 
9
- const logFormat = printf(({ level, message, timestamp }) => {
10
- return `${timestamp} ${level}: ${message}`;
10
+ const logFormat = printf(({ level, message, timestamp, ...metadata }) => {
11
+ let msg = `${timestamp} ${level}: ${message}`;
12
+ // Add metadata if present
13
+ if (Object.keys(metadata).length > 0) {
14
+ msg += ` ${JSON.stringify(metadata)}`;
15
+ }
16
+ return msg;
11
17
  });
12
18
 
13
19
  const logger = winston.createLogger({
14
- level: isProduction ? 'warn' : (isDebug ? 'debug' : 'info'),
20
+ // Set log level based on environment and debug flag
21
+ level: isDebug ? 'debug' : (isProduction ? 'warn' : 'info'),
15
22
  format: combine(
16
23
  timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),
17
24
  colorize(),
@@ -19,10 +26,33 @@ const logger = winston.createLogger({
19
26
  ),
20
27
  transports: [
21
28
  new winston.transports.Console({
22
- level: isProduction ? 'warn' : (isDebug ? 'debug' : 'info'),
29
+ level: isDebug ? 'debug' : (isProduction ? 'warn' : 'info'),
23
30
  silent: process.env.NODE_ENV === 'test'
24
31
  })
25
32
  ]
26
33
  });
27
34
 
28
- export default logger;
35
+ // Add helper methods
36
+ logger.logRequest = (method, path, params = {}) => {
37
+ logger.debug(`Request: ${method} ${path}`, params);
38
+ };
39
+
40
+ logger.logError = (error, source = 'unknown') => {
41
+ logger.error(`Error in ${source}: ${error.message}`, {
42
+ error: error.stack || error.message,
43
+ source
44
+ });
45
+ };
46
+
47
+ logger.shouldLog = (level) => {
48
+ const currentLevel = logger.level;
49
+ const levels = {
50
+ error: 0,
51
+ warn: 1,
52
+ info: 2,
53
+ debug: 3
54
+ };
55
+ return levels[level] <= levels[currentLevel];
56
+ };
57
+
58
+ export default logger;
@@ -342,6 +342,83 @@ export async function executeSQL(projectDir, databaseName, sql, env = {}, remote
342
342
  }
343
343
  }
344
344
 
345
+ /**
346
+ * Fetches the latest `limit` records for a given table from the remote database.
347
+ *
348
+ * This implementation uses the executeSQL function with the remote flag enabled.
349
+ * It orders the results based on the provided ordering column. If no ordering column is provided,
350
+ * it falls back to the default "id" column.
351
+ *
352
+ * @param {string} projectDir - The project directory.
353
+ * @param {string} databaseName - The D1 database name.
354
+ * @param {string} tableName - The table to fetch records for.
355
+ * @param {object} env - Environment variables (including credentials).
356
+ * @param {number} limit - The number of records to fetch.
357
+ * @param {string} [orderingColumn="id"] - The column to order by.
358
+ * @returns {Promise<Array<object>>} Array of row objects.
359
+ */
360
+ export async function fetchRemoteTableData(
361
+ projectDir,
362
+ databaseName,
363
+ tableName,
364
+ env,
365
+ limit,
366
+ orderingColumn = "id"
367
+ ) {
368
+ // Use the provided ordering column; if not provided, default to "id".
369
+ const query = `SELECT * FROM "${tableName}" ORDER BY "${orderingColumn}" DESC LIMIT ${limit};`;
370
+ try {
371
+ // Execute the SQL command on the remote database.
372
+ const result = await executeSQL(projectDir, databaseName, query, env, true);
373
+
374
+ // ExecuteSQL returns stdout that should contain a JSON array starting from a '['.
375
+ const jsonStart = result.indexOf('[');
376
+ if (jsonStart === -1) {
377
+ throw new Error(`Unexpected result format: ${result}`);
378
+ }
379
+ const jsonStr = result.substring(jsonStart);
380
+ const parsed = JSON.parse(jsonStr);
381
+ // Assuming the structure: parsed[0].results contains the rows.
382
+ const rows = parsed[0]?.results || [];
383
+ return rows;
384
+ } catch (error) {
385
+ logger.error(`Error fetching remote data for table ${tableName}:`, error);
386
+ throw error;
387
+ }
388
+ }
389
+
390
+ /**
391
+ * Generates a bulk insert SQL statement for the specified table and rows.
392
+ *
393
+ * This function constructs a single INSERT statement that inserts multiple rows.
394
+ * It escapes single quotes in string values. You may need to extend this for
395
+ * additional data types (e.g., numbers, dates, booleans) or more complex structures.
396
+ *
397
+ * @param {string} tableName - The table to insert into.
398
+ * @param {Array<object>} rows - An array of objects, each representing a row.
399
+ * @returns {string} The bulk insert SQL statement.
400
+ */
401
+ export function generateBulkInsertSQL(tableName, rows) {
402
+ if (!rows || rows.length === 0) return '';
403
+
404
+ // Get the list of columns from the first row object.
405
+ const columns = Object.keys(rows[0]);
406
+ const columnList = columns.map(col => `"${col}"`).join(', ');
407
+
408
+ // Build the values list for each row.
409
+ const valuesList = rows.map(row => {
410
+ const values = columns.map(col => {
411
+ const value = row[col];
412
+ if (value === null || value === undefined) return 'NULL';
413
+ // For simplicity, treat the value as a string.
414
+ return `'${String(value).replace(/'/g, "''")}'`;
415
+ }).join(', ');
416
+ return `(${values})`;
417
+ }).join(', ');
418
+
419
+ return `INSERT INTO "${tableName}" (${columnList}) VALUES ${valuesList};`;
420
+ }
421
+
345
422
  // ---------------------------------------------------------------------
346
423
  // SQL Formatting and Helper Functions
347
424
  // ---------------------------------------------------------------------