@neon/sdk 0.0.0 → 0.2.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 (222) hide show
  1. package/LICENSE.md +178 -0
  2. package/README.md +349 -0
  3. package/dist/_virtual/_rolldown/runtime.js +14 -0
  4. package/dist/client/client/client.gen.d.ts +7 -0
  5. package/dist/client/client/client.gen.d.ts.map +1 -0
  6. package/dist/client/client/client.gen.js +176 -0
  7. package/dist/client/client/client.gen.js.map +1 -0
  8. package/dist/client/client/index.d.ts +10 -0
  9. package/dist/client/client/index.js +6 -0
  10. package/dist/client/client/types.gen.d.ts +124 -0
  11. package/dist/client/client/types.gen.d.ts.map +1 -0
  12. package/dist/client/client/types.gen.js +1 -0
  13. package/dist/client/client/utils.gen.d.ts +42 -0
  14. package/dist/client/client/utils.gen.d.ts.map +1 -0
  15. package/dist/client/client/utils.gen.js +179 -0
  16. package/dist/client/client/utils.gen.js.map +1 -0
  17. package/dist/client/client.gen.d.ts +18 -0
  18. package/dist/client/client.gen.d.ts.map +1 -0
  19. package/dist/client/client.gen.js +8 -0
  20. package/dist/client/client.gen.js.map +1 -0
  21. package/dist/client/core/auth.gen.d.ts +29 -0
  22. package/dist/client/core/auth.gen.d.ts.map +1 -0
  23. package/dist/client/core/auth.gen.js +12 -0
  24. package/dist/client/core/auth.gen.js.map +1 -0
  25. package/dist/client/core/bodySerializer.gen.d.ts +29 -0
  26. package/dist/client/core/bodySerializer.gen.d.ts.map +1 -0
  27. package/dist/client/core/bodySerializer.gen.js +33 -0
  28. package/dist/client/core/bodySerializer.gen.js.map +1 -0
  29. package/dist/client/core/params.gen.d.ts +46 -0
  30. package/dist/client/core/params.gen.d.ts.map +1 -0
  31. package/dist/client/core/params.gen.js +65 -0
  32. package/dist/client/core/params.gen.js.map +1 -0
  33. package/dist/client/core/pathSerializer.gen.d.ts +52 -0
  34. package/dist/client/core/pathSerializer.gen.d.ts.map +1 -0
  35. package/dist/client/core/pathSerializer.gen.js +82 -0
  36. package/dist/client/core/pathSerializer.gen.js.map +1 -0
  37. package/dist/client/core/queryKeySerializer.gen.d.ts +22 -0
  38. package/dist/client/core/queryKeySerializer.gen.d.ts.map +1 -0
  39. package/dist/client/core/queryKeySerializer.gen.js +64 -0
  40. package/dist/client/core/queryKeySerializer.gen.js.map +1 -0
  41. package/dist/client/core/serverSentEvents.gen.d.ts +88 -0
  42. package/dist/client/core/serverSentEvents.gen.d.ts.map +1 -0
  43. package/dist/client/core/serverSentEvents.gen.js +95 -0
  44. package/dist/client/core/serverSentEvents.gen.js.map +1 -0
  45. package/dist/client/core/types.gen.d.ts +80 -0
  46. package/dist/client/core/types.gen.d.ts.map +1 -0
  47. package/dist/client/core/types.gen.js +1 -0
  48. package/dist/client/core/utils.gen.d.ts +33 -0
  49. package/dist/client/core/utils.gen.d.ts.map +1 -0
  50. package/dist/client/core/utils.gen.js +78 -0
  51. package/dist/client/core/utils.gen.js.map +1 -0
  52. package/dist/client/index.d.ts +3 -0
  53. package/dist/client/index.js +2 -0
  54. package/dist/client/sdk.gen.d.ts +1362 -0
  55. package/dist/client/sdk.gen.d.ts.map +1 -0
  56. package/dist/client/sdk.gen.js +4315 -0
  57. package/dist/client/sdk.gen.js.map +1 -0
  58. package/dist/client/types.gen.d.ts +9938 -0
  59. package/dist/client/types.gen.d.ts.map +1 -0
  60. package/dist/client/types.gen.js +1 -0
  61. package/dist/index.d.ts +19 -0
  62. package/dist/index.js +4 -0
  63. package/dist/neon/client.d.ts +52 -0
  64. package/dist/neon/client.d.ts.map +1 -0
  65. package/dist/neon/client.js +40 -0
  66. package/dist/neon/client.js.map +1 -0
  67. package/dist/neon/client.test-d.d.ts +1 -0
  68. package/dist/neon/client.test-d.js +76 -0
  69. package/dist/neon/client.test-d.js.map +1 -0
  70. package/dist/neon/config.d.ts +40 -0
  71. package/dist/neon/config.d.ts.map +1 -0
  72. package/dist/neon/config.js +23 -0
  73. package/dist/neon/config.js.map +1 -0
  74. package/dist/neon/connection.d.ts +22 -0
  75. package/dist/neon/connection.d.ts.map +1 -0
  76. package/dist/neon/connection.js +33 -0
  77. package/dist/neon/connection.js.map +1 -0
  78. package/dist/neon/context.d.ts +50 -0
  79. package/dist/neon/context.d.ts.map +1 -0
  80. package/dist/neon/context.js +59 -0
  81. package/dist/neon/context.js.map +1 -0
  82. package/dist/neon/coverage.d.ts +26 -0
  83. package/dist/neon/coverage.d.ts.map +1 -0
  84. package/dist/neon/coverage.js +229 -0
  85. package/dist/neon/coverage.js.map +1 -0
  86. package/dist/neon/errors.d.ts +78 -0
  87. package/dist/neon/errors.d.ts.map +1 -0
  88. package/dist/neon/errors.js +116 -0
  89. package/dist/neon/errors.js.map +1 -0
  90. package/dist/neon/paginate.d.ts +34 -0
  91. package/dist/neon/paginate.d.ts.map +1 -0
  92. package/dist/neon/paginate.js +51 -0
  93. package/dist/neon/paginate.js.map +1 -0
  94. package/dist/neon/resources/account.d.ts +45 -0
  95. package/dist/neon/resources/account.d.ts.map +1 -0
  96. package/dist/neon/resources/account.js +65 -0
  97. package/dist/neon/resources/account.js.map +1 -0
  98. package/dist/neon/resources/branches.d.ts +84 -0
  99. package/dist/neon/resources/branches.d.ts.map +1 -0
  100. package/dist/neon/resources/branches.js +132 -0
  101. package/dist/neon/resources/branches.js.map +1 -0
  102. package/dist/neon/resources/consumption.d.ts +22 -0
  103. package/dist/neon/resources/consumption.d.ts.map +1 -0
  104. package/dist/neon/resources/consumption.js +59 -0
  105. package/dist/neon/resources/consumption.js.map +1 -0
  106. package/dist/neon/resources/dataapi.d.ts +25 -0
  107. package/dist/neon/resources/dataapi.d.ts.map +1 -0
  108. package/dist/neon/resources/dataapi.js +59 -0
  109. package/dist/neon/resources/dataapi.js.map +1 -0
  110. package/dist/neon/resources/databases.d.ts +30 -0
  111. package/dist/neon/resources/databases.d.ts.map +1 -0
  112. package/dist/neon/resources/databases.js +68 -0
  113. package/dist/neon/resources/databases.js.map +1 -0
  114. package/dist/neon/resources/endpoints.d.ts +39 -0
  115. package/dist/neon/resources/endpoints.d.ts.map +1 -0
  116. package/dist/neon/resources/endpoints.js +89 -0
  117. package/dist/neon/resources/endpoints.js.map +1 -0
  118. package/dist/neon/resources/operations.d.ts +27 -0
  119. package/dist/neon/resources/operations.d.ts.map +1 -0
  120. package/dist/neon/resources/operations.js +50 -0
  121. package/dist/neon/resources/operations.js.map +1 -0
  122. package/dist/neon/resources/postgres.d.ts +45 -0
  123. package/dist/neon/resources/postgres.d.ts.map +1 -0
  124. package/dist/neon/resources/postgres.js +104 -0
  125. package/dist/neon/resources/postgres.js.map +1 -0
  126. package/dist/neon/resources/projects.d.ts +84 -0
  127. package/dist/neon/resources/projects.d.ts.map +1 -0
  128. package/dist/neon/resources/projects.js +111 -0
  129. package/dist/neon/resources/projects.js.map +1 -0
  130. package/dist/neon/resources/roles.d.ts +40 -0
  131. package/dist/neon/resources/roles.d.ts.map +1 -0
  132. package/dist/neon/resources/roles.js +78 -0
  133. package/dist/neon/resources/roles.js.map +1 -0
  134. package/dist/neon/resources/snapshots.d.ts +86 -0
  135. package/dist/neon/resources/snapshots.d.ts.map +1 -0
  136. package/dist/neon/resources/snapshots.js +125 -0
  137. package/dist/neon/resources/snapshots.js.map +1 -0
  138. package/dist/neon/result.d.ts +32 -0
  139. package/dist/neon/result.d.ts.map +1 -0
  140. package/dist/neon/result.js +26 -0
  141. package/dist/neon/result.js.map +1 -0
  142. package/dist/neon/retry.d.ts +17 -0
  143. package/dist/neon/retry.d.ts.map +1 -0
  144. package/dist/neon/retry.js +42 -0
  145. package/dist/neon/retry.js.map +1 -0
  146. package/dist/neon/wait.d.ts +27 -0
  147. package/dist/neon/wait.d.ts.map +1 -0
  148. package/dist/neon/wait.js +70 -0
  149. package/dist/neon/wait.js.map +1 -0
  150. package/dist/node_modules/.pnpm/@vitest_pretty-format@3.0.9/node_modules/@vitest/pretty-format/dist/index.js +879 -0
  151. package/dist/node_modules/.pnpm/@vitest_pretty-format@3.0.9/node_modules/@vitest/pretty-format/dist/index.js.map +1 -0
  152. package/dist/node_modules/.pnpm/@vitest_runner@3.0.9/node_modules/@vitest/runner/dist/chunk-tasks.js +30 -0
  153. package/dist/node_modules/.pnpm/@vitest_runner@3.0.9/node_modules/@vitest/runner/dist/chunk-tasks.js.map +1 -0
  154. package/dist/node_modules/.pnpm/@vitest_runner@3.0.9/node_modules/@vitest/runner/dist/index.js +578 -0
  155. package/dist/node_modules/.pnpm/@vitest_runner@3.0.9/node_modules/@vitest/runner/dist/index.js.map +1 -0
  156. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.js +92 -0
  157. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.js.map +1 -0
  158. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/helpers.js +43 -0
  159. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/helpers.js.map +1 -0
  160. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/index.js +450 -0
  161. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/index.js.map +1 -0
  162. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/source-map.js +168 -0
  163. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/source-map.js.map +1 -0
  164. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/branding.js +10 -0
  165. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/branding.js.map +1 -0
  166. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/index.js +109 -0
  167. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/index.js.map +1 -0
  168. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/messages.js +10 -0
  169. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/messages.js.map +1 -0
  170. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/overloads.js +10 -0
  171. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/overloads.js.map +1 -0
  172. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/utils.js +10 -0
  173. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/utils.js.map +1 -0
  174. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/arguments.js +11 -0
  175. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/arguments.js.map +1 -0
  176. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/array.js +16 -0
  177. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/array.js.map +1 -0
  178. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/bigint.js +11 -0
  179. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/bigint.js.map +1 -0
  180. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/class.js +15 -0
  181. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/class.js.map +1 -0
  182. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/date.js +13 -0
  183. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/date.js.map +1 -0
  184. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/error.js +34 -0
  185. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/error.js.map +1 -0
  186. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/function.js +12 -0
  187. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/function.js.map +1 -0
  188. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/helpers.js +122 -0
  189. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/helpers.js.map +1 -0
  190. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/html.js +39 -0
  191. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/html.js.map +1 -0
  192. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/index.js +99 -0
  193. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/index.js.map +1 -0
  194. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/map.js +25 -0
  195. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/map.js.map +1 -0
  196. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/number.js +14 -0
  197. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/number.js.map +1 -0
  198. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/object.js +21 -0
  199. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/object.js.map +1 -0
  200. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/promise.js +6 -0
  201. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/promise.js.map +1 -0
  202. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/regexp.js +12 -0
  203. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/regexp.js.map +1 -0
  204. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/set.js +18 -0
  205. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/set.js.map +1 -0
  206. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/string.js +24 -0
  207. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/string.js.map +1 -0
  208. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/symbol.js +9 -0
  209. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/symbol.js.map +1 -0
  210. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/typedarray.js +30 -0
  211. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/typedarray.js.map +1 -0
  212. package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.js +82 -0
  213. package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.js.map +1 -0
  214. package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/node.js +7 -0
  215. package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/node.js.map +1 -0
  216. package/dist/node_modules/.pnpm/vitest@3.0.9_@types_debug@4.1.13_@types_node@20.19.17_jiti@2.7.0_jsdom@26.1.0_lightning_fb7ae83398b95c49208c9194029bba02/node_modules/vitest/dist/index.js +8 -0
  217. package/dist/node_modules/.pnpm/vitest@3.0.9_@types_debug@4.1.13_@types_node@20.19.17_jiti@2.7.0_jsdom@26.1.0_lightning_fb7ae83398b95c49208c9194029bba02/node_modules/vitest/dist/index.js.map +1 -0
  218. package/dist/raw.d.ts +13 -0
  219. package/dist/raw.d.ts.map +1 -0
  220. package/dist/raw.js +159 -0
  221. package/dist/raw.js.map +1 -0
  222. package/package.json +58 -16
