alchemy 0.67.0 → 0.68.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 (750) hide show
  1. package/bin/alchemy.js +25563 -26265
  2. package/bin/alchemy.ts +6 -2
  3. package/bin/commands/configure.ts +194 -0
  4. package/bin/commands/login.ts +99 -55
  5. package/bin/commands/logout.ts +66 -0
  6. package/bin/trpc.ts +27 -2
  7. package/lib/apply.d.ts +2 -2
  8. package/lib/apply.d.ts.map +1 -1
  9. package/lib/apply.js +18 -15
  10. package/lib/apply.js.map +1 -1
  11. package/lib/auth.d.ts +72 -0
  12. package/lib/auth.d.ts.map +1 -0
  13. package/lib/auth.js +163 -0
  14. package/lib/auth.js.map +1 -0
  15. package/lib/aws/bucket.d.ts +12 -3
  16. package/lib/aws/bucket.d.ts.map +1 -1
  17. package/lib/aws/bucket.js +2 -2
  18. package/lib/aws/bucket.js.map +1 -1
  19. package/lib/aws/control/resource.d.ts +34 -3
  20. package/lib/aws/control/resource.d.ts.map +1 -1
  21. package/lib/aws/control/resource.js +3 -3
  22. package/lib/aws/control/resource.js.map +1 -1
  23. package/lib/aws/ec2/internet-gateway-attachment.d.ts +1 -2
  24. package/lib/aws/ec2/internet-gateway-attachment.d.ts.map +1 -1
  25. package/lib/aws/ec2/internet-gateway-attachment.js +4 -4
  26. package/lib/aws/ec2/internet-gateway-attachment.js.map +1 -1
  27. package/lib/aws/ec2/internet-gateway.d.ts +1 -2
  28. package/lib/aws/ec2/internet-gateway.d.ts.map +1 -1
  29. package/lib/aws/ec2/internet-gateway.js +2 -2
  30. package/lib/aws/ec2/internet-gateway.js.map +1 -1
  31. package/lib/aws/ec2/nat-gateway.d.ts +1 -2
  32. package/lib/aws/ec2/nat-gateway.d.ts.map +1 -1
  33. package/lib/aws/ec2/nat-gateway.js +2 -2
  34. package/lib/aws/ec2/nat-gateway.js.map +1 -1
  35. package/lib/aws/ec2/route-table-association.d.ts +1 -2
  36. package/lib/aws/ec2/route-table-association.d.ts.map +1 -1
  37. package/lib/aws/ec2/route-table-association.js +2 -2
  38. package/lib/aws/ec2/route-table-association.js.map +1 -1
  39. package/lib/aws/ec2/route-table.d.ts +1 -2
  40. package/lib/aws/ec2/route-table.d.ts.map +1 -1
  41. package/lib/aws/ec2/route-table.js +2 -2
  42. package/lib/aws/ec2/route-table.js.map +1 -1
  43. package/lib/aws/ec2/route.d.ts +1 -2
  44. package/lib/aws/ec2/route.d.ts.map +1 -1
  45. package/lib/aws/ec2/route.js +2 -2
  46. package/lib/aws/ec2/route.js.map +1 -1
  47. package/lib/aws/ec2/security-group-rule.d.ts +1 -2
  48. package/lib/aws/ec2/security-group-rule.d.ts.map +1 -1
  49. package/lib/aws/ec2/security-group-rule.js +2 -2
  50. package/lib/aws/ec2/security-group-rule.js.map +1 -1
  51. package/lib/aws/ec2/security-group.d.ts +1 -2
  52. package/lib/aws/ec2/security-group.d.ts.map +1 -1
  53. package/lib/aws/ec2/security-group.js +2 -2
  54. package/lib/aws/ec2/security-group.js.map +1 -1
  55. package/lib/aws/ec2/subnet.d.ts +1 -2
  56. package/lib/aws/ec2/subnet.d.ts.map +1 -1
  57. package/lib/aws/ec2/subnet.js +2 -2
  58. package/lib/aws/ec2/subnet.js.map +1 -1
  59. package/lib/aws/ec2/vpc.d.ts +1 -2
  60. package/lib/aws/ec2/vpc.d.ts.map +1 -1
  61. package/lib/aws/ec2/vpc.js +2 -2
  62. package/lib/aws/ec2/vpc.js.map +1 -1
  63. package/lib/aws/function.d.ts +116 -3
  64. package/lib/aws/function.d.ts.map +1 -1
  65. package/lib/aws/function.js +2 -2
  66. package/lib/aws/function.js.map +1 -1
  67. package/lib/aws/oidc/github-oidc-provider.d.ts +13 -2
  68. package/lib/aws/oidc/github-oidc-provider.d.ts.map +1 -1
  69. package/lib/aws/oidc/oidc-provider.d.ts +48 -3
  70. package/lib/aws/oidc/oidc-provider.d.ts.map +1 -1
  71. package/lib/aws/oidc/oidc-provider.js +2 -2
  72. package/lib/aws/oidc/oidc-provider.js.map +1 -1
  73. package/lib/aws/policy-attachment.d.ts +2 -3
  74. package/lib/aws/policy-attachment.d.ts.map +1 -1
  75. package/lib/aws/policy-attachment.js +1 -1
  76. package/lib/aws/policy-attachment.js.map +1 -1
  77. package/lib/aws/policy.d.ts +1 -2
  78. package/lib/aws/policy.d.ts.map +1 -1
  79. package/lib/aws/policy.js +4 -4
  80. package/lib/aws/policy.js.map +1 -1
  81. package/lib/aws/queue.d.ts +1 -2
  82. package/lib/aws/queue.d.ts.map +1 -1
  83. package/lib/aws/queue.js +4 -4
  84. package/lib/aws/queue.js.map +1 -1
  85. package/lib/aws/role.d.ts +1 -2
  86. package/lib/aws/role.d.ts.map +1 -1
  87. package/lib/aws/role.js +2 -2
  88. package/lib/aws/role.js.map +1 -1
  89. package/lib/aws/ses.d.ts +1 -2
  90. package/lib/aws/ses.d.ts.map +1 -1
  91. package/lib/aws/ses.js +2 -2
  92. package/lib/aws/ses.js.map +1 -1
  93. package/lib/aws/ssm-parameter.d.ts +1 -2
  94. package/lib/aws/ssm-parameter.d.ts.map +1 -1
  95. package/lib/aws/ssm-parameter.js +2 -2
  96. package/lib/aws/ssm-parameter.js.map +1 -1
  97. package/lib/aws/table.d.ts +1 -2
  98. package/lib/aws/table.d.ts.map +1 -1
  99. package/lib/aws/table.js +2 -2
  100. package/lib/aws/table.js.map +1 -1
  101. package/lib/cloudflare/account-api-token.d.ts +1 -2
  102. package/lib/cloudflare/account-api-token.d.ts.map +1 -1
  103. package/lib/cloudflare/account-api-token.js +2 -2
  104. package/lib/cloudflare/account-api-token.js.map +1 -1
  105. package/lib/cloudflare/ai-gateway.d.ts +1 -2
  106. package/lib/cloudflare/ai-gateway.d.ts.map +1 -1
  107. package/lib/cloudflare/ai-gateway.js +2 -2
  108. package/lib/cloudflare/ai-gateway.js.map +1 -1
  109. package/lib/cloudflare/api-gateway-operation.d.ts +1 -2
  110. package/lib/cloudflare/api-gateway-operation.d.ts.map +1 -1
  111. package/lib/cloudflare/api-gateway-operation.js +2 -2
  112. package/lib/cloudflare/api-gateway-operation.js.map +1 -1
  113. package/lib/cloudflare/api-schema.d.ts +1 -2
  114. package/lib/cloudflare/api-schema.d.ts.map +1 -1
  115. package/lib/cloudflare/api-schema.js +2 -2
  116. package/lib/cloudflare/api-schema.js.map +1 -1
  117. package/lib/cloudflare/api-shield.d.ts +1 -2
  118. package/lib/cloudflare/api-shield.d.ts.map +1 -1
  119. package/lib/cloudflare/api-shield.js +2 -2
  120. package/lib/cloudflare/api-shield.js.map +1 -1
  121. package/lib/cloudflare/api.d.ts +18 -10
  122. package/lib/cloudflare/api.d.ts.map +1 -1
  123. package/lib/cloudflare/api.js +93 -38
  124. package/lib/cloudflare/api.js.map +1 -1
  125. package/lib/cloudflare/assets.d.ts +21 -43
  126. package/lib/cloudflare/assets.d.ts.map +1 -1
  127. package/lib/cloudflare/assets.js +78 -70
  128. package/lib/cloudflare/assets.js.map +1 -1
  129. package/lib/cloudflare/auth.d.ts +91 -17
  130. package/lib/cloudflare/auth.d.ts.map +1 -1
  131. package/lib/cloudflare/auth.js +141 -62
  132. package/lib/cloudflare/auth.js.map +1 -1
  133. package/lib/cloudflare/bound.d.ts +1 -1
  134. package/lib/cloudflare/bound.d.ts.map +1 -1
  135. package/lib/cloudflare/bucket.d.ts +60 -8
  136. package/lib/cloudflare/bucket.d.ts.map +1 -1
  137. package/lib/cloudflare/bucket.js +161 -18
  138. package/lib/cloudflare/bucket.js.map +1 -1
  139. package/lib/cloudflare/bundle/plugin-wasm.js +4 -2
  140. package/lib/cloudflare/bundle/plugin-wasm.js.map +1 -1
  141. package/lib/cloudflare/certificate-pack.d.ts +1 -2
  142. package/lib/cloudflare/certificate-pack.d.ts.map +1 -1
  143. package/lib/cloudflare/certificate-pack.js +4 -4
  144. package/lib/cloudflare/certificate-pack.js.map +1 -1
  145. package/lib/cloudflare/compatibility-date.gen.d.ts +1 -1
  146. package/lib/cloudflare/compatibility-date.gen.js +1 -1
  147. package/lib/cloudflare/container.d.ts +1 -2
  148. package/lib/cloudflare/container.d.ts.map +1 -1
  149. package/lib/cloudflare/container.js +6 -6
  150. package/lib/cloudflare/container.js.map +1 -1
  151. package/lib/cloudflare/custom-domain.d.ts +1 -2
  152. package/lib/cloudflare/custom-domain.d.ts.map +1 -1
  153. package/lib/cloudflare/custom-domain.js +2 -2
  154. package/lib/cloudflare/custom-domain.js.map +1 -1
  155. package/lib/cloudflare/d1-database.d.ts +2 -3
  156. package/lib/cloudflare/d1-database.d.ts.map +1 -1
  157. package/lib/cloudflare/d1-database.js +5 -5
  158. package/lib/cloudflare/d1-database.js.map +1 -1
  159. package/lib/cloudflare/dispatch-namespace.d.ts +2 -3
  160. package/lib/cloudflare/dispatch-namespace.d.ts.map +1 -1
  161. package/lib/cloudflare/dispatch-namespace.js +3 -3
  162. package/lib/cloudflare/dispatch-namespace.js.map +1 -1
  163. package/lib/cloudflare/dns-records.d.ts +1 -2
  164. package/lib/cloudflare/dns-records.d.ts.map +1 -1
  165. package/lib/cloudflare/dns-records.js +4 -4
  166. package/lib/cloudflare/dns-records.js.map +1 -1
  167. package/lib/cloudflare/email-address.d.ts +1 -2
  168. package/lib/cloudflare/email-address.d.ts.map +1 -1
  169. package/lib/cloudflare/email-address.js +6 -6
  170. package/lib/cloudflare/email-address.js.map +1 -1
  171. package/lib/cloudflare/email-catch-all.d.ts +1 -2
  172. package/lib/cloudflare/email-catch-all.d.ts.map +1 -1
  173. package/lib/cloudflare/email-catch-all.js +4 -4
  174. package/lib/cloudflare/email-catch-all.js.map +1 -1
  175. package/lib/cloudflare/email-routing.d.ts +1 -2
  176. package/lib/cloudflare/email-routing.d.ts.map +1 -1
  177. package/lib/cloudflare/email-routing.js +4 -4
  178. package/lib/cloudflare/email-routing.js.map +1 -1
  179. package/lib/cloudflare/email-rule.d.ts +1 -2
  180. package/lib/cloudflare/email-rule.d.ts.map +1 -1
  181. package/lib/cloudflare/email-rule.js +4 -4
  182. package/lib/cloudflare/email-rule.js.map +1 -1
  183. package/lib/cloudflare/hyperdrive.d.ts +1 -2
  184. package/lib/cloudflare/hyperdrive.d.ts.map +1 -1
  185. package/lib/cloudflare/hyperdrive.js +4 -4
  186. package/lib/cloudflare/hyperdrive.js.map +1 -1
  187. package/lib/cloudflare/kv-namespace.d.ts +2 -3
  188. package/lib/cloudflare/kv-namespace.d.ts.map +1 -1
  189. package/lib/cloudflare/kv-namespace.js +5 -5
  190. package/lib/cloudflare/kv-namespace.js.map +1 -1
  191. package/lib/cloudflare/miniflare/delete.js +1 -1
  192. package/lib/cloudflare/miniflare/delete.js.map +1 -1
  193. package/lib/cloudflare/miniflare/miniflare-worker-proxy.d.ts.map +1 -1
  194. package/lib/cloudflare/miniflare/miniflare-worker-proxy.js +2 -7
  195. package/lib/cloudflare/miniflare/miniflare-worker-proxy.js.map +1 -1
  196. package/lib/cloudflare/miniflare/remote-binding-proxy.d.ts.map +1 -1
  197. package/lib/cloudflare/miniflare/remote-binding-proxy.js +15 -4
  198. package/lib/cloudflare/miniflare/remote-binding-proxy.js.map +1 -1
  199. package/lib/cloudflare/permission-groups.d.ts +1 -2
  200. package/lib/cloudflare/permission-groups.d.ts.map +1 -1
  201. package/lib/cloudflare/permission-groups.js +1 -1
  202. package/lib/cloudflare/permission-groups.js.map +1 -1
  203. package/lib/cloudflare/pipeline.d.ts +2 -3
  204. package/lib/cloudflare/pipeline.d.ts.map +1 -1
  205. package/lib/cloudflare/pipeline.js +5 -5
  206. package/lib/cloudflare/pipeline.js.map +1 -1
  207. package/lib/cloudflare/queue-consumer.d.ts +1 -2
  208. package/lib/cloudflare/queue-consumer.d.ts.map +1 -1
  209. package/lib/cloudflare/queue-consumer.js +4 -4
  210. package/lib/cloudflare/queue-consumer.js.map +1 -1
  211. package/lib/cloudflare/queue.d.ts +1 -2
  212. package/lib/cloudflare/queue.d.ts.map +1 -1
  213. package/lib/cloudflare/queue.js +4 -4
  214. package/lib/cloudflare/queue.js.map +1 -1
  215. package/lib/cloudflare/react-router/plugin.d.ts.map +1 -1
  216. package/lib/cloudflare/react-router/plugin.js +13 -0
  217. package/lib/cloudflare/react-router/plugin.js.map +1 -1
  218. package/lib/cloudflare/redirect-rule.d.ts +1 -2
  219. package/lib/cloudflare/redirect-rule.d.ts.map +1 -1
  220. package/lib/cloudflare/redirect-rule.js +4 -4
  221. package/lib/cloudflare/redirect-rule.js.map +1 -1
  222. package/lib/cloudflare/route.d.ts +1 -2
  223. package/lib/cloudflare/route.d.ts.map +1 -1
  224. package/lib/cloudflare/route.js +4 -4
  225. package/lib/cloudflare/route.js.map +1 -1
  226. package/lib/cloudflare/ruleset.d.ts +1 -2
  227. package/lib/cloudflare/ruleset.d.ts.map +1 -1
  228. package/lib/cloudflare/ruleset.js +2 -2
  229. package/lib/cloudflare/ruleset.js.map +1 -1
  230. package/lib/cloudflare/secret.d.ts +2 -3
  231. package/lib/cloudflare/secret.d.ts.map +1 -1
  232. package/lib/cloudflare/secret.js +3 -3
  233. package/lib/cloudflare/secret.js.map +1 -1
  234. package/lib/cloudflare/secrets-store.d.ts +2 -3
  235. package/lib/cloudflare/secrets-store.d.ts.map +1 -1
  236. package/lib/cloudflare/secrets-store.js +3 -3
  237. package/lib/cloudflare/secrets-store.js.map +1 -1
  238. package/lib/cloudflare/tunnel.d.ts +2 -3
  239. package/lib/cloudflare/tunnel.d.ts.map +1 -1
  240. package/lib/cloudflare/tunnel.js +3 -3
  241. package/lib/cloudflare/tunnel.js.map +1 -1
  242. package/lib/cloudflare/user.d.ts +3 -2
  243. package/lib/cloudflare/user.d.ts.map +1 -1
  244. package/lib/cloudflare/user.js +7 -5
  245. package/lib/cloudflare/user.js.map +1 -1
  246. package/lib/cloudflare/vectorize-index.d.ts +2 -3
  247. package/lib/cloudflare/vectorize-index.d.ts.map +1 -1
  248. package/lib/cloudflare/vectorize-index.js +6 -6
  249. package/lib/cloudflare/vectorize-index.js.map +1 -1
  250. package/lib/cloudflare/vectorize-metadata-index.d.ts +2 -3
  251. package/lib/cloudflare/vectorize-metadata-index.d.ts.map +1 -1
  252. package/lib/cloudflare/vectorize-metadata-index.js +4 -4
  253. package/lib/cloudflare/vectorize-metadata-index.js.map +1 -1
  254. package/lib/cloudflare/website.js +1 -1
  255. package/lib/cloudflare/website.js.map +1 -1
  256. package/lib/cloudflare/worker-assets.d.ts +1 -29
  257. package/lib/cloudflare/worker-assets.d.ts.map +1 -1
  258. package/lib/cloudflare/worker-assets.js +9 -42
  259. package/lib/cloudflare/worker-assets.js.map +1 -1
  260. package/lib/cloudflare/worker-stub.d.ts +2 -3
  261. package/lib/cloudflare/worker-stub.d.ts.map +1 -1
  262. package/lib/cloudflare/worker-stub.js +3 -3
  263. package/lib/cloudflare/worker-stub.js.map +1 -1
  264. package/lib/cloudflare/worker-subdomain.d.ts +4 -3
  265. package/lib/cloudflare/worker-subdomain.d.ts.map +1 -1
  266. package/lib/cloudflare/worker-subdomain.js +5 -5
  267. package/lib/cloudflare/worker-subdomain.js.map +1 -1
  268. package/lib/cloudflare/worker.d.ts +3 -4
  269. package/lib/cloudflare/worker.d.ts.map +1 -1
  270. package/lib/cloudflare/worker.js +6 -5
  271. package/lib/cloudflare/worker.js.map +1 -1
  272. package/lib/cloudflare/zone.d.ts +1 -2
  273. package/lib/cloudflare/zone.d.ts.map +1 -1
  274. package/lib/cloudflare/zone.js +2 -2
  275. package/lib/cloudflare/zone.js.map +1 -1
  276. package/lib/context.d.ts +8 -8
  277. package/lib/context.d.ts.map +1 -1
  278. package/lib/context.js.map +1 -1
  279. package/lib/destroy.d.ts +1 -1
  280. package/lib/destroy.d.ts.map +1 -1
  281. package/lib/destroy.js.map +1 -1
  282. package/lib/dns/import-dns.d.ts +1 -2
  283. package/lib/dns/import-dns.d.ts.map +1 -1
  284. package/lib/dns/import-dns.js +2 -2
  285. package/lib/dns/import-dns.js.map +1 -1
  286. package/lib/docker/container.d.ts +1 -2
  287. package/lib/docker/container.d.ts.map +1 -1
  288. package/lib/docker/container.js +2 -3
  289. package/lib/docker/container.js.map +1 -1
  290. package/lib/docker/image.d.ts +1 -2
  291. package/lib/docker/image.d.ts.map +1 -1
  292. package/lib/docker/image.js +9 -9
  293. package/lib/docker/image.js.map +1 -1
  294. package/lib/docker/network.d.ts +1 -2
  295. package/lib/docker/network.d.ts.map +1 -1
  296. package/lib/docker/network.js +2 -3
  297. package/lib/docker/network.js.map +1 -1
  298. package/lib/docker/remote-image.d.ts +1 -2
  299. package/lib/docker/remote-image.d.ts.map +1 -1
  300. package/lib/docker/remote-image.js +2 -3
  301. package/lib/docker/remote-image.js.map +1 -1
  302. package/lib/docker/volume.d.ts +1 -2
  303. package/lib/docker/volume.d.ts.map +1 -1
  304. package/lib/docker/volume.js +2 -3
  305. package/lib/docker/volume.js.map +1 -1
  306. package/lib/esbuild/bundle.d.ts +1 -2
  307. package/lib/esbuild/bundle.d.ts.map +1 -1
  308. package/lib/esbuild/bundle.js +4 -4
  309. package/lib/esbuild/bundle.js.map +1 -1
  310. package/lib/fs/copy-file.d.ts +1 -2
  311. package/lib/fs/copy-file.d.ts.map +1 -1
  312. package/lib/fs/copy-file.js +2 -2
  313. package/lib/fs/copy-file.js.map +1 -1
  314. package/lib/fs/file.d.ts +1 -2
  315. package/lib/fs/file.d.ts.map +1 -1
  316. package/lib/fs/file.js +2 -2
  317. package/lib/fs/file.js.map +1 -1
  318. package/lib/fs/folder.d.ts +1 -2
  319. package/lib/fs/folder.d.ts.map +1 -1
  320. package/lib/fs/folder.js +2 -2
  321. package/lib/fs/folder.js.map +1 -1
  322. package/lib/github/comment.d.ts +1 -2
  323. package/lib/github/comment.d.ts.map +1 -1
  324. package/lib/github/comment.js +4 -4
  325. package/lib/github/comment.js.map +1 -1
  326. package/lib/github/repository-environment.d.ts +1 -2
  327. package/lib/github/repository-environment.d.ts.map +1 -1
  328. package/lib/github/repository-environment.js +2 -2
  329. package/lib/github/repository-environment.js.map +1 -1
  330. package/lib/github/repository-webhook.d.ts +1 -2
  331. package/lib/github/repository-webhook.d.ts.map +1 -1
  332. package/lib/github/repository-webhook.js +2 -2
  333. package/lib/github/repository-webhook.js.map +1 -1
  334. package/lib/github/secret.d.ts +1 -2
  335. package/lib/github/secret.d.ts.map +1 -1
  336. package/lib/github/secret.js +2 -2
  337. package/lib/github/secret.js.map +1 -1
  338. package/lib/neon/api/client.gen.d.ts +13 -0
  339. package/lib/neon/api/client.gen.d.ts.map +1 -0
  340. package/lib/neon/api/client.gen.js +7 -0
  341. package/lib/neon/api/client.gen.js.map +1 -0
  342. package/lib/neon/api/sdk.gen.d.ts +880 -0
  343. package/lib/neon/api/sdk.gen.d.ts.map +1 -0
  344. package/lib/neon/api/sdk.gen.js +1527 -0
  345. package/lib/neon/api/sdk.gen.js.map +1 -0
  346. package/lib/neon/api/types.gen.d.ts +7250 -0
  347. package/lib/neon/api/types.gen.d.ts.map +1 -0
  348. package/lib/neon/api/types.gen.js +2 -0
  349. package/lib/neon/api/types.gen.js.map +1 -0
  350. package/lib/neon/api.d.ts +14 -49
  351. package/lib/neon/api.d.ts.map +1 -1
  352. package/lib/neon/api.js +36 -114
  353. package/lib/neon/api.js.map +1 -1
  354. package/lib/neon/branch.d.ts +141 -0
  355. package/lib/neon/branch.d.ts.map +1 -0
  356. package/lib/neon/branch.js +112 -0
  357. package/lib/neon/branch.js.map +1 -0
  358. package/lib/neon/index.d.ts +1 -1
  359. package/lib/neon/index.d.ts.map +1 -1
  360. package/lib/neon/index.js +1 -1
  361. package/lib/neon/index.js.map +1 -1
  362. package/lib/neon/project.d.ts +32 -242
  363. package/lib/neon/project.d.ts.map +1 -1
  364. package/lib/neon/project.js +90 -269
  365. package/lib/neon/project.js.map +1 -1
  366. package/lib/neon/utils.d.ts +49 -0
  367. package/lib/neon/utils.d.ts.map +1 -0
  368. package/lib/neon/utils.js +44 -0
  369. package/lib/neon/utils.js.map +1 -0
  370. package/lib/os/exec.d.ts +1 -2
  371. package/lib/os/exec.d.ts.map +1 -1
  372. package/lib/os/exec.js +2 -2
  373. package/lib/os/exec.js.map +1 -1
  374. package/lib/planetscale/api/client.gen.d.ts +12 -1749
  375. package/lib/planetscale/api/client.gen.d.ts.map +1 -1
  376. package/lib/planetscale/api/client.gen.js +6 -2400
  377. package/lib/planetscale/api/client.gen.js.map +1 -1
  378. package/lib/planetscale/api/sdk.gen.d.ts +1582 -0
  379. package/lib/planetscale/api/sdk.gen.d.ts.map +1 -0
  380. package/lib/planetscale/api/sdk.gen.js +2219 -0
  381. package/lib/planetscale/api/sdk.gen.js.map +1 -0
  382. package/lib/planetscale/api/types.gen.d.ts +594 -449
  383. package/lib/planetscale/api/types.gen.d.ts.map +1 -1
  384. package/lib/planetscale/api.d.ts +43 -0
  385. package/lib/planetscale/api.d.ts.map +1 -0
  386. package/lib/planetscale/api.js +53 -0
  387. package/lib/planetscale/api.js.map +1 -0
  388. package/lib/planetscale/branch.d.ts +2 -3
  389. package/lib/planetscale/branch.d.ts.map +1 -1
  390. package/lib/planetscale/branch.js +17 -15
  391. package/lib/planetscale/branch.js.map +1 -1
  392. package/lib/planetscale/database.d.ts +2 -3
  393. package/lib/planetscale/database.d.ts.map +1 -1
  394. package/lib/planetscale/database.js +34 -34
  395. package/lib/planetscale/database.js.map +1 -1
  396. package/lib/planetscale/index.d.ts +1 -1
  397. package/lib/planetscale/index.d.ts.map +1 -1
  398. package/lib/planetscale/index.js +1 -1
  399. package/lib/planetscale/index.js.map +1 -1
  400. package/lib/planetscale/password.d.ts +2 -3
  401. package/lib/planetscale/password.d.ts.map +1 -1
  402. package/lib/planetscale/password.js +11 -11
  403. package/lib/planetscale/password.js.map +1 -1
  404. package/lib/planetscale/role.d.ts +2 -3
  405. package/lib/planetscale/role.d.ts.map +1 -1
  406. package/lib/planetscale/role.js +18 -18
  407. package/lib/planetscale/role.js.map +1 -1
  408. package/lib/planetscale/utils.d.ts +1 -1
  409. package/lib/planetscale/utils.d.ts.map +1 -1
  410. package/lib/planetscale/utils.js +17 -33
  411. package/lib/planetscale/utils.js.map +1 -1
  412. package/lib/random/random-string.d.ts +1 -2
  413. package/lib/random/random-string.d.ts.map +1 -1
  414. package/lib/random/random-string.js +3 -3
  415. package/lib/random/random-string.js.map +1 -1
  416. package/lib/resource.d.ts +4 -1
  417. package/lib/resource.d.ts.map +1 -1
  418. package/lib/resource.js.map +1 -1
  419. package/lib/sentry/client-key.d.ts +1 -2
  420. package/lib/sentry/client-key.d.ts.map +1 -1
  421. package/lib/sentry/client-key.js +2 -2
  422. package/lib/sentry/client-key.js.map +1 -1
  423. package/lib/sentry/project.d.ts +1 -2
  424. package/lib/sentry/project.d.ts.map +1 -1
  425. package/lib/sentry/project.js +2 -2
  426. package/lib/sentry/project.js.map +1 -1
  427. package/lib/sentry/team.d.ts +1 -2
  428. package/lib/sentry/team.d.ts.map +1 -1
  429. package/lib/sentry/team.js +2 -2
  430. package/lib/sentry/team.js.map +1 -1
  431. package/lib/state/r2-rest-state-store.d.ts +1 -0
  432. package/lib/state/r2-rest-state-store.d.ts.map +1 -1
  433. package/lib/state/r2-rest-state-store.js +15 -34
  434. package/lib/state/r2-rest-state-store.js.map +1 -1
  435. package/lib/stripe/card.d.ts +1 -2
  436. package/lib/stripe/card.d.ts.map +1 -1
  437. package/lib/stripe/card.js +2 -2
  438. package/lib/stripe/card.js.map +1 -1
  439. package/lib/stripe/coupon.d.ts +1 -2
  440. package/lib/stripe/coupon.d.ts.map +1 -1
  441. package/lib/stripe/coupon.js +2 -2
  442. package/lib/stripe/coupon.js.map +1 -1
  443. package/lib/stripe/customer.d.ts +1 -2
  444. package/lib/stripe/customer.d.ts.map +1 -1
  445. package/lib/stripe/customer.js +2 -2
  446. package/lib/stripe/customer.js.map +1 -1
  447. package/lib/stripe/entitlements-feature.d.ts +1 -2
  448. package/lib/stripe/entitlements-feature.d.ts.map +1 -1
  449. package/lib/stripe/entitlements-feature.js +2 -2
  450. package/lib/stripe/entitlements-feature.js.map +1 -1
  451. package/lib/stripe/file.d.ts +1 -2
  452. package/lib/stripe/file.d.ts.map +1 -1
  453. package/lib/stripe/file.js +2 -2
  454. package/lib/stripe/file.js.map +1 -1
  455. package/lib/stripe/meter.d.ts +1 -2
  456. package/lib/stripe/meter.d.ts.map +1 -1
  457. package/lib/stripe/meter.js +1 -1
  458. package/lib/stripe/meter.js.map +1 -1
  459. package/lib/stripe/portal-configuration.d.ts +1 -2
  460. package/lib/stripe/portal-configuration.d.ts.map +1 -1
  461. package/lib/stripe/portal-configuration.js +2 -2
  462. package/lib/stripe/portal-configuration.js.map +1 -1
  463. package/lib/stripe/price.d.ts +1 -2
  464. package/lib/stripe/price.d.ts.map +1 -1
  465. package/lib/stripe/price.js +2 -2
  466. package/lib/stripe/price.js.map +1 -1
  467. package/lib/stripe/product-feature.d.ts +1 -2
  468. package/lib/stripe/product-feature.d.ts.map +1 -1
  469. package/lib/stripe/product-feature.js +2 -2
  470. package/lib/stripe/product-feature.js.map +1 -1
  471. package/lib/stripe/product.d.ts +1 -2
  472. package/lib/stripe/product.d.ts.map +1 -1
  473. package/lib/stripe/product.js +2 -2
  474. package/lib/stripe/product.js.map +1 -1
  475. package/lib/stripe/promotion-code.d.ts +1 -2
  476. package/lib/stripe/promotion-code.d.ts.map +1 -1
  477. package/lib/stripe/promotion-code.js +2 -2
  478. package/lib/stripe/promotion-code.js.map +1 -1
  479. package/lib/stripe/shipping-rate.d.ts +1 -2
  480. package/lib/stripe/shipping-rate.d.ts.map +1 -1
  481. package/lib/stripe/shipping-rate.js +2 -2
  482. package/lib/stripe/shipping-rate.js.map +1 -1
  483. package/lib/stripe/tax-rate.d.ts +1 -2
  484. package/lib/stripe/tax-rate.d.ts.map +1 -1
  485. package/lib/stripe/tax-rate.js +2 -2
  486. package/lib/stripe/tax-rate.js.map +1 -1
  487. package/lib/stripe/webhook.d.ts +16 -3
  488. package/lib/stripe/webhook.d.ts.map +1 -1
  489. package/lib/stripe/webhook.js +2 -2
  490. package/lib/stripe/webhook.js.map +1 -1
  491. package/lib/test/bun.d.ts.map +1 -1
  492. package/lib/test/bun.js +1 -0
  493. package/lib/test/bun.js.map +1 -1
  494. package/lib/test/options.d.ts +5 -0
  495. package/lib/test/options.d.ts.map +1 -1
  496. package/lib/test/vitest.d.ts.map +1 -1
  497. package/lib/test/vitest.js +1 -0
  498. package/lib/test/vitest.js.map +1 -1
  499. package/lib/upstash/redis.d.ts +1 -2
  500. package/lib/upstash/redis.d.ts.map +1 -1
  501. package/lib/upstash/redis.js.map +1 -1
  502. package/lib/util/api/client/client.gen.d.ts +3 -0
  503. package/lib/util/api/client/client.gen.d.ts.map +1 -0
  504. package/lib/util/api/client/client.gen.js +205 -0
  505. package/lib/util/api/client/client.gen.js.map +1 -0
  506. package/lib/util/api/client/index.d.ts +8 -0
  507. package/lib/util/api/client/index.d.ts.map +1 -0
  508. package/lib/util/api/client/index.js +6 -0
  509. package/lib/util/api/client/index.js.map +1 -0
  510. package/lib/util/api/client/types.gen.d.ts +125 -0
  511. package/lib/util/api/client/types.gen.d.ts.map +1 -0
  512. package/lib/util/api/client/types.gen.js +2 -0
  513. package/lib/util/api/client/types.gen.js.map +1 -0
  514. package/lib/util/api/client/utils.gen.d.ts +34 -0
  515. package/lib/util/api/client/utils.gen.d.ts.map +1 -0
  516. package/lib/util/api/client/utils.gen.js +231 -0
  517. package/lib/util/api/client/utils.gen.js.map +1 -0
  518. package/lib/util/api/core/auth.gen.d.ts +19 -0
  519. package/lib/util/api/core/auth.gen.d.ts.map +1 -0
  520. package/lib/util/api/core/auth.gen.js +15 -0
  521. package/lib/util/api/core/auth.gen.js.map +1 -0
  522. package/lib/util/api/core/bodySerializer.gen.d.ts +18 -0
  523. package/lib/util/api/core/bodySerializer.gen.d.ts.map +1 -0
  524. package/lib/util/api/core/bodySerializer.gen.js +58 -0
  525. package/lib/util/api/core/bodySerializer.gen.js.map +1 -0
  526. package/lib/util/api/core/params.gen.d.ts +34 -0
  527. package/lib/util/api/core/params.gen.d.ts.map +1 -0
  528. package/lib/util/api/core/params.gen.js +89 -0
  529. package/lib/util/api/core/params.gen.js.map +1 -0
  530. package/lib/util/api/core/pathSerializer.gen.d.ts +34 -0
  531. package/lib/util/api/core/pathSerializer.gen.d.ts.map +1 -0
  532. package/lib/util/api/core/pathSerializer.gen.js +115 -0
  533. package/lib/util/api/core/pathSerializer.gen.js.map +1 -0
  534. package/lib/util/api/core/serverSentEvents.gen.d.ts +72 -0
  535. package/lib/util/api/core/serverSentEvents.gen.d.ts.map +1 -0
  536. package/lib/util/api/core/serverSentEvents.gen.js +136 -0
  537. package/lib/util/api/core/serverSentEvents.gen.js.map +1 -0
  538. package/lib/util/api/core/types.gen.d.ts +79 -0
  539. package/lib/util/api/core/types.gen.d.ts.map +1 -0
  540. package/lib/util/api/core/types.gen.js +2 -0
  541. package/lib/util/api/core/types.gen.js.map +1 -0
  542. package/lib/util/api/core/utils.gen.d.ts +20 -0
  543. package/lib/util/api/core/utils.gen.d.ts.map +1 -0
  544. package/lib/util/api/core/utils.gen.js +88 -0
  545. package/lib/util/api/core/utils.gen.js.map +1 -0
  546. package/lib/util/http.d.ts +7 -2
  547. package/lib/util/http.d.ts.map +1 -1
  548. package/lib/util/http.js +29 -11
  549. package/lib/util/http.js.map +1 -1
  550. package/lib/util/lock.d.ts +20 -0
  551. package/lib/util/lock.d.ts.map +1 -0
  552. package/lib/util/lock.js +45 -0
  553. package/lib/util/lock.js.map +1 -0
  554. package/lib/util/memoize.d.ts +6 -0
  555. package/lib/util/memoize.d.ts.map +1 -1
  556. package/lib/util/memoize.js +23 -0
  557. package/lib/util/memoize.js.map +1 -1
  558. package/lib/util/oauth-client.d.ts +71 -0
  559. package/lib/util/oauth-client.d.ts.map +1 -0
  560. package/lib/util/oauth-client.js +188 -0
  561. package/lib/util/oauth-client.js.map +1 -0
  562. package/lib/util/poll.d.ts +33 -0
  563. package/lib/util/poll.d.ts.map +1 -0
  564. package/lib/util/poll.js +19 -0
  565. package/lib/util/poll.js.map +1 -0
  566. package/lib/vercel/project-domain.d.ts +1 -2
  567. package/lib/vercel/project-domain.d.ts.map +1 -1
  568. package/lib/vercel/project-domain.js.map +1 -1
  569. package/lib/vercel/project.d.ts +1 -2
  570. package/lib/vercel/project.d.ts.map +1 -1
  571. package/lib/vercel/project.js +2 -2
  572. package/lib/vercel/project.js.map +1 -1
  573. package/package.json +5 -1
  574. package/src/apply.ts +32 -29
  575. package/src/auth.ts +253 -0
  576. package/src/aws/bucket.ts +3 -3
  577. package/src/aws/control/resource.ts +4 -6
  578. package/src/aws/ec2/internet-gateway-attachment.ts +5 -6
  579. package/src/aws/ec2/internet-gateway.ts +3 -5
  580. package/src/aws/ec2/nat-gateway.ts +3 -5
  581. package/src/aws/ec2/route-table-association.ts +3 -5
  582. package/src/aws/ec2/route-table.ts +3 -5
  583. package/src/aws/ec2/route.ts +3 -3
  584. package/src/aws/ec2/security-group-rule.ts +3 -5
  585. package/src/aws/ec2/security-group.ts +3 -5
  586. package/src/aws/ec2/subnet.ts +3 -3
  587. package/src/aws/ec2/vpc.ts +3 -3
  588. package/src/aws/function.ts +3 -3
  589. package/src/aws/oidc/oidc-provider.ts +3 -5
  590. package/src/aws/policy-attachment.ts +2 -4
  591. package/src/aws/policy.ts +5 -5
  592. package/src/aws/queue.ts +5 -5
  593. package/src/aws/role.ts +3 -3
  594. package/src/aws/ses.ts +3 -3
  595. package/src/aws/ssm-parameter.ts +3 -3
  596. package/src/aws/table.ts +3 -3
  597. package/src/cloudflare/account-api-token.ts +3 -4
  598. package/src/cloudflare/ai-gateway.ts +3 -5
  599. package/src/cloudflare/api-gateway-operation.ts +3 -4
  600. package/src/cloudflare/api-schema.ts +25 -26
  601. package/src/cloudflare/api-shield.ts +3 -4
  602. package/src/cloudflare/api.ts +122 -57
  603. package/src/cloudflare/assets.ts +95 -136
  604. package/src/cloudflare/auth.ts +160 -95
  605. package/src/cloudflare/bound.ts +1 -1
  606. package/src/cloudflare/bucket.ts +321 -58
  607. package/src/cloudflare/bundle/plugin-wasm.ts +5 -5
  608. package/src/cloudflare/certificate-pack.ts +5 -6
  609. package/src/cloudflare/compatibility-date.gen.ts +1 -1
  610. package/src/cloudflare/container.ts +7 -8
  611. package/src/cloudflare/custom-domain.ts +3 -5
  612. package/src/cloudflare/d1-database.ts +33 -34
  613. package/src/cloudflare/dispatch-namespace.ts +5 -6
  614. package/src/cloudflare/dns-records.ts +5 -5
  615. package/src/cloudflare/email-address.ts +7 -7
  616. package/src/cloudflare/email-catch-all.ts +6 -6
  617. package/src/cloudflare/email-routing.ts +5 -5
  618. package/src/cloudflare/email-rule.ts +5 -5
  619. package/src/cloudflare/hyperdrive.ts +35 -36
  620. package/src/cloudflare/kv-namespace.ts +31 -32
  621. package/src/cloudflare/miniflare/delete.ts +1 -1
  622. package/src/cloudflare/miniflare/miniflare-worker-proxy.ts +2 -7
  623. package/src/cloudflare/miniflare/remote-binding-proxy.ts +16 -4
  624. package/src/cloudflare/permission-groups.ts +4 -6
  625. package/src/cloudflare/pipeline.ts +29 -30
  626. package/src/cloudflare/queue-consumer.ts +5 -7
  627. package/src/cloudflare/queue.ts +42 -43
  628. package/src/cloudflare/react-router/plugin.ts +20 -0
  629. package/src/cloudflare/redirect-rule.ts +5 -5
  630. package/src/cloudflare/route.ts +5 -5
  631. package/src/cloudflare/ruleset.ts +3 -4
  632. package/src/cloudflare/secret.ts +35 -36
  633. package/src/cloudflare/secrets-store.ts +5 -8
  634. package/src/cloudflare/tunnel.ts +5 -7
  635. package/src/cloudflare/user.ts +12 -9
  636. package/src/cloudflare/vectorize-index.ts +8 -12
  637. package/src/cloudflare/vectorize-metadata-index.ts +6 -8
  638. package/src/cloudflare/website.ts +1 -1
  639. package/src/cloudflare/worker-assets.ts +10 -56
  640. package/src/cloudflare/worker-stub.ts +5 -5
  641. package/src/cloudflare/worker-subdomain.ts +6 -7
  642. package/src/cloudflare/worker.ts +91 -91
  643. package/src/cloudflare/zone.ts +3 -3
  644. package/src/context.ts +9 -7
  645. package/src/destroy.ts +2 -2
  646. package/src/dns/import-dns.ts +3 -5
  647. package/src/docker/container.ts +3 -6
  648. package/src/docker/image.ts +13 -13
  649. package/src/docker/network.ts +3 -4
  650. package/src/docker/remote-image.ts +3 -6
  651. package/src/docker/volume.ts +3 -4
  652. package/src/esbuild/bundle.ts +10 -8
  653. package/src/fs/copy-file.ts +3 -3
  654. package/src/fs/file.ts +3 -3
  655. package/src/fs/folder.ts +3 -3
  656. package/src/github/comment.ts +5 -7
  657. package/src/github/repository-environment.ts +3 -5
  658. package/src/github/repository-webhook.ts +3 -5
  659. package/src/github/secret.ts +3 -5
  660. package/src/neon/api/client.gen.ts +28 -0
  661. package/src/neon/api/sdk.gen.ts +2596 -0
  662. package/src/neon/api/types.gen.ts +8287 -0
  663. package/src/neon/api.ts +51 -147
  664. package/src/neon/branch.ts +278 -0
  665. package/src/neon/index.ts +1 -1
  666. package/src/neon/project.ts +136 -721
  667. package/src/neon/utils.ts +105 -0
  668. package/src/os/exec.ts +3 -3
  669. package/src/planetscale/api/client.gen.ts +28 -2882
  670. package/src/planetscale/api/sdk.gen.ts +3336 -0
  671. package/src/planetscale/api/types.gen.ts +778 -450
  672. package/src/planetscale/api.ts +101 -0
  673. package/src/planetscale/branch.ts +20 -19
  674. package/src/planetscale/database.ts +69 -70
  675. package/src/planetscale/index.ts +1 -1
  676. package/src/planetscale/password.ts +18 -22
  677. package/src/planetscale/role.ts +21 -21
  678. package/src/planetscale/utils.ts +20 -74
  679. package/src/random/random-string.ts +4 -4
  680. package/src/resource.ts +6 -2
  681. package/src/sentry/client-key.ts +3 -5
  682. package/src/sentry/project.ts +3 -5
  683. package/src/sentry/team.ts +3 -3
  684. package/src/state/r2-rest-state-store.ts +15 -57
  685. package/src/stripe/card.ts +3 -3
  686. package/src/stripe/coupon.ts +3 -3
  687. package/src/stripe/customer.ts +3 -3
  688. package/src/stripe/entitlements-feature.ts +3 -5
  689. package/src/stripe/file.ts +3 -3
  690. package/src/stripe/meter.ts +3 -3
  691. package/src/stripe/portal-configuration.ts +3 -5
  692. package/src/stripe/price.ts +3 -3
  693. package/src/stripe/product-feature.ts +3 -5
  694. package/src/stripe/product.ts +3 -3
  695. package/src/stripe/promotion-code.ts +3 -5
  696. package/src/stripe/shipping-rate.ts +3 -5
  697. package/src/stripe/tax-rate.ts +3 -3
  698. package/src/stripe/webhook.ts +3 -5
  699. package/src/test/bun.ts +1 -0
  700. package/src/test/options.ts +6 -0
  701. package/src/test/vitest.ts +1 -0
  702. package/src/upstash/redis.ts +1 -3
  703. package/src/util/api/client/client.gen.ts +268 -0
  704. package/src/util/api/client/index.ts +25 -0
  705. package/src/util/api/client/types.gen.ts +268 -0
  706. package/src/util/api/client/utils.gen.ts +331 -0
  707. package/src/util/api/core/auth.gen.ts +42 -0
  708. package/src/util/api/core/bodySerializer.gen.ts +92 -0
  709. package/src/util/api/core/params.gen.ts +153 -0
  710. package/src/util/api/core/pathSerializer.gen.ts +181 -0
  711. package/src/util/api/core/serverSentEvents.gen.ts +264 -0
  712. package/src/util/api/core/types.gen.ts +118 -0
  713. package/src/util/api/core/utils.gen.ts +143 -0
  714. package/src/util/http.ts +38 -11
  715. package/src/util/lock.ts +48 -0
  716. package/src/util/memoize.ts +26 -0
  717. package/src/util/oauth-client.ts +238 -0
  718. package/src/util/poll.ts +55 -0
  719. package/src/vercel/project-domain.ts +1 -3
  720. package/src/vercel/project.ts +3 -3
  721. package/workers/cloudflare-state-store.js +8 -5619
  722. package/workers/dofs-state-store.js +2 -802
  723. package/workers/remote-binding-proxy.js +3 -39
  724. package/workers/remote-binding-proxy.ts +126 -35
  725. package/workers/tunnel-proxy.js +6 -73
  726. package/lib/cloudflare/asset-manifest.d.ts +0 -15
  727. package/lib/cloudflare/asset-manifest.d.ts.map +0 -1
  728. package/lib/cloudflare/asset-manifest.js +0 -1
  729. package/lib/cloudflare/asset-manifest.js.map +0 -1
  730. package/lib/cloudflare/oauth.d.ts +0 -22
  731. package/lib/cloudflare/oauth.d.ts.map +0 -1
  732. package/lib/cloudflare/oauth.js +0 -214
  733. package/lib/cloudflare/oauth.js.map +0 -1
  734. package/lib/neon/api-error.d.ts +0 -31
  735. package/lib/neon/api-error.d.ts.map +0 -1
  736. package/lib/neon/api-error.js +0 -73
  737. package/lib/neon/api-error.js.map +0 -1
  738. package/lib/planetscale/api/index.d.ts +0 -3
  739. package/lib/planetscale/api/index.d.ts.map +0 -1
  740. package/lib/planetscale/api/index.js +0 -4
  741. package/lib/planetscale/api/index.js.map +0 -1
  742. package/lib/util/neverthrow.d.ts +0 -16
  743. package/lib/util/neverthrow.d.ts.map +0 -1
  744. package/lib/util/neverthrow.js +0 -46
  745. package/lib/util/neverthrow.js.map +0 -1
  746. package/src/cloudflare/asset-manifest.ts +0 -16
  747. package/src/cloudflare/oauth.ts +0 -301
  748. package/src/neon/api-error.ts +0 -81
  749. package/src/planetscale/api/index.ts +0 -4
  750. package/src/util/neverthrow.ts +0 -64
