neon-testing 2.7.0 → 3.0.0-beta.1

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 (80) hide show
  1. package/README.md +58 -41
  2. package/dist/bun.d.ts +11 -0
  3. package/dist/bun.d.ts.map +1 -0
  4. package/dist/bun.js +10 -0
  5. package/dist/bun.js.map +1 -0
  6. package/dist/{index.d.ts → core.d.ts} +49 -29
  7. package/dist/core.d.ts.map +1 -0
  8. package/dist/{index.js → core.js} +34 -122
  9. package/dist/core.js.map +1 -0
  10. package/dist/lib/barrier.d.ts.map +1 -0
  11. package/dist/lib/barrier.js.map +1 -0
  12. package/dist/lib/cleared-database-url.d.ts +10 -0
  13. package/dist/lib/cleared-database-url.d.ts.map +1 -0
  14. package/dist/lib/cleared-database-url.js +10 -0
  15. package/dist/lib/cleared-database-url.js.map +1 -0
  16. package/dist/lib/expires-in.d.ts +5 -0
  17. package/dist/lib/expires-in.d.ts.map +1 -0
  18. package/dist/lib/expires-in.js +21 -0
  19. package/dist/lib/expires-in.js.map +1 -0
  20. package/dist/lib/singleton.d.ts.map +1 -0
  21. package/dist/lib/singleton.js.map +1 -0
  22. package/dist/lib/ssl.d.ts +9 -0
  23. package/dist/lib/ssl.d.ts.map +1 -0
  24. package/dist/lib/ssl.js +21 -0
  25. package/dist/lib/ssl.js.map +1 -0
  26. package/dist/lib/with-retry.d.ts +12 -0
  27. package/dist/lib/with-retry.d.ts.map +1 -0
  28. package/dist/lib/with-retry.js +39 -0
  29. package/dist/lib/with-retry.js.map +1 -0
  30. package/dist/lib/ws-error.d.ts +6 -0
  31. package/dist/lib/ws-error.d.ts.map +1 -0
  32. package/dist/lib/ws-error.js +15 -0
  33. package/dist/lib/ws-error.js.map +1 -0
  34. package/dist/setup.d.ts +2 -0
  35. package/dist/setup.d.ts.map +1 -0
  36. package/dist/setup.js +9 -0
  37. package/dist/setup.js.map +1 -0
  38. package/dist/utils.d.ts +2 -8
  39. package/dist/utils.d.ts.map +1 -1
  40. package/dist/utils.js +2 -8
  41. package/dist/utils.js.map +1 -1
  42. package/dist/vitest.d.ts +11 -0
  43. package/dist/vitest.d.ts.map +1 -0
  44. package/dist/vitest.js +9 -0
  45. package/dist/vitest.js.map +1 -0
  46. package/package.json +62 -30
  47. package/src/bun.ts +13 -0
  48. package/src/core.ts +375 -0
  49. package/src/lib/barrier.ts +22 -0
  50. package/src/lib/cleared-database-url.ts +9 -0
  51. package/src/lib/expires-in.ts +24 -0
  52. package/src/lib/singleton.ts +10 -0
  53. package/src/lib/ssl.ts +24 -0
  54. package/src/lib/with-retry.ts +55 -0
  55. package/src/lib/ws-error.ts +17 -0
  56. package/src/setup.ts +10 -0
  57. package/src/utils.ts +2 -0
  58. package/src/vitest.ts +12 -0
  59. package/dist/barrier.d.ts.map +0 -1
  60. package/dist/barrier.js.map +0 -1
  61. package/dist/browser-empty.d.ts +0 -2
  62. package/dist/browser-empty.d.ts.map +0 -1
  63. package/dist/browser-empty.js +0 -4
  64. package/dist/browser-empty.js.map +0 -1
  65. package/dist/index.d.ts.map +0 -1
  66. package/dist/index.js.map +0 -1
  67. package/dist/singleton.d.ts.map +0 -1
  68. package/dist/singleton.js.map +0 -1
  69. package/dist/vite-plugin.d.ts +0 -13
  70. package/dist/vite-plugin.d.ts.map +0 -1
  71. package/dist/vite-plugin.js +0 -26
  72. package/dist/vite-plugin.js.map +0 -1
  73. package/dist/vitest-setup.d.ts +0 -3
  74. package/dist/vitest-setup.d.ts.map +0 -1
  75. package/dist/vitest-setup.js +0 -10
  76. package/dist/vitest-setup.js.map +0 -1
  77. /package/dist/{barrier.d.ts → lib/barrier.d.ts} +0 -0
  78. /package/dist/{barrier.js → lib/barrier.js} +0 -0
  79. /package/dist/{singleton.d.ts → lib/singleton.d.ts} +0 -0
  80. /package/dist/{singleton.js → lib/singleton.js} +0 -0
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Validates the expiresIn option
3
+ */
4
+ export function validateExpiresIn(expiresIn) {
5
+ if (expiresIn === null) {
6
+ return;
7
+ }
8
+ if (expiresIn === undefined) {
9
+ return;
10
+ }
11
+ if (!Number.isInteger(expiresIn)) {
12
+ throw new Error("expiresIn must be an integer");
13
+ }
14
+ if (expiresIn <= 0) {
15
+ throw new Error("expiresIn must be a positive integer");
16
+ }
17
+ if (expiresIn > 2592000) {
18
+ throw new Error("expiresIn must not exceed 30 days (2,592,000 seconds)");
19
+ }
20
+ }
21
+ //# sourceMappingURL=expires-in.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expires-in.js","sourceRoot":"","sources":["../../src/lib/expires-in.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAoC;IACpE,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACvB,OAAO;IACT,CAAC;IAED,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO;IACT,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;IAED,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IAED,IAAI,SAAS,GAAG,OAAO,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"singleton.d.ts","sourceRoot":"","sources":["../../src/lib/singleton.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,CAM1D"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"singleton.js","sourceRoot":"","sources":["../../src/lib/singleton.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,aAAa,CAAI,OAAgB;IAC/C,IAAI,QAAuB,CAAC;IAC5B,OAAO,GAAG,EAAE;QACV,QAAQ,KAAK,OAAO,EAAE,CAAC;QACvB,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Rewrite the `sslmode` (and related) query params on a Neon connection URI.
3
+ *
4
+ * Neon's API returns URIs with `sslmode=require`. In pg v9 /
5
+ * pg-connection-string v3 this mode will adopt libpq semantics (encrypt
6
+ * without CA verification) instead of today's effective `verify-full`.
7
+ */
8
+ export declare function applySslMode(uri: string, mode: "verify-full" | "require" | undefined): string;
9
+ //# sourceMappingURL=ssl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ssl.d.ts","sourceRoot":"","sources":["../../src/lib/ssl.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,aAAa,GAAG,SAAS,GAAG,SAAS,GAC1C,MAAM,CAaR"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Rewrite the `sslmode` (and related) query params on a Neon connection URI.
3
+ *
4
+ * Neon's API returns URIs with `sslmode=require`. In pg v9 /
5
+ * pg-connection-string v3 this mode will adopt libpq semantics (encrypt
6
+ * without CA verification) instead of today's effective `verify-full`.
7
+ */
8
+ export function applySslMode(uri, mode) {
9
+ if (mode === undefined)
10
+ return uri;
11
+ const url = new URL(uri);
12
+ url.searchParams.set("sslmode", mode);
13
+ if (mode === "require") {
14
+ url.searchParams.set("uselibpqcompat", "true");
15
+ }
16
+ else {
17
+ url.searchParams.delete("uselibpqcompat");
18
+ }
19
+ return url.toString();
20
+ }
21
+ //# sourceMappingURL=ssl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ssl.js","sourceRoot":"","sources":["../../src/lib/ssl.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAC1B,GAAW,EACX,IAA2C;IAE3C,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,GAAG,CAAC;IAEnC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAEtC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;IACjD,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Reusable API call wrapper with automatic retry on 423 errors with exponential
3
+ * backoff
4
+ *
5
+ * https://neon.com/docs/reference/typescript-sdk#error-handling
6
+ * https://neon.com/docs/changelog/2022-07-20
7
+ */
8
+ export declare function withRetry<T>(fn: () => Promise<T>, options: {
9
+ maxRetries: number;
10
+ baseDelayMs: number;
11
+ }): Promise<T>;
12
+ //# sourceMappingURL=with-retry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-retry.d.ts","sourceRoot":"","sources":["../../src/lib/with-retry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAC/B,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,EAAE;IACP,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB,GACA,OAAO,CAAC,CAAC,CAAC,CAyCZ"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Reusable API call wrapper with automatic retry on 423 errors with exponential
3
+ * backoff
4
+ *
5
+ * https://neon.com/docs/reference/typescript-sdk#error-handling
6
+ * https://neon.com/docs/changelog/2022-07-20
7
+ */
8
+ export async function withRetry(fn, options) {
9
+ if (!Number.isInteger(options.maxRetries) || options.maxRetries <= 0) {
10
+ throw new Error("maxRetries must be a positive integer");
11
+ }
12
+ if (!Number.isInteger(options.baseDelayMs) || options.baseDelayMs <= 0) {
13
+ throw new Error("baseDelayMs must be a positive integer");
14
+ }
15
+ for (let attempt = 1; attempt <= options.maxRetries; attempt++) {
16
+ try {
17
+ return await fn();
18
+ }
19
+ catch (error) {
20
+ const status = error?.response?.status;
21
+ // Retry on 423 (resource locked) with exponential backoff
22
+ if (status === 423 && attempt < options.maxRetries) {
23
+ const delay = options.baseDelayMs * Math.pow(2, attempt - 1);
24
+ console.log(`API call failed with 423, retrying in ${delay}ms (attempt ${attempt}/${options.maxRetries})`);
25
+ await new Promise((resolve) => setTimeout(resolve, delay));
26
+ continue;
27
+ }
28
+ // Surface Neon API error details that are otherwise buried in the Axios error
29
+ if (error?.response?.data?.code) {
30
+ const { code, message } = error.response.data;
31
+ throw new Error(`Neon API error - HTTP ${status} - ${code} - ${message}`, { cause: error });
32
+ }
33
+ // Non-API errors (network, timeouts, etc.) pass through as-is
34
+ throw error;
35
+ }
36
+ }
37
+ throw new Error("apiCallWithRetry reached unexpected end");
38
+ }
39
+ //# sourceMappingURL=with-retry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-retry.js","sourceRoot":"","sources":["../../src/lib/with-retry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,EAAoB,EACpB,OAGC;IAED,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,UAAU,IAAI,CAAC,EAAE,CAAC;QACrE,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,WAAW,IAAI,CAAC,EAAE,CAAC;QACvE,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,OAAO,CAAC,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC;QAC/D,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,EAAE,CAAC;QACpB,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,MAAM,GAAG,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC;YAEvC,0DAA0D;YAC1D,IAAI,MAAM,KAAK,GAAG,IAAI,OAAO,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;gBACnD,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC;gBAE7D,OAAO,CAAC,GAAG,CACT,yCAAyC,KAAK,eAAe,OAAO,IAAI,OAAO,CAAC,UAAU,GAAG,CAC9F,CAAC;gBACF,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;gBAE3D,SAAS;YACX,CAAC;YAED,8EAA8E;YAC9E,IAAI,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;gBAChC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;gBAC9C,MAAM,IAAI,KAAK,CACb,yBAAyB,MAAM,MAAM,IAAI,MAAM,OAAO,EAAE,EACxD,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;YACJ,CAAC;YAED,8DAA8D;YAC9D,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Error handler: Suppress Neon WebSocket "Connection terminated unexpectedly"
3
+ * error
4
+ */
5
+ export declare const neonWsErrorHandler: (error: Error) => void;
6
+ //# sourceMappingURL=ws-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ws-error.d.ts","sourceRoot":"","sources":["../../src/lib/ws-error.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,KAAK,SAY9C,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Error handler: Suppress Neon WebSocket "Connection terminated unexpectedly"
3
+ * error
4
+ */
5
+ export const neonWsErrorHandler = (error) => {
6
+ const isNeonWsClose = error.message.includes("Connection terminated unexpectedly") &&
7
+ error.stack?.includes("@neondatabase/serverless");
8
+ if (isNeonWsClose) {
9
+ // Swallow this specific Neon WS termination error
10
+ return;
11
+ }
12
+ // For any other error, detach and rethrow
13
+ throw error;
14
+ };
15
+ //# sourceMappingURL=ws-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ws-error.js","sourceRoot":"","sources":["../../src/lib/ws-error.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAY,EAAE,EAAE;IACjD,MAAM,aAAa,GACjB,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,oCAAoC,CAAC;QAC5D,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,0BAA0B,CAAC,CAAC;IAEpD,IAAI,aAAa,EAAE,CAAC;QAClB,kDAAkD;QAClD,OAAO;IACT,CAAC;IAED,0CAA0C;IAC1C,MAAM,KAAK,CAAC;AACd,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":""}
package/dist/setup.js ADDED
@@ -0,0 +1,9 @@
1
+ import { CLEARED_DATABASE_URL } from "./lib/cleared-database-url.js";
2
+ // Overwrites any existing DATABASE_URL so a test file that forgot to call
3
+ // `neonTesting()` can't reach the pre-configured database. Loaded as a
4
+ // test-runner preload (Vitest `setupFiles` / Bun `bunfig` `preload`).
5
+ if (process.env.DATABASE_URL && process.env.NEON_TESTING_DEBUG === "true") {
6
+ console.debug("[neon-testing] Overwriting existing DATABASE_URL");
7
+ }
8
+ process.env.DATABASE_URL = CLEARED_DATABASE_URL;
9
+ //# sourceMappingURL=setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE,0EAA0E;AAC1E,uEAAuE;AACvE,sEAAsE;AACtE,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,KAAK,MAAM,EAAE,CAAC;IAC1E,OAAO,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;AACpE,CAAC;AAED,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,oBAAoB,CAAC"}
package/dist/utils.d.ts CHANGED
@@ -1,9 +1,3 @@
1
- import { neonTesting as neonTestingVite } from "./vite-plugin.js";
2
- export { lazySingleton } from "./singleton.js";
3
- export { createBarrier } from "./barrier.js";
4
- /**
5
- * @deprecated Import the Vite plugin from "neon-testing/vite" instead. This
6
- * export will be removed in the next major version.
7
- */
8
- export declare const neonTesting: typeof neonTestingVite;
1
+ export { lazySingleton } from "./lib/singleton.js";
2
+ export { createBarrier } from "./lib/barrier.js";
9
3
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,WAAW,wBAAkB,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/utils.js CHANGED
@@ -1,9 +1,3 @@
1
- import { neonTesting as neonTestingVite } from "./vite-plugin.js";
2
- export { lazySingleton } from "./singleton.js";
3
- export { createBarrier } from "./barrier.js";
4
- /**
5
- * @deprecated Import the Vite plugin from "neon-testing/vite" instead. This
6
- * export will be removed in the next major version.
7
- */
8
- export const neonTesting = neonTestingVite;
1
+ export { lazySingleton } from "./lib/singleton.js";
2
+ export { createBarrier } from "./lib/barrier.js";
9
3
  //# sourceMappingURL=utils.js.map
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC","sourcesContent":["import { neonTesting as neonTestingVite } from \"./vite-plugin.js\";\nexport { lazySingleton } from \"./singleton.js\";\nexport { createBarrier } from \"./barrier.js\";\n\n/**\n * @deprecated Import the Vite plugin from \"neon-testing/vite\" instead. This\n * export will be removed in the next major version.\n */\nexport const neonTesting = neonTestingVite;\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { MakeNeonTestingOptions } from "./core.js";
2
+ export type { MakeNeonTestingOptions, NeonTestingOptions } from "./core.js";
3
+ /**
4
+ * Create a Neon test-branch factory wired to Vitest's lifecycle hooks.
5
+ */
6
+ export declare function makeNeonTesting(options: MakeNeonTestingOptions): {
7
+ (overrides?: import("./core.js").NeonTestingOptions): () => import("@neondatabase/api-client").Branch | undefined;
8
+ deleteAllTestBranches: () => Promise<void>;
9
+ api: import("@neondatabase/api-client").Api<unknown>;
10
+ };
11
+ //# sourceMappingURL=vitest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.d.ts","sourceRoot":"","sources":["../src/vitest.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAExD,YAAY,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE5E;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB;;;;EAE9D"}
package/dist/vitest.js ADDED
@@ -0,0 +1,9 @@
1
+ import { beforeAll, afterAll } from "vitest";
2
+ import { makeNeonTestingCore } from "./core.js";
3
+ /**
4
+ * Create a Neon test-branch factory wired to Vitest's lifecycle hooks.
5
+ */
6
+ export function makeNeonTesting(options) {
7
+ return makeNeonTestingCore({ ...options, hooks: { beforeAll, afterAll } });
8
+ }
9
+ //# sourceMappingURL=vitest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.js","sourceRoot":"","sources":["../src/vitest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAKhD;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,OAA+B;IAC7D,OAAO,mBAAmB,CAAC,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;AAC7E,CAAC"}
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "neon-testing",
3
- "version": "2.7.0",
4
- "description": "A Vitest utility for seamless integration tests with Neon Postgres",
3
+ "version": "3.0.0-beta.1",
4
+ "description": "A testing utility for seamless integration tests with Neon Postgres, for Vitest and Bun Test.",
5
5
  "keywords": [
6
6
  "neon",
7
7
  "postgres",
8
8
  "postgresql",
9
- "vitest"
9
+ "vitest",
10
+ "bun",
11
+ "testing"
10
12
  ],
11
13
  "author": "Mikael Lirbank",
12
14
  "license": "MIT",
@@ -15,60 +17,90 @@
15
17
  "bugs": "https://github.com/starmode-base/neon-testing/issues",
16
18
  "type": "module",
17
19
  "exports": {
18
- ".": {
19
- "types": "./dist/index.d.ts",
20
- "import": "./dist/index.js"
20
+ "./core": {
21
+ "types": "./dist/core.d.ts",
22
+ "import": "./dist/core.js"
23
+ },
24
+ "./vitest": {
25
+ "types": "./dist/vitest.d.ts",
26
+ "import": "./dist/vitest.js"
27
+ },
28
+ "./bun": {
29
+ "types": "./dist/bun.d.ts",
30
+ "import": "./dist/bun.js"
21
31
  },
22
32
  "./utils": {
23
33
  "types": "./dist/utils.d.ts",
24
34
  "import": "./dist/utils.js"
25
35
  },
26
- "./vite": {
27
- "types": "./dist/vite-plugin.d.ts",
28
- "import": "./dist/vite-plugin.js"
36
+ "./setup": {
37
+ "types": "./dist/setup.d.ts",
38
+ "import": "./dist/setup.js"
29
39
  }
30
40
  },
31
41
  "files": [
32
- "dist"
42
+ "dist",
43
+ "src",
44
+ "!src/**/*.test.ts"
33
45
  ],
46
+ "engines": {
47
+ "node": ">=22"
48
+ },
34
49
  "scripts": {
35
50
  "dev": "tsc -p tsconfig.build.json --watch",
36
- "build": "rm -rf dist && tsc -p tsconfig.build.json && tsc && prettier --check . && vitest run",
51
+ "build": "rm -rf dist && tsc -p tsconfig.build.json",
52
+ "prepublishOnly": "bun run build",
53
+ "check": "prettier --check . && bun run build && tsc && bun run check:drift && bun run test",
54
+ "check:drift": "diff -r -x neon-testing.ts tests-bun tests-vitest",
37
55
  "format": "prettier --write .",
38
- "test": "vitest",
56
+ "test": "vitest run && bun test",
57
+ "test:unit": "vitest run src",
58
+ "test:unit:watch": "vitest src",
59
+ "test:examples": "vitest run examples",
60
+ "test:examples:watch": "vitest examples",
61
+ "test:vitest": "vitest run tests-vitest",
62
+ "test:vitest:watch": "vitest tests-vitest",
63
+ "test:bun": "bun test",
64
+ "test:bun:watch": "bun test --watch",
39
65
  "skills:update": "bunx skills add neondatabase/agent-skills",
40
66
  "clean:soft": "rm -rf node_modules dist && bun install",
41
67
  "clean:hard": "rm -rf node_modules dist bun.lock && bun install",
42
- "release:patch": "bun pm version patch",
43
- "release:minor": "bun pm version minor",
44
- "release:major": "bun pm version major",
45
- "release:beta": "bun pm version prerelease --preid=beta",
46
- "release:beta:patch": "bun pm version prepatch --preid=beta",
47
- "release:beta:minor": "bun pm version preminor --preid=beta",
48
- "release:beta:major": "bun pm version premajor --preid=beta",
68
+ "release:patch": "bun pm version patch --message 'release: v%s'",
69
+ "release:minor": "bun pm version minor --message 'release: v%s'",
70
+ "release:major": "bun pm version major --message 'release: v%s'",
71
+ "release:beta": "bun pm version prerelease --preid=beta --message 'release: v%s'",
72
+ "release:beta:patch": "bun pm version prepatch --preid=beta --message 'release: v%s'",
73
+ "release:beta:minor": "bun pm version preminor --preid=beta --message 'release: v%s'",
74
+ "release:beta:major": "bun pm version premajor --preid=beta --message 'release: v%s'",
75
+ "preversion": "test \"$(git branch --show-current)\" = main && git pull --ff-only",
49
76
  "postversion": "git push --follow-tags"
50
77
  },
51
78
  "dependencies": {
52
- "@neondatabase/api-client": "^2.7.1"
79
+ "@neondatabase/api-client": "2.7.1"
53
80
  },
54
81
  "peerDependencies": {
55
- "vite": "^7",
82
+ "@neondatabase/serverless": "^1",
56
83
  "vitest": "^3 || ^4"
57
84
  },
85
+ "peerDependenciesMeta": {
86
+ "@neondatabase/serverless": {
87
+ "optional": true
88
+ },
89
+ "vitest": {
90
+ "optional": true
91
+ }
92
+ },
58
93
  "devDependencies": {
59
- "@neondatabase/serverless": "^1.0.2",
94
+ "@neondatabase/serverless": "^1.1.0",
95
+ "@types/bun": "^1.3.14",
60
96
  "@types/pg": "^8.20.0",
61
97
  "dotenv": "^17.4.2",
62
98
  "drizzle-orm": "^0.45.2",
63
- "pg": "^8.20.0",
99
+ "pg": "^8.21.0",
64
100
  "postgres": "^3.4.9",
65
- "prettier": "^3.8.2",
101
+ "prettier": "^3.8.4",
66
102
  "tiny-invariant": "^1.3.3",
67
- "typescript": "^5.9.3",
68
- "vite": "^7.3.2",
69
- "vitest": "^4.1.4"
70
- },
71
- "browser": {
72
- "./dist/vite-plugin.js": "./dist/browser-empty.js"
103
+ "typescript": "^6.0.3",
104
+ "vitest": "^4.1.9"
73
105
  }
74
106
  }
package/src/bun.ts ADDED
@@ -0,0 +1,13 @@
1
+ /// <reference types="bun" />
2
+ import { beforeAll, afterAll } from "bun:test";
3
+ import { makeNeonTestingCore } from "./core.js";
4
+ import type { MakeNeonTestingOptions } from "./core.js";
5
+
6
+ export type { MakeNeonTestingOptions, NeonTestingOptions } from "./core.js";
7
+
8
+ /**
9
+ * Create a Neon test-branch factory wired to Bun's lifecycle hooks.
10
+ */
11
+ export function makeNeonTesting(options: MakeNeonTestingOptions) {
12
+ return makeNeonTestingCore({ ...options, hooks: { beforeAll, afterAll } });
13
+ }