@@ -0,0 +1,33 @@
1
+ import { NeonError } from "./errors.js";
2
+ import { err, ok } from "./result.js";
3
+ //#region src/neon/connection.ts
4
+ /**
5
+ * Pick a connection string from a create response's `connection_uris`.
6
+ *
7
+ * Neon returns the **direct** URI; the pooled URI is the same string with the host
8
+ * swapped for the `-pooler` host (`connection_parameters.pooler_host`), so we derive it
9
+ * without an extra request. Returns `undefined` when the response carries no connection
10
+ * URI (e.g. a branch created from a parent with multiple roles/databases).
11
+ */
12
+ function pickConnectionString(uris, pooled) {
13
+ const details = uris?.[0];
14
+ if (!details) return void 0;
15
+ if (!pooled) return details.connection_uri;
16
+ const { host, pooler_host } = details.connection_parameters;
17
+ if (!host || !pooler_host) return details.connection_uri;
18
+ return details.connection_uri.replace(host, pooler_host);
19
+ }
20
+ /**
21
+ * Attach a derived connection string to a create result, returning a `client`-kind
22
+ * {@link NeonError} when the response carries no connection URI.
23
+ */
24
+ function withConnectionString(result, uris, build, pooled) {
25
+ if (result.error) return err(result.error);
26
+ const connectionString = pickConnectionString(uris(result.data), pooled);
27
+ if (!connectionString) return err(new NeonError("The response did not include a connection URI (the branch or project may have multiple roles or databases). Use `raw.getConnectionUri` with an explicit role and database.", "client"));
28
+ return ok(build(result.data, connectionString));
29
+ }
30
+ //#endregion
31
+ export { pickConnectionString, withConnectionString };
32
+
33
+ //# sourceMappingURL=connection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.js","names":[],"sources":["../../src/neon/connection.ts"],"sourcesContent":["import type { ConnectionDetails } from \"../client/types.gen.js\";\nimport { NeonError } from \"./errors.js\";\nimport { err, type NeonResult, ok } from \"./result.js\";\n\n/**\n * Pick a connection string from a create response's `connection_uris`.\n *\n * Neon returns the **direct** URI; the pooled URI is the same string with the host\n * swapped for the `-pooler` host (`connection_parameters.pooler_host`), so we derive it\n * without an extra request. Returns `undefined` when the response carries no connection\n * URI (e.g. a branch created from a parent with multiple roles/databases).\n */\nexport function pickConnectionString(\n\turis: ConnectionDetails[] | undefined,\n\tpooled: boolean,\n): string | undefined {\n\tconst details = uris?.[0];\n\tif (!details) return undefined;\n\tif (!pooled) return details.connection_uri;\n\tconst { host, pooler_host } = details.connection_parameters;\n\tif (!host || !pooler_host) return details.connection_uri;\n\treturn details.connection_uri.replace(host, pooler_host);\n}\n\n/**\n * Attach a derived connection string to a create result, returning a `client`-kind\n * {@link NeonError} when the response carries no connection URI.\n */\nexport function withConnectionString<D, T>(\n\tresult: NeonResult<D>,\n\turis: (data: D) => ConnectionDetails[] | undefined,\n\tbuild: (data: D, connectionString: string) => T,\n\tpooled: boolean,\n): NeonResult<T> {\n\tif (result.error) return err(result.error);\n\tconst connectionString = pickConnectionString(uris(result.data), pooled);\n\tif (!connectionString) {\n\t\treturn err(\n\t\t\tnew NeonError(\n\t\t\t\t\"The response did not include a connection URI (the branch or project may have multiple roles or databases). Use `raw.getConnectionUri` with an explicit role and database.\",\n\t\t\t\t\"client\",\n\t\t\t),\n\t\t);\n\t}\n\treturn ok(build(result.data, connectionString));\n}\n"],"mappings":";;;;;;;;;;;AAYA,SAAgB,qBACf,MACA,QACqB;CACrB,MAAM,UAAU,OAAO;CACvB,IAAI,CAAC,SAAS,OAAO,KAAA;CACrB,IAAI,CAAC,QAAQ,OAAO,QAAQ;CAC5B,MAAM,EAAE,MAAM,gBAAgB,QAAQ;CACtC,IAAI,CAAC,QAAQ,CAAC,aAAa,OAAO,QAAQ;CAC1C,OAAO,QAAQ,eAAe,QAAQ,MAAM,WAAW;AACxD;;;;;AAMA,SAAgB,qBACf,QACA,MACA,OACA,QACgB;CAChB,IAAI,OAAO,OAAO,OAAO,IAAI,OAAO,KAAK;CACzC,MAAM,mBAAmB,qBAAqB,KAAK,OAAO,IAAI,GAAG,MAAM;CACvE,IAAI,CAAC,kBACJ,OAAO,IACN,IAAI,UACH,8KACA,QACD,CACD;CAED,OAAO,GAAG,MAAM,OAAO,MAAM,gBAAgB,CAAC;AAC/C"}
@@ -0,0 +1,50 @@
1
+ import { Client } from "../client/client/types.gen.js";
2
+ import { NeonResult } from "./result.js";
3
+ import { WaitForOptions } from "./wait.js";
4
+
5
+ //#region src/neon/context.d.ts
6
+ /** Fully-resolved runtime configuration shared by every resource namespace. */
7
+ interface ResolvedConfig {
8
+ client: Client;
9
+ throwOnError: boolean;
10
+ retries: number;
11
+ waitForReadiness: boolean;
12
+ waitOptions: WaitForOptions;
13
+ orgId?: string;
14
+ }
15
+ /** Per-call overrides accepted by every ergonomic method. */
16
+ interface CallOptions<Throw extends boolean = boolean> {
17
+ /** Override the client's `throwOnError` for this call. */
18
+ throwOnError?: Throw;
19
+ /** Override the client's `waitForReadiness` for this call (mutations only). */
20
+ waitForReadiness?: boolean;
21
+ signal?: AbortSignal;
22
+ }
23
+ interface RawResult<D> {
24
+ data?: D | undefined;
25
+ error?: unknown;
26
+ response?: Response | undefined;
27
+ }
28
+ /**
29
+ * Shared execution core: runs a raw client call with retries, maps its envelope to the
30
+ * ergonomic resource shape, optionally waits for provisioning operations, and applies the
31
+ * resolved `throwOnError` policy. Returns the bare value (throwing) or a {@link NeonResult}.
32
+ */
33
+ declare class RequestContext {
34
+ #private;
35
+ constructor(config: ResolvedConfig);
36
+ get client(): Client;
37
+ get defaults(): ResolvedConfig;
38
+ /** Run a raw call and map its body; applies the resolved `throwOnError` policy. */
39
+ run<D, T>(opts: CallOptions | undefined, exec: (client: Client) => Promise<RawResult<D>>, map: (data: D) => T): Promise<T | NeonResult<T>>;
40
+ /** Like {@link run} but for endpoints that may return an empty (204) body. */
41
+ runVoid<D>(opts: CallOptions | undefined, exec: (client: Client) => Promise<RawResult<D>>): Promise<void | NeonResult<void>>;
42
+ /**
43
+ * Run a raw call and map its body, returning the {@link NeonResult} envelope (no
44
+ * throw). Used by `run` and by workflows that post-process the result.
45
+ */
46
+ execute<D, T>(opts: CallOptions | undefined, exec: (client: Client) => Promise<RawResult<D>>, map: (data: D) => T): Promise<NeonResult<T>>;
47
+ }
48
+ //#endregion
49
+ export { CallOptions, RequestContext, ResolvedConfig };
50
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","names":[],"sources":["../../src/neon/context.ts"],"mappings":";;;;;;UAWiB,cAAA;EAAA,MAAA,EACR,MADQ;EAAc,YAAA,EAAA,OAAA;SACtB,EAAA,MAAA;kBAIK,EAAA,OAAA;EAAc,WAAA,EAAd,cAAc;EAKX,KAAA,CAAA,EAAA,MAAW;;;AAKlB,UALO,WAKP,CAAA,cAAA,OAAA,GAAA,OAAA,CAAA,CAAA;EAAW;EAGX,YAAS,CAAA,EANH,KAMG;EAAA;kBACX,CAAA,EAAA,OAAA;QAEI,CAAA,EANF,WAME;AAAQ;AAQpB,UAXU,SAWG,CAAA,CAAc,CAAA,CAAA;EAAA,IAAA,CAAA,EAVnB,CAUmB,GAAA,SAAA;OAGN,CAAA,EAAA,OAAA;UAIN,CAAA,EAfH,QAeG,GAAA,SAAA;;;;;;;AAYD,cAnBD,cAAA,CAmBC;UAAM;aACR,CAAA,MAAA,EAjBS,cAiBT;MAAe,MAAA,CAAA,CAAA,EAbZ,MAaY;MAAX,QAAA,CAAA,CAAA,EATC,cASD;;KAOR,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,IAAA,EAVA,WAUA,GAAA,SAAA,EAAA,IAAA,EAAA,CAAA,MAAA,EATS,MAST,EAAA,GAToB,OASpB,CAT4B,SAS5B,CATsC,CAStC,CAAA,CAAA,EAAA,GAAA,EAAA,CAAA,IAAA,EARM,CAQN,EAAA,GARY,CAQZ,CAAA,EAPJ,OAOI,CAPI,CAOJ,GAPQ,UAOR,CAPmB,CAOnB,CAAA,CAAA;;SACsC,CAAA,CAAA,CAAA,CAAA,IAAA,EADtC,WACsC,GAAA,SAAA,EAAA,IAAA,EAAA,CAAA,MAAA,EAA7B,MAA6B,EAAA,GAAlB,OAAkB,CAAV,SAAU,CAAA,CAAA,CAAA,CAAA,CAAA,EAC1C,OAD0C,CAAA,IAAA,GAC3B,UAD2B,CAAA,IAAA,CAAA,CAAA;;;;;SAyBtC,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,IAAA,EAAA,WAAA,GAAA,SAAA,EAAA,IAAA,EAAA,CAAA,MAAA,EACS,MADT,EAAA,GACoB,OADpB,CAC4B,SAD5B,CACsC,CADtC,CAAA,CAAA,EAAA,GAAA,EAAA,CAAA,IAAA,EAEM,CAFN,EAAA,GAEY,CAFZ,CAAA,EAGJ,OAHI,CAGI,UAHJ,CAGe,CAHf,CAAA,CAAA"}
@@ -0,0 +1,59 @@
1
+ import { toNeonError } from "./errors.js";
2
+ import { err, finalize, ok } from "./result.js";
3
+ import { withRetries } from "./retry.js";
4
+ import { hasOperations, waitForOperations } from "./wait.js";
5
+ //#region src/neon/context.ts
6
+ /**
7
+ * Shared execution core: runs a raw client call with retries, maps its envelope to the
8
+ * ergonomic resource shape, optionally waits for provisioning operations, and applies the
9
+ * resolved `throwOnError` policy. Returns the bare value (throwing) or a {@link NeonResult}.
10
+ */
11
+ var RequestContext = class {
12
+ #config;
13
+ constructor(config) {
14
+ this.#config = config;
15
+ }
16
+ get client() {
17
+ return this.#config.client;
18
+ }
19
+ get defaults() {
20
+ return this.#config;
21
+ }
22
+ /** Run a raw call and map its body; applies the resolved `throwOnError` policy. */
23
+ async run(opts, exec, map) {
24
+ const shouldThrow = opts?.throwOnError ?? this.#config.throwOnError;
25
+ return finalize(await this.execute(opts, exec, map), shouldThrow);
26
+ }
27
+ /** Like {@link run} but for endpoints that may return an empty (204) body. */
28
+ async runVoid(opts, exec) {
29
+ const shouldThrow = opts?.throwOnError ?? this.#config.throwOnError;
30
+ const raw = await withRetries(() => exec(this.#config.client), this.#config.retries, opts?.signal);
31
+ if (raw.error !== void 0) return finalize(err(toNeonError(raw.error, raw.response)), shouldThrow);
32
+ const readiness = await this.#maybeWait(opts, raw.data);
33
+ if (readiness?.error) return finalize(err(readiness.error), shouldThrow);
34
+ return finalize(ok(void 0), shouldThrow);
35
+ }
36
+ /**
37
+ * Run a raw call and map its body, returning the {@link NeonResult} envelope (no
38
+ * throw). Used by `run` and by workflows that post-process the result.
39
+ */
40
+ async execute(opts, exec, map) {
41
+ const raw = await withRetries(() => exec(this.#config.client), this.#config.retries, opts?.signal);
42
+ if (raw.error || raw.data === void 0) return err(toNeonError(raw.error, raw.response));
43
+ const readiness = await this.#maybeWait(opts, raw.data);
44
+ if (readiness?.error) return err(readiness.error);
45
+ return ok(map(raw.data));
46
+ }
47
+ /** Poll provisioning operations when `waitForReadiness` is on and the body has any. */
48
+ async #maybeWait(opts, data) {
49
+ if (!(opts?.waitForReadiness ?? this.#config.waitForReadiness) || !hasOperations(data)) return void 0;
50
+ return waitForOperations(this.#config.client, data.operations, {
51
+ ...this.#config.waitOptions,
52
+ signal: opts?.signal ?? this.#config.waitOptions.signal
53
+ });
54
+ }
55
+ };
56
+ //#endregion
57
+ export { RequestContext };
58
+
59
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","names":["#config","#maybeWait"],"sources":["../../src/neon/context.ts"],"sourcesContent":["import type { Client } from \"../client/client/index.js\";\nimport { toNeonError } from \"./errors.js\";\nimport { err, finalize, type NeonResult, ok } from \"./result.js\";\nimport { withRetries } from \"./retry.js\";\nimport {\n\thasOperations,\n\ttype WaitForOptions,\n\twaitForOperations,\n} from \"./wait.js\";\n\n/** Fully-resolved runtime configuration shared by every resource namespace. */\nexport interface ResolvedConfig {\n\tclient: Client;\n\tthrowOnError: boolean;\n\tretries: number;\n\twaitForReadiness: boolean;\n\twaitOptions: WaitForOptions;\n\torgId?: string;\n}\n\n/** Per-call overrides accepted by every ergonomic method. */\nexport interface CallOptions<Throw extends boolean = boolean> {\n\t/** Override the client's `throwOnError` for this call. */\n\tthrowOnError?: Throw;\n\t/** Override the client's `waitForReadiness` for this call (mutations only). */\n\twaitForReadiness?: boolean;\n\tsignal?: AbortSignal;\n}\n\ninterface RawResult<D> {\n\tdata?: D | undefined;\n\terror?: unknown;\n\tresponse?: Response | undefined;\n}\n\n/**\n * Shared execution core: runs a raw client call with retries, maps its envelope to the\n * ergonomic resource shape, optionally waits for provisioning operations, and applies the\n * resolved `throwOnError` policy. Returns the bare value (throwing) or a {@link NeonResult}.\n */\nexport class RequestContext {\n\treadonly #config: ResolvedConfig;\n\n\tconstructor(config: ResolvedConfig) {\n\t\tthis.#config = config;\n\t}\n\n\tget client(): Client {\n\t\treturn this.#config.client;\n\t}\n\n\tget defaults(): ResolvedConfig {\n\t\treturn this.#config;\n\t}\n\n\t/** Run a raw call and map its body; applies the resolved `throwOnError` policy. */\n\tasync run<D, T>(\n\t\topts: CallOptions | undefined,\n\t\texec: (client: Client) => Promise<RawResult<D>>,\n\t\tmap: (data: D) => T,\n\t): Promise<T | NeonResult<T>> {\n\t\tconst shouldThrow = opts?.throwOnError ?? this.#config.throwOnError;\n\t\treturn finalize(await this.execute(opts, exec, map), shouldThrow);\n\t}\n\n\t/** Like {@link run} but for endpoints that may return an empty (204) body. */\n\tasync runVoid<D>(\n\t\topts: CallOptions | undefined,\n\t\texec: (client: Client) => Promise<RawResult<D>>,\n\t): Promise<void | NeonResult<void>> {\n\t\tconst shouldThrow = opts?.throwOnError ?? this.#config.throwOnError;\n\t\tconst raw = await withRetries(\n\t\t\t() => exec(this.#config.client),\n\t\t\tthis.#config.retries,\n\t\t\topts?.signal,\n\t\t);\n\t\tif (raw.error !== undefined) {\n\t\t\treturn finalize(\n\t\t\t\terr<void>(toNeonError(raw.error, raw.response)),\n\t\t\t\tshouldThrow,\n\t\t\t);\n\t\t}\n\t\tconst readiness = await this.#maybeWait(opts, raw.data);\n\t\tif (readiness?.error)\n\t\t\treturn finalize(err<void>(readiness.error), shouldThrow);\n\t\treturn finalize(ok(undefined), shouldThrow);\n\t}\n\n\t/**\n\t * Run a raw call and map its body, returning the {@link NeonResult} envelope (no\n\t * throw). Used by `run` and by workflows that post-process the result.\n\t */\n\tasync execute<D, T>(\n\t\topts: CallOptions | undefined,\n\t\texec: (client: Client) => Promise<RawResult<D>>,\n\t\tmap: (data: D) => T,\n\t): Promise<NeonResult<T>> {\n\t\tconst raw = await withRetries(\n\t\t\t() => exec(this.#config.client),\n\t\t\tthis.#config.retries,\n\t\t\topts?.signal,\n\t\t);\n\t\tif (raw.error || raw.data === undefined) {\n\t\t\treturn err(toNeonError(raw.error, raw.response));\n\t\t}\n\t\tconst readiness = await this.#maybeWait(opts, raw.data);\n\t\tif (readiness?.error) return err(readiness.error);\n\t\treturn ok(map(raw.data));\n\t}\n\n\t/** Poll provisioning operations when `waitForReadiness` is on and the body has any. */\n\tasync #maybeWait(\n\t\topts: CallOptions | undefined,\n\t\tdata: unknown,\n\t): Promise<NeonResult<void> | undefined> {\n\t\tconst wait = opts?.waitForReadiness ?? this.#config.waitForReadiness;\n\t\tif (!wait || !hasOperations(data)) return undefined;\n\t\treturn waitForOperations(this.#config.client, data.operations, {\n\t\t\t...this.#config.waitOptions,\n\t\t\tsignal: opts?.signal ?? this.#config.waitOptions.signal,\n\t\t});\n\t}\n}\n"],"mappings":";;;;;;;;;;AAwCA,IAAa,iBAAb,MAA4B;CAC3B;CAEA,YAAY,QAAwB;EACnC,KAAKA,UAAU;CAChB;CAEA,IAAI,SAAiB;EACpB,OAAO,KAAKA,QAAQ;CACrB;CAEA,IAAI,WAA2B;EAC9B,OAAO,KAAKA;CACb;;CAGA,MAAM,IACL,MACA,MACA,KAC6B;EAC7B,MAAM,cAAc,MAAM,gBAAgB,KAAKA,QAAQ;EACvD,OAAO,SAAS,MAAM,KAAK,QAAQ,MAAM,MAAM,GAAG,GAAG,WAAW;CACjE;;CAGA,MAAM,QACL,MACA,MACmC;EACnC,MAAM,cAAc,MAAM,gBAAgB,KAAKA,QAAQ;EACvD,MAAM,MAAM,MAAM,kBACX,KAAK,KAAKA,QAAQ,MAAM,GAC9B,KAAKA,QAAQ,SACb,MAAM,MACP;EACA,IAAI,IAAI,UAAU,KAAA,GACjB,OAAO,SACN,IAAU,YAAY,IAAI,OAAO,IAAI,QAAQ,CAAC,GAC9C,WACD;EAED,MAAM,YAAY,MAAM,KAAKC,WAAW,MAAM,IAAI,IAAI;EACtD,IAAI,WAAW,OACd,OAAO,SAAS,IAAU,UAAU,KAAK,GAAG,WAAW;EACxD,OAAO,SAAS,GAAG,KAAA,CAAS,GAAG,WAAW;CAC3C;;;;;CAMA,MAAM,QACL,MACA,MACA,KACyB;EACzB,MAAM,MAAM,MAAM,kBACX,KAAK,KAAKD,QAAQ,MAAM,GAC9B,KAAKA,QAAQ,SACb,MAAM,MACP;EACA,IAAI,IAAI,SAAS,IAAI,SAAS,KAAA,GAC7B,OAAO,IAAI,YAAY,IAAI,OAAO,IAAI,QAAQ,CAAC;EAEhD,MAAM,YAAY,MAAM,KAAKC,WAAW,MAAM,IAAI,IAAI;EACtD,IAAI,WAAW,OAAO,OAAO,IAAI,UAAU,KAAK;EAChD,OAAO,GAAG,IAAI,IAAI,IAAI,CAAC;CACxB;;CAGA,MAAMA,WACL,MACA,MACwC;EAExC,IAAI,EADS,MAAM,oBAAoB,KAAKD,QAAQ,qBACvC,CAAC,cAAc,IAAI,GAAG,OAAO,KAAA;EAC1C,OAAO,kBAAkB,KAAKA,QAAQ,QAAQ,KAAK,YAAY;GAC9D,GAAG,KAAKA,QAAQ;GAChB,QAAQ,MAAM,UAAU,KAAKA,QAAQ,YAAY;EAClD,CAAC;CACF;AACD"}
@@ -0,0 +1,26 @@
1
+ //#region src/neon/coverage.d.ts
2
+ /**
3
+ * Drift guard for the ergonomic layer.
4
+ *
5
+ * The raw layer is regenerated from the OpenAPI spec, so it auto-tracks new endpoints.
6
+ * The ergonomic resource namespaces are hand-authored, so they can silently fall behind.
7
+ * `coverage.test.ts` compares the generated operation set against {@link EXPECTED_OPERATIONS}
8
+ * and fails CI when they differ — forcing a conscious decision on every spec change:
9
+ * either wrap the new operation in a resource (and add it to {@link WRAPPED}) or accept
10
+ * that it stays raw-only (and add it to the snapshot below).
11
+ *
12
+ * Workflow when the test fails after a `pnpm generate`:
13
+ * 1. Review the `added` / `removed` operations the test reports.
14
+ * 2. Wrap the ones worth ergonomic treatment (and list them in {@link WRAPPED}).
15
+ * 3. Update {@link EXPECTED_OPERATIONS} to match the new generated set.
16
+ */
17
+ /** Operations surfaced by the ergonomic `createNeonClient` namespaces. */
18
+ declare const WRAPPED: ReadonlySet<string>;
19
+ /**
20
+ * Committed snapshot of every operation the generated client exposes. Update this
21
+ * deliberately whenever the spec (and thus the generated client) changes.
22
+ */
23
+ declare const EXPECTED_OPERATIONS: ReadonlySet<string>;
24
+ //#endregion
25
+ export { EXPECTED_OPERATIONS, WRAPPED };
26
+ //# sourceMappingURL=coverage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coverage.d.ts","names":[],"sources":["../../src/neon/coverage.ts"],"mappings":";;AAiBA;AA0EA;;;;;;;;;;;;;;cA1Ea,SAAS;;;;;cA0ET,qBAAqB"}
@@ -0,0 +1,229 @@
1
+ //#region src/neon/coverage.ts
2
+ /**
3
+ * Drift guard for the ergonomic layer.
4
+ *
5
+ * The raw layer is regenerated from the OpenAPI spec, so it auto-tracks new endpoints.
6
+ * The ergonomic resource namespaces are hand-authored, so they can silently fall behind.
7
+ * `coverage.test.ts` compares the generated operation set against {@link EXPECTED_OPERATIONS}
8
+ * and fails CI when they differ — forcing a conscious decision on every spec change:
9
+ * either wrap the new operation in a resource (and add it to {@link WRAPPED}) or accept
10
+ * that it stays raw-only (and add it to the snapshot below).
11
+ *
12
+ * Workflow when the test fails after a `pnpm generate`:
13
+ * 1. Review the `added` / `removed` operations the test reports.
14
+ * 2. Wrap the ones worth ergonomic treatment (and list them in {@link WRAPPED}).
15
+ * 3. Update {@link EXPECTED_OPERATIONS} to match the new generated set.
16
+ */
17
+ /** Operations surfaced by the ergonomic `createNeonClient` namespaces. */
18
+ const WRAPPED = /* @__PURE__ */ new Set([
19
+ "listProjects",
20
+ "getProject",
21
+ "createProject",
22
+ "updateProject",
23
+ "deleteProject",
24
+ "transferProjectsFromOrgToOrg",
25
+ "transferProjectsFromUserToOrg",
26
+ "listProjectBranches",
27
+ "getProjectBranch",
28
+ "createProjectBranch",
29
+ "updateProjectBranch",
30
+ "deleteProjectBranch",
31
+ "setDefaultProjectBranch",
32
+ "finalizeRestoreBranch",
33
+ "getProjectOperation",
34
+ "listProjectOperations",
35
+ "listProjectEndpoints",
36
+ "getProjectEndpoint",
37
+ "createProjectEndpoint",
38
+ "updateProjectEndpoint",
39
+ "deleteProjectEndpoint",
40
+ "startProjectEndpoint",
41
+ "suspendProjectEndpoint",
42
+ "restartProjectEndpoint",
43
+ "listProjectBranchDatabases",
44
+ "getProjectBranchDatabase",
45
+ "createProjectBranchDatabase",
46
+ "updateProjectBranchDatabase",
47
+ "deleteProjectBranchDatabase",
48
+ "listProjectBranchRoles",
49
+ "getProjectBranchRole",
50
+ "createProjectBranchRole",
51
+ "deleteProjectBranchRole",
52
+ "getProjectBranchRolePassword",
53
+ "resetProjectBranchRolePassword",
54
+ "getConnectionUri",
55
+ "getProjectBranchDataApi",
56
+ "createProjectBranchDataApi",
57
+ "updateProjectBranchDataApi",
58
+ "deleteProjectBranchDataApi",
59
+ "listSnapshots",
60
+ "createSnapshot",
61
+ "updateSnapshot",
62
+ "deleteSnapshot",
63
+ "restoreSnapshot",
64
+ "getSnapshotSchedule",
65
+ "setSnapshotSchedule",
66
+ "getConsumptionHistoryPerProject",
67
+ "getConsumptionHistoryPerProjectV2",
68
+ "getConsumptionHistoryPerBranchV2",
69
+ "getCurrentUserInfo",
70
+ "getCurrentUserOrganizations",
71
+ "getActiveRegions",
72
+ "listApiKeys",
73
+ "createApiKey",
74
+ "revokeApiKey"
75
+ ]);
76
+ /**
77
+ * Committed snapshot of every operation the generated client exposes. Update this
78
+ * deliberately whenever the spec (and thus the generated client) changes.
79
+ */
80
+ const EXPECTED_OPERATIONS = /* @__PURE__ */ new Set([
81
+ "acceptProjectTransferRequest",
82
+ "addBranchNeonAuthOauthProvider",
83
+ "addBranchNeonAuthTrustedDomain",
84
+ "addNeonAuthDomainToRedirectUriWhitelist",
85
+ "addNeonAuthOauthProvider",
86
+ "addProjectJwks",
87
+ "assignOrganizationVpcEndpoint",
88
+ "assignProjectVpcEndpoint",
89
+ "countProjectBranches",
90
+ "createApiKey",
91
+ "createBranchNeonAuthNewUser",
92
+ "createNeonAuth",
93
+ "createNeonAuthIntegration",
94
+ "createNeonAuthNewUser",
95
+ "createNeonAuthProviderSdkKeys",
96
+ "createOrgApiKey",
97
+ "createOrganizationInvitations",
98
+ "createProject",
99
+ "createProjectBranch",
100
+ "createProjectBranchAnonymized",
101
+ "createProjectBranchDataApi",
102
+ "createProjectBranchDatabase",
103
+ "createProjectBranchRole",
104
+ "createProjectEndpoint",
105
+ "createProjectTransferRequest",
106
+ "createSnapshot",
107
+ "deleteBranchNeonAuthOauthProvider",
108
+ "deleteBranchNeonAuthTrustedDomain",
109
+ "deleteBranchNeonAuthUser",
110
+ "deleteNeonAuthDomainFromRedirectUriWhitelist",
111
+ "deleteNeonAuthIntegration",
112
+ "deleteNeonAuthOauthProvider",
113
+ "deleteNeonAuthUser",
114
+ "deleteOrganizationSpendingLimit",
115
+ "deleteOrganizationVpcEndpoint",
116
+ "deleteProject",
117
+ "deleteProjectBranch",
118
+ "deleteProjectBranchDataApi",
119
+ "deleteProjectBranchDatabase",
120
+ "deleteProjectBranchRole",
121
+ "deleteProjectEndpoint",
122
+ "deleteProjectJwks",
123
+ "deleteProjectVpcEndpoint",
124
+ "deleteSnapshot",
125
+ "disableNeonAuth",
126
+ "finalizeRestoreBranch",
127
+ "getActiveRegions",
128
+ "getAnonymizedBranchStatus",
129
+ "getAuthDetails",
130
+ "getAvailablePreloadLibraries",
131
+ "getConnectionUri",
132
+ "getConsumptionHistoryPerBranchV2",
133
+ "getConsumptionHistoryPerProject",
134
+ "getConsumptionHistoryPerProjectV2",
135
+ "getCurrentUserInfo",
136
+ "getCurrentUserOrganizations",
137
+ "getMaskingRules",
138
+ "getNeonAuth",
139
+ "getNeonAuthAllowLocalhost",
140
+ "getNeonAuthEmailAndPasswordConfig",
141
+ "getNeonAuthEmailProvider",
142
+ "getNeonAuthEmailServer",
143
+ "getNeonAuthPhoneNumberPlugin",
144
+ "getNeonAuthPluginConfigs",
145
+ "getNeonAuthWebhookConfig",
146
+ "getOrganization",
147
+ "getOrganizationInvitations",
148
+ "getOrganizationMember",
149
+ "getOrganizationMembers",
150
+ "getOrganizationSpendingLimit",
151
+ "getOrganizationVpcEndpointDetails",
152
+ "getProject",
153
+ "getProjectAdvisorSecurityIssues",
154
+ "getProjectBranch",
155
+ "getProjectBranchDataApi",
156
+ "getProjectBranchDatabase",
157
+ "getProjectBranchRole",
158
+ "getProjectBranchRolePassword",
159
+ "getProjectBranchSchema",
160
+ "getProjectBranchSchemaComparison",
161
+ "getProjectEndpoint",
162
+ "getProjectJwks",
163
+ "getProjectOperation",
164
+ "getSnapshotSchedule",
165
+ "grantPermissionToProject",
166
+ "listApiKeys",
167
+ "listBranchNeonAuthOauthProviders",
168
+ "listBranchNeonAuthTrustedDomains",
169
+ "listNeonAuthIntegrations",
170
+ "listNeonAuthOauthProviders",
171
+ "listNeonAuthRedirectUriWhitelistDomains",
172
+ "listOrgApiKeys",
173
+ "listOrganizationVpcEndpoints",
174
+ "listOrganizationVpcEndpointsAllRegions",
175
+ "listProjectBranchDatabases",
176
+ "listProjectBranchEndpoints",
177
+ "listProjectBranchRoles",
178
+ "listProjectBranches",
179
+ "listProjectEndpoints",
180
+ "listProjectOperations",
181
+ "listProjectPermissions",
182
+ "listProjectVpcEndpoints",
183
+ "listProjects",
184
+ "listSharedProjects",
185
+ "listSnapshots",
186
+ "recoverProject",
187
+ "removeOrganizationMember",
188
+ "resetProjectBranchRolePassword",
189
+ "restartProjectEndpoint",
190
+ "restoreProjectBranch",
191
+ "restoreSnapshot",
192
+ "revokeApiKey",
193
+ "revokeOrgApiKey",
194
+ "revokePermissionFromProject",
195
+ "sendNeonAuthTestEmail",
196
+ "setDefaultProjectBranch",
197
+ "setOrganizationSpendingLimit",
198
+ "setSnapshotSchedule",
199
+ "startAnonymization",
200
+ "startProjectEndpoint",
201
+ "suspendProjectEndpoint",
202
+ "transferNeonAuthProviderProject",
203
+ "transferProjectsFromOrgToOrg",
204
+ "transferProjectsFromUserToOrg",
205
+ "updateBranchNeonAuthOauthProvider",
206
+ "updateMaskingRules",
207
+ "updateNeonAuthAllowLocalhost",
208
+ "updateNeonAuthConfig",
209
+ "updateNeonAuthEmailAndPasswordConfig",
210
+ "updateNeonAuthEmailProvider",
211
+ "updateNeonAuthEmailServer",
212
+ "updateNeonAuthMagicLinkPlugin",
213
+ "updateNeonAuthOauthProvider",
214
+ "updateNeonAuthOrganizationPlugin",
215
+ "updateNeonAuthPhoneNumberPlugin",
216
+ "updateNeonAuthUserRole",
217
+ "updateNeonAuthWebhookConfig",
218
+ "updateOrganizationMember",
219
+ "updateProject",
220
+ "updateProjectBranch",
221
+ "updateProjectBranchDataApi",
222
+ "updateProjectBranchDatabase",
223
+ "updateProjectEndpoint",
224
+ "updateSnapshot"
225
+ ]);
226
+ //#endregion
227
+ export { EXPECTED_OPERATIONS, WRAPPED };
228
+
229
+ //# sourceMappingURL=coverage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coverage.js","names":[],"sources":["../../src/neon/coverage.ts"],"sourcesContent":["/**\n * Drift guard for the ergonomic layer.\n *\n * The raw layer is regenerated from the OpenAPI spec, so it auto-tracks new endpoints.\n * The ergonomic resource namespaces are hand-authored, so they can silently fall behind.\n * `coverage.test.ts` compares the generated operation set against {@link EXPECTED_OPERATIONS}\n * and fails CI when they differ — forcing a conscious decision on every spec change:\n * either wrap the new operation in a resource (and add it to {@link WRAPPED}) or accept\n * that it stays raw-only (and add it to the snapshot below).\n *\n * Workflow when the test fails after a `pnpm generate`:\n * 1. Review the `added` / `removed` operations the test reports.\n * 2. Wrap the ones worth ergonomic treatment (and list them in {@link WRAPPED}).\n * 3. Update {@link EXPECTED_OPERATIONS} to match the new generated set.\n */\n\n/** Operations surfaced by the ergonomic `createNeonClient` namespaces. */\nexport const WRAPPED: ReadonlySet<string> = new Set([\n\t// projects\n\t\"listProjects\",\n\t\"getProject\",\n\t\"createProject\",\n\t\"updateProject\",\n\t\"deleteProject\",\n\t// projects: transfer\n\t\"transferProjectsFromOrgToOrg\",\n\t\"transferProjectsFromUserToOrg\",\n\t// branches\n\t\"listProjectBranches\",\n\t\"getProjectBranch\",\n\t\"createProjectBranch\",\n\t\"updateProjectBranch\",\n\t\"deleteProjectBranch\",\n\t\"setDefaultProjectBranch\",\n\t\"finalizeRestoreBranch\",\n\t// operations\n\t\"getProjectOperation\",\n\t\"listProjectOperations\",\n\t// postgres: endpoints\n\t\"listProjectEndpoints\",\n\t\"getProjectEndpoint\",\n\t\"createProjectEndpoint\",\n\t\"updateProjectEndpoint\",\n\t\"deleteProjectEndpoint\",\n\t\"startProjectEndpoint\",\n\t\"suspendProjectEndpoint\",\n\t\"restartProjectEndpoint\",\n\t// postgres: databases\n\t\"listProjectBranchDatabases\",\n\t\"getProjectBranchDatabase\",\n\t\"createProjectBranchDatabase\",\n\t\"updateProjectBranchDatabase\",\n\t\"deleteProjectBranchDatabase\",\n\t// postgres: roles\n\t\"listProjectBranchRoles\",\n\t\"getProjectBranchRole\",\n\t\"createProjectBranchRole\",\n\t\"deleteProjectBranchRole\",\n\t\"getProjectBranchRolePassword\",\n\t\"resetProjectBranchRolePassword\",\n\t// postgres: connection string + data api\n\t\"getConnectionUri\",\n\t\"getProjectBranchDataApi\",\n\t\"createProjectBranchDataApi\",\n\t\"updateProjectBranchDataApi\",\n\t\"deleteProjectBranchDataApi\",\n\t// snapshots\n\t\"listSnapshots\",\n\t\"createSnapshot\",\n\t\"updateSnapshot\",\n\t\"deleteSnapshot\",\n\t\"restoreSnapshot\",\n\t\"getSnapshotSchedule\",\n\t\"setSnapshotSchedule\",\n\t// consumption\n\t\"getConsumptionHistoryPerProject\",\n\t\"getConsumptionHistoryPerProjectV2\",\n\t\"getConsumptionHistoryPerBranchV2\",\n\t// account\n\t\"getCurrentUserInfo\",\n\t\"getCurrentUserOrganizations\",\n\t\"getActiveRegions\",\n\t\"listApiKeys\",\n\t\"createApiKey\",\n\t\"revokeApiKey\",\n]);\n\n/**\n * Committed snapshot of every operation the generated client exposes. Update this\n * deliberately whenever the spec (and thus the generated client) changes.\n */\nexport const EXPECTED_OPERATIONS: ReadonlySet<string> = new Set([\n\t\"acceptProjectTransferRequest\",\n\t\"addBranchNeonAuthOauthProvider\",\n\t\"addBranchNeonAuthTrustedDomain\",\n\t\"addNeonAuthDomainToRedirectUriWhitelist\",\n\t\"addNeonAuthOauthProvider\",\n\t\"addProjectJwks\",\n\t\"assignOrganizationVpcEndpoint\",\n\t\"assignProjectVpcEndpoint\",\n\t\"countProjectBranches\",\n\t\"createApiKey\",\n\t\"createBranchNeonAuthNewUser\",\n\t\"createNeonAuth\",\n\t\"createNeonAuthIntegration\",\n\t\"createNeonAuthNewUser\",\n\t\"createNeonAuthProviderSdkKeys\",\n\t\"createOrgApiKey\",\n\t\"createOrganizationInvitations\",\n\t\"createProject\",\n\t\"createProjectBranch\",\n\t\"createProjectBranchAnonymized\",\n\t\"createProjectBranchDataApi\",\n\t\"createProjectBranchDatabase\",\n\t\"createProjectBranchRole\",\n\t\"createProjectEndpoint\",\n\t\"createProjectTransferRequest\",\n\t\"createSnapshot\",\n\t\"deleteBranchNeonAuthOauthProvider\",\n\t\"deleteBranchNeonAuthTrustedDomain\",\n\t\"deleteBranchNeonAuthUser\",\n\t\"deleteNeonAuthDomainFromRedirectUriWhitelist\",\n\t\"deleteNeonAuthIntegration\",\n\t\"deleteNeonAuthOauthProvider\",\n\t\"deleteNeonAuthUser\",\n\t\"deleteOrganizationSpendingLimit\",\n\t\"deleteOrganizationVpcEndpoint\",\n\t\"deleteProject\",\n\t\"deleteProjectBranch\",\n\t\"deleteProjectBranchDataApi\",\n\t\"deleteProjectBranchDatabase\",\n\t\"deleteProjectBranchRole\",\n\t\"deleteProjectEndpoint\",\n\t\"deleteProjectJwks\",\n\t\"deleteProjectVpcEndpoint\",\n\t\"deleteSnapshot\",\n\t\"disableNeonAuth\",\n\t\"finalizeRestoreBranch\",\n\t\"getActiveRegions\",\n\t\"getAnonymizedBranchStatus\",\n\t\"getAuthDetails\",\n\t\"getAvailablePreloadLibraries\",\n\t\"getConnectionUri\",\n\t\"getConsumptionHistoryPerBranchV2\",\n\t\"getConsumptionHistoryPerProject\",\n\t\"getConsumptionHistoryPerProjectV2\",\n\t\"getCurrentUserInfo\",\n\t\"getCurrentUserOrganizations\",\n\t\"getMaskingRules\",\n\t\"getNeonAuth\",\n\t\"getNeonAuthAllowLocalhost\",\n\t\"getNeonAuthEmailAndPasswordConfig\",\n\t\"getNeonAuthEmailProvider\",\n\t\"getNeonAuthEmailServer\",\n\t\"getNeonAuthPhoneNumberPlugin\",\n\t\"getNeonAuthPluginConfigs\",\n\t\"getNeonAuthWebhookConfig\",\n\t\"getOrganization\",\n\t\"getOrganizationInvitations\",\n\t\"getOrganizationMember\",\n\t\"getOrganizationMembers\",\n\t\"getOrganizationSpendingLimit\",\n\t\"getOrganizationVpcEndpointDetails\",\n\t\"getProject\",\n\t\"getProjectAdvisorSecurityIssues\",\n\t\"getProjectBranch\",\n\t\"getProjectBranchDataApi\",\n\t\"getProjectBranchDatabase\",\n\t\"getProjectBranchRole\",\n\t\"getProjectBranchRolePassword\",\n\t\"getProjectBranchSchema\",\n\t\"getProjectBranchSchemaComparison\",\n\t\"getProjectEndpoint\",\n\t\"getProjectJwks\",\n\t\"getProjectOperation\",\n\t\"getSnapshotSchedule\",\n\t\"grantPermissionToProject\",\n\t\"listApiKeys\",\n\t\"listBranchNeonAuthOauthProviders\",\n\t\"listBranchNeonAuthTrustedDomains\",\n\t\"listNeonAuthIntegrations\",\n\t\"listNeonAuthOauthProviders\",\n\t\"listNeonAuthRedirectUriWhitelistDomains\",\n\t\"listOrgApiKeys\",\n\t\"listOrganizationVpcEndpoints\",\n\t\"listOrganizationVpcEndpointsAllRegions\",\n\t\"listProjectBranchDatabases\",\n\t\"listProjectBranchEndpoints\",\n\t\"listProjectBranchRoles\",\n\t\"listProjectBranches\",\n\t\"listProjectEndpoints\",\n\t\"listProjectOperations\",\n\t\"listProjectPermissions\",\n\t\"listProjectVpcEndpoints\",\n\t\"listProjects\",\n\t\"listSharedProjects\",\n\t\"listSnapshots\",\n\t\"recoverProject\",\n\t\"removeOrganizationMember\",\n\t\"resetProjectBranchRolePassword\",\n\t\"restartProjectEndpoint\",\n\t\"restoreProjectBranch\",\n\t\"restoreSnapshot\",\n\t\"revokeApiKey\",\n\t\"revokeOrgApiKey\",\n\t\"revokePermissionFromProject\",\n\t\"sendNeonAuthTestEmail\",\n\t\"setDefaultProjectBranch\",\n\t\"setOrganizationSpendingLimit\",\n\t\"setSnapshotSchedule\",\n\t\"startAnonymization\",\n\t\"startProjectEndpoint\",\n\t\"suspendProjectEndpoint\",\n\t\"transferNeonAuthProviderProject\",\n\t\"transferProjectsFromOrgToOrg\",\n\t\"transferProjectsFromUserToOrg\",\n\t\"updateBranchNeonAuthOauthProvider\",\n\t\"updateMaskingRules\",\n\t\"updateNeonAuthAllowLocalhost\",\n\t\"updateNeonAuthConfig\",\n\t\"updateNeonAuthEmailAndPasswordConfig\",\n\t\"updateNeonAuthEmailProvider\",\n\t\"updateNeonAuthEmailServer\",\n\t\"updateNeonAuthMagicLinkPlugin\",\n\t\"updateNeonAuthOauthProvider\",\n\t\"updateNeonAuthOrganizationPlugin\",\n\t\"updateNeonAuthPhoneNumberPlugin\",\n\t\"updateNeonAuthUserRole\",\n\t\"updateNeonAuthWebhookConfig\",\n\t\"updateOrganizationMember\",\n\t\"updateProject\",\n\t\"updateProjectBranch\",\n\t\"updateProjectBranchDataApi\",\n\t\"updateProjectBranchDatabase\",\n\t\"updateProjectEndpoint\",\n\t\"updateSnapshot\",\n]);\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,0BAA+B,IAAI,IAAI;CAEnD;CACA;CACA;CACA;CACA;CAEA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;;;;AAMD,MAAa,sCAA2C,IAAI,IAAI;CAC/D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC"}
@@ -0,0 +1,78 @@
1
+ //#region src/neon/errors.d.ts
2
+ /**
3
+ * Typed error hierarchy surfaced on the `error` channel of every ergonomic call (and
4
+ * thrown when `throwOnError` is set). All are `Error` subclasses with a `kind`
5
+ * discriminant, so the same value works whether you read it from `{ error }` or `catch`
6
+ * it.
7
+ */
8
+ type NeonErrorKind = "api" | "not_found" | "auth" | "rate_limit" | "operation" | "timeout" | "network" | "client";
9
+ /** Base class for every error the ergonomic layer produces. */
10
+ declare class NeonError extends Error {
11
+ readonly kind: NeonErrorKind;
12
+ constructor(message: string, kind: NeonErrorKind, options?: {
13
+ cause?: unknown;
14
+ });
15
+ }
16
+ /** A non-2xx HTTP response from the Neon API. */
17
+ declare class NeonApiError extends NeonError {
18
+ /** HTTP status code. */
19
+ readonly status: number;
20
+ /** Machine-readable Neon error code (`GeneralError.code`), when present. */
21
+ readonly code?: string;
22
+ /** Neon request id (`X-Request-Id` / `GeneralError.request_id`), when present. */
23
+ readonly requestId?: string;
24
+ /** The raw response, when one was received. */
25
+ readonly response?: Response;
26
+ /** The parsed error body, as returned by the API. */
27
+ readonly body: unknown;
28
+ constructor(message: string, init: {
29
+ kind?: NeonErrorKind;
30
+ status: number;
31
+ code?: string;
32
+ requestId?: string;
33
+ response?: Response;
34
+ body?: unknown;
35
+ });
36
+ }
37
+ /** 404 — the resource does not exist. */
38
+ declare class NeonNotFoundError extends NeonApiError {
39
+ constructor(message: string, init: ConstructorParameters<typeof NeonApiError>[1]);
40
+ }
41
+ /** 401/403 — the API key is missing, invalid, or lacks permission. */
42
+ declare class NeonAuthError extends NeonApiError {
43
+ constructor(message: string, init: ConstructorParameters<typeof NeonApiError>[1]);
44
+ }
45
+ /** 429 — rate limited (after retries, if enabled, were exhausted). */
46
+ declare class NeonRateLimitError extends NeonApiError {
47
+ constructor(message: string, init: ConstructorParameters<typeof NeonApiError>[1]);
48
+ }
49
+ /** An awaited Neon operation ended in a non-success terminal state. */
50
+ declare class NeonOperationError extends NeonError {
51
+ /** The id of the operation that failed. */
52
+ readonly operationId: string;
53
+ /** The terminal status reported by the API (`failed` / `error` / `cancelled`). */
54
+ readonly status: string;
55
+ constructor(message: string, init: {
56
+ operationId: string;
57
+ status: string;
58
+ });
59
+ }
60
+ /** Waiting for operations to finish exceeded the configured timeout. */
61
+ declare class NeonTimeoutError extends NeonError {
62
+ constructor(message: string);
63
+ }
64
+ /** A transport-level failure (DNS, connection, abort) — no HTTP response received. */
65
+ declare class NeonNetworkError extends NeonError {
66
+ constructor(message: string, options?: {
67
+ cause?: unknown;
68
+ });
69
+ }
70
+ /**
71
+ * Build the right {@link NeonError} subclass from a raw client result. `error` is the
72
+ * decoded error body (Neon `GeneralError`); `response` is present unless the failure was
73
+ * transport-level.
74
+ */
75
+ declare function toNeonError(error: unknown, response: Response | undefined): NeonError;
76
+ //#endregion
77
+ export { NeonApiError, NeonAuthError, NeonError, NeonErrorKind, NeonNetworkError, NeonNotFoundError, NeonOperationError, NeonRateLimitError, NeonTimeoutError, toNeonError };
78
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","names":[],"sources":["../../src/neon/errors.ts"],"mappings":";;AAOA;AAWA;;;;AAA+B,KAXnB,aAAA,GAWmB,KAAA,GAAA,WAAA,GAAA,MAAA,GAAA,YAAA,GAAA,WAAA,GAAA,SAAA,GAAA,SAAA,GAAA,QAAA;AAAK;AAevB,cAfA,SAAA,SAAkB,KAAA,CAeL;EAAA,SAAA,IAAA,EAdV,aAcU;aAQL,CAAA,OAAA,EAAA,MAAA,EAAA,IAAA,EAlBb,aAkBa,EAAA,QAAA,EAAA;IAOX,KAAA,CAAA,EAAA,OAAA;;;AAfiC;AAiC9B,cAjCA,YAAA,SAAqB,SAAA,CAiCH;EAAA;WAGM,MAAA,EAAA,MAAA;;WAHE,IAAA,CAAA,EAAA,MAAA;EAAY;EAUtC,SAAA,SAAc,CAAA,EAAA,MAAA;EAAA;WAGU,QAAA,CAAA,EAtChB,QAsCgB;;WAHF,IAAA,EAAA,OAAA;EAAY,WAAA,CAAA,OAAA,EAAA,MAAA,EAAA,IAAA,EAAA;IAUlC,IAAA,CAAA,EAtCH,aAsCsB;IAAA,MAAA,EAAA,MAAA;IAGK,IAAA,CAAA,EAAA,MAAA;IAA7B,SAAA,CAAA,EAAA,MAAA;IAHgC,QAAA,CAAA,EAlC1B,QAkC0B;IAAY,IAAA,CAAA,EAAA,OAAA;EAUvC,CAAA;AAiBb;AAOA;AA6BgB,cAnFH,iBAAA,SAA0B,YAAA,CAmFZ;EAAA,WAAA,CAAA,OAAA,EAAA,MAAA,EAAA,IAAA,EAhFnB,qBAgFmB,CAAA,OAhFU,YAgFV,CAAA,CAAA,CAAA,CAAA;;;AAGf,cA5EC,aAAA,SAAsB,YAAA,CA4EvB;qCAzEJ,6BAA6B;;;cAOxB,kBAAA,SAA2B,YAAA;qCAGhC,6BAA6B;;;cAOxB,kBAAA,SAA2B,SAAS;;;;;;;;;;;cAiBpC,gBAAA,SAAyB,SAAS;;;;cAOlC,gBAAA,SAAyB,SAAS;;;;;;;;;;iBA6B/B,WAAA,2BAEL,uBACR"}
@@ -0,0 +1,116 @@
1
+ //#region src/neon/errors.ts
2
+ /** Base class for every error the ergonomic layer produces. */
3
+ var NeonError = class extends Error {
4
+ kind;
5
+ constructor(message, kind, options) {
6
+ super(message, options);
7
+ this.name = new.target.name;
8
+ this.kind = kind;
9
+ }
10
+ };
11
+ /** A non-2xx HTTP response from the Neon API. */
12
+ var NeonApiError = class extends NeonError {
13
+ /** HTTP status code. */
14
+ status;
15
+ /** Machine-readable Neon error code (`GeneralError.code`), when present. */
16
+ code;
17
+ /** Neon request id (`X-Request-Id` / `GeneralError.request_id`), when present. */
18
+ requestId;
19
+ /** The raw response, when one was received. */
20
+ response;
21
+ /** The parsed error body, as returned by the API. */
22
+ body;
23
+ constructor(message, init) {
24
+ super(message, init.kind ?? "api");
25
+ this.status = init.status;
26
+ this.code = init.code;
27
+ this.requestId = init.requestId;
28
+ this.response = init.response;
29
+ this.body = init.body;
30
+ }
31
+ };
32
+ /** 404 — the resource does not exist. */
33
+ var NeonNotFoundError = class extends NeonApiError {
34
+ constructor(message, init) {
35
+ super(message, {
36
+ ...init,
37
+ kind: "not_found"
38
+ });
39
+ }
40
+ };
41
+ /** 401/403 — the API key is missing, invalid, or lacks permission. */
42
+ var NeonAuthError = class extends NeonApiError {
43
+ constructor(message, init) {
44
+ super(message, {
45
+ ...init,
46
+ kind: "auth"
47
+ });
48
+ }
49
+ };
50
+ /** 429 — rate limited (after retries, if enabled, were exhausted). */
51
+ var NeonRateLimitError = class extends NeonApiError {
52
+ constructor(message, init) {
53
+ super(message, {
54
+ ...init,
55
+ kind: "rate_limit"
56
+ });
57
+ }
58
+ };
59
+ /** An awaited Neon operation ended in a non-success terminal state. */
60
+ var NeonOperationError = class extends NeonError {
61
+ /** The id of the operation that failed. */
62
+ operationId;
63
+ /** The terminal status reported by the API (`failed` / `error` / `cancelled`). */
64
+ status;
65
+ constructor(message, init) {
66
+ super(message, "operation");
67
+ this.operationId = init.operationId;
68
+ this.status = init.status;
69
+ }
70
+ };
71
+ /** Waiting for operations to finish exceeded the configured timeout. */
72
+ var NeonTimeoutError = class extends NeonError {
73
+ constructor(message) {
74
+ super(message, "timeout");
75
+ }
76
+ };
77
+ /** A transport-level failure (DNS, connection, abort) — no HTTP response received. */
78
+ var NeonNetworkError = class extends NeonError {
79
+ constructor(message, options) {
80
+ super(message, "network", options);
81
+ }
82
+ };
83
+ function readApiErrorBody(body) {
84
+ if (typeof body !== "object" || body === null) return {};
85
+ const out = {};
86
+ if ("message" in body && typeof body.message === "string") out.message = body.message;
87
+ if ("code" in body && typeof body.code === "string") out.code = body.code;
88
+ if ("request_id" in body && typeof body.request_id === "string") out.request_id = body.request_id;
89
+ return out;
90
+ }
91
+ /**
92
+ * Build the right {@link NeonError} subclass from a raw client result. `error` is the
93
+ * decoded error body (Neon `GeneralError`); `response` is present unless the failure was
94
+ * transport-level.
95
+ */
96
+ function toNeonError(error, response) {
97
+ if (!response) return new NeonNetworkError("Network error: no response received from the Neon API.", { cause: error });
98
+ const parsed = readApiErrorBody(error);
99
+ const status = response.status;
100
+ const message = parsed.message ?? `Neon API request failed with status ${status}.`;
101
+ const init = {
102
+ status,
103
+ code: parsed.code,
104
+ requestId: parsed.request_id ?? response.headers.get("x-request-id") ?? void 0,
105
+ response,
106
+ body: error
107
+ };
108
+ if (status === 404) return new NeonNotFoundError(message, init);
109
+ if (status === 401 || status === 403) return new NeonAuthError(message, init);
110
+ if (status === 429) return new NeonRateLimitError(message, init);
111
+ return new NeonApiError(message, init);
112
+ }
113
+ //#endregion
114
+ export { NeonApiError, NeonAuthError, NeonError, NeonNetworkError, NeonNotFoundError, NeonOperationError, NeonRateLimitError, NeonTimeoutError, toNeonError };
115
+
116
+ //# sourceMappingURL=errors.js.map