@surf-ai/sdk 1.0.0-alpha.33 → 1.0.0-alpha.34
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/db/index.d.cts +19 -7
- package/dist/db/index.d.ts +19 -7
- package/package.json +1 -1
package/dist/db/index.d.cts
CHANGED
|
@@ -34,12 +34,13 @@ declare function watchSchema(schemaPath: string, options?: {
|
|
|
34
34
|
/**
|
|
35
35
|
* @surf-ai/sdk/db — Database helpers via HTTP proxy to Neon PostgreSQL.
|
|
36
36
|
*
|
|
37
|
-
* All queries go through the Surf API proxy
|
|
38
|
-
*
|
|
37
|
+
* All queries go through the Surf API proxy. There is no locally-instantiated
|
|
38
|
+
* Drizzle ORM client — `drizzle-orm/pg-core` is used only to declare the
|
|
39
|
+
* schema; reads and writes go through dbQuery().
|
|
39
40
|
*
|
|
40
41
|
* Usage:
|
|
41
42
|
* const { dbQuery } = require('@surf-ai/sdk/db')
|
|
42
|
-
* const
|
|
43
|
+
* const { rows } = await dbQuery('SELECT * FROM users WHERE id = $1', [userId])
|
|
43
44
|
*/
|
|
44
45
|
|
|
45
46
|
/**
|
|
@@ -54,14 +55,25 @@ declare function dbProvision(): Promise<{
|
|
|
54
55
|
}>;
|
|
55
56
|
/**
|
|
56
57
|
* Execute a SQL query via db/query.
|
|
57
|
-
* Uses pg-proxy driver under the hood — Drizzle ORM calls this automatically.
|
|
58
58
|
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
59
|
+
* Returns a pg-style result — use `result.rows` for the row data:
|
|
60
|
+
* const { rows } = await dbQuery('SELECT * FROM users')
|
|
61
|
+
* const [row] = (await dbQuery('INSERT ... RETURNING *', [...])).rows
|
|
62
|
+
*
|
|
63
|
+
* @param options.arrayMode - When true, each row is a positional array instead
|
|
64
|
+
* of an object keyed by column name. Default false (object rows).
|
|
61
65
|
*/
|
|
62
66
|
declare function dbQuery(sql: string, params?: any[], options?: {
|
|
63
67
|
arrayMode?: boolean;
|
|
64
|
-
}): Promise<
|
|
68
|
+
}): Promise<{
|
|
69
|
+
rows: any[];
|
|
70
|
+
rowCount?: number;
|
|
71
|
+
fields?: Array<{
|
|
72
|
+
name: string;
|
|
73
|
+
type: string;
|
|
74
|
+
}>;
|
|
75
|
+
truncated?: boolean;
|
|
76
|
+
}>;
|
|
65
77
|
/**
|
|
66
78
|
* List tables in the user's database.
|
|
67
79
|
*/
|
package/dist/db/index.d.ts
CHANGED
|
@@ -34,12 +34,13 @@ declare function watchSchema(schemaPath: string, options?: {
|
|
|
34
34
|
/**
|
|
35
35
|
* @surf-ai/sdk/db — Database helpers via HTTP proxy to Neon PostgreSQL.
|
|
36
36
|
*
|
|
37
|
-
* All queries go through the Surf API proxy
|
|
38
|
-
*
|
|
37
|
+
* All queries go through the Surf API proxy. There is no locally-instantiated
|
|
38
|
+
* Drizzle ORM client — `drizzle-orm/pg-core` is used only to declare the
|
|
39
|
+
* schema; reads and writes go through dbQuery().
|
|
39
40
|
*
|
|
40
41
|
* Usage:
|
|
41
42
|
* const { dbQuery } = require('@surf-ai/sdk/db')
|
|
42
|
-
* const
|
|
43
|
+
* const { rows } = await dbQuery('SELECT * FROM users WHERE id = $1', [userId])
|
|
43
44
|
*/
|
|
44
45
|
|
|
45
46
|
/**
|
|
@@ -54,14 +55,25 @@ declare function dbProvision(): Promise<{
|
|
|
54
55
|
}>;
|
|
55
56
|
/**
|
|
56
57
|
* Execute a SQL query via db/query.
|
|
57
|
-
* Uses pg-proxy driver under the hood — Drizzle ORM calls this automatically.
|
|
58
58
|
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
59
|
+
* Returns a pg-style result — use `result.rows` for the row data:
|
|
60
|
+
* const { rows } = await dbQuery('SELECT * FROM users')
|
|
61
|
+
* const [row] = (await dbQuery('INSERT ... RETURNING *', [...])).rows
|
|
62
|
+
*
|
|
63
|
+
* @param options.arrayMode - When true, each row is a positional array instead
|
|
64
|
+
* of an object keyed by column name. Default false (object rows).
|
|
61
65
|
*/
|
|
62
66
|
declare function dbQuery(sql: string, params?: any[], options?: {
|
|
63
67
|
arrayMode?: boolean;
|
|
64
|
-
}): Promise<
|
|
68
|
+
}): Promise<{
|
|
69
|
+
rows: any[];
|
|
70
|
+
rowCount?: number;
|
|
71
|
+
fields?: Array<{
|
|
72
|
+
name: string;
|
|
73
|
+
type: string;
|
|
74
|
+
}>;
|
|
75
|
+
truncated?: boolean;
|
|
76
|
+
}>;
|
|
65
77
|
/**
|
|
66
78
|
* List tables in the user's database.
|
|
67
79
|
*/
|