package/src/neon/api.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import type { Secret } from "../secret.ts";
2
- import { withExponentialBackoff } from "../util/retry.ts";
3
- import { safeFetch } from "../util/safe-fetch.ts";
2
+ import { createClient } from "../util/api/client/client.gen.ts";
3
+ import type { ClientOptions } from "../util/api/client/types.gen.ts";
4
+ import { createConfig } from "../util/api/client/utils.gen.ts";
5
+ import { NeonClient } from "./api/sdk.gen.ts";
6
+ import type { GeneralError } from "./api/types.gen.ts";
4
7
 
5
8
  /**
6
9
  * Options for Neon API requests
@@ -18,162 +21,63 @@ export interface NeonApiOptions {
18
21
  apiKey?: Secret;
19
22
  }
20
23
 
24
+ export class NeonError extends Error {
25
+ status: number;
26
+ method: string;
27
+ url: string;
28
+ code: string;
29
+
30
+ constructor(props: {
31
+ error: GeneralError;
32
+ request: Request;
33
+ response: Response;
34
+ }) {
35
+ const { code, message, ...rest } = props.error;
36
+ super(
37
+ `A request to the Neon API failed (${props.response.status}): ${message}`,
38
+ );
39
+ this.status = props.response.status;
40
+ this.method = props.request.method;
41
+ this.url = props.request.url;
42
+ this.code = code;
43
+ Object.assign(this, rest);
44
+ }
45
+ }
46
+
21
47
  /**
22
48
  * Create a NeonApi instance with environment variable fallback
23
49
  * @param options API options
24
50
  * @returns NeonApi instance
25
51
  */
