@superblocksteam/sdk-api 2.0.102 → 2.0.103

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 (216) hide show
  1. package/README.md +47 -41
  2. package/dist/api/definition.d.ts +1 -1
  3. package/dist/api/definition.d.ts.map +1 -1
  4. package/dist/api/definition.js.map +1 -1
  5. package/dist/api/definition.test.js.map +1 -1
  6. package/dist/api/streaming.d.ts +1 -1
  7. package/dist/api/streaming.d.ts.map +1 -1
  8. package/dist/api/streaming.js.map +1 -1
  9. package/dist/api/streaming.test.js +2 -2
  10. package/dist/api/streaming.test.js.map +1 -1
  11. package/dist/integrations/athena/client.d.ts +1 -1
  12. package/dist/integrations/athena/client.d.ts.map +1 -1
  13. package/dist/integrations/athena/client.js.map +1 -1
  14. package/dist/integrations/athena/types.d.ts.map +1 -1
  15. package/dist/integrations/base/graphql-integration-client.d.ts +2 -2
  16. package/dist/integrations/base/graphql-integration-client.d.ts.map +1 -1
  17. package/dist/integrations/base/graphql-integration-client.js.map +1 -1
  18. package/dist/integrations/base/rest-api-integration-client.d.ts +3 -3
  19. package/dist/integrations/base/rest-api-integration-client.d.ts.map +1 -1
  20. package/dist/integrations/base/rest-api-integration-client.js.map +1 -1
  21. package/dist/integrations/base/types.d.ts.map +1 -1
  22. package/dist/integrations/bigquery/client.d.ts +1 -1
  23. package/dist/integrations/bigquery/client.d.ts.map +1 -1
  24. package/dist/integrations/bigquery/client.js.map +1 -1
  25. package/dist/integrations/bigquery/types.d.ts.map +1 -1
  26. package/dist/integrations/cockroachdb/client.d.ts +1 -1
  27. package/dist/integrations/cockroachdb/client.d.ts.map +1 -1
  28. package/dist/integrations/cockroachdb/client.js.map +1 -1
  29. package/dist/integrations/cockroachdb/types.d.ts.map +1 -1
  30. package/dist/integrations/cosmosdb/client.d.ts +1 -1
  31. package/dist/integrations/cosmosdb/client.d.ts.map +1 -1
  32. package/dist/integrations/cosmosdb/client.js.map +1 -1
  33. package/dist/integrations/cosmosdb/client.test.js.map +1 -1
  34. package/dist/integrations/cosmosdb/types.d.ts.map +1 -1
  35. package/dist/integrations/couchbase/client.d.ts +9 -3
  36. package/dist/integrations/couchbase/client.d.ts.map +1 -1
  37. package/dist/integrations/couchbase/client.js +27 -33
  38. package/dist/integrations/couchbase/client.js.map +1 -1
  39. package/dist/integrations/couchbase/types.d.ts.map +1 -1
  40. package/dist/integrations/databricks/client.d.ts +1 -1
  41. package/dist/integrations/databricks/client.d.ts.map +1 -1
  42. package/dist/integrations/databricks/client.js.map +1 -1
  43. package/dist/integrations/databricks/types.d.ts.map +1 -1
  44. package/dist/integrations/declarations.d.ts +36 -36
  45. package/dist/integrations/declarations.d.ts.map +1 -1
  46. package/dist/integrations/declarations.test.js.map +1 -1
  47. package/dist/integrations/dynamodb/client.d.ts +1 -1
  48. package/dist/integrations/dynamodb/client.d.ts.map +1 -1
  49. package/dist/integrations/dynamodb/client.js.map +1 -1
  50. package/dist/integrations/dynamodb/types.d.ts.map +1 -1
  51. package/dist/integrations/gcs/client.d.ts +1 -1
  52. package/dist/integrations/gcs/client.d.ts.map +1 -1
  53. package/dist/integrations/gcs/client.js.map +1 -1
  54. package/dist/integrations/gcs/types.d.ts.map +1 -1
  55. package/dist/integrations/graphql/types.d.ts +1 -1
  56. package/dist/integrations/graphql/types.d.ts.map +1 -1
  57. package/dist/integrations/gsheets/client.d.ts +1 -1
  58. package/dist/integrations/gsheets/client.d.ts.map +1 -1
  59. package/dist/integrations/gsheets/client.js.map +1 -1
  60. package/dist/integrations/gsheets/types.d.ts.map +1 -1
  61. package/dist/integrations/kafka/client.d.ts +1 -1
  62. package/dist/integrations/kafka/client.d.ts.map +1 -1
  63. package/dist/integrations/kafka/client.js.map +1 -1
  64. package/dist/integrations/kafka/types.d.ts.map +1 -1
  65. package/dist/integrations/kinesis/client.d.ts +1 -1
  66. package/dist/integrations/kinesis/client.d.ts.map +1 -1
  67. package/dist/integrations/kinesis/client.js.map +1 -1
  68. package/dist/integrations/lakebase/client.d.ts +1 -1
  69. package/dist/integrations/lakebase/client.d.ts.map +1 -1
  70. package/dist/integrations/lakebase/client.js.map +1 -1
  71. package/dist/integrations/lakebase/types.d.ts.map +1 -1
  72. package/dist/integrations/mariadb/client.d.ts +1 -1
  73. package/dist/integrations/mariadb/client.d.ts.map +1 -1
  74. package/dist/integrations/mariadb/client.js.map +1 -1
  75. package/dist/integrations/mariadb/types.d.ts.map +1 -1
  76. package/dist/integrations/mongodb/client.d.ts +1 -1
  77. package/dist/integrations/mongodb/client.d.ts.map +1 -1
  78. package/dist/integrations/mongodb/client.js.map +1 -1
  79. package/dist/integrations/mongodb/types.d.ts.map +1 -1
  80. package/dist/integrations/mssql/client.d.ts +1 -1
  81. package/dist/integrations/mssql/client.d.ts.map +1 -1
  82. package/dist/integrations/mssql/client.js.map +1 -1
  83. package/dist/integrations/mssql/types.d.ts.map +1 -1
  84. package/dist/integrations/mysql/client.d.ts +1 -1
  85. package/dist/integrations/mysql/client.d.ts.map +1 -1
  86. package/dist/integrations/mysql/client.js.map +1 -1
  87. package/dist/integrations/mysql/types.d.ts.map +1 -1
  88. package/dist/integrations/oracledb/client.d.ts +1 -1
  89. package/dist/integrations/oracledb/client.d.ts.map +1 -1
  90. package/dist/integrations/oracledb/client.js.map +1 -1
  91. package/dist/integrations/oracledb/types.d.ts.map +1 -1
  92. package/dist/integrations/postgres/client.d.ts +2 -2
  93. package/dist/integrations/postgres/client.d.ts.map +1 -1
  94. package/dist/integrations/postgres/client.js.map +1 -1
  95. package/dist/integrations/postgres/types.d.ts.map +1 -1
  96. package/dist/integrations/python/client.d.ts +2 -2
  97. package/dist/integrations/python/client.d.ts.map +1 -1
  98. package/dist/integrations/python/client.js.map +1 -1
  99. package/dist/integrations/python/client.test.js.map +1 -1
  100. package/dist/integrations/python/types.d.ts.map +1 -1
  101. package/dist/integrations/redis/client.d.ts +1 -1
  102. package/dist/integrations/redis/client.d.ts.map +1 -1
  103. package/dist/integrations/redis/client.js.map +1 -1
  104. package/dist/integrations/redis/types.d.ts.map +1 -1
  105. package/dist/integrations/redshift/client.d.ts +1 -1
  106. package/dist/integrations/redshift/client.d.ts.map +1 -1
  107. package/dist/integrations/redshift/client.js.map +1 -1
  108. package/dist/integrations/redshift/types.d.ts.map +1 -1
  109. package/dist/integrations/registry.d.ts.map +1 -1
  110. package/dist/integrations/registry.js +22 -22
  111. package/dist/integrations/registry.js.map +1 -1
  112. package/dist/integrations/registry.test.js.map +1 -1
  113. package/dist/integrations/s3/client.d.ts +1 -1
  114. package/dist/integrations/s3/client.d.ts.map +1 -1
  115. package/dist/integrations/s3/client.js.map +1 -1
  116. package/dist/integrations/s3/types.d.ts +3 -1
  117. package/dist/integrations/s3/types.d.ts.map +1 -1
  118. package/dist/integrations/salesforce/client.d.ts +1 -1
  119. package/dist/integrations/salesforce/client.d.ts.map +1 -1
  120. package/dist/integrations/salesforce/client.js.map +1 -1
  121. package/dist/integrations/salesforce/types.d.ts.map +1 -1
  122. package/dist/integrations/smtp/client.d.ts +1 -1
  123. package/dist/integrations/smtp/client.d.ts.map +1 -1
  124. package/dist/integrations/smtp/client.js.map +1 -1
  125. package/dist/integrations/snowflake/client.d.ts +1 -1
  126. package/dist/integrations/snowflake/client.d.ts.map +1 -1
  127. package/dist/integrations/snowflake/client.js.map +1 -1
  128. package/dist/integrations/snowflake/types.d.ts.map +1 -1
  129. package/dist/integrations/snowflakepostgres/client.d.ts +1 -1
  130. package/dist/integrations/snowflakepostgres/client.d.ts.map +1 -1
  131. package/dist/integrations/snowflakepostgres/client.js.map +1 -1
  132. package/dist/integrations/snowflakepostgres/types.d.ts.map +1 -1
  133. package/dist/runtime/context.d.ts +2 -2
  134. package/dist/runtime/context.d.ts.map +1 -1
  135. package/dist/runtime/context.js.map +1 -1
  136. package/dist/runtime/streaming-context.d.ts +2 -2
  137. package/dist/runtime/streaming-context.d.ts.map +1 -1
  138. package/dist/runtime/streaming-context.js.map +1 -1
  139. package/dist/runtime/streaming-executor.d.ts.map +1 -1
  140. package/dist/runtime/streaming-executor.js +1 -1
  141. package/dist/runtime/streaming-executor.js.map +1 -1
  142. package/dist/types.d.ts.map +1 -1
  143. package/package.json +1 -1
  144. package/src/api/definition.test.ts +1 -0
  145. package/src/api/definition.ts +1 -1
  146. package/src/api/streaming.test.ts +3 -2
  147. package/src/api/streaming.ts +2 -1
  148. package/src/integrations/athena/client.ts +5 -3
  149. package/src/integrations/athena/types.ts +1 -0
  150. package/src/integrations/base/graphql-integration-client.ts +3 -2
  151. package/src/integrations/base/rest-api-integration-client.ts +9 -7
  152. package/src/integrations/base/types.ts +1 -0
  153. package/src/integrations/bigquery/client.ts +5 -3
  154. package/src/integrations/bigquery/types.ts +1 -0
  155. package/src/integrations/cockroachdb/client.ts +5 -3
  156. package/src/integrations/cockroachdb/types.ts +1 -0
  157. package/src/integrations/cosmosdb/client.test.ts +2 -1
  158. package/src/integrations/cosmosdb/client.ts +5 -3
  159. package/src/integrations/cosmosdb/types.ts +1 -0
  160. package/src/integrations/couchbase/client.ts +34 -46
  161. package/src/integrations/couchbase/types.ts +1 -0
  162. package/src/integrations/databricks/client.ts +5 -3
  163. package/src/integrations/databricks/types.ts +1 -0
  164. package/src/integrations/declarations.test.ts +1 -0
  165. package/src/integrations/declarations.ts +36 -36
  166. package/src/integrations/dynamodb/client.ts +3 -2
  167. package/src/integrations/dynamodb/types.ts +1 -0
  168. package/src/integrations/gcs/client.ts +5 -3
  169. package/src/integrations/gcs/types.ts +1 -0
  170. package/src/integrations/graphql/types.ts +2 -1
  171. package/src/integrations/gsheets/client.ts +5 -3
  172. package/src/integrations/gsheets/types.ts +1 -0
  173. package/src/integrations/kafka/client.ts +3 -2
  174. package/src/integrations/kafka/types.ts +1 -0
  175. package/src/integrations/kinesis/client.ts +2 -2
  176. package/src/integrations/lakebase/README.md +242 -0
  177. package/src/integrations/lakebase/client.ts +6 -4
  178. package/src/integrations/lakebase/types.ts +1 -0
  179. package/src/integrations/mariadb/client.ts +5 -3
  180. package/src/integrations/mariadb/types.ts +1 -0
  181. package/src/integrations/mongodb/client.ts +5 -3
  182. package/src/integrations/mongodb/types.ts +1 -0
  183. package/src/integrations/mssql/client.ts +5 -3
  184. package/src/integrations/mssql/types.ts +1 -0
  185. package/src/integrations/mysql/client.ts +5 -3
  186. package/src/integrations/mysql/types.ts +1 -0
  187. package/src/integrations/oracledb/client.ts +5 -3
  188. package/src/integrations/oracledb/types.ts +1 -0
  189. package/src/integrations/postgres/client.ts +6 -4
  190. package/src/integrations/postgres/types.ts +1 -0
  191. package/src/integrations/python/client.test.ts +3 -2
  192. package/src/integrations/python/client.ts +5 -3
  193. package/src/integrations/python/types.ts +1 -0
  194. package/src/integrations/redis/client.ts +3 -2
  195. package/src/integrations/redis/types.ts +1 -0
  196. package/src/integrations/redshift/client.ts +5 -3
  197. package/src/integrations/redshift/types.ts +1 -0
  198. package/src/integrations/registry.test.ts +1 -0
  199. package/src/integrations/registry.ts +23 -23
  200. package/src/integrations/restapiintegration/README.md +359 -0
  201. package/src/integrations/s3/client.ts +5 -3
  202. package/src/integrations/s3/types.ts +4 -1
  203. package/src/integrations/salesforce/client.ts +3 -2
  204. package/src/integrations/salesforce/types.ts +1 -0
  205. package/src/integrations/smtp/README.md +220 -0
  206. package/src/integrations/smtp/client.ts +4 -2
  207. package/src/integrations/snowflake/client.ts +5 -3
  208. package/src/integrations/snowflake/types.ts +1 -0
  209. package/src/integrations/snowflakecortex/README.md +216 -0
  210. package/src/integrations/snowflakepostgres/README.md +233 -0
  211. package/src/integrations/snowflakepostgres/client.ts +1 -1
  212. package/src/integrations/snowflakepostgres/types.ts +1 -0
  213. package/src/runtime/context.ts +10 -10
  214. package/src/runtime/streaming-context.ts +10 -10
  215. package/src/runtime/streaming-executor.ts +4 -4
  216. package/src/types.ts +1 -0
