@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,32 @@
1
+ import { NeonError } from "./errors.js";
2
+
3
+ //#region src/neon/result.d.ts
4
+
5
+ /**
6
+ * The uniform result envelope returned by every ergonomic call when `throwOnError` is
7
+ * off (the default). A discriminated union: when `error` is set, `data` is `undefined`,
8
+ * and vice versa.
9
+ */
10
+ type NeonResult<T> = {
11
+ data: T;
12
+ error: undefined;
13
+ } | {
14
+ data: undefined;
15
+ error: NeonError;
16
+ };
17
+ /**
18
+ * The return type of a method, conditioned on whether errors are thrown. With
19
+ * `throwOnError`, the method resolves to the bare `T` (and throws on failure); otherwise
20
+ * it resolves to {@link NeonResult}.
21
+ */
22
+ type Outcome<T, Throw extends boolean> = Throw extends true ? T : NeonResult<T>;
23
+ declare function ok<T>(data: T): NeonResult<T>;
24
+ declare function err<T>(error: NeonError): NeonResult<T>;
25
+ /**
26
+ * Apply the `throwOnError` policy to a result: return the bare value (throwing on error)
27
+ * when `shouldThrow`, otherwise return the {@link NeonResult} envelope.
28
+ */
29
+ declare function finalize<T>(result: NeonResult<T>, shouldThrow: boolean): T | NeonResult<T>;
30
+ //#endregion
31
+ export { NeonResult, Outcome, err, finalize, ok };
32
+ //# sourceMappingURL=result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.d.ts","names":[],"sources":["../../src/neon/result.ts"],"mappings":";;;;;;AAOA;;;AAE6B,KAFjB,UAEiB,CAAA,CAAA,CAAA,GAAA;EAAS,IAAA,EAD3B,CAC2B;EAO1B,KAAA,EAAA,SAAO;CAAA,GAAA;MAA6B,EAAA,SAAA;OAC7C,EAR0B,SAQ1B;;;AACU;AAEb;;;AAA2C,KAJ/B,OAI+B,CAAA,CAAA,EAAA,cAAA,OAAA,CAAA,GAJK,KAIL,SAAA,IAAA,GAHxC,CAGwC,GAFxC,UAEwC,CAF7B,CAE6B,CAAA;AAAX,iBAAhB,EAAgB,CAAA,CAAA,CAAA,CAAA,IAAA,EAAJ,CAAI,CAAA,EAAA,UAAA,CAAW,CAAX,CAAA;AAAU,iBAI1B,GAJ0B,CAAA,CAAA,CAAA,CAAA,KAAA,EAIZ,SAJY,CAAA,EAIA,UAJA,CAIW,CAJX,CAAA;AAI1C;;;;AAA0C,iBAQ1B,QAR0B,CAAA,CAAA,CAAA,CAAA,MAAA,EASjC,UATiC,CAStB,CATsB,CAAA,EAAA,WAAA,EAAA,OAAA,CAAA,EAWvC,CAXuC,GAWnC,UAXmC,CAWxB,CAXwB,CAAA"}
@@ -0,0 +1,26 @@
1
+ //#region src/neon/result.ts
2
+ function ok(data) {
3
+ return {
4
+ data,
5
+ error: void 0
6
+ };
7
+ }
8
+ function err(error) {
9
+ return {
10
+ data: void 0,
11
+ error
12
+ };
13
+ }
14
+ /**
15
+ * Apply the `throwOnError` policy to a result: return the bare value (throwing on error)
16
+ * when `shouldThrow`, otherwise return the {@link NeonResult} envelope.
17
+ */
18
+ function finalize(result, shouldThrow) {
19
+ if (!shouldThrow) return result;
20
+ if (result.error) throw result.error;
21
+ return result.data;
22
+ }
23
+ //#endregion
24
+ export { err, finalize, ok };
25
+
26
+ //# sourceMappingURL=result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.js","names":[],"sources":["../../src/neon/result.ts"],"sourcesContent":["import type { NeonError } from \"./errors.js\";\n\n/**\n * The uniform result envelope returned by every ergonomic call when `throwOnError` is\n * off (the default). A discriminated union: when `error` is set, `data` is `undefined`,\n * and vice versa.\n */\nexport type NeonResult<T> =\n\t| { data: T; error: undefined }\n\t| { data: undefined; error: NeonError };\n\n/**\n * The return type of a method, conditioned on whether errors are thrown. With\n * `throwOnError`, the method resolves to the bare `T` (and throws on failure); otherwise\n * it resolves to {@link NeonResult}.\n */\nexport type Outcome<T, Throw extends boolean> = Throw extends true\n\t? T\n\t: NeonResult<T>;\n\nexport function ok<T>(data: T): NeonResult<T> {\n\treturn { data, error: undefined };\n}\n\nexport function err<T>(error: NeonError): NeonResult<T> {\n\treturn { data: undefined, error };\n}\n\n/**\n * Apply the `throwOnError` policy to a result: return the bare value (throwing on error)\n * when `shouldThrow`, otherwise return the {@link NeonResult} envelope.\n */\nexport function finalize<T>(\n\tresult: NeonResult<T>,\n\tshouldThrow: boolean,\n): T | NeonResult<T> {\n\tif (!shouldThrow) return result;\n\tif (result.error) throw result.error;\n\treturn result.data;\n}\n"],"mappings":";AAoBA,SAAgB,GAAM,MAAwB;CAC7C,OAAO;EAAE;EAAM,OAAO,KAAA;CAAU;AACjC;AAEA,SAAgB,IAAO,OAAiC;CACvD,OAAO;EAAE,MAAM,KAAA;EAAW;CAAM;AACjC;;;;;AAMA,SAAgB,SACf,QACA,aACoB;CACpB,IAAI,CAAC,aAAa,OAAO;CACzB,IAAI,OAAO,OAAO,MAAM,OAAO;CAC/B,OAAO,OAAO;AACf"}
@@ -0,0 +1,17 @@
1
+ //#region src/neon/retry.d.ts
2
+ /**
3
+ * Minimal retry-with-backoff for idempotent reads and 429s. The raw layer does no
4
+ * retries; the ergonomic client opts in via `retries` config.
5
+ */
6
+ interface RawOutcome {
7
+ error?: unknown;
8
+ response?: Response | undefined;
9
+ }
10
+ /**
11
+ * Run `exec` up to `retries + 1` times, retrying only on retryable HTTP statuses
12
+ * (`423`, `429`, `5xx`). Non-retryable errors and successes return immediately.
13
+ */
14
+ declare function withRetries<T extends RawOutcome>(exec: () => Promise<T>, retries: number, signal?: AbortSignal): Promise<T>;
15
+ //#endregion
16
+ export { RawOutcome, withRetries };
17
+ //# sourceMappingURL=retry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.d.ts","names":[],"sources":["../../src/neon/retry.ts"],"mappings":";;AAKA;AAuCA;;AAA4C,UAvC3B,UAAA,CAuC2B;OACvB,CAAA,EAAA,OAAA;UAAR,CAAA,EAtCD,QAsCC,GAAA,SAAA;;;;AAGH;;iBAJY,sBAAsB,wBAC/B,QAAQ,8BAEX,cACP,QAAQ"}
@@ -0,0 +1,42 @@
1
+ //#region src/neon/retry.ts
2
+ const RETRYABLE_STATUS = /* @__PURE__ */ new Set([
3
+ 423,
4
+ 429,
5
+ 503
6
+ ]);
7
+ function backoffMs(attempt, response) {
8
+ const retryAfter = response?.headers.get("retry-after");
9
+ if (retryAfter) {
10
+ const seconds = Number(retryAfter);
11
+ if (Number.isFinite(seconds)) return seconds * 1e3;
12
+ }
13
+ const ceiling = Math.min(1e4, 250 * 2 ** attempt);
14
+ return Math.random() * ceiling;
15
+ }
16
+ const sleep = (ms, signal) => new Promise((resolve, reject) => {
17
+ if (signal?.aborted) return reject(signal.reason);
18
+ const id = setTimeout(resolve, ms);
19
+ signal?.addEventListener("abort", () => {
20
+ clearTimeout(id);
21
+ reject(signal.reason);
22
+ }, { once: true });
23
+ });
24
+ /**
25
+ * Run `exec` up to `retries + 1` times, retrying only on retryable HTTP statuses
26
+ * (`423`, `429`, `5xx`). Non-retryable errors and successes return immediately.
27
+ */
28
+ async function withRetries(exec, retries, signal) {
29
+ let attempt = 0;
30
+ for (;;) {
31
+ const result = await exec();
32
+ const status = result.response?.status;
33
+ const retryable = status !== void 0 && RETRYABLE_STATUS.has(status);
34
+ if (!result.error || !retryable || attempt >= retries) return result;
35
+ await sleep(backoffMs(attempt, result.response), signal);
36
+ attempt += 1;
37
+ }
38
+ }
39
+ //#endregion
40
+ export { withRetries };
41
+
42
+ //# sourceMappingURL=retry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.js","names":[],"sources":["../../src/neon/retry.ts"],"sourcesContent":["/**\n * Minimal retry-with-backoff for idempotent reads and 429s. The raw layer does no\n * retries; the ergonomic client opts in via `retries` config.\n */\n\nexport interface RawOutcome {\n\terror?: unknown;\n\tresponse?: Response | undefined;\n}\n\n// Only statuses Neon documents as always-safe to retry (no work performed / locked /\n// rate limited) — safe for non-idempotent methods too. 5xx is intentionally excluded\n// from the default since a mutating request may have partially applied.\nconst RETRYABLE_STATUS = new Set([423, 429, 503]);\n\nfunction backoffMs(attempt: number, response: Response | undefined): number {\n\tconst retryAfter = response?.headers.get(\"retry-after\");\n\tif (retryAfter) {\n\t\tconst seconds = Number(retryAfter);\n\t\tif (Number.isFinite(seconds)) return seconds * 1000;\n\t}\n\t// exponential backoff with full jitter: base 250ms, capped at 10s\n\tconst ceiling = Math.min(10_000, 250 * 2 ** attempt);\n\treturn Math.random() * ceiling;\n}\n\nconst sleep = (ms: number, signal?: AbortSignal): Promise<void> =>\n\tnew Promise((resolve, reject) => {\n\t\tif (signal?.aborted) return reject(signal.reason);\n\t\tconst id = setTimeout(resolve, ms);\n\t\tsignal?.addEventListener(\n\t\t\t\"abort\",\n\t\t\t() => {\n\t\t\t\tclearTimeout(id);\n\t\t\t\treject(signal.reason);\n\t\t\t},\n\t\t\t{ once: true },\n\t\t);\n\t});\n\n/**\n * Run `exec` up to `retries + 1` times, retrying only on retryable HTTP statuses\n * (`423`, `429`, `5xx`). Non-retryable errors and successes return immediately.\n */\nexport async function withRetries<T extends RawOutcome>(\n\texec: () => Promise<T>,\n\tretries: number,\n\tsignal?: AbortSignal,\n): Promise<T> {\n\tlet attempt = 0;\n\tfor (;;) {\n\t\tconst result = await exec();\n\t\tconst status = result.response?.status;\n\t\tconst retryable = status !== undefined && RETRYABLE_STATUS.has(status);\n\t\tif (!result.error || !retryable || attempt >= retries) return result;\n\t\tawait sleep(backoffMs(attempt, result.response), signal);\n\t\tattempt += 1;\n\t}\n}\n"],"mappings":";AAaA,MAAM,mCAAmB,IAAI,IAAI;CAAC;CAAK;CAAK;AAAG,CAAC;AAEhD,SAAS,UAAU,SAAiB,UAAwC;CAC3E,MAAM,aAAa,UAAU,QAAQ,IAAI,aAAa;CACtD,IAAI,YAAY;EACf,MAAM,UAAU,OAAO,UAAU;EACjC,IAAI,OAAO,SAAS,OAAO,GAAG,OAAO,UAAU;CAChD;CAEA,MAAM,UAAU,KAAK,IAAI,KAAQ,MAAM,KAAK,OAAO;CACnD,OAAO,KAAK,OAAO,IAAI;AACxB;AAEA,MAAM,SAAS,IAAY,WAC1B,IAAI,SAAS,SAAS,WAAW;CAChC,IAAI,QAAQ,SAAS,OAAO,OAAO,OAAO,MAAM;CAChD,MAAM,KAAK,WAAW,SAAS,EAAE;CACjC,QAAQ,iBACP,eACM;EACL,aAAa,EAAE;EACf,OAAO,OAAO,MAAM;CACrB,GACA,EAAE,MAAM,KAAK,CACd;AACD,CAAC;;;;;AAMF,eAAsB,YACrB,MACA,SACA,QACa;CACb,IAAI,UAAU;CACd,SAAS;EACR,MAAM,SAAS,MAAM,KAAK;EAC1B,MAAM,SAAS,OAAO,UAAU;EAChC,MAAM,YAAY,WAAW,KAAA,KAAa,iBAAiB,IAAI,MAAM;EACrE,IAAI,CAAC,OAAO,SAAS,CAAC,aAAa,WAAW,SAAS,OAAO;EAC9D,MAAM,MAAM,UAAU,SAAS,OAAO,QAAQ,GAAG,MAAM;EACvD,WAAW;CACZ;AACD"}
@@ -0,0 +1,27 @@
1
+ import { Client } from "../client/client/types.gen.js";
2
+ import { Operation } from "../client/types.gen.js";
3
+ import { NeonResult } from "./result.js";
4
+
5
+ //#region src/neon/wait.d.ts
6
+ interface WaitForOptions {
7
+ /** How often to poll each pending operation. Default 1000ms. */
8
+ pollIntervalMs?: number;
9
+ /** Overall deadline before giving up. Default 300000ms (5 min). */
10
+ timeoutMs?: number;
11
+ signal?: AbortSignal;
12
+ }
13
+ /**
14
+ * Poll the given operations until each reaches a terminal `finished`/`skipped` state.
15
+ * Returns an error result carrying {@link NeonOperationError} if any operation ends in
16
+ * `failed`/`error`/`cancelled`, or {@link NeonTimeoutError} if the deadline is exceeded.
17
+ *
18
+ * Composable: usable directly with operations obtained from the raw layer.
19
+ */
20
+ declare function waitForOperations(client: Client, operations: readonly Operation[], options?: WaitForOptions): Promise<NeonResult<void>>;
21
+ /** Type guard: does a response body carry an `operations` array we can wait on? */
22
+ declare function hasOperations(data: unknown): data is {
23
+ operations: Operation[];
24
+ };
25
+ //#endregion
26
+ export { WaitForOptions, hasOperations, waitForOperations };
27
+ //# sourceMappingURL=wait.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wait.d.ts","names":[],"sources":["../../src/neon/wait.ts"],"mappings":";;;;;UAaiB,cAAA;;EAAA,cAAA,CAAA,EAAc,MAAA;EA6BT;EAAiB,SAAA,CAAA,EAAA,MAAA;QAC9B,CAAA,EAzBC,WAyBD;;;;;AAGC;AAqDV;;;iBAzDsB,iBAAA,SACb,6BACa,uBACZ,iBACP,QAAQ;;iBAqDK,aAAA;cAES"}
@@ -0,0 +1,70 @@
1
+ import { NeonOperationError, NeonTimeoutError, toNeonError } from "./errors.js";
2
+ import { err, ok } from "./result.js";
3
+ import { getProjectOperation } from "../client/sdk.gen.js";
4
+ //#region src/neon/wait.ts
5
+ const SUCCESS = /* @__PURE__ */ new Set(["finished", "skipped"]);
6
+ const FAILURE = /* @__PURE__ */ new Set([
7
+ "failed",
8
+ "error",
9
+ "cancelled"
10
+ ]);
11
+ const sleep = (ms, signal) => new Promise((resolve, reject) => {
12
+ if (signal?.aborted) return reject(signal.reason);
13
+ const id = setTimeout(resolve, ms);
14
+ signal?.addEventListener("abort", () => {
15
+ clearTimeout(id);
16
+ reject(signal.reason);
17
+ }, { once: true });
18
+ });
19
+ /**
20
+ * Poll the given operations until each reaches a terminal `finished`/`skipped` state.
21
+ * Returns an error result carrying {@link NeonOperationError} if any operation ends in
22
+ * `failed`/`error`/`cancelled`, or {@link NeonTimeoutError} if the deadline is exceeded.
23
+ *
24
+ * Composable: usable directly with operations obtained from the raw layer.
25
+ */
26
+ async function waitForOperations(client, operations, options = {}) {
27
+ const pollIntervalMs = options.pollIntervalMs ?? 1e3;
28
+ const timeoutMs = options.timeoutMs ?? 3e5;
29
+ const deadline = Date.now() + timeoutMs;
30
+ let pending = operations.filter((op) => !SUCCESS.has(op.status));
31
+ for (const op of pending) if (FAILURE.has(op.status)) return err(operationFailed(op));
32
+ pending = pending.filter((op) => !FAILURE.has(op.status));
33
+ while (pending.length > 0) {
34
+ if (Date.now() > deadline) return err(new NeonTimeoutError(`Timed out after ${timeoutMs}ms waiting for ${pending.length} operation(s) to finish.`));
35
+ await sleep(pollIntervalMs, options.signal);
36
+ const stillPending = [];
37
+ for (const op of pending) {
38
+ const { data, error, response } = await getProjectOperation({
39
+ client,
40
+ path: {
41
+ project_id: op.project_id,
42
+ operation_id: op.id
43
+ },
44
+ throwOnError: false,
45
+ signal: options.signal
46
+ });
47
+ if (error || !data) return err(toNeonError(error, response));
48
+ const current = data.operation;
49
+ if (FAILURE.has(current.status)) return err(operationFailed(current));
50
+ if (!SUCCESS.has(current.status)) stillPending.push(current);
51
+ }
52
+ pending = stillPending;
53
+ }
54
+ return ok(void 0);
55
+ }
56
+ function operationFailed(op) {
57
+ const detail = op.error ? `: ${op.error}` : "";
58
+ return new NeonOperationError(`Operation ${op.id} (${op.action}) ended with status "${op.status}"${detail}.`, {
59
+ operationId: op.id,
60
+ status: op.status
61
+ });
62
+ }
63
+ /** Type guard: does a response body carry an `operations` array we can wait on? */
64
+ function hasOperations(data) {
65
+ return typeof data === "object" && data !== null && "operations" in data && Array.isArray(data.operations);
66
+ }
67
+ //#endregion
68
+ export { hasOperations, waitForOperations };
69
+
70
+ //# sourceMappingURL=wait.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wait.js","names":[],"sources":["../../src/neon/wait.ts"],"sourcesContent":["import type { Client } from \"../client/client/index.js\";\nimport { getProjectOperation } from \"../client/sdk.gen.js\";\nimport type { Operation, OperationStatus } from \"../client/types.gen.js\";\nimport { NeonOperationError, NeonTimeoutError, toNeonError } from \"./errors.js\";\nimport { err, type NeonResult, ok } from \"./result.js\";\n\nconst SUCCESS: ReadonlySet<OperationStatus> = new Set([\"finished\", \"skipped\"]);\nconst FAILURE: ReadonlySet<OperationStatus> = new Set([\n\t\"failed\",\n\t\"error\",\n\t\"cancelled\",\n]);\n\nexport interface WaitForOptions {\n\t/** How often to poll each pending operation. Default 1000ms. */\n\tpollIntervalMs?: number;\n\t/** Overall deadline before giving up. Default 300000ms (5 min). */\n\ttimeoutMs?: number;\n\tsignal?: AbortSignal;\n}\n\nconst sleep = (ms: number, signal?: AbortSignal): Promise<void> =>\n\tnew Promise((resolve, reject) => {\n\t\tif (signal?.aborted) return reject(signal.reason);\n\t\tconst id = setTimeout(resolve, ms);\n\t\tsignal?.addEventListener(\n\t\t\t\"abort\",\n\t\t\t() => {\n\t\t\t\tclearTimeout(id);\n\t\t\t\treject(signal.reason);\n\t\t\t},\n\t\t\t{ once: true },\n\t\t);\n\t});\n\n/**\n * Poll the given operations until each reaches a terminal `finished`/`skipped` state.\n * Returns an error result carrying {@link NeonOperationError} if any operation ends in\n * `failed`/`error`/`cancelled`, or {@link NeonTimeoutError} if the deadline is exceeded.\n *\n * Composable: usable directly with operations obtained from the raw layer.\n */\nexport async function waitForOperations(\n\tclient: Client,\n\toperations: readonly Operation[],\n\toptions: WaitForOptions = {},\n): Promise<NeonResult<void>> {\n\tconst pollIntervalMs = options.pollIntervalMs ?? 1000;\n\tconst timeoutMs = options.timeoutMs ?? 300_000;\n\tconst deadline = Date.now() + timeoutMs;\n\n\t// Track only operations that aren't already in a terminal state.\n\tlet pending = operations.filter((op) => !SUCCESS.has(op.status));\n\n\tfor (const op of pending) {\n\t\tif (FAILURE.has(op.status)) return err(operationFailed(op));\n\t}\n\tpending = pending.filter((op) => !FAILURE.has(op.status));\n\n\twhile (pending.length > 0) {\n\t\tif (Date.now() > deadline) {\n\t\t\treturn err(\n\t\t\t\tnew NeonTimeoutError(\n\t\t\t\t\t`Timed out after ${timeoutMs}ms waiting for ${pending.length} operation(s) to finish.`,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\tawait sleep(pollIntervalMs, options.signal);\n\n\t\tconst stillPending: Operation[] = [];\n\t\tfor (const op of pending) {\n\t\t\tconst { data, error, response } = await getProjectOperation({\n\t\t\t\tclient,\n\t\t\t\tpath: { project_id: op.project_id, operation_id: op.id },\n\t\t\t\tthrowOnError: false,\n\t\t\t\tsignal: options.signal,\n\t\t\t});\n\t\t\tif (error || !data) return err(toNeonError(error, response));\n\n\t\t\tconst current = data.operation;\n\t\t\tif (FAILURE.has(current.status))\n\t\t\t\treturn err(operationFailed(current));\n\t\t\tif (!SUCCESS.has(current.status)) stillPending.push(current);\n\t\t}\n\t\tpending = stillPending;\n\t}\n\n\treturn ok(undefined);\n}\n\nfunction operationFailed(op: Operation): NeonOperationError {\n\tconst detail = op.error ? `: ${op.error}` : \"\";\n\treturn new NeonOperationError(\n\t\t`Operation ${op.id} (${op.action}) ended with status \"${op.status}\"${detail}.`,\n\t\t{ operationId: op.id, status: op.status },\n\t);\n}\n\n/** Type guard: does a response body carry an `operations` array we can wait on? */\nexport function hasOperations(\n\tdata: unknown,\n): data is { operations: Operation[] } {\n\treturn (\n\t\ttypeof data === \"object\" &&\n\t\tdata !== null &&\n\t\t\"operations\" in data &&\n\t\tArray.isArray(data.operations)\n\t);\n}\n"],"mappings":";;;;AAMA,MAAM,0BAAwC,IAAI,IAAI,CAAC,YAAY,SAAS,CAAC;AAC7E,MAAM,0BAAwC,IAAI,IAAI;CACrD;CACA;CACA;AACD,CAAC;AAUD,MAAM,SAAS,IAAY,WAC1B,IAAI,SAAS,SAAS,WAAW;CAChC,IAAI,QAAQ,SAAS,OAAO,OAAO,OAAO,MAAM;CAChD,MAAM,KAAK,WAAW,SAAS,EAAE;CACjC,QAAQ,iBACP,eACM;EACL,aAAa,EAAE;EACf,OAAO,OAAO,MAAM;CACrB,GACA,EAAE,MAAM,KAAK,CACd;AACD,CAAC;;;;;;;;AASF,eAAsB,kBACrB,QACA,YACA,UAA0B,CAAC,GACC;CAC5B,MAAM,iBAAiB,QAAQ,kBAAkB;CACjD,MAAM,YAAY,QAAQ,aAAa;CACvC,MAAM,WAAW,KAAK,IAAI,IAAI;CAG9B,IAAI,UAAU,WAAW,QAAQ,OAAO,CAAC,QAAQ,IAAI,GAAG,MAAM,CAAC;CAE/D,KAAK,MAAM,MAAM,SAChB,IAAI,QAAQ,IAAI,GAAG,MAAM,GAAG,OAAO,IAAI,gBAAgB,EAAE,CAAC;CAE3D,UAAU,QAAQ,QAAQ,OAAO,CAAC,QAAQ,IAAI,GAAG,MAAM,CAAC;CAExD,OAAO,QAAQ,SAAS,GAAG;EAC1B,IAAI,KAAK,IAAI,IAAI,UAChB,OAAO,IACN,IAAI,iBACH,mBAAmB,UAAU,iBAAiB,QAAQ,OAAO,yBAC9D,CACD;EAED,MAAM,MAAM,gBAAgB,QAAQ,MAAM;EAE1C,MAAM,eAA4B,CAAC;EACnC,KAAK,MAAM,MAAM,SAAS;GACzB,MAAM,EAAE,MAAM,OAAO,aAAa,MAAM,oBAAoB;IAC3D;IACA,MAAM;KAAE,YAAY,GAAG;KAAY,cAAc,GAAG;IAAG;IACvD,cAAc;IACd,QAAQ,QAAQ;GACjB,CAAC;GACD,IAAI,SAAS,CAAC,MAAM,OAAO,IAAI,YAAY,OAAO,QAAQ,CAAC;GAE3D,MAAM,UAAU,KAAK;GACrB,IAAI,QAAQ,IAAI,QAAQ,MAAM,GAC7B,OAAO,IAAI,gBAAgB,OAAO,CAAC;GACpC,IAAI,CAAC,QAAQ,IAAI,QAAQ,MAAM,GAAG,aAAa,KAAK,OAAO;EAC5D;EACA,UAAU;CACX;CAEA,OAAO,GAAG,KAAA,CAAS;AACpB;AAEA,SAAS,gBAAgB,IAAmC;CAC3D,MAAM,SAAS,GAAG,QAAQ,KAAK,GAAG,UAAU;CAC5C,OAAO,IAAI,mBACV,aAAa,GAAG,GAAG,IAAI,GAAG,OAAO,uBAAuB,GAAG,OAAO,GAAG,OAAO,IAC5E;EAAE,aAAa,GAAG;EAAI,QAAQ,GAAG;CAAO,CACzC;AACD;;AAGA,SAAgB,cACf,MACsC;CACtC,OACC,OAAO,SAAS,YAChB,SAAS,QACT,gBAAgB,QAChB,MAAM,QAAQ,KAAK,UAAU;AAE/B"}