26
- export function createNeonApi(options: Partial<NeonApiOptions> = {}): NeonApi {
27
- return new NeonApi({
28
- baseUrl: options.baseUrl,
29
- apiKey: options.apiKey,
30
- });
31
- }
32
-
33
- /**
34
- * Get authentication headers for Neon API
35
- * @param options NeonApiOptions
36
- * @returns Headers for authentication
37
- */
38
- export async function getNeonAuthHeaders(
39
- options: Partial<NeonApiOptions>,
40
- ): Promise<Record<string, string>> {
52
+ export function createNeonApi(
53
+ options: Partial<NeonApiOptions> = {},
54
+ ): NeonClient {
41
55
  const apiKey = options.apiKey?.unencrypted ?? process.env.NEON_API_KEY;
42
-
43
56
  if (!apiKey) {
44
57
  throw new Error(
45
58
  "Neon API key is required. Set NEON_API_KEY environment variable or provide apiKey option.",
46
59
  );
47
60
  }
48
-
49
- return {
50
- "Content-Type": "application/json",
51
- Accept: "application/json",
52
- Authorization: `Bearer ${apiKey}`,
53
- };
54
- }
55
-
56
- /**
57
- * Neon API client using raw fetch
58
- */
59
- export class NeonApi {
60
- public readonly baseUrl: string;
61
-
62
- /**
63
- * Create a new Neon API client
64
- * Use createNeonApi factory function instead of direct constructor
65
- *
66
- * @param options API options
67
- */
68
- constructor(private readonly options: NeonApiOptions) {
69
- this.baseUrl = options.baseUrl ?? "https://console.neon.tech/api/v2";
70
- }
71
-
72
- /**
73
- * Make a fetch request to the Neon API
74
- *
75
- * @param path API path (without base URL)
76
- * @param init Fetch init options
77
- * @returns Raw Response object from fetch
78
- */
79
- async fetch(path: string, init: RequestInit = {}): Promise<Response> {
80
- let headers: Record<string, string> = {};
81
-
82
- if (Array.isArray(init.headers)) {
83
- init.headers.forEach(([key, value]) => {
84
- headers[key] = value;
85
- });
86
- } else if (init.headers instanceof Headers) {
87
- init.headers.forEach((value, key) => {
88
- headers[key] = value;
61
+ const client = createClient(
62
+ createConfig<ClientOptions>({
63
+ baseUrl: options.baseUrl ?? "https://console.neon.tech/api/v2",
64
+ throwOnError: true,
65
+ headers: {
66
+ Authorization: `Bearer ${apiKey}`,
67
+ },
68
+ }),
69
+ );
70
+ client.interceptors.error.use((error, response, request, options) => {
71
+ if (options.throwOnError !== false) {
72
+ throw new NeonError({
73
+ error: error as GeneralError,
74
+ request,
75
+ response,
89
76
  });
90
- } else if (init.headers) {
91
- headers = init.headers as Record<string, string>;
92
77
  }
93
-
94
- headers = {
95
- ...(await getNeonAuthHeaders(this.options)),
96
- ...headers,
97
- };
98
-
99
- // Use withExponentialBackoff for automatic retry on network errors
100
- return withExponentialBackoff(
101
- () =>
102
- safeFetch(`${this.baseUrl}${path}`, {
103
- ...init,
104
- headers,
105
- }),
106
- (error) => {
107
- // Only retry on network-related errors
108
- const errorMsg = (error as Error).message || "";
109
- const isNetworkError =
110
- errorMsg.includes("socket connection was closed") ||
111
- errorMsg.includes("ECONNRESET") ||
112
- errorMsg.includes("ETIMEDOUT") ||
113
- errorMsg.includes("ECONNREFUSED");
114
-
115
- return isNetworkError || error?.status?.toString().startsWith("5");
116
- },
117
- 5, // Maximum 5 attempts (1 initial + 4 retries)
118
- 1000, // Start with 1s delay, will exponentially increase
119
- );
120
- }
121
-
122
- /**
123
- * Helper for GET requests
124
- */
125
- async get(path: string, init: RequestInit = {}): Promise<Response> {
126
- return this.fetch(path, { ...init, method: "GET" });
127
- }
128
-
129
- /**
130
- * Helper for POST requests
131
- */
132
- async post(
133
- path: string,
134
- body: any,
135
- init: RequestInit = {},
136
- ): Promise<Response> {
137
- const requestBody =
138
- body instanceof FormData
139
- ? body
140
- : typeof body === "string"
141
- ? body
142
- : JSON.stringify(body);
143
- return this.fetch(path, { ...init, method: "POST", body: requestBody });
144
- }
145
-
146
- /**
147
- * Helper for PUT requests
148
- */
149
- async put(
150
- path: string,
151
- body: any,
152
- init: RequestInit = {},
153
- ): Promise<Response> {
154
- const requestBody = body instanceof FormData ? body : JSON.stringify(body);
155
- return this.fetch(path, { ...init, method: "PUT", body: requestBody });
156
- }
157
-
158
- /**
159
- * Helper for PATCH requests
160
- */
161
- async patch(
162
- path: string,
163
- body: any,
164
- init: RequestInit = {},
165
- ): Promise<Response> {
166
- return this.fetch(path, {
167
- ...init,
168
- method: "PATCH",
169
- body: JSON.stringify(body),
170
- });
171
- }
172
-
173
- /**
174
- * Helper for DELETE requests
175
- */
176
- async delete(path: string, init: RequestInit = {}): Promise<Response> {
177
- return this.fetch(path, { ...init, method: "DELETE" });
178
- }
78
+ return error;
79
+ });
80
+ return new NeonClient({
81
+ client,
82
+ });
179
83
  }
@@ -0,0 +1,278 @@
1
+ import type { Context } from "../context.ts";
2
+ import { Resource } from "../resource.ts";
3
+ import { createNeonApi, type NeonApiOptions } from "./api.ts";
4
+ import type * as neon from "./api/types.gen.ts";
5
+ import type { NeonProject } from "./project.ts";
6
+ import {
7
+ formatConnectionUri,
8
+ formatRole,
9
+ waitForOperations,
10
+ type NeonConnectionUri,
11
+ type NeonRole,
12
+ } from "./utils.ts";
13
+
14
+ export interface NeonBranchProps extends NeonApiOptions {
15
+ /**
16
+ * The project to create the new branch in.
17
+ * This can be a Project object or an ID string.
18
+ */
19
+ project: string | NeonProject;
20
+ /**
21
+ * The name of the branch.
22
+ * @default `${app}-${stage}-${id}`
23
+ */
24
+ name?: string;
25
+ /**
26
+ * Whether the branch is protected.
27
+ * @default false.
28
+ */
29
+ protected?: boolean;
30
+ /**
31
+ * The parent branch to create the new branch from. Default is the project's default branch.
32
+ * This can be a Branch object or an ID string beginning with `br-`.
33
+ */
34
+ parentBranch?: string | NeonBranch | neon.Branch;
35
+ /**
36
+ * A Log Sequence Number (LSN) on the parent branch. The branch will be created with data from this LSN.
37
+ */
38
+ parentLsn?: string;
39
+ /**
40
+ * A timestamp identifying a point in time on the parent branch. The branch will be created with data starting from this point in time.
41
+ * The timestamp must be provided in ISO 8601 format; for example: `2024-02-26T12:00:00Z`.
42
+ */
43
+ parentTimestamp?: string;
44
+ /**
45
+ * The timestamp when the branch is scheduled to expire and be automatically deleted.
46
+ * Must be set by the client following the [RFC 3339, section 5.6](https://tools.ietf.org/html/rfc3339#section-5.6) format with precision up to seconds (such as 2025-06-09T18:02:16Z).
47
+ * Deletion is performed by a background job and may not occur exactly at the specified time.
48
+ *
49
+ * Access to this feature is currently limited to participants in the Early Access Program.
50
+ */
51
+ expiresAt?: string;
52
+ /**
53
+ * The source of initialization for the branch. Valid values are `schema-only` and `parent-data` (default).
54
+ * * `schema-only` - creates a new root branch containing only the schema. Use `parent_id` to specify the source branch. Optionally, you can provide `parent_lsn` or `parent_timestamp` to branch from a specific point in time or LSN. These fields define which branch to copy the schema from and at what point—they do not establish a parent-child relationship between the `parent_id` branch and the new schema-only branch.
55
+ * * `parent-data` - creates the branch with both schema and data from the parent.
56
+ * @default "parent-data"
57
+ */
58
+ initSource?: "schema-only" | "parent-data";
59
+ /**
60
+ * The endpoints to create for the branch.
61
+ *
62
+ * Warning: If you do not configure endpoints, you will not be able to connect to the branch.
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * [
67
+ * {
68
+ * type: "read-write",
69
+ * },
70
+ * {
71
+ * type: "read-only",
72
+ * },
73
+ * ]
74
+ * ```
75
+ */
76
+ endpoints: neon.BranchCreateRequestEndpointOptions[];
77
+ }
78
+
79
+ export interface NeonBranch extends Resource<"neon::Branch"> {
80
+ /**
81
+ * The branch ID. This value is generated when a branch is created. A branch_id value has a br- prefix. For example: br-small-term-683261.
82
+ */
83
+ id: string;
84
+ /**
85
+ * The ID of the project to which the branch belongs.
86
+ */
87
+ projectId: string;
88
+ /**
89
+ * The ID of the parent branch.
90
+ */
91
+ parentBranchId: string | undefined;
92
+ /**
93
+ * A Log Sequence Number (LSN) on the parent branch. The branch will be created with data from this LSN.
94
+ */
95
+ parentLsn: string | undefined;
96
+ /**
97
+ * A timestamp identifying a point in time on the parent branch. The branch will be created with data starting from this point in time.
98
+ * The timestamp must be provided in ISO 8601 format; for example: `2024-02-26T12:00:00Z`.
99
+ */
100
+ parentTimestamp: string | undefined;
101
+ /**
102
+ * The source of initialization for the branch.
103
+ */
104
+ initSource: "schema-only" | "parent-data" | undefined;
105
+ /**
106
+ * The name of the branch.
107
+ */
108
+ name: string;
109
+ /**
110
+ * Whether the branch is protected.
111
+ */
112
+ protected: boolean;
113
+ /**
114
+ * Whether the branch is the default branch.
115
+ */
116
+ default: boolean;
117
+ /**
118
+ * The timestamp when the branch was created.
119
+ */
120
+ createdAt: Date;
121
+ /**
122
+ * The timestamp when the branch was last updated.
123
+ */
124
+ updatedAt: Date;
125
+ /**
126
+ * The timestamp when the branch is scheduled to expire and be automatically deleted.
127
+ * Must be set by the client following the RFC 3339, section 5.6 format with precision up to seconds (such as 2025-06-09T18:02:16Z).
128
+ * Deletion is performed by a background job and may not occur exactly at the specified time.
129
+ */
130
+ expiresAt: Date | undefined;
131
+ /**
132
+ * The endpoints for the branch.
133
+ */
134
+ endpoints: neon.Endpoint[];
135
+ /**
136
+ * The databases for the branch.
137
+ */
138
+ databases: neon.Database[];
139
+ /**
140
+ * The roles for the branch.
141
+ */
142
+ roles: NeonRole[];
143
+ /**
144
+ * The connection URIs for the branch.
145
+ */
146
+ connectionUris: NeonConnectionUri[];
147
+ }
148
+
149
+ export const NeonBranch = Resource(
150
+ "neon::Branch",
151
+ async function (
152
+ this: Context<NeonBranch>,
153
+ id: string,
154
+ props: NeonBranchProps,
155
+ ) {
156
+ const api = createNeonApi(props);
157
+ const name =
158
+ props.name ?? this.output?.name ?? this.scope.createPhysicalName(id);
159
+ const projectId =
160
+ typeof props.project === "string" ? props.project : props.project.id;
161
+ const parentBranchId =
162
+ typeof props.parentBranch === "string"
163
+ ? props.parentBranch
164
+ : props.parentBranch?.id;
165
+
166
+ switch (this.phase) {
167
+ case "delete": {
168
+ if (this.output?.id) {
169
+ const res = await api.deleteProjectBranch({
170
+ path: {
171
+ project_id: this.output.projectId,
172
+ branch_id: this.output.id,
173
+ },
174
+ throwOnError: false,
175
+ });
176
+ if (res.error && res.response.status !== 404) {
177
+ throw new Error(`Failed to delete branch: ${res.error.message}`, {
178
+ cause: res.error,
179
+ });
180
+ }
181
+ }
182
+ return this.destroy();
183
+ }
184
+ case "create": {
185
+ const { data } = await api.createProjectBranch({
186
+ path: {
187
+ project_id: projectId,
188
+ },
189
+ body: {
190
+ branch: {
191
+ name,
192
+ protected: props.protected,
193
+ parent_id: parentBranchId,
194
+ parent_lsn: props.parentLsn,
195
+ parent_timestamp: props.parentTimestamp,
196
+ expires_at: props.expiresAt,
197
+ init_source: props.initSource,
198
+ },
199
+ endpoints: props.endpoints,
200
+ },
201
+ });
202
+
203
+ // Endpoints have fields that are updated after operations are complete.
204
+ await waitForOperations(api, data.operations);
205
+ const endpoints = await Promise.all(
206
+ data.endpoints.map((endpoint) =>
207
+ api
208
+ .getProjectEndpoint({
209
+ path: {
210
+ project_id: projectId,
211
+ endpoint_id: endpoint.id,
212
+ },
213
+ })
214
+ .then((res) => res.data.endpoint),
215
+ ),
216
+ );
217
+
218
+ return this({
219
+ id: data.branch.id,
220
+ name: data.branch.name,
221
+ projectId: data.branch.project_id,
222
+ protected: data.branch.protected,
223
+ default: data.branch.default,
224
+ parentBranchId: data.branch.parent_id,
225
+ parentLsn: data.branch.parent_lsn,
226
+ parentTimestamp: data.branch.parent_timestamp,
227
+ initSource: data.branch.init_source as
228
+ | "schema-only"
229
+ | "parent-data"
230
+ | undefined,
231
+ createdAt: new Date(data.branch.created_at),
232
+ updatedAt: new Date(data.branch.updated_at),
233
+ expiresAt: data.branch.expires_at
234
+ ? new Date(data.branch.expires_at)
235
+ : undefined,
236
+ endpoints,
237
+ databases: data.databases,
238
+ roles: data.roles.map(formatRole),
239
+ connectionUris: data.connection_uris?.map(formatConnectionUri) ?? [],
240
+ });
241
+ }
242
+ case "update": {
243
+ if (
244
+ this.output.projectId !== projectId ||
245
+ (parentBranchId && this.output.parentBranchId !== parentBranchId) ||
246
+ (props.parentLsn && this.output.parentLsn !== props.parentLsn) ||
247
+ (props.parentTimestamp &&
248
+ this.output.parentTimestamp !== props.parentTimestamp) ||
249
+ this.output.initSource !== (props.initSource ?? "parent-data")
250
+ ) {
251
+ this.replace();
252
+ }
253
+ const { data } = await api.updateProjectBranch({
254
+ path: {
255
+ project_id: projectId,
256
+ branch_id: this.output.id,
257
+ },
258
+ body: {
259
+ branch: {
260
+ name: name !== this.output.name ? name : undefined, // prevents 400: cannot set branch to the same name
261
+ protected: props.protected ?? false,
262
+ expires_at: props.expiresAt ?? null,
263
+ },
264
+ },
265
+ });
266
+ return this({
267
+ ...this.output,
268
+ name,
269
+ protected: data.branch.protected,
270
+ updatedAt: new Date(data.branch.updated_at),
271
+ expiresAt: data.branch.expires_at
272
+ ? new Date(data.branch.expires_at)
273
+ : undefined,
274
+ });
275
+ }
276
+ }
277
+ },
278
+ );
package/src/neon/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./api-error.ts";
2
1
  export * from "./api.ts";
2
+ export * from "./branch.ts";
3
3
  export * from "./project.ts";