@@ -4,13 +4,15 @@
4
4
  * Uses the native GCS plugin type from @superblocksteam/types.
5
5
  */
6
6
 
7
- import type { z } from "zod";
8
7
  import type { PartialMessage } from "@bufbuild/protobuf";
8
+ import type { z } from "zod";
9
+
9
10
  import type { Plugin as GCSPlugin } from "@superblocksteam/types/dist/src/plugins/gcs/v1/plugin_pb";
10
- import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
11
- import type { QueryExecutor, TraceMetadata } from "../registry.js";
11
+
12
12
  import { RestApiValidationError } from "../../errors.js";
13
13
  import { IntegrationError } from "../../runtime/errors.js";
14
+ import type { QueryExecutor, TraceMetadata } from "../registry.js";
15
+ import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
14
16
  import type {
15
17
  GCSClient,
16
18
  GCSAction,
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  import type { z } from "zod";
6
+
6
7
  import type { BaseIntegrationClient } from "../../types.js";
7
8
  import type { TraceMetadata } from "../registry.js";
8
9
 
@@ -2,9 +2,10 @@
2
2
  * GraphQL client types.
3
3
  */
4
4
 
5
+ import type { z } from "zod";
6
+
5
7
  import type { BaseIntegrationClient } from "../../types.js";
6
8
  import type { TraceMetadata } from "../registry.js";
7
- import type { z } from "zod";
8
9
 
9
10
  /**
10
11
  * GraphQL client for executing queries and mutations.
@@ -4,13 +4,15 @@
4
4
  * Uses the native Google Sheets plugin type from @superblocksteam/types.
5
5
  */
6
6
 
7
- import type { z } from "zod";
8
7
  import type { PartialMessage } from "@bufbuild/protobuf";
8
+ import type { z } from "zod";
9
+
9
10
  import type { Plugin as GSheetsPlugin } from "@superblocksteam/types/dist/src/plugins/gsheets/v1/plugin_pb";
10
- import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
11
- import type { QueryExecutor, TraceMetadata } from "../registry.js";
11
+
12
12
  import { RestApiValidationError } from "../../errors.js";
13
13
  import { IntegrationError } from "../../runtime/errors.js";
14
+ import type { QueryExecutor, TraceMetadata } from "../registry.js";
15
+ import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
14
16
  import type {
15
17
  GoogleSheetsClient,
16
18
  GoogleSheetsAction,
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  import type { z } from "zod";
6
+
6
7
  import type { BaseIntegrationClient } from "../../types.js";
7
8
  import type { TraceMetadata } from "../registry.js";
8
9
 
@@ -5,10 +5,11 @@
5
5
  */
6
6
 
7
7
  import type { z } from "zod";
8
- import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
9
- import type { QueryExecutor, TraceMetadata } from "../registry.js";
8
+
10
9
  import { RestApiValidationError } from "../../errors.js";
11
10
  import { IntegrationError } from "../../runtime/errors.js";
11
+ import type { QueryExecutor, TraceMetadata } from "../registry.js";
12
+ import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
12
13
  import type {
13
14
  KafkaClient,
14
15
  KafkaConsumeParams,
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  import type { z } from "zod";
6
+
6
7
  import type { BaseIntegrationClient } from "../../types.js";
7
8
  import type { TraceMetadata } from "../registry.js";
8
9
 
@@ -5,9 +5,9 @@
5
5
  * Supports PUT (write records) and GET (read records) operations.
6
6
  */
7
7
 
8
- import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
9
- import type { QueryExecutor, TraceMetadata } from "../registry.js";
10
8
  import { IntegrationError } from "../../runtime/errors.js";
9
+ import type { QueryExecutor, TraceMetadata } from "../registry.js";
10
+ import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
11
11
  import type {
12
12
  KinesisClient,
13
13
  KinesisPutParams,
@@ -0,0 +1,242 @@
1
+ # Lakebase Client
2
+
3
+ Execute SQL queries and statements against Lakebase databases with full type safety and runtime validation.
4
+
5
+ ## Methods
6
+
7
+ | Method | Description |
8
+ | ------------------------------------------- | -------------------------------------------------------------------------- |
9
+ | `query<T>(sql, schema, params?, metadata?)` | Execute a SELECT query and return validated, typed results |
10
+ | `execute(sql, params?, metadata?)` | Execute a statement (INSERT, UPDATE, DELETE) and return affected row count |
11
+
12
+ ## Usage
13
+
14
+ ### Basic Query with Schema Validation
15
+
16
+ ```typescript
17
+ import { api, z, lakebase } from "@superblocksteam/sdk-api";
18
+
19
+ // Integration ID from the integrations panel
20
+ const LAKEBASE_DB = "a1b2c3d4-5678-90ab-cdef-111111111111";
21
+
22
+ const UserSchema = z.object({
23
+ id: z.string(),
24
+ name: z.string(),
25
+ email: z.string(),
26
+ created_at: z.string(),
27
+ });
28
+
29
+ export default api({
30
+ name: "GetUsers",
31
+ integrations: {
32
+ db: lakebase(LAKEBASE_DB),
33
+ },
34
+ input: z.object({
35
+ status: z.string(),
36
+ }),
37
+ output: z.object({
38
+ users: z.array(UserSchema),
39
+ }),
40
+ async run(ctx, { status }) {
41
+ const users = await ctx.integrations.db.query(
42
+ "SELECT id, name, email, created_at FROM users WHERE status = $1",
43
+ UserSchema,
44
+ [status],
45
+ );
46
+
47
+ return { users };
48
+ },
49
+ });
50
+ ```
51
+
52
+ ### Executing INSERT, UPDATE, DELETE Statements
53
+
54
+ ```typescript
55
+ import { api, z, lakebase } from "@superblocksteam/sdk-api";
56
+
57
+ const LAKEBASE_DB = "a1b2c3d4-5678-90ab-cdef-111111111111";
58
+
59
+ export default api({
60
+ name: "ManageUsers",
61
+ integrations: {
62
+ db: lakebase(LAKEBASE_DB),
63
+ },
64
+ input: z.object({
65
+ name: z.string(),
66
+ email: z.string(),
67
+ }),
68
+ output: z.object({ success: z.boolean() }),
69
+
70
+ async run(ctx, { name, email }) {
71
+ // INSERT
72
+ await ctx.integrations.db.execute(
73
+ "INSERT INTO users (name, email) VALUES ($1, $2)",
74
+ [name, email],
75
+ );
76
+
77
+ // UPDATE
78
+ const updateResult = await ctx.integrations.db.execute(
79
+ "UPDATE users SET last_login = NOW() WHERE email = $1",
80
+ [email],
81
+ );
82
+ console.log(`Updated ${updateResult.rowCount} rows`);
83
+
84
+ // DELETE
85
+ const deleteResult = await ctx.integrations.db.execute(
86
+ "DELETE FROM sessions WHERE expires_at < NOW()",
87
+ );
88
+ console.log(`Deleted ${deleteResult.rowCount} expired sessions`);
89
+
90
+ return { success: true };
91
+ },
92
+ });
93
+ ```
94
+
95
+ ### Query with JOIN
96
+
97
+ ```typescript
98
+ const OrderSchema = z.object({
99
+ order_id: z.string(),
100
+ customer_name: z.string(),
101
+ total: z.string(), // NUMERIC as string
102
+ });
103
+
104
+ const orders = await ctx.integrations.db.query(
105
+ `SELECT o.id as order_id, c.name as customer_name, o.total
106
+ FROM orders o
107
+ JOIN customers c ON o.customer_id = c.id
108
+ WHERE o.status = $1`,
109
+ OrderSchema,
110
+ ["pending"],
111
+ );
112
+ ```
113
+
114
+ ## Trace Metadata
115
+
116
+ All methods accept an optional `metadata` parameter as the last argument for diagnostics labeling:
117
+
118
+ ```typescript
119
+ const users = await ctx.integrations.db.query(
120
+ "SELECT * FROM users WHERE status = $1",
121
+ UserSchema,
122
+ ["active"],
123
+ { label: "Fetch active users" },
124
+ );
125
+
126
+ await ctx.integrations.db.execute(
127
+ "DELETE FROM sessions WHERE expires_at < NOW()",
128
+ undefined, // no params
129
+ { label: "Clean expired sessions" },
130
+ );
131
+ ```
132
+
133
+ When `includeDiagnostics` is enabled, `label` and `description` appear in the trace view. See the [root SDK README](../../../README.md#trace-metadata) for details.
134
+
135
+ ## Common Pitfalls
136
+
137
+ ### Uses `$1` Placeholders (PostgreSQL-Style)
138
+
139
+ Lakebase uses `$1, $2, ...` for parameter placeholders, following PostgreSQL conventions:
140
+
141
+ ```typescript
142
+ // WRONG - Question-mark placeholders
143
+ const users = await ctx.integrations.db.query(
144
+ "SELECT * FROM users WHERE name = ? AND status = ?",
145
+ UserSchema,
146
+ [name, status],
147
+ );
148
+
149
+ // CORRECT - Use $1, $2, ... placeholders
150
+ const users = await ctx.integrations.db.query(
151
+ "SELECT * FROM users WHERE name = $1 AND status = $2",
152
+ UserSchema,
153
+ [name, status],
154
+ );
155
+ ```
156
+
157
+ ### Schema Parameter is Required
158
+
159
+ The `query()` method requires a Zod schema for runtime validation:
160
+
161
+ ```typescript
162
+ // WRONG - Missing schema parameter
163
+ const users = await ctx.integrations.db.query(
164
+ "SELECT * FROM users",
165
+ [
166
+ /* params */
167
+ ], // This is wrong - params are 3rd argument
168
+ );
169
+
170
+ // CORRECT - Schema is the second parameter
171
+ const users = await ctx.integrations.db.query(
172
+ "SELECT * FROM users WHERE id = $1",
173
+ UserSchema, // Schema is required
174
+ [userId], // Params are optional, third argument
175
+ );
176
+ ```
177
+
178
+ ### Use Parameterized Queries to Prevent SQL Injection
179
+
180
+ Always use `$1, $2, ...` placeholders instead of string interpolation:
181
+
182
+ ```typescript
183
+ // WRONG - SQL injection vulnerability
184
+ const users = await ctx.integrations.db.query(
185
+ `SELECT * FROM users WHERE name = '${userName}'`, // DANGEROUS!
186
+ UserSchema,
187
+ );
188
+
189
+ // CORRECT - Use parameterized queries
190
+ const users = await ctx.integrations.db.query(
191
+ "SELECT * FROM users WHERE name = $1",
192
+ UserSchema,
193
+ [userName], // Safe - value is escaped
194
+ );
195
+ ```
196
+
197
+ ### NUMERIC/DECIMAL Values Returned as Strings
198
+
199
+ Large `NUMERIC` and `DECIMAL` columns are returned as strings to preserve precision:
200
+
201
+ ```typescript
202
+ // WRONG - May lose precision
203
+ const schema = z.object({ price: z.number() });
204
+
205
+ // CORRECT - Keep as string or transform
206
+ const schema = z.object({
207
+ price: z.string().transform((val) => parseFloat(val)),
208
+ });
209
+ ```
210
+
211
+ ### Handling NULL Values
212
+
213
+ ```typescript
214
+ // WRONG - Will fail if column contains NULL
215
+ const schema = z.object({ bio: z.string() });
216
+
217
+ // CORRECT - Mark nullable columns
218
+ const schema = z.object({ bio: z.string().nullable() });
219
+ ```
220
+
221
+ ## Error Handling
222
+
223
+ ### QueryValidationError
224
+
225
+ Thrown when query results fail schema validation:
226
+
227
+ ```typescript
228
+ import { QueryValidationError } from "@superblocksteam/sdk-api";
229
+
230
+ try {
231
+ const users = await ctx.integrations.db.query(
232
+ "SELECT * FROM users",
233
+ UserSchema,
234
+ );
235
+ } catch (error) {
236
+ if (error instanceof QueryValidationError) {
237
+ console.error("Row index:", error.details.rowIndex);
238
+ console.error("Validation errors:", error.details.errors);
239
+ console.error("Actual row data:", error.details.row);
240
+ }
241
+ }
242
+ ```
@@ -5,15 +5,17 @@
5
5
  * Supports server-side parameterized SQL queries via the `parameters` field.
6
6
  */
7
7
 
8
- import type { z } from "zod";
9
8
  import type { PartialMessage } from "@bufbuild/protobuf";
9
+ import type { z } from "zod";
10
+
10
11
  import type { Plugin as LakebasePlugin } from "@superblocksteam/types/dist/src/plugins/lakebase/v1/plugin_pb";
11
- import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
12
- import type { QueryExecutor, TraceMetadata } from "../registry.js";
13
- import type { LakebaseClient } from "./types.js";
12
+
14
13
  import { QueryValidationError } from "../../errors.js";
15
14
  import { IntegrationError } from "../../runtime/errors.js";
15
+ import type { QueryExecutor, TraceMetadata } from "../registry.js";
16
+ import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
16
17
  import { describeType } from "../utils.js";
18
+ import type { LakebaseClient } from "./types.js";
17
19
 
18
20
  /**
19
21
  * Lakebase request type derived from proto definition.
@@ -6,6 +6,7 @@
6
6
  */
7
7
 
8
8
  import type { z } from "zod";
9
+
9
10
  import type { BaseIntegrationClient } from "../../types.js";
10
11
  import type { TraceMetadata } from "../registry.js";
11
12
 
@@ -5,13 +5,15 @@
5
5
  * runtime validation using Zod schemas.
6
6
  */
7
7
 
8
- import type { z } from "zod";
9
8
  import type { PartialMessage } from "@bufbuild/protobuf";
9
+ import type { z } from "zod";
10
+
10
11
  import type { Plugin as MariaDBPlugin } from "@superblocksteam/types/dist/src/plugins/mariadb/v1/plugin_pb";
11
- import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
12
- import type { QueryExecutor, TraceMetadata } from "../registry.js";
12
+
13
13
  import { QueryValidationError } from "../../errors.js";
14
14
  import { IntegrationError } from "../../runtime/errors.js";
15
+ import type { QueryExecutor, TraceMetadata } from "../registry.js";
16
+ import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
15
17
  import { describeType } from "../utils.js";
16
18
  import type { MariaDBClient } from "./types.js";
17
19
 
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  import type { z } from "zod";
8
+
8
9
  import type { BaseIntegrationClient } from "../../types.js";
9
10
  import type { TraceMetadata } from "../registry.js";
10
11
 
@@ -4,13 +4,15 @@
4
4
  * Uses the native MongoDB plugin type from @superblocksteam/types.
5
5
  */
6
6
 
7
- import type { z } from "zod";
8
7
  import type { PartialMessage } from "@bufbuild/protobuf";
8
+ import type { z } from "zod";
9
+
9
10
  import type { Plugin as MongoDBPlugin } from "@superblocksteam/types/dist/src/plugins/mongodb/v1/plugin_pb";
10
- import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
11
- import type { QueryExecutor, TraceMetadata } from "../registry.js";
11
+
12
12
  import { RestApiValidationError } from "../../errors.js";
13
13
  import { IntegrationError } from "../../runtime/errors.js";
14
+ import type { QueryExecutor, TraceMetadata } from "../registry.js";
15
+ import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
14
16
  import type { MongoDBClient, MongoDBAction, MongoDBParams } from "./types.js";
15
17
 
16
18
  /**
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  import type { z } from "zod";
6
+
6
7
  import type { BaseIntegrationClient } from "../../types.js";
7
8
  import type { TraceMetadata } from "../registry.js";
8
9
 
@@ -5,13 +5,15 @@
5
5
  * runtime validation using Zod schemas.
6
6
  */
7
7
 
8
- import type { z } from "zod";
9
8
  import type { PartialMessage } from "@bufbuild/protobuf";
9
+ import type { z } from "zod";
10
+
10
11
  import type { Plugin as MSSQLPlugin } from "@superblocksteam/types/dist/src/plugins/mssql/v1/plugin_pb";
11
- import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
12
- import type { QueryExecutor, TraceMetadata } from "../registry.js";
12
+
13
13
  import { QueryValidationError } from "../../errors.js";
14
14
  import { IntegrationError } from "../../runtime/errors.js";
15
+ import type { QueryExecutor, TraceMetadata } from "../registry.js";
16
+ import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
15
17
  import { describeType } from "../utils.js";
16
18
  import type { MSSQLClient } from "./types.js";
17
19
 
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  import type { z } from "zod";
8
+
8
9
  import type { BaseIntegrationClient } from "../../types.js";
9
10
  import type { TraceMetadata } from "../registry.js";
10
11
 
@@ -5,13 +5,15 @@
5
5
  * runtime validation using Zod schemas.
6
6
  */
7
7
 
8
- import type { z } from "zod";
9
8
  import type { PartialMessage } from "@bufbuild/protobuf";
9
+ import type { z } from "zod";
10
+
10
11
  import type { Plugin as MySQLPlugin } from "@superblocksteam/types/dist/src/plugins/mysql/v1/plugin_pb";
11
- import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
12
- import type { QueryExecutor, TraceMetadata } from "../registry.js";
12
+
13
13
  import { QueryValidationError } from "../../errors.js";
14
14
  import { IntegrationError } from "../../runtime/errors.js";
15
+ import type { QueryExecutor, TraceMetadata } from "../registry.js";
16
+ import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
15
17
  import { describeType } from "../utils.js";
16
18
  import type { MySQLClient } from "./types.js";
17
19
 
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  import type { z } from "zod";
8
+
8
9
  import type { BaseIntegrationClient } from "../../types.js";
9
10
  import type { TraceMetadata } from "../registry.js";
10
11
 
@@ -5,13 +5,15 @@
5
5
  * runtime validation using Zod schemas.
6
6
  */
7
7
 
8
- import type { z } from "zod";
9
8
  import type { PartialMessage } from "@bufbuild/protobuf";
9
+ import type { z } from "zod";
10
+
10
11
  import type { Plugin as OracleDBPlugin } from "@superblocksteam/types/dist/src/plugins/oracledb/v1/plugin_pb";
11
- import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
12
- import type { QueryExecutor, TraceMetadata } from "../registry.js";
12
+
13
13
  import { QueryValidationError } from "../../errors.js";
14
14
  import { IntegrationError } from "../../runtime/errors.js";
15
+ import type { QueryExecutor, TraceMetadata } from "../registry.js";
16
+ import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
15
17
  import { describeType } from "../utils.js";
16
18
  import type { OracleDBClient } from "./types.js";
17
19
 
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  import type { z } from "zod";
8
+
8
9
  import type { BaseIntegrationClient } from "../../types.js";
9
10
  import type { TraceMetadata } from "../registry.js";
10
11
 
@@ -5,15 +5,17 @@
5
5
  * for type-safe request building.
6
6
  */
7
7
 
8
- import type { z } from "zod";
9
8
  import type { PartialMessage } from "@bufbuild/protobuf";
9
+ import type { z } from "zod";
10
+
10
11
  import type { Plugin as PostgresPlugin } from "@superblocksteam/types/dist/src/plugins/postgresql/v1/plugin_pb";
11
- import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
12
- import type { QueryExecutor, TraceMetadata } from "../registry.js";
13
- import type { PostgresClient } from "./types.js";
12
+
14
13
  import { QueryValidationError } from "../../errors.js";
15
14
  import { IntegrationError } from "../../runtime/errors.js";
15
+ import type { QueryExecutor, TraceMetadata } from "../registry.js";
16
+ import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
16
17
  import { describeType } from "../utils.js";
18
+ import type { PostgresClient } from "./types.js";
17
19
  /**
18
20
  * PostgreSQL request type derived from proto definition.
19
21
  * Using PartialMessage allows optional fields.
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  import type { z } from "zod";
6
+
6
7
  import type { BaseIntegrationClient } from "../../types.js";
7
8
  import type { TraceMetadata } from "../registry.js";
8
9
 
@@ -4,9 +4,10 @@
4
4
 
5
5
  import { describe, it, expect, vi } from "vitest";
6
6
  import { z } from "zod";
7
- import { PythonClientImpl } from "./client.js";
8
- import type { IntegrationConfig } from "../types.js";
7
+
9
8
  import type { QueryExecutor } from "../registry.js";
9
+ import type { IntegrationConfig } from "../types.js";
10
+ import { PythonClientImpl } from "./client.js";
10
11
 
11
12
  /** Helper to compute expected base64-encoded json.loads preamble. */
12
13
  function expectedBindingsLine(bindings: Record<string, unknown>): string {
@@ -4,13 +4,15 @@
4
4
  * Executes Python code via the orchestrator with type-safe bindings.
5
5
  */
6
6
 
7
- import type { z } from "zod";
8
7
  import type { PartialMessage } from "@bufbuild/protobuf";
8
+ import type { z } from "zod";
9
+
9
10
  import type { Plugin as PythonPlugin } from "@superblocksteam/types/dist/src/plugins/python/v1/plugin_pb";
10
- import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
11
+
12
+ import { CodeExecutionError } from "../../errors.js";
11
13
  import type { QueryExecutor, TraceMetadata } from "../registry.js";
14
+ import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
12
15
  import type { PythonClient } from "./types.js";
13
- import { CodeExecutionError } from "../../errors.js";
14
16
 
15
17
  /**
16
18
  * Python plugin request type derived from proto definition.
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  import type { z } from "zod";
6
+
6
7
  import type { BaseIntegrationClient } from "../../types.js";
7
8
  import type { TraceMetadata } from "../registry.js";
8
9
 
@@ -11,10 +11,11 @@
11
11
  */
12
12
 
13
13
  import type { z } from "zod";
14
- import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
15
- import type { QueryExecutor, TraceMetadata } from "../registry.js";
14
+
16
15
  import { RestApiValidationError } from "../../errors.js";
17
16
  import { IntegrationError } from "../../runtime/errors.js";
17
+ import type { QueryExecutor, TraceMetadata } from "../registry.js";
18
+ import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
18
19
  import type { RedisClient } from "./types.js";
19
20
 
20
21
  /**
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  import type { z } from "zod";
6
+
6
7
  import type { BaseIntegrationClient } from "../../types.js";
7
8
  import type { TraceMetadata } from "../registry.js";
8
9
 
@@ -5,13 +5,15 @@
5
5
  * runtime validation using Zod schemas.
6
6
  */
7
7
 
8
- import type { z } from "zod";
9
8
  import type { PartialMessage } from "@bufbuild/protobuf";
9
+ import type { z } from "zod";
10
+
10
11
  import type { Plugin as RedshiftPlugin } from "@superblocksteam/types/dist/src/plugins/redshift/v1/plugin_pb";
11
- import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
12
- import type { QueryExecutor, TraceMetadata } from "../registry.js";
12
+
13
13
  import { QueryValidationError } from "../../errors.js";
14
14
  import { IntegrationError } from "../../runtime/errors.js";
15
+ import type { QueryExecutor, TraceMetadata } from "../registry.js";
16
+ import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
15
17
  import { describeType } from "../utils.js";
16
18
  import type { RedshiftClient } from "./types.js";
17
19
 
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  import type { z } from "zod";
8
+
8
9
  import type { BaseIntegrationClient } from "../../types.js";
9
10
  import type { TraceMetadata } from "../registry.js";
10
11
 
@@ -1,4 +1,5 @@
1
1
  import { describe, expect, it, vi } from "vitest";
2
+
2
3
  import {
3
4
  createClient,
4
5
  isPluginSupported,