@porulle/adapter-neon 0.64.0 → 0.65.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.
package/dist/index.d.ts CHANGED
@@ -1,11 +1,6 @@
1
1
  import { type NeonHttpDatabase } from "drizzle-orm/neon-http";
2
- import { type NeonDatabase } from "drizzle-orm/neon-serverless";
3
- import { type PostgresJsDatabase } from "drizzle-orm/postgres-js";
4
- import type { DatabaseAdapter } from "@porulle/core";
2
+ import { type DatabaseAdapter } from "@porulle/core";
5
3
  type HttpClient = NeonHttpDatabase<Record<string, unknown>>;
6
- type WsClient = NeonDatabase<Record<string, unknown>>;
7
- type PgClient = PostgresJsDatabase<Record<string, never>>;
8
- type AnyDb = HttpClient | WsClient | PgClient;
9
4
  export interface NeonAdapterOptions {
10
5
  /** Direct Neon connection string (postgresql://...neon.tech/...). */
11
6
  connectionString: string;
@@ -49,12 +44,6 @@ export type NeonDatabaseAdapter = DatabaseAdapter<HttpClient, unknown>;
49
44
  * wraps both its handler and an inner unit of work gets one connection, not two.
50
45
  */
51
46
  export declare function withPooledTransactions<T>(fn: () => Promise<T>): Promise<T>;
52
- /**
53
- * Normalizes `.execute()` to the postgres-js shape (array of rows). Core and
54
- * custom routes iterate `.execute()` results directly; the raw neon drivers
55
- * return `{ rows, command, rowCount }`, which breaks that contract.
56
- */
57
- export declare function normalizeExecuteShape<T extends AnyDb>(db: T): T;
58
47
  export declare function neonAdapter(options: NeonAdapterOptions): NeonDatabaseAdapter;
59
48
  export {};
60
49
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqBA,OAAO,EAA0B,KAAK,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,EAAwB,KAAK,YAAY,EAAE,MAAM,6BAA6B,CAAC;AACtF,OAAO,EAAwB,KAAK,kBAAkB,EAAE,MAAM,yBAAy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AC,CAAC,CAAC;AAI5D,MAAM,WAAW,kBAAkB;IACjC,qEAAqE;IACrE,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,UAAU,CAAC,EAAE;QAAE,gBAAgB,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;CACvD;AAED,MAAM,MAAM,mBAAmB,GAAG,eAAe,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAUvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,sBAAsB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAahF;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,mBAAmB,CAgF5E"}
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ import { drizzle as drizzleHttp } from "drizzle-orm/neon-http";
23
23
  import { drizzle as drizzleWs } from "drizzle-orm/neon-serverless";
24
24
  import { drizzle as drizzlePg } from "drizzle-orm/postgres-js";
25
25
  import postgres from "postgres";
26
+ import { normalizeExecuteShape } from "@porulle/core";
26
27
  if (typeof WebSocket !== "undefined") {
27
28
  neonConfig.webSocketConstructor = WebSocket;
28
29
  }
@@ -72,32 +73,6 @@ export async function withPooledTransactions(fn) {
72
73
  await client.end({ timeout: 1 }).catch(() => { });
73
74
  }
74
75
  }
75
- /**
76
- * Normalizes `.execute()` to the postgres-js shape (array of rows). Core and
77
- * custom routes iterate `.execute()` results directly; the raw neon drivers
78
- * return `{ rows, command, rowCount }`, which breaks that contract.
79
- */
80
- export function normalizeExecuteShape(db) {
81
- const handler = {
82
- get(target, prop, receiver) {
83
- const orig = Reflect.get(target, prop, receiver);
84
- if (prop === "execute" && typeof orig === "function") {
85
- return async (...args) => {
86
- const result = await orig.apply(target, args);
87
- if (result &&
88
- typeof result === "object" &&
89
- "rows" in result &&
90
- Array.isArray(result.rows)) {
91
- return result.rows;
92
- }
93
- return result;
94
- };
95
- }
96
- return orig;
97
- },
98
- };
99
- return new Proxy(db, handler);
100
- }
101
76
  export function neonAdapter(options) {
102
77
  const httpConnectionString = options.connectionString;
103
78
  const sql = neon(httpConnectionString);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@porulle/adapter-neon",
3
- "version": "0.64.0",
3
+ "version": "0.65.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -14,15 +14,15 @@
14
14
  "@neondatabase/serverless": "^1.0.1",
15
15
  "drizzle-orm": "^0.45.1",
16
16
  "postgres": "^3.4.7",
17
- "@porulle/core": "0.64.0"
17
+ "@porulle/core": "0.65.0"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@types/node": "^24.5.2",
21
21
  "eslint": "^9.39.1",
22
22
  "typescript": "5.9.2",
23
23
  "vitest": "^3.2.4",
24
- "@porulle/eslint-config": "0.1.0",
25
- "@porulle/typescript-config": "0.1.0"
24
+ "@porulle/typescript-config": "0.1.0",
25
+ "@porulle/eslint-config": "0.1.0"
26
26
  },
27
27
  "publishConfig": {
28
28
  "access": "public"
package/src/index.ts CHANGED
@@ -23,7 +23,7 @@ import { drizzle as drizzleHttp, type NeonHttpDatabase } from "drizzle-orm/neon-
23
23
  import { drizzle as drizzleWs, type NeonDatabase } from "drizzle-orm/neon-serverless";
24
24
  import { drizzle as drizzlePg, type PostgresJsDatabase } from "drizzle-orm/postgres-js";
25
25
  import postgres from "postgres";
26
- import type { DatabaseAdapter } from "@porulle/core";
26
+ import { normalizeExecuteShape, type DatabaseAdapter } from "@porulle/core";
27
27
 
28
28
  if (typeof WebSocket !== "undefined") {
29
29
  neonConfig.webSocketConstructor = WebSocket as unknown as typeof neonConfig.webSocketConstructor;
@@ -32,7 +32,6 @@ if (typeof WebSocket !== "undefined") {
32
32
  type HttpClient = NeonHttpDatabase<Record<string, unknown>>;
33
33
  type WsClient = NeonDatabase<Record<string, unknown>>;
34
34
  type PgClient = PostgresJsDatabase<Record<string, never>>;
35
- type AnyDb = HttpClient | WsClient | PgClient;
36
35
 
37
36
  export interface NeonAdapterOptions {
38
37
  /** Direct Neon connection string (postgresql://...neon.tech/...). */
@@ -99,35 +98,6 @@ export async function withPooledTransactions<T>(fn: () => Promise<T>): Promise<T
99
98
  }
100
99
  }
101
100
 
102
- /**
103
- * Normalizes `.execute()` to the postgres-js shape (array of rows). Core and
104
- * custom routes iterate `.execute()` results directly; the raw neon drivers
105
- * return `{ rows, command, rowCount }`, which breaks that contract.
106
- */
107
- export function normalizeExecuteShape<T extends AnyDb>(db: T): T {
108
- const handler: ProxyHandler<T> = {
109
- get(target, prop, receiver) {
110
- const orig = Reflect.get(target, prop, receiver);
111
- if (prop === "execute" && typeof orig === "function") {
112
- return async (...args: unknown[]) => {
113
- const result = await (orig as (...a: unknown[]) => Promise<unknown>).apply(target, args);
114
- if (
115
- result &&
116
- typeof result === "object" &&
117
- "rows" in result &&
118
- Array.isArray((result as { rows: unknown[] }).rows)
119
- ) {
120
- return (result as { rows: unknown[] }).rows;
121
- }
122
- return result;
123
- };
124
- }
125
- return orig;
126
- },
127
- };
128
- return new Proxy(db, handler);
129
- }
130
-
131
101
  export function neonAdapter(options: NeonAdapterOptions): NeonDatabaseAdapter {
132
102
  const httpConnectionString = options.connectionString;
133
103