d1s 0.2.8 → 0.2.10

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 (361) hide show
  1. package/dist/.next/.next/BUILD_ID +1 -1
  2. package/dist/.next/.next/app-build-manifest.json +49 -42
  3. package/dist/.next/.next/app-path-routes-manifest.json +1 -1
  4. package/dist/.next/.next/build-manifest.json +3 -3
  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/3.pack +0 -0
  11. package/dist/.next/.next/cache/webpack/client-production/4.pack +0 -0
  12. package/dist/.next/.next/cache/webpack/client-production/index.pack +0 -0
  13. package/dist/.next/.next/cache/webpack/client-production/index.pack.old +0 -0
  14. package/dist/.next/.next/cache/webpack/edge-server-production/index.pack +0 -0
  15. package/dist/.next/.next/cache/webpack/server-production/0.pack +0 -0
  16. package/dist/.next/.next/cache/webpack/server-production/1.pack +0 -0
  17. package/dist/.next/.next/cache/webpack/server-production/2.pack +0 -0
  18. package/dist/.next/.next/cache/webpack/server-production/index.pack +0 -0
  19. package/dist/.next/.next/cache/webpack/server-production/index.pack.old +0 -0
  20. package/dist/.next/.next/next-minimal-server.js.nft.json +1 -1
  21. package/dist/.next/.next/next-server.js.nft.json +1 -1
  22. package/dist/.next/.next/prerender-manifest.json +1 -1
  23. package/dist/.next/.next/required-server-files.json +1 -1
  24. package/dist/.next/.next/server/app/_not-found/page.js +1 -1
  25. package/dist/.next/.next/server/app/_not-found/page.js.nft.json +1 -1
  26. package/dist/.next/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  27. package/dist/.next/.next/server/app/_not-found.html +1 -1
  28. package/dist/.next/.next/server/app/_not-found.rsc +4 -4
  29. package/dist/.next/.next/server/app/api/cloudflare/route.js +1 -1
  30. package/dist/.next/.next/server/app/api/cloudflare/route_client-reference-manifest.js +1 -1
  31. package/dist/.next/.next/server/app/api/databases/route.js +1 -1
  32. package/dist/.next/.next/server/app/api/databases/route_client-reference-manifest.js +1 -1
  33. package/dist/.next/.next/server/app/api/migrations/sync/route.js +28 -3
  34. package/dist/.next/.next/server/app/api/migrations/sync/route.js.nft.json +1 -1
  35. package/dist/.next/.next/server/app/api/migrations/sync/route_client-reference-manifest.js +1 -1
  36. package/dist/.next/.next/server/app/api/migrations/sync-files/route.js +26 -1
  37. package/dist/.next/.next/server/app/api/migrations/sync-files/route.js.nft.json +1 -1
  38. package/dist/.next/.next/server/app/api/migrations/sync-files/route_client-reference-manifest.js +1 -1
  39. package/dist/.next/.next/server/app/api/pull-data/confirm/route.js +1 -0
  40. package/dist/.next/.next/server/app/api/pull-data/confirm/route.js.nft.json +1 -0
  41. package/dist/.next/.next/server/app/api/pull-data/confirm/route_client-reference-manifest.js +1 -0
  42. package/dist/.next/.next/server/app/api/pull-remote/confirm/route.js +26 -1
  43. package/dist/.next/.next/server/app/api/pull-remote/confirm/route.js.nft.json +1 -1
  44. package/dist/.next/.next/server/app/api/pull-remote/confirm/route_client-reference-manifest.js +1 -1
  45. package/dist/.next/.next/server/app/api/pull-remote/preview/route.js +26 -1
  46. package/dist/.next/.next/server/app/api/pull-remote/preview/route.js.nft.json +1 -1
  47. package/dist/.next/.next/server/app/api/pull-remote/preview/route_client-reference-manifest.js +1 -1
  48. package/dist/.next/.next/server/app/api/push-remote/confirm/route.js +28 -3
  49. package/dist/.next/.next/server/app/api/push-remote/confirm/route.js.nft.json +1 -1
  50. package/dist/.next/.next/server/app/api/push-remote/confirm/route_client-reference-manifest.js +1 -1
  51. package/dist/.next/.next/server/app/api/push-remote/preview/route.js +28 -3
  52. package/dist/.next/.next/server/app/api/push-remote/preview/route.js.nft.json +1 -1
  53. package/dist/.next/.next/server/app/api/push-remote/preview/route_client-reference-manifest.js +1 -1
  54. package/dist/.next/.next/server/app/api/query/route.js +27 -2
  55. package/dist/.next/.next/server/app/api/query/route.js.nft.json +1 -1
  56. package/dist/.next/.next/server/app/api/query/route_client-reference-manifest.js +1 -1
  57. package/dist/.next/.next/server/app/api/tables/[name]/route.js +4 -4
  58. package/dist/.next/.next/server/app/api/tables/[name]/route_client-reference-manifest.js +1 -1
  59. package/dist/.next/.next/server/app/api/tables/route.js +2 -2
  60. package/dist/.next/.next/server/app/api/tables/route_client-reference-manifest.js +1 -1
  61. package/dist/.next/.next/server/app/api/update/route.js +1 -5
  62. package/dist/.next/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
  63. package/dist/.next/.next/server/app/index.html +3 -3
  64. package/dist/.next/.next/server/app/index.rsc +5 -5
  65. package/dist/.next/.next/server/app/page.js +10 -10
  66. package/dist/.next/.next/server/app/page.js.nft.json +1 -1
  67. package/dist/.next/.next/server/app/page_client-reference-manifest.js +1 -1
  68. package/dist/.next/.next/server/app-paths-manifest.json +5 -4
  69. package/dist/.next/.next/server/chunks/226.js +30 -0
  70. package/dist/.next/.next/server/chunks/90.js +1 -0
  71. package/dist/.next/.next/server/chunks/992.js +1 -1
  72. package/dist/.next/.next/server/middleware-build-manifest.js +1 -1
  73. package/dist/.next/.next/server/next-font-manifest.js +1 -1
  74. package/dist/.next/.next/server/next-font-manifest.json +1 -1
  75. package/dist/.next/.next/server/pages/404.html +1 -1
  76. package/dist/.next/.next/server/pages/500.html +1 -1
  77. package/dist/.next/.next/server/pages-manifest.json +1 -1
  78. package/dist/.next/.next/server/server-reference-manifest.json +1 -1
  79. package/dist/.next/.next/static/5dBGGUmK5q7of4h5Rahrg/_buildManifest.js +1 -0
  80. package/dist/.next/.next/static/PflNFnmFsNegSqhzjI6lA/_buildManifest.js +1 -0
  81. package/dist/.next/.next/static/chunks/{958-98887928efebfdf7.js → 700-dc8f9f08b166c5e6.js} +1 -1
  82. package/dist/.next/.next/static/chunks/{735-c9144179c6bd7d06.js → 735-b885dfec6353171d.js} +1 -1
  83. package/dist/.next/.next/static/chunks/app/api/cloudflare/route-b77846f372b01f38.js +1 -0
  84. package/dist/.next/.next/static/chunks/app/api/databases/route-407794f8145d9a0b.js +1 -0
  85. package/dist/.next/.next/static/chunks/app/api/migrations/sync/route-9f480f5590369a8f.js +1 -0
  86. package/dist/.next/.next/static/chunks/app/api/migrations/sync-files/route-92010db279b4dd8e.js +1 -0
  87. package/dist/.next/.next/static/chunks/app/api/pull-data/confirm/route-a02fe6d3cdd0a535.js +1 -0
  88. package/dist/.next/.next/static/chunks/app/api/pull-remote/confirm/route-f401a03507d1da50.js +1 -0
  89. package/dist/.next/.next/static/chunks/app/api/pull-remote/preview/route-3c53814b5cb8b6b0.js +1 -0
  90. package/dist/.next/.next/static/chunks/app/api/push-remote/confirm/route-8f359249e907c63b.js +1 -0
  91. package/dist/.next/.next/static/chunks/app/api/push-remote/preview/route-b51bf94f39c17a9d.js +1 -0
  92. package/dist/.next/.next/static/chunks/app/api/query/route-87bae2d4aebaf859.js +1 -0
  93. package/dist/.next/.next/static/chunks/app/api/tables/[name]/route-d20ca163b9c03e7c.js +1 -0
  94. package/dist/.next/.next/static/chunks/app/api/tables/route-0f46f911562abcdf.js +1 -0
  95. package/dist/.next/.next/static/chunks/app/api/update/route-14edc1917760bce0.js +1 -0
  96. package/dist/.next/.next/static/chunks/app/layout-be6ee67cf0c92654.js +1 -0
  97. package/dist/.next/.next/static/chunks/app/page-16ec561fc8bebb5d.js +1 -0
  98. package/dist/.next/.next/static/chunks/{main-app-d36cdfb402b40f13.js → main-app-fa35024de9bd9284.js} +1 -1
  99. package/dist/.next/.next/static/css/0c512cea5f3d317a.css +3 -0
  100. package/dist/.next/.next/static/p8875OZM4iDNsPzmoyLe7/_buildManifest.js +1 -0
  101. package/dist/.next/.next/trace +3 -3
  102. package/dist/.next/.next/types/app/api/cloudflare/route.ts +1 -1
  103. package/dist/.next/.next/types/app/api/databases/route.ts +1 -1
  104. package/dist/.next/.next/types/app/api/migrations/sync/route.ts +1 -1
  105. package/dist/.next/.next/types/app/api/migrations/sync-files/route.ts +1 -1
  106. package/dist/.next/.next/types/app/api/pull-data/confirm/route.ts +347 -0
  107. package/dist/.next/.next/types/app/api/pull-remote/confirm/route.ts +1 -1
  108. package/dist/.next/.next/types/app/api/pull-remote/preview/route.ts +1 -1
  109. package/dist/.next/.next/types/app/api/push-remote/confirm/route.ts +1 -1
  110. package/dist/.next/.next/types/app/api/push-remote/preview/route.ts +1 -1
  111. package/dist/.next/.next/types/app/api/query/route.ts +1 -1
  112. package/dist/.next/.next/types/app/api/tables/[name]/route.ts +1 -1
  113. package/dist/.next/.next/types/app/api/tables/route.ts +1 -1
  114. package/dist/.next/.next/types/app/api/update/route.ts +1 -1
  115. package/dist/.next/.next/types/app/page.ts +1 -1
  116. package/dist/.next/BUILD_ID +1 -1
  117. package/dist/.next/app-build-manifest.json +53 -39
  118. package/dist/.next/app-path-routes-manifest.json +1 -1
  119. package/dist/.next/build-manifest.json +3 -3
  120. package/dist/.next/cache/.rscinfo +1 -1
  121. package/dist/.next/cache/.tsbuildinfo +1 -1
  122. package/dist/.next/cache/webpack/client-production/0.pack +0 -0
  123. package/dist/.next/cache/webpack/client-production/index.pack +0 -0
  124. package/dist/.next/cache/webpack/edge-server-production/index.pack +0 -0
  125. package/dist/.next/cache/webpack/server-production/0.pack +0 -0
  126. package/dist/.next/cache/webpack/server-production/index.pack +0 -0
  127. package/dist/.next/next-minimal-server.js.nft.json +1 -1
  128. package/dist/.next/next-server.js.nft.json +1 -1
  129. package/dist/.next/prerender-manifest.json +1 -1
  130. package/dist/.next/required-server-files.json +1 -1
  131. package/dist/.next/server/app/_not-found/page.js +1 -1
  132. package/dist/.next/server/app/_not-found/page.js.nft.json +1 -1
  133. package/dist/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  134. package/dist/.next/server/app/_not-found.html +1 -1
  135. package/dist/.next/server/app/_not-found.rsc +4 -4
  136. package/dist/.next/server/app/api/cloudflare/route.js +1 -1
  137. package/dist/.next/server/app/api/cloudflare/route.js.nft.json +1 -1
  138. package/dist/.next/server/app/api/cloudflare/route_client-reference-manifest.js +1 -1
  139. package/dist/.next/server/app/api/databases/route.js +1 -1
  140. package/dist/.next/server/app/api/databases/route.js.nft.json +1 -1
  141. package/dist/.next/server/app/api/databases/route_client-reference-manifest.js +1 -1
  142. package/dist/.next/server/app/api/migrations/sync/route.js +28 -3
  143. package/dist/.next/server/app/api/migrations/sync/route.js.nft.json +1 -1
  144. package/dist/.next/server/app/api/migrations/sync/route_client-reference-manifest.js +1 -1
  145. package/dist/.next/server/app/api/migrations/sync-files/route.js +26 -1
  146. package/dist/.next/server/app/api/migrations/sync-files/route.js.nft.json +1 -1
  147. package/dist/.next/server/app/api/migrations/sync-files/route_client-reference-manifest.js +1 -1
  148. package/dist/.next/server/app/api/pull-data/confirm/route.js +1 -0
  149. package/dist/.next/server/app/api/pull-data/confirm/route.js.nft.json +1 -0
  150. package/dist/.next/server/app/api/pull-data/confirm/route_client-reference-manifest.js +1 -0
  151. package/dist/.next/server/app/api/pull-remote/confirm/route.js +26 -1
  152. package/dist/.next/server/app/api/pull-remote/confirm/route.js.nft.json +1 -1
  153. package/dist/.next/server/app/api/pull-remote/confirm/route_client-reference-manifest.js +1 -1
  154. package/dist/.next/server/app/api/pull-remote/preview/route.js +26 -1
  155. package/dist/.next/server/app/api/pull-remote/preview/route.js.nft.json +1 -1
  156. package/dist/.next/server/app/api/pull-remote/preview/route_client-reference-manifest.js +1 -1
  157. package/dist/.next/server/app/api/push-remote/confirm/route.js +28 -3
  158. package/dist/.next/server/app/api/push-remote/confirm/route.js.nft.json +1 -1
  159. package/dist/.next/server/app/api/push-remote/confirm/route_client-reference-manifest.js +1 -1
  160. package/dist/.next/server/app/api/push-remote/preview/route.js +28 -3
  161. package/dist/.next/server/app/api/push-remote/preview/route.js.nft.json +1 -1
  162. package/dist/.next/server/app/api/push-remote/preview/route_client-reference-manifest.js +1 -1
  163. package/dist/.next/server/app/api/query/route.js +27 -2
  164. package/dist/.next/server/app/api/query/route.js.nft.json +1 -1
  165. package/dist/.next/server/app/api/query/route_client-reference-manifest.js +1 -1
  166. package/dist/.next/server/app/api/tables/[name]/route.js +3 -3
  167. package/dist/.next/server/app/api/tables/[name]/route.js.nft.json +1 -1
  168. package/dist/.next/server/app/api/tables/[name]/route_client-reference-manifest.js +1 -1
  169. package/dist/.next/server/app/api/tables/route.js +2 -2
  170. package/dist/.next/server/app/api/tables/route.js.nft.json +1 -1
  171. package/dist/.next/server/app/api/tables/route_client-reference-manifest.js +1 -1
  172. package/dist/.next/server/app/api/update/route.js +1 -0
  173. package/dist/.next/server/app/api/update/route.js.nft.json +1 -0
  174. package/dist/.next/server/app/api/update/route_client-reference-manifest.js +1 -0
  175. package/dist/.next/server/app/index.html +3 -3
  176. package/dist/.next/server/app/index.rsc +5 -5
  177. package/dist/.next/server/app/page.js +13 -11
  178. package/dist/.next/server/app/page.js.nft.json +1 -1
  179. package/dist/.next/server/app/page_client-reference-manifest.js +1 -1
  180. package/dist/.next/server/app-paths-manifest.json +6 -4
  181. package/dist/.next/server/chunks/226.js +30 -0
  182. package/dist/.next/server/chunks/391.js +23 -0
  183. package/dist/.next/server/chunks/452.js +1 -0
  184. package/dist/.next/server/chunks/627.js +3 -3
  185. package/dist/.next/server/chunks/638.js +3 -3
  186. package/dist/.next/server/chunks/90.js +1 -0
  187. package/dist/.next/server/chunks/992.js +3 -3
  188. package/dist/.next/server/middleware-build-manifest.js +1 -1
  189. package/dist/.next/server/next-font-manifest.js +1 -1
  190. package/dist/.next/server/next-font-manifest.json +1 -1
  191. package/dist/.next/server/pages/404.html +1 -1
  192. package/dist/.next/server/pages/500.html +1 -1
  193. package/dist/.next/server/pages/_app.js +1 -1
  194. package/dist/.next/server/pages/_document.js +1 -1
  195. package/dist/.next/server/pages/_error.js +1 -1
  196. package/dist/.next/server/server-reference-manifest.json +1 -1
  197. package/dist/.next/static/chunks/700-dc8f9f08b166c5e6.js +1 -0
  198. package/dist/.next/static/chunks/{735-c9144179c6bd7d06.js → 735-b885dfec6353171d.js} +1 -1
  199. package/dist/.next/static/chunks/app/api/cloudflare/route-b77846f372b01f38.js +1 -0
  200. package/dist/.next/static/chunks/app/api/databases/route-407794f8145d9a0b.js +1 -0
  201. package/dist/.next/static/chunks/app/api/migrations/sync/route-9f480f5590369a8f.js +1 -0
  202. package/dist/.next/static/chunks/app/api/migrations/sync-files/route-92010db279b4dd8e.js +1 -0
  203. package/dist/.next/static/chunks/app/api/pull-data/confirm/route-a02fe6d3cdd0a535.js +1 -0
  204. package/dist/.next/static/chunks/app/api/pull-remote/confirm/route-f401a03507d1da50.js +1 -0
  205. package/dist/.next/static/chunks/app/api/pull-remote/preview/route-3c53814b5cb8b6b0.js +1 -0
  206. package/dist/.next/static/chunks/app/api/push-remote/confirm/route-8f359249e907c63b.js +1 -0
  207. package/dist/.next/static/chunks/app/api/push-remote/preview/route-b51bf94f39c17a9d.js +1 -0
  208. package/dist/.next/static/chunks/app/api/query/route-87bae2d4aebaf859.js +1 -0
  209. package/dist/.next/static/chunks/app/api/tables/[name]/route-d20ca163b9c03e7c.js +1 -0
  210. package/dist/.next/static/chunks/app/api/tables/route-0f46f911562abcdf.js +1 -0
  211. package/dist/.next/static/chunks/app/api/update/route-14edc1917760bce0.js +1 -0
  212. package/dist/.next/static/chunks/app/layout-be6ee67cf0c92654.js +1 -0
  213. package/dist/.next/static/chunks/app/page-16ec561fc8bebb5d.js +1 -0
  214. package/dist/.next/static/chunks/{main-app-d36cdfb402b40f13.js → main-app-fa35024de9bd9284.js} +1 -1
  215. package/dist/.next/static/css/0c512cea5f3d317a.css +3 -0
  216. package/dist/.next/static 2/5dBGGUmK5q7of4h5Rahrg/_buildManifest.js +1 -0
  217. package/dist/.next/trace +16 -14
  218. package/dist/.next/types/app/api/cloudflare/route.ts +1 -1
  219. package/dist/.next/types/app/api/databases/route.ts +1 -1
  220. package/dist/.next/types/app/api/migrations/sync/route.ts +1 -1
  221. package/dist/.next/types/app/api/migrations/sync-files/route.ts +1 -1
  222. package/dist/.next/types/app/api/pull-data/confirm/route.ts +347 -0
  223. package/dist/.next/types/app/api/pull-remote/confirm/route.ts +1 -1
  224. package/dist/.next/types/app/api/pull-remote/preview/route.ts +1 -1
  225. package/dist/.next/types/app/api/push-remote/confirm/route.ts +1 -1
  226. package/dist/.next/types/app/api/push-remote/preview/route.ts +1 -1
  227. package/dist/.next/types/app/api/query/route.ts +1 -1
  228. package/dist/.next/types/app/api/tables/[name]/route.ts +1 -1
  229. package/dist/.next/types/app/api/tables/route.ts +1 -1
  230. package/dist/.next/types/app/api/update/route.ts +347 -0
  231. package/dist/.next/types/app/page.ts +1 -1
  232. package/dist/app/api/pull-data/confirm/route.js +230 -0
  233. package/dist/app/api/update/route.js +45 -0
  234. package/dist/app/app/api/pull-data/confirm/route.js +230 -0
  235. package/dist/app/app/api/update/route.js +40 -6
  236. package/dist/app/app/page.jsx +21 -17
  237. package/dist/app/page.jsx +24 -14
  238. package/dist/d1-studio.js +8 -195
  239. package/dist/lib/logger.js +35 -5
  240. package/dist/lib/sql-operations.js +107 -24
  241. package/dist/lib/version-utils.js +34 -0
  242. package/package.json +2 -2
  243. package/scripts/studio.js +8 -195
  244. package/src/app/api/pull-data/confirm/route.js +230 -0
  245. package/src/app/api/update/route.js +40 -6
  246. package/src/app/page.jsx +21 -17
  247. package/src/components/environment-handler.jsx +70 -16
  248. package/src/components/environment-select.jsx +6 -3
  249. package/src/components/pull-preview-toast.jsx +90 -63
  250. package/src/components/sidebar.jsx +27 -25
  251. package/src/components/update-banner.jsx +70 -41
  252. package/src/context/database-context.js +4 -4
  253. package/src/lib/logger.js +35 -5
  254. package/src/lib/sql-operations.js +107 -24
  255. package/src/lib/version-utils.js +34 -0
  256. package/dist/.next/.next/cache/webpack/client-development/0.pack.gz +0 -0
  257. package/dist/.next/.next/cache/webpack/client-development/1.pack.gz +0 -0
  258. package/dist/.next/.next/cache/webpack/client-development/2.pack.gz +0 -0
  259. package/dist/.next/.next/cache/webpack/client-development/3.pack.gz +0 -0
  260. package/dist/.next/.next/cache/webpack/client-development/4.pack.gz +0 -0
  261. package/dist/.next/.next/cache/webpack/client-development/index.pack.gz +0 -0
  262. package/dist/.next/.next/cache/webpack/client-development/index.pack.gz.old +0 -0
  263. package/dist/.next/.next/cache/webpack/client-production/10.pack +0 -0
  264. package/dist/.next/.next/cache/webpack/client-production/11.pack +0 -0
  265. package/dist/.next/.next/cache/webpack/client-production/12.pack +0 -0
  266. package/dist/.next/.next/cache/webpack/client-production/13.pack +0 -0
  267. package/dist/.next/.next/cache/webpack/client-production/14.pack +0 -0
  268. package/dist/.next/.next/cache/webpack/client-production/5.pack +0 -0
  269. package/dist/.next/.next/cache/webpack/client-production/6.pack +0 -0
  270. package/dist/.next/.next/cache/webpack/client-production/7.pack +0 -0
  271. package/dist/.next/.next/cache/webpack/client-production/8.pack +0 -0
  272. package/dist/.next/.next/cache/webpack/client-production/9.pack +0 -0
  273. package/dist/.next/.next/cache/webpack/server-development/0.pack.gz +0 -0
  274. package/dist/.next/.next/cache/webpack/server-development/1.pack.gz +0 -0
  275. package/dist/.next/.next/cache/webpack/server-development/2.pack.gz +0 -0
  276. package/dist/.next/.next/cache/webpack/server-development/3.pack.gz +0 -0
  277. package/dist/.next/.next/cache/webpack/server-development/4.pack.gz +0 -0
  278. package/dist/.next/.next/cache/webpack/server-development/index.pack.gz +0 -0
  279. package/dist/.next/.next/cache/webpack/server-development/index.pack.gz.old +0 -0
  280. package/dist/.next/.next/cache/webpack/server-production/10.pack +0 -0
  281. package/dist/.next/.next/cache/webpack/server-production/11.pack +0 -0
  282. package/dist/.next/.next/cache/webpack/server-production/12.pack +0 -0
  283. package/dist/.next/.next/cache/webpack/server-production/13.pack +0 -0
  284. package/dist/.next/.next/cache/webpack/server-production/3.pack +0 -0
  285. package/dist/.next/.next/cache/webpack/server-production/4.pack +0 -0
  286. package/dist/.next/.next/cache/webpack/server-production/5.pack +0 -0
  287. package/dist/.next/.next/cache/webpack/server-production/6.pack +0 -0
  288. package/dist/.next/.next/cache/webpack/server-production/7.pack +0 -0
  289. package/dist/.next/.next/cache/webpack/server-production/8.pack +0 -0
  290. package/dist/.next/.next/cache/webpack/server-production/9.pack +0 -0
  291. package/dist/.next/.next/server/chunks/336.js +0 -1
  292. package/dist/.next/.next/server/chunks/686.js +0 -23
  293. package/dist/.next/.next/server/chunks/801.js +0 -55
  294. package/dist/.next/.next/static/IWRJZhjf8U8mjzz4h0VNE/_buildManifest.js +0 -1
  295. package/dist/.next/.next/static/JrwgdSDcipr0Zh7k19Cj_/_buildManifest.js +0 -1
  296. package/dist/.next/.next/static/chunks/422-6fa3c14fc64ad67b.js +0 -1
  297. package/dist/.next/.next/static/chunks/app/api/cloudflare/route-3458d78022185d7f.js +0 -1
  298. package/dist/.next/.next/static/chunks/app/api/cloudflare/route-5133155a604f2719.js +0 -1
  299. package/dist/.next/.next/static/chunks/app/api/databases/route-63a31080b565794e.js +0 -1
  300. package/dist/.next/.next/static/chunks/app/api/databases/route-64255424877a9f72.js +0 -1
  301. package/dist/.next/.next/static/chunks/app/api/migrations/sync/route-03766b3afcf043ba.js +0 -1
  302. package/dist/.next/.next/static/chunks/app/api/migrations/sync/route-d97667565b4a59b6.js +0 -1
  303. package/dist/.next/.next/static/chunks/app/api/migrations/sync-files/route-02fa291c8000dadf.js +0 -1
  304. package/dist/.next/.next/static/chunks/app/api/migrations/sync-files/route-7089bcbfeb6b5260.js +0 -1
  305. package/dist/.next/.next/static/chunks/app/api/pull-remote/confirm/route-7e05bb8920127abe.js +0 -1
  306. package/dist/.next/.next/static/chunks/app/api/pull-remote/confirm/route-9143e6e4c3f05162.js +0 -1
  307. package/dist/.next/.next/static/chunks/app/api/pull-remote/preview/route-0fa15f783e8a306c.js +0 -1
  308. package/dist/.next/.next/static/chunks/app/api/pull-remote/preview/route-c963d143a51aed66.js +0 -1
  309. package/dist/.next/.next/static/chunks/app/api/push-remote/confirm/route-072132c0a6cb3df3.js +0 -1
  310. package/dist/.next/.next/static/chunks/app/api/push-remote/confirm/route-96691f1880e4ed14.js +0 -1
  311. package/dist/.next/.next/static/chunks/app/api/push-remote/preview/route-a798679c67374552.js +0 -1
  312. package/dist/.next/.next/static/chunks/app/api/push-remote/preview/route-ca6bf35aa72661ee.js +0 -1
  313. package/dist/.next/.next/static/chunks/app/api/query/route-1466f6b7ffd8b6c0.js +0 -1
  314. package/dist/.next/.next/static/chunks/app/api/query/route-e90d0030a5083e20.js +0 -1
  315. package/dist/.next/.next/static/chunks/app/api/tables/[name]/route-1efe63e73b480e58.js +0 -1
  316. package/dist/.next/.next/static/chunks/app/api/tables/[name]/route-898d3f85fc8544c4.js +0 -1
  317. package/dist/.next/.next/static/chunks/app/api/tables/route-3772b4f480c4b4a4.js +0 -1
  318. package/dist/.next/.next/static/chunks/app/api/tables/route-91650359fc3735cb.js +0 -1
  319. package/dist/.next/.next/static/chunks/app/api/update/route-504d663df9124f97.js +0 -1
  320. package/dist/.next/.next/static/chunks/app/layout-8360fab69b848283.js +0 -1
  321. package/dist/.next/.next/static/chunks/app/page-2c28a255a4ecd8d4.js +0 -1
  322. package/dist/.next/.next/static/chunks/app/page-3db7feef57019055.js +0 -1
  323. package/dist/.next/.next/static/chunks/app/page-79049bfa6cc07e11.js +0 -1
  324. package/dist/.next/.next/static/css/4957328384ed5c42.css +0 -3
  325. package/dist/.next/.next/static/css/cf41da7a0d47f779.css +0 -3
  326. package/dist/.next/.next/static/gc8l1G6KXOeLLOM7VJip6/_buildManifest.js +0 -1
  327. package/dist/.next/.next/static/kYsJoni86CJWDuTkc1xU6/_buildManifest.js +0 -1
  328. package/dist/.next/.next/static/scC5qwQC9H7rR1groM0Q-/_buildManifest.js +0 -1
  329. package/dist/.next/.next/static/scC5qwQC9H7rR1groM0Q-/_ssgManifest.js +0 -1
  330. package/dist/.next/.next/static/tEHOI_-t-iqfJClNzuo9m/_buildManifest.js +0 -1
  331. package/dist/.next/.next/static/tEHOI_-t-iqfJClNzuo9m/_ssgManifest.js +0 -1
  332. package/dist/.next/.next/static/vin2VQs5pM_dH2e2_I7AN/_buildManifest.js +0 -1
  333. package/dist/.next/.next/static/vin2VQs5pM_dH2e2_I7AN/_ssgManifest.js +0 -1
  334. package/dist/.next/.next/static/wHKwQhaxin5_i06GFVDHb/_buildManifest.js +0 -1
  335. package/dist/.next/.next/static/wHKwQhaxin5_i06GFVDHb/_ssgManifest.js +0 -1
  336. package/dist/.next/.next/static/xW4MspD8XibrhXDi_q2IO/_buildManifest.js +0 -1
  337. package/dist/.next/.next/static/xW4MspD8XibrhXDi_q2IO/_ssgManifest.js +0 -1
  338. package/dist/.next/server/chunks/336.js +0 -1
  339. package/dist/.next/server/chunks/686.js +0 -23
  340. package/dist/.next/server/chunks/801.js +0 -55
  341. package/dist/.next/static/ZwNOdZJ0LOtE0AJMNWwzY/_buildManifest.js +0 -1
  342. package/dist/.next/static/ZwNOdZJ0LOtE0AJMNWwzY/_ssgManifest.js +0 -1
  343. package/dist/.next/static/chunks/422-6fa3c14fc64ad67b.js +0 -1
  344. package/dist/.next/static/chunks/app/api/cloudflare/route-3458d78022185d7f.js +0 -1
  345. package/dist/.next/static/chunks/app/api/databases/route-64255424877a9f72.js +0 -1
  346. package/dist/.next/static/chunks/app/api/migrations/sync/route-03766b3afcf043ba.js +0 -1
  347. package/dist/.next/static/chunks/app/api/migrations/sync-files/route-02fa291c8000dadf.js +0 -1
  348. package/dist/.next/static/chunks/app/api/pull-remote/confirm/route-7e05bb8920127abe.js +0 -1
  349. package/dist/.next/static/chunks/app/api/pull-remote/preview/route-0fa15f783e8a306c.js +0 -1
  350. package/dist/.next/static/chunks/app/api/push-remote/confirm/route-96691f1880e4ed14.js +0 -1
  351. package/dist/.next/static/chunks/app/api/push-remote/preview/route-a798679c67374552.js +0 -1
  352. package/dist/.next/static/chunks/app/api/query/route-e90d0030a5083e20.js +0 -1
  353. package/dist/.next/static/chunks/app/api/tables/[name]/route-1efe63e73b480e58.js +0 -1
  354. package/dist/.next/static/chunks/app/api/tables/route-3772b4f480c4b4a4.js +0 -1
  355. package/dist/.next/static/chunks/app/layout-8360fab69b848283.js +0 -1
  356. package/dist/.next/static/chunks/app/page-79049bfa6cc07e11.js +0 -1
  357. package/dist/.next/static/css/cf41da7a0d47f779.css +0 -3
  358. /package/dist/.next/.next/static/{IWRJZhjf8U8mjzz4h0VNE → 5dBGGUmK5q7of4h5Rahrg}/_ssgManifest.js +0 -0
  359. /package/dist/.next/.next/static/{JrwgdSDcipr0Zh7k19Cj_ → PflNFnmFsNegSqhzjI6lA}/_ssgManifest.js +0 -0
  360. /package/dist/.next/.next/static/{gc8l1G6KXOeLLOM7VJip6 → p8875OZM4iDNsPzmoyLe7}/_ssgManifest.js +0 -0
  361. /package/dist/.next/{.next/static/kYsJoni86CJWDuTkc1xU6 → static 2/5dBGGUmK5q7of4h5Rahrg}/_ssgManifest.js +0 -0
@@ -0,0 +1,347 @@
1
+ // File: /Users/kona/Desktop/d1studio/src/app/api/update/route.js
2
+ import * as entry from '../../../../../src/app/api/update/route.js'
3
+ import type { NextRequest } from 'next/server.js'
4
+
5
+ type TEntry = typeof import('../../../../../src/app/api/update/route.js')
6
+
7
+ type SegmentParams<T extends Object = any> = T extends Record<string, any>
8
+ ? { [K in keyof T]: T[K] extends string ? string | string[] | undefined : never }
9
+ : T
10
+
11
+ // Check that the entry is a valid entry
12
+ checkFields<Diff<{
13
+ GET?: Function
14
+ HEAD?: Function
15
+ OPTIONS?: Function
16
+ POST?: Function
17
+ PUT?: Function
18
+ DELETE?: Function
19
+ PATCH?: Function
20
+ config?: {}
21
+ generateStaticParams?: Function
22
+ revalidate?: RevalidateRange<TEntry> | false
23
+ dynamic?: 'auto' | 'force-dynamic' | 'error' | 'force-static'
24
+ dynamicParams?: boolean
25
+ fetchCache?: 'auto' | 'force-no-store' | 'only-no-store' | 'default-no-store' | 'default-cache' | 'only-cache' | 'force-cache'
26
+ preferredRegion?: 'auto' | 'global' | 'home' | string | string[]
27
+ runtime?: 'nodejs' | 'experimental-edge' | 'edge'
28
+ maxDuration?: number
29
+
30
+ }, TEntry, ''>>()
31
+
32
+ type RouteContext = { params: Promise<SegmentParams> }
33
+ // Check the prop type of the entry function
34
+ if ('GET' in entry) {
35
+ checkFields<
36
+ Diff<
37
+ ParamCheck<Request | NextRequest>,
38
+ {
39
+ __tag__: 'GET'
40
+ __param_position__: 'first'
41
+ __param_type__: FirstArg<MaybeField<TEntry, 'GET'>>
42
+ },
43
+ 'GET'
44
+ >
45
+ >()
46
+ checkFields<
47
+ Diff<
48
+ ParamCheck<RouteContext>,
49
+ {
50
+ __tag__: 'GET'
51
+ __param_position__: 'second'
52
+ __param_type__: SecondArg<MaybeField<TEntry, 'GET'>>
53
+ },
54
+ 'GET'
55
+ >
56
+ >()
57
+
58
+ checkFields<
59
+ Diff<
60
+ {
61
+ __tag__: 'GET',
62
+ __return_type__: Response | void | never | Promise<Response | void | never>
63
+ },
64
+ {
65
+ __tag__: 'GET',
66
+ __return_type__: ReturnType<MaybeField<TEntry, 'GET'>>
67
+ },
68
+ 'GET'
69
+ >
70
+ >()
71
+ }
72
+ // Check the prop type of the entry function
73
+ if ('HEAD' in entry) {
74
+ checkFields<
75
+ Diff<
76
+ ParamCheck<Request | NextRequest>,
77
+ {
78
+ __tag__: 'HEAD'
79
+ __param_position__: 'first'
80
+ __param_type__: FirstArg<MaybeField<TEntry, 'HEAD'>>
81
+ },
82
+ 'HEAD'
83
+ >
84
+ >()
85
+ checkFields<
86
+ Diff<
87
+ ParamCheck<RouteContext>,
88
+ {
89
+ __tag__: 'HEAD'
90
+ __param_position__: 'second'
91
+ __param_type__: SecondArg<MaybeField<TEntry, 'HEAD'>>
92
+ },
93
+ 'HEAD'
94
+ >
95
+ >()
96
+
97
+ checkFields<
98
+ Diff<
99
+ {
100
+ __tag__: 'HEAD',
101
+ __return_type__: Response | void | never | Promise<Response | void | never>
102
+ },
103
+ {
104
+ __tag__: 'HEAD',
105
+ __return_type__: ReturnType<MaybeField<TEntry, 'HEAD'>>
106
+ },
107
+ 'HEAD'
108
+ >
109
+ >()
110
+ }
111
+ // Check the prop type of the entry function
112
+ if ('OPTIONS' in entry) {
113
+ checkFields<
114
+ Diff<
115
+ ParamCheck<Request | NextRequest>,
116
+ {
117
+ __tag__: 'OPTIONS'
118
+ __param_position__: 'first'
119
+ __param_type__: FirstArg<MaybeField<TEntry, 'OPTIONS'>>
120
+ },
121
+ 'OPTIONS'
122
+ >
123
+ >()
124
+ checkFields<
125
+ Diff<
126
+ ParamCheck<RouteContext>,
127
+ {
128
+ __tag__: 'OPTIONS'
129
+ __param_position__: 'second'
130
+ __param_type__: SecondArg<MaybeField<TEntry, 'OPTIONS'>>
131
+ },
132
+ 'OPTIONS'
133
+ >
134
+ >()
135
+
136
+ checkFields<
137
+ Diff<
138
+ {
139
+ __tag__: 'OPTIONS',
140
+ __return_type__: Response | void | never | Promise<Response | void | never>
141
+ },
142
+ {
143
+ __tag__: 'OPTIONS',
144
+ __return_type__: ReturnType<MaybeField<TEntry, 'OPTIONS'>>
145
+ },
146
+ 'OPTIONS'
147
+ >
148
+ >()
149
+ }
150
+ // Check the prop type of the entry function
151
+ if ('POST' in entry) {
152
+ checkFields<
153
+ Diff<
154
+ ParamCheck<Request | NextRequest>,
155
+ {
156
+ __tag__: 'POST'
157
+ __param_position__: 'first'
158
+ __param_type__: FirstArg<MaybeField<TEntry, 'POST'>>
159
+ },
160
+ 'POST'
161
+ >
162
+ >()
163
+ checkFields<
164
+ Diff<
165
+ ParamCheck<RouteContext>,
166
+ {
167
+ __tag__: 'POST'
168
+ __param_position__: 'second'
169
+ __param_type__: SecondArg<MaybeField<TEntry, 'POST'>>
170
+ },
171
+ 'POST'
172
+ >
173
+ >()
174
+
175
+ checkFields<
176
+ Diff<
177
+ {
178
+ __tag__: 'POST',
179
+ __return_type__: Response | void | never | Promise<Response | void | never>
180
+ },
181
+ {
182
+ __tag__: 'POST',
183
+ __return_type__: ReturnType<MaybeField<TEntry, 'POST'>>
184
+ },
185
+ 'POST'
186
+ >
187
+ >()
188
+ }
189
+ // Check the prop type of the entry function
190
+ if ('PUT' in entry) {
191
+ checkFields<
192
+ Diff<
193
+ ParamCheck<Request | NextRequest>,
194
+ {
195
+ __tag__: 'PUT'
196
+ __param_position__: 'first'
197
+ __param_type__: FirstArg<MaybeField<TEntry, 'PUT'>>
198
+ },
199
+ 'PUT'
200
+ >
201
+ >()
202
+ checkFields<
203
+ Diff<
204
+ ParamCheck<RouteContext>,
205
+ {
206
+ __tag__: 'PUT'
207
+ __param_position__: 'second'
208
+ __param_type__: SecondArg<MaybeField<TEntry, 'PUT'>>
209
+ },
210
+ 'PUT'
211
+ >
212
+ >()
213
+
214
+ checkFields<
215
+ Diff<
216
+ {
217
+ __tag__: 'PUT',
218
+ __return_type__: Response | void | never | Promise<Response | void | never>
219
+ },
220
+ {
221
+ __tag__: 'PUT',
222
+ __return_type__: ReturnType<MaybeField<TEntry, 'PUT'>>
223
+ },
224
+ 'PUT'
225
+ >
226
+ >()
227
+ }
228
+ // Check the prop type of the entry function
229
+ if ('DELETE' in entry) {
230
+ checkFields<
231
+ Diff<
232
+ ParamCheck<Request | NextRequest>,
233
+ {
234
+ __tag__: 'DELETE'
235
+ __param_position__: 'first'
236
+ __param_type__: FirstArg<MaybeField<TEntry, 'DELETE'>>
237
+ },
238
+ 'DELETE'
239
+ >
240
+ >()
241
+ checkFields<
242
+ Diff<
243
+ ParamCheck<RouteContext>,
244
+ {
245
+ __tag__: 'DELETE'
246
+ __param_position__: 'second'
247
+ __param_type__: SecondArg<MaybeField<TEntry, 'DELETE'>>
248
+ },
249
+ 'DELETE'
250
+ >
251
+ >()
252
+
253
+ checkFields<
254
+ Diff<
255
+ {
256
+ __tag__: 'DELETE',
257
+ __return_type__: Response | void | never | Promise<Response | void | never>
258
+ },
259
+ {
260
+ __tag__: 'DELETE',
261
+ __return_type__: ReturnType<MaybeField<TEntry, 'DELETE'>>
262
+ },
263
+ 'DELETE'
264
+ >
265
+ >()
266
+ }
267
+ // Check the prop type of the entry function
268
+ if ('PATCH' in entry) {
269
+ checkFields<
270
+ Diff<
271
+ ParamCheck<Request | NextRequest>,
272
+ {
273
+ __tag__: 'PATCH'
274
+ __param_position__: 'first'
275
+ __param_type__: FirstArg<MaybeField<TEntry, 'PATCH'>>
276
+ },
277
+ 'PATCH'
278
+ >
279
+ >()
280
+ checkFields<
281
+ Diff<
282
+ ParamCheck<RouteContext>,
283
+ {
284
+ __tag__: 'PATCH'
285
+ __param_position__: 'second'
286
+ __param_type__: SecondArg<MaybeField<TEntry, 'PATCH'>>
287
+ },
288
+ 'PATCH'
289
+ >
290
+ >()
291
+
292
+ checkFields<
293
+ Diff<
294
+ {
295
+ __tag__: 'PATCH',
296
+ __return_type__: Response | void | never | Promise<Response | void | never>
297
+ },
298
+ {
299
+ __tag__: 'PATCH',
300
+ __return_type__: ReturnType<MaybeField<TEntry, 'PATCH'>>
301
+ },
302
+ 'PATCH'
303
+ >
304
+ >()
305
+ }
306
+
307
+ // Check the arguments and return type of the generateStaticParams function
308
+ if ('generateStaticParams' in entry) {
309
+ checkFields<Diff<{ params: SegmentParams }, FirstArg<MaybeField<TEntry, 'generateStaticParams'>>, 'generateStaticParams'>>()
310
+ checkFields<Diff<{ __tag__: 'generateStaticParams', __return_type__: any[] | Promise<any[]> }, { __tag__: 'generateStaticParams', __return_type__: ReturnType<MaybeField<TEntry, 'generateStaticParams'>> }>>()
311
+ }
312
+
313
+ export interface PageProps {
314
+ params?: Promise<SegmentParams>
315
+ searchParams?: Promise<any>
316
+ }
317
+ export interface LayoutProps {
318
+ children?: React.ReactNode
319
+
320
+ params?: Promise<SegmentParams>
321
+ }
322
+
323
+ // =============
324
+ // Utility types
325
+ type RevalidateRange<T> = T extends { revalidate: any } ? NonNegative<T['revalidate']> : never
326
+
327
+ // If T is unknown or any, it will be an empty {} type. Otherwise, it will be the same as Omit<T, keyof Base>.
328
+ type OmitWithTag<T, K extends keyof any, _M> = Omit<T, K>
329
+ type Diff<Base, T extends Base, Message extends string = ''> = 0 extends (1 & T) ? {} : OmitWithTag<T, keyof Base, Message>
330
+
331
+ type FirstArg<T extends Function> = T extends (...args: [infer T, any]) => any ? unknown extends T ? any : T : never
332
+ type SecondArg<T extends Function> = T extends (...args: [any, infer T]) => any ? unknown extends T ? any : T : never
333
+ type MaybeField<T, K extends string> = T extends { [k in K]: infer G } ? G extends Function ? G : never : never
334
+
335
+ type ParamCheck<T> = {
336
+ __tag__: string
337
+ __param_position__: string
338
+ __param_type__: T
339
+ }
340
+
341
+ function checkFields<_ extends { [k in keyof any]: never }>() {}
342
+
343
+ // https://github.com/sindresorhus/type-fest
344
+ type Numeric = number | bigint
345
+ type Zero = 0 | 0n
346
+ type Negative<T extends Numeric> = T extends Zero ? never : `${T}` extends `-${string}` ? T : never
347
+ type NonNegative<T extends Numeric> = T extends Zero ? T : Negative<T> extends never ? T : '__invalid_negative_number__'
@@ -1,4 +1,4 @@
1
- // File: /Users/karenredona/Desktop/d1studio/src/app/page.jsx
1
+ // File: /Users/kona/Desktop/d1studio/src/app/page.jsx
2
2
  import * as entry from '../../../src/app/page.js'
3
3
  import type { ResolvingMetadata, ResolvingViewport } from 'next/dist/lib/metadata/types/metadata-interface.js'
4
4
 
@@ -0,0 +1,230 @@
1
+ // api/pull-data/confirm/route.js
2
+
3
+ import { NextResponse } from 'next/server';
4
+ import { executeSQL } from '@/lib/sql-operations';
5
+ import { getCurrentSchema } from '@/lib/schema-operations';
6
+ import { findWranglerConfig } from '@/lib/find-wrangler-config.js';
7
+ import logger from '@/lib/logger';
8
+ import {
9
+ fetchRemoteTableData as fetchRemoteDataHelper,
10
+ generateBulkInsertSQL
11
+ } from '@/lib/sql-operations';
12
+
13
+ /**
14
+ * Helper to extract the ordering column (primary key) from a table's schema.
15
+ * Assumes that each table’s schema object contains a "columns" array with an "isPrimaryKey" flag.
16
+ *
17
+ * @param {object} tableSchema - Schema info for the table.
18
+ * @returns {string} The column name to use for ordering.
19
+ */
20
+ function getOrderingColumn(tableSchema) {
21
+ const pkColumn = tableSchema.columns?.find(col => col.isPrimaryKey);
22
+ const orderingCol = pkColumn ? pkColumn.name : 'rowid';
23
+ logger.debug(`Determined ordering column for table ${tableSchema.name || 'unknown'}: ${orderingCol}`);
24
+ return orderingCol;
25
+ }
26
+
27
+ /**
28
+ * Computes an insertion order for tables based on their foreign key dependencies.
29
+ * The returned array is sorted so that if table A is referenced by table B,
30
+ * then A appears earlier in the list.
31
+ *
32
+ * @param {Array<object>} tableSchemas - Array of table schema objects.
33
+ * @returns {Array<string>} Ordered array of table names.
34
+ */
35
+ function computeInsertionOrder(tableSchemas) {
36
+ // Build a dependency graph: key = table name, value = set of tables that this table depends on.
37
+ const graph = {};
38
+ tableSchemas.forEach(table => {
39
+ // Initialize graph for this table.
40
+ graph[table.name] = new Set();
41
+ // Use a regex to find FOREIGN KEY references in the table's SQL.
42
+ // This regex assumes the foreign key clause looks like:
43
+ // FOREIGN KEY (...) REFERENCES referencedTable(...)
44
+ const fkRegex = /FOREIGN KEY\s*\([^)]*\)\s+REFERENCES\s+(\w+)/gi;
45
+ let match;
46
+ while ((match = fkRegex.exec(table.sql)) !== null) {
47
+ const referencedTable = match[1];
48
+ graph[table.name].add(referencedTable);
49
+ }
50
+ });
51
+ logger.debug('Computed dependency graph:', graph);
52
+
53
+ // Topological sort (depth-first search) to compute insertion order.
54
+ const sorted = [];
55
+ const visited = {}; // 'temp' = visiting, 'perm' = done
56
+
57
+ function visit(tableName) {
58
+ if (visited[tableName] === 'temp') {
59
+ throw new Error(`Cycle detected in dependencies at table ${tableName}`);
60
+ }
61
+ if (!visited[tableName]) {
62
+ visited[tableName] = 'temp';
63
+ // Visit all tables that this table depends on.
64
+ graph[tableName].forEach(dep => {
65
+ // Only visit if the dependency is in our graph (i.e. among our tables)
66
+ if (graph[dep]) {
67
+ visit(dep);
68
+ }
69
+ });
70
+ visited[tableName] = 'perm';
71
+ sorted.push(tableName);
72
+ }
73
+ }
74
+
75
+ Object.keys(graph).forEach(tableName => {
76
+ if (!visited[tableName]) {
77
+ visit(tableName);
78
+ }
79
+ });
80
+
81
+ logger.debug('Computed insertion order (parent tables first):', sorted);
82
+ return sorted;
83
+ }
84
+
85
+ /**
86
+ * Applies the data pull by:
87
+ * 1. Fetching the local schema to determine table names and primary keys.
88
+ * 2. Computing the insertion order so that parent tables are inserted before child tables.
89
+ * 3. For each table (in insertion order), fetching the latest 100 records from the remote database.
90
+ * 4. Generating a bulk insert statement and executing it.
91
+ *
92
+ * This function aborts the entire process if any insert fails.
93
+ *
94
+ * @param {string} projectDir
95
+ * @param {string} accountId
96
+ * @param {string} apiToken
97
+ * @param {string} databaseName
98
+ * @returns {object} Details of data pulled.
99
+ */
100
+ async function applyDataPull(projectDir, accountId, apiToken, databaseName) {
101
+ logger.debug('Starting data pull process...');
102
+ const env = {
103
+ ...process.env,
104
+ CLOUDFLARE_API_TOKEN: apiToken,
105
+ CLOUDFLARE_ACCOUNT_ID: accountId
106
+ };
107
+
108
+ logger.debug('Fetching current schema for data pull...');
109
+ const currentSchema = await getCurrentSchema(projectDir, databaseName, env, false);
110
+ // Filter for table objects that have a name.
111
+ const tableSchemas = currentSchema.filter(obj => obj.type === 'table' && obj.name);
112
+ logger.debug('Local table schema for data pull:', tableSchemas.map(t => t.name));
113
+
114
+ // Compute insertion order based on foreign key dependencies.
115
+ const insertionOrder = computeInsertionOrder(tableSchemas);
116
+ logger.debug('Final computed insertion order:', insertionOrder);
117
+
118
+ // Process each table in the computed insertion order.
119
+ for (const tableName of insertionOrder) {
120
+ const table = tableSchemas.find(t => t.name === tableName);
121
+ if (!table) {
122
+ logger.debug(`Skipping table ${tableName} as it is not in the current schema list.`);
123
+ continue;
124
+ }
125
+ logger.debug(`Processing table: ${tableName}`);
126
+ const orderingColumn = getOrderingColumn(table);
127
+ logger.debug(`Fetching data for table: ${tableName} ordered by ${orderingColumn}`);
128
+
129
+ // Fetch remote data.
130
+ const rows = await fetchRemoteDataHelper(
131
+ projectDir,
132
+ databaseName,
133
+ tableName,
134
+ env,
135
+ 75,
136
+ orderingColumn
137
+ );
138
+ logger.debug(`Fetched ${rows.length} records for table: ${tableName}`);
139
+
140
+ if (rows.length > 0) {
141
+ const insertSQL = generateBulkInsertSQL(tableName, rows);
142
+ logger.debug(`Generated bulk insert SQL for ${tableName}: ${insertSQL}`);
143
+
144
+ try {
145
+ // Execute the insert SQL directly.
146
+ await executeSQL(projectDir, databaseName, insertSQL, env, false);
147
+ logger.debug(`Bulk inserted ${rows.length} records into table: ${tableName}`);
148
+ } catch (insertError) {
149
+ logger.error(`Error inserting data into table ${tableName}:`, insertError);
150
+ // Abort the entire process to preserve data integrity.
151
+ throw new Error(`Data pull failed for table ${tableName}: ${insertError.message}`);
152
+ }
153
+ } else {
154
+ logger.debug(`No data fetched for table: ${tableName}`);
155
+ }
156
+ }
157
+ logger.debug('Data pull process completed successfully.');
158
+ return { message: 'All data pulled successfully.' };
159
+ }
160
+
161
+ export async function POST(req) {
162
+ try {
163
+ logger.debug('Received request for data pull.');
164
+ const { accountId, apiToken } = await req.json();
165
+ const projectDir = process.env.D1_PROJECT_DIR;
166
+ if (!projectDir) {
167
+ return NextResponse.json(
168
+ {
169
+ success: false,
170
+ error: {
171
+ type: 'VALIDATION_ERROR',
172
+ message: 'Project directory not configured'
173
+ }
174
+ },
175
+ { status: 500 }
176
+ );
177
+ }
178
+ const wranglerResult = await findWranglerConfig(projectDir);
179
+ if (!wranglerResult || !wranglerResult.config) {
180
+ return NextResponse.json(
181
+ {
182
+ success: false,
183
+ error: {
184
+ type: 'VALIDATION_ERROR',
185
+ message: 'Could not find Wrangler configuration'
186
+ }
187
+ },
188
+ { status: 400 }
189
+ );
190
+ }
191
+ const config = wranglerResult.config;
192
+ if (!config.d1_databases?.length) {
193
+ return NextResponse.json(
194
+ {
195
+ success: false,
196
+ error: {
197
+ type: 'VALIDATION_ERROR',
198
+ message: 'No D1 databases configured'
199
+ }
200
+ },
201
+ { status: 400 }
202
+ );
203
+ }
204
+ const databaseName = config.d1_databases[0].database_name;
205
+ logger.debug(`Initiating data pull for database: ${databaseName}`);
206
+ const result = await applyDataPull(projectDir, accountId, apiToken, databaseName);
207
+ logger.debug('Data pull result:', result);
208
+ return NextResponse.json({
209
+ success: true,
210
+ message: result.message,
211
+ details: result
212
+ });
213
+ } catch (error) {
214
+ logger.error('Pull data confirm error:', error);
215
+ return NextResponse.json(
216
+ {
217
+ success: false,
218
+ error: {
219
+ type: error.type || 'EXECUTION_ERROR',
220
+ message: error.message || 'Failed to apply data pull'
221
+ }
222
+ },
223
+ { status: 500 }
224
+ );
225
+ }
226
+ }
227
+
228
+ export async function OPTIONS() {
229
+ return new NextResponse(null, { status: 204 });
230
+ }
@@ -0,0 +1,45 @@
1
+ // app/api/update/route.js
2
+ import { NextResponse } from 'next/server';
3
+ import pkg from '../../../../package.json' assert { type: 'json' };
4
+
5
+ export async function GET() {
6
+ try {
7
+ // Get current version from package.json
8
+ const currentVersion = pkg.version;
9
+
10
+ // Fetch the latest version from npm registry
11
+ const response = await fetch('https://registry.npmjs.org/d1s/latest', {
12
+ headers: {
13
+ 'Accept': 'application/json',
14
+ 'User-Agent': 'd1-studio'
15
+ },
16
+ // Add cache control to prevent excessive requests
17
+ cache: 'no-cache'
18
+ });
19
+
20
+ if (!response.ok) {
21
+ throw new Error('Failed to check for updates');
22
+ }
23
+
24
+ const data = await response.json();
25
+ const latestVersion = data.version;
26
+
27
+ // Compare versions - only return update info if there's a newer version
28
+ if (latestVersion && currentVersion && latestVersion !== currentVersion) {
29
+ console.log(`Update available: ${currentVersion} → ${latestVersion}`);
30
+ return NextResponse.json({
31
+ update: {
32
+ latest: latestVersion,
33
+ current: currentVersion
34
+ }
35
+ });
36
+ }
37
+
38
+ // No update available
39
+ return NextResponse.json({ update: null });
40
+ } catch (error) {
41
+ console.error('Error checking for updates:', error);
42
+ // Return null on error to prevent banner from showing
43
+ return NextResponse.json({ update: null });
44
+ }
45
+ }