@superblocksteam/sdk-api 0.0.5 → 0.0.7

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 (487) hide show
  1. package/README.md +351 -427
  2. package/dist/api/definition.d.ts +12 -7
  3. package/dist/api/definition.d.ts.map +1 -1
  4. package/dist/api/definition.js +19 -12
  5. package/dist/api/definition.js.map +1 -1
  6. package/dist/api/definition.test.js +39 -15
  7. package/dist/api/definition.test.js.map +1 -1
  8. package/dist/api/index.d.ts +0 -2
  9. package/dist/api/index.d.ts.map +1 -1
  10. package/dist/api/index.js +0 -2
  11. package/dist/api/index.js.map +1 -1
  12. package/dist/errors.d.ts +1 -45
  13. package/dist/errors.d.ts.map +1 -1
  14. package/dist/errors.js +1 -33
  15. package/dist/errors.js.map +1 -1
  16. package/dist/index.d.ts +16 -17
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +18 -15
  19. package/dist/index.js.map +1 -1
  20. package/dist/integrations/anthropic/types.d.ts +3 -22
  21. package/dist/integrations/anthropic/types.d.ts.map +1 -1
  22. package/dist/integrations/athena/client.d.ts +1 -1
  23. package/dist/integrations/athena/client.d.ts.map +1 -1
  24. package/dist/integrations/athena/client.js.map +1 -1
  25. package/dist/integrations/athena/types.d.ts +2 -2
  26. package/dist/integrations/athena/types.d.ts.map +1 -1
  27. package/dist/integrations/base/graphql-integration-client.d.ts +8 -4
  28. package/dist/integrations/base/graphql-integration-client.d.ts.map +1 -1
  29. package/dist/integrations/base/graphql-integration-client.js +18 -5
  30. package/dist/integrations/base/graphql-integration-client.js.map +1 -1
  31. package/dist/integrations/base/index.d.ts +3 -2
  32. package/dist/integrations/base/index.d.ts.map +1 -1
  33. package/dist/integrations/base/index.js +1 -0
  34. package/dist/integrations/base/index.js.map +1 -1
  35. package/dist/integrations/base/rest-api-client-base.d.ts +48 -0
  36. package/dist/integrations/base/rest-api-client-base.d.ts.map +1 -0
  37. package/dist/integrations/base/rest-api-client-base.js +98 -0
  38. package/dist/integrations/base/rest-api-client-base.js.map +1 -0
  39. package/dist/integrations/base/rest-api-integration-client.d.ts +11 -65
  40. package/dist/integrations/base/rest-api-integration-client.d.ts.map +1 -1
  41. package/dist/integrations/base/rest-api-integration-client.js +11 -174
  42. package/dist/integrations/base/rest-api-integration-client.js.map +1 -1
  43. package/dist/integrations/base/types.d.ts +1 -67
  44. package/dist/integrations/base/types.d.ts.map +1 -1
  45. package/dist/integrations/bigquery/client.d.ts +1 -1
  46. package/dist/integrations/bigquery/client.d.ts.map +1 -1
  47. package/dist/integrations/bigquery/client.js.map +1 -1
  48. package/dist/integrations/bigquery/types.d.ts +3 -3
  49. package/dist/integrations/bigquery/types.d.ts.map +1 -1
  50. package/dist/integrations/box/types.d.ts +1 -1
  51. package/dist/integrations/cockroachdb/client.d.ts +1 -1
  52. package/dist/integrations/cockroachdb/client.d.ts.map +1 -1
  53. package/dist/integrations/cockroachdb/client.js.map +1 -1
  54. package/dist/integrations/cockroachdb/types.d.ts.map +1 -1
  55. package/dist/integrations/cosmosdb/client.d.ts +1 -1
  56. package/dist/integrations/cosmosdb/client.d.ts.map +1 -1
  57. package/dist/integrations/cosmosdb/client.js.map +1 -1
  58. package/dist/integrations/cosmosdb/client.test.js.map +1 -1
  59. package/dist/integrations/cosmosdb/types.d.ts.map +1 -1
  60. package/dist/integrations/databricks/client.d.ts +1 -1
  61. package/dist/integrations/databricks/client.d.ts.map +1 -1
  62. package/dist/integrations/databricks/client.js.map +1 -1
  63. package/dist/integrations/databricks/types.d.ts +3 -3
  64. package/dist/integrations/databricks/types.d.ts.map +1 -1
  65. package/dist/integrations/declarations.d.ts +36 -104
  66. package/dist/integrations/declarations.d.ts.map +1 -1
  67. package/dist/integrations/declarations.js +5 -68
  68. package/dist/integrations/declarations.js.map +1 -1
  69. package/dist/integrations/declarations.test.js.map +1 -1
  70. package/dist/integrations/documentation-resolver.test.d.ts +2 -0
  71. package/dist/integrations/documentation-resolver.test.d.ts.map +1 -0
  72. package/dist/integrations/documentation-resolver.test.js +608 -0
  73. package/dist/integrations/documentation-resolver.test.js.map +1 -0
  74. package/dist/integrations/documentation.d.ts +8 -0
  75. package/dist/integrations/documentation.d.ts.map +1 -0
  76. package/dist/integrations/documentation.js +277 -0
  77. package/dist/integrations/documentation.js.map +1 -0
  78. package/dist/integrations/documentation.test.d.ts +2 -0
  79. package/dist/integrations/documentation.test.d.ts.map +1 -0
  80. package/dist/integrations/documentation.test.js +81 -0
  81. package/dist/integrations/documentation.test.js.map +1 -0
  82. package/dist/integrations/dynamodb/client.d.ts +1 -1
  83. package/dist/integrations/dynamodb/client.d.ts.map +1 -1
  84. package/dist/integrations/dynamodb/client.js.map +1 -1
  85. package/dist/integrations/dynamodb/types.d.ts.map +1 -1
  86. package/dist/integrations/gcs/client.d.ts +1 -1
  87. package/dist/integrations/gcs/client.d.ts.map +1 -1
  88. package/dist/integrations/gcs/client.js.map +1 -1
  89. package/dist/integrations/gcs/types.d.ts.map +1 -1
  90. package/dist/integrations/googledrive/types.d.ts +1 -1
  91. package/dist/integrations/graphql/client.test.d.ts +15 -0
  92. package/dist/integrations/graphql/client.test.d.ts.map +1 -0
  93. package/dist/integrations/graphql/client.test.js +148 -0
  94. package/dist/integrations/graphql/client.test.js.map +1 -0
  95. package/dist/integrations/graphql/types.d.ts +22 -3
  96. package/dist/integrations/graphql/types.d.ts.map +1 -1
  97. package/dist/integrations/gsheets/client.d.ts +1 -1
  98. package/dist/integrations/gsheets/client.d.ts.map +1 -1
  99. package/dist/integrations/gsheets/client.js.map +1 -1
  100. package/dist/integrations/gsheets/types.d.ts.map +1 -1
  101. package/dist/integrations/index.d.ts +2 -12
  102. package/dist/integrations/index.d.ts.map +1 -1
  103. package/dist/integrations/index.js +2 -8
  104. package/dist/integrations/index.js.map +1 -1
  105. package/dist/integrations/lakebase/client.d.ts +1 -1
  106. package/dist/integrations/lakebase/client.d.ts.map +1 -1
  107. package/dist/integrations/lakebase/client.js.map +1 -1
  108. package/dist/integrations/lakebase/types.d.ts +4 -4
  109. package/dist/integrations/lakebase/types.d.ts.map +1 -1
  110. package/dist/integrations/mariadb/client.d.ts +1 -1
  111. package/dist/integrations/mariadb/client.d.ts.map +1 -1
  112. package/dist/integrations/mariadb/client.js.map +1 -1
  113. package/dist/integrations/mariadb/types.d.ts +2 -2
  114. package/dist/integrations/mariadb/types.d.ts.map +1 -1
  115. package/dist/integrations/mongodb/client.d.ts +1 -1
  116. package/dist/integrations/mongodb/client.d.ts.map +1 -1
  117. package/dist/integrations/mongodb/client.js.map +1 -1
  118. package/dist/integrations/mongodb/types.d.ts.map +1 -1
  119. package/dist/integrations/mssql/client.d.ts +1 -1
  120. package/dist/integrations/mssql/client.d.ts.map +1 -1
  121. package/dist/integrations/mssql/client.js.map +1 -1
  122. package/dist/integrations/mssql/types.d.ts +2 -2
  123. package/dist/integrations/mssql/types.d.ts.map +1 -1
  124. package/dist/integrations/mysql/client.d.ts +1 -1
  125. package/dist/integrations/mysql/client.d.ts.map +1 -1
  126. package/dist/integrations/mysql/client.js.map +1 -1
  127. package/dist/integrations/mysql/types.d.ts +4 -4
  128. package/dist/integrations/mysql/types.d.ts.map +1 -1
  129. package/dist/integrations/openai_v2/types.d.ts +4 -22
  130. package/dist/integrations/openai_v2/types.d.ts.map +1 -1
  131. package/dist/integrations/oracledb/client.d.ts +1 -1
  132. package/dist/integrations/oracledb/client.d.ts.map +1 -1
  133. package/dist/integrations/oracledb/client.js.map +1 -1
  134. package/dist/integrations/oracledb/types.d.ts +2 -2
  135. package/dist/integrations/oracledb/types.d.ts.map +1 -1
  136. package/dist/integrations/postgres/client.d.ts +2 -2
  137. package/dist/integrations/postgres/client.d.ts.map +1 -1
  138. package/dist/integrations/postgres/client.js.map +1 -1
  139. package/dist/integrations/postgres/types.d.ts.map +1 -1
  140. package/dist/integrations/redshift/client.d.ts +1 -1
  141. package/dist/integrations/redshift/client.d.ts.map +1 -1
  142. package/dist/integrations/redshift/client.js.map +1 -1
  143. package/dist/integrations/redshift/types.d.ts.map +1 -1
  144. package/dist/integrations/registry.d.ts +6 -27
  145. package/dist/integrations/registry.d.ts.map +1 -1
  146. package/dist/integrations/registry.js +64 -88
  147. package/dist/integrations/registry.js.map +1 -1
  148. package/dist/integrations/registry.test.js +1 -3
  149. package/dist/integrations/registry.test.js.map +1 -1
  150. package/dist/integrations/restapiintegration/types.d.ts +2 -2
  151. package/dist/integrations/restapiintegration/types.d.ts.map +1 -1
  152. package/dist/integrations/s3/client.d.ts +1 -1
  153. package/dist/integrations/s3/client.d.ts.map +1 -1
  154. package/dist/integrations/s3/client.js.map +1 -1
  155. package/dist/integrations/s3/types.d.ts +3 -1
  156. package/dist/integrations/s3/types.d.ts.map +1 -1
  157. package/dist/integrations/salesforce/client.d.ts +1 -1
  158. package/dist/integrations/salesforce/client.d.ts.map +1 -1
  159. package/dist/integrations/salesforce/client.js.map +1 -1
  160. package/dist/integrations/salesforce/types.d.ts.map +1 -1
  161. package/dist/integrations/slack/client.d.ts +13 -9
  162. package/dist/integrations/slack/client.d.ts.map +1 -1
  163. package/dist/integrations/slack/client.js +60 -8
  164. package/dist/integrations/slack/client.js.map +1 -1
  165. package/dist/integrations/slack/client.test.d.ts +11 -0
  166. package/dist/integrations/slack/client.test.d.ts.map +1 -0
  167. package/dist/integrations/slack/client.test.js +368 -0
  168. package/dist/integrations/slack/client.test.js.map +1 -0
  169. package/dist/integrations/slack/index.d.ts +2 -1
  170. package/dist/integrations/slack/index.d.ts.map +1 -1
  171. package/dist/integrations/slack/index.js +1 -0
  172. package/dist/integrations/slack/index.js.map +1 -1
  173. package/dist/integrations/slack/types.d.ts +127 -28
  174. package/dist/integrations/slack/types.d.ts.map +1 -1
  175. package/dist/integrations/slack/types.js +27 -1
  176. package/dist/integrations/slack/types.js.map +1 -1
  177. package/dist/integrations/smtp/client.d.ts +1 -1
  178. package/dist/integrations/smtp/client.d.ts.map +1 -1
  179. package/dist/integrations/smtp/client.js.map +1 -1
  180. package/dist/integrations/snowflake/client.d.ts +3 -3
  181. package/dist/integrations/snowflake/client.d.ts.map +1 -1
  182. package/dist/integrations/snowflake/client.js +2 -2
  183. package/dist/integrations/snowflake/client.js.map +1 -1
  184. package/dist/integrations/snowflake/types.d.ts.map +1 -1
  185. package/dist/integrations/snowflakecortex/client.d.ts +1 -2
  186. package/dist/integrations/snowflakecortex/client.d.ts.map +1 -1
  187. package/dist/integrations/snowflakecortex/client.js +1 -2
  188. package/dist/integrations/snowflakecortex/client.js.map +1 -1
  189. package/dist/integrations/snowflakecortex/types.d.ts +3 -4
  190. package/dist/integrations/snowflakecortex/types.d.ts.map +1 -1
  191. package/dist/integrations/snowflakepostgres/client.d.ts +1 -1
  192. package/dist/integrations/snowflakepostgres/client.d.ts.map +1 -1
  193. package/dist/integrations/snowflakepostgres/client.js.map +1 -1
  194. package/dist/integrations/snowflakepostgres/types.d.ts.map +1 -1
  195. package/dist/runtime/context.d.ts +3 -3
  196. package/dist/runtime/context.d.ts.map +1 -1
  197. package/dist/runtime/context.js.map +1 -1
  198. package/dist/runtime/executor.d.ts +2 -2
  199. package/dist/runtime/index.d.ts +0 -3
  200. package/dist/runtime/index.d.ts.map +1 -1
  201. package/dist/runtime/index.js +1 -6
  202. package/dist/runtime/index.js.map +1 -1
  203. package/dist/types.d.ts +15 -6
  204. package/dist/types.d.ts.map +1 -1
  205. package/package.json +2 -2
  206. package/src/api/definition.test.ts +41 -15
  207. package/src/api/definition.ts +20 -13
  208. package/src/api/index.ts +0 -4
  209. package/src/errors.ts +1 -49
  210. package/src/index.ts +20 -61
  211. package/src/integrations/airtable/docs.manifest.json +5 -0
  212. package/src/integrations/anthropic/README.md +5 -101
  213. package/src/integrations/anthropic/docs.manifest.json +5 -0
  214. package/src/integrations/anthropic/types.ts +3 -29
  215. package/src/integrations/asana/README.md +12 -12
  216. package/src/integrations/asana/docs.manifest.json +5 -0
  217. package/src/integrations/athena/README.md +4 -4
  218. package/src/integrations/athena/client.ts +5 -3
  219. package/src/integrations/athena/docs.manifest.json +5 -0
  220. package/src/integrations/athena/types.ts +3 -2
  221. package/src/integrations/base/graphql-integration-client.ts +27 -5
  222. package/src/integrations/base/index.ts +2 -3
  223. package/src/integrations/base/rest-api-client-base.ts +134 -0
  224. package/src/integrations/base/rest-api-integration-client.ts +15 -239
  225. package/src/integrations/base/types.ts +4 -74
  226. package/src/integrations/bigquery/README.md +28 -3
  227. package/src/integrations/bigquery/client.ts +5 -3
  228. package/src/integrations/bigquery/docs.manifest.json +5 -0
  229. package/src/integrations/bigquery/types.ts +4 -3
  230. package/src/integrations/bitbucket/README.md +19 -19
  231. package/src/integrations/bitbucket/docs.manifest.json +5 -0
  232. package/src/integrations/box/README.md +24 -24
  233. package/src/integrations/box/docs.manifest.json +5 -0
  234. package/src/integrations/box/types.ts +1 -1
  235. package/src/integrations/circleci/README.md +18 -18
  236. package/src/integrations/circleci/docs.manifest.json +5 -0
  237. package/src/integrations/cockroachdb/client.ts +5 -3
  238. package/src/integrations/cockroachdb/docs.manifest.json +5 -0
  239. package/src/integrations/cockroachdb/types.ts +1 -0
  240. package/src/integrations/cohere/README.md +11 -11
  241. package/src/integrations/cohere/docs.manifest.json +5 -0
  242. package/src/integrations/confluence/docs.manifest.json +5 -0
  243. package/src/integrations/cosmosdb/client.test.ts +2 -1
  244. package/src/integrations/cosmosdb/client.ts +5 -3
  245. package/src/integrations/cosmosdb/docs.manifest.json +5 -0
  246. package/src/integrations/cosmosdb/types.ts +1 -0
  247. package/src/integrations/databricks/README.md +29 -4
  248. package/src/integrations/databricks/client.ts +5 -3
  249. package/src/integrations/databricks/docs.manifest.json +5 -0
  250. package/src/integrations/databricks/types.ts +4 -3
  251. package/src/integrations/datadog/docs.manifest.json +5 -0
  252. package/src/integrations/declarations.test.ts +1 -0
  253. package/src/integrations/declarations.ts +36 -136
  254. package/src/integrations/documentation-resolver.test.ts +704 -0
  255. package/src/integrations/documentation.test.ts +120 -0
  256. package/src/integrations/documentation.ts +421 -0
  257. package/src/integrations/dropbox/docs.manifest.json +5 -0
  258. package/src/integrations/dynamodb/client.ts +3 -2
  259. package/src/integrations/dynamodb/docs.manifest.json +5 -0
  260. package/src/integrations/dynamodb/types.ts +1 -0
  261. package/src/integrations/elasticsearch/docs.manifest.json +5 -0
  262. package/src/integrations/fireworks/README.md +43 -17
  263. package/src/integrations/fireworks/docs.manifest.json +5 -0
  264. package/src/integrations/front/docs.manifest.json +5 -0
  265. package/src/integrations/gcs/client.ts +5 -3
  266. package/src/integrations/gcs/docs.manifest.json +5 -0
  267. package/src/integrations/gcs/types.ts +1 -0
  268. package/src/integrations/gemini/docs.manifest.json +5 -0
  269. package/src/integrations/github/docs.manifest.json +5 -0
  270. package/src/integrations/googleanalytics/README.md +2 -2
  271. package/src/integrations/googleanalytics/docs.manifest.json +5 -0
  272. package/src/integrations/googledrive/README.md +27 -24
  273. package/src/integrations/googledrive/docs.manifest.json +5 -0
  274. package/src/integrations/googledrive/types.ts +1 -1
  275. package/src/integrations/graphql/README.md +2 -2
  276. package/src/integrations/graphql/client.test.ts +220 -0
  277. package/src/integrations/graphql/docs.manifest.json +5 -0
  278. package/src/integrations/graphql/types.ts +23 -1
  279. package/src/integrations/groq/README.md +49 -42
  280. package/src/integrations/groq/docs.manifest.json +5 -0
  281. package/src/integrations/gsheets/README.md +2 -2
  282. package/src/integrations/gsheets/client.ts +5 -3
  283. package/src/integrations/gsheets/docs.manifest.json +5 -0
  284. package/src/integrations/gsheets/types.ts +1 -0
  285. package/src/integrations/hubspot/docs.manifest.json +5 -0
  286. package/src/integrations/index.ts +1 -52
  287. package/src/integrations/intercom/docs.manifest.json +5 -0
  288. package/src/integrations/jira/docs.manifest.json +5 -0
  289. package/src/integrations/lakebase/README.md +242 -0
  290. package/src/integrations/lakebase/client.ts +6 -4
  291. package/src/integrations/lakebase/docs.manifest.json +5 -0
  292. package/src/integrations/lakebase/types.ts +5 -4
  293. package/src/integrations/launchdarkly/README.md +2 -2
  294. package/src/integrations/launchdarkly/docs.manifest.json +5 -0
  295. package/src/integrations/mariadb/README.md +3 -3
  296. package/src/integrations/mariadb/client.ts +5 -3
  297. package/src/integrations/mariadb/docs.manifest.json +5 -0
  298. package/src/integrations/mariadb/types.ts +3 -2
  299. package/src/integrations/mistral/README.md +39 -13
  300. package/src/integrations/mistral/docs.manifest.json +5 -0
  301. package/src/integrations/mongodb/README.md +65 -12
  302. package/src/integrations/mongodb/client.ts +5 -3
  303. package/src/integrations/mongodb/docs.manifest.json +5 -0
  304. package/src/integrations/mongodb/types.ts +1 -0
  305. package/src/integrations/mssql/README.md +3 -3
  306. package/src/integrations/mssql/client.ts +5 -3
  307. package/src/integrations/mssql/docs.manifest.json +5 -0
  308. package/src/integrations/mssql/types.ts +3 -2
  309. package/src/integrations/mysql/README.md +4 -4
  310. package/src/integrations/mysql/client.ts +5 -3
  311. package/src/integrations/mysql/docs.manifest.json +5 -0
  312. package/src/integrations/mysql/types.ts +5 -4
  313. package/src/integrations/notion/docs.manifest.json +5 -0
  314. package/src/integrations/openai_v2/README.md +44 -116
  315. package/src/integrations/openai_v2/docs.manifest.json +5 -0
  316. package/src/integrations/openai_v2/types.ts +4 -29
  317. package/src/integrations/oracledb/README.md +3 -3
  318. package/src/integrations/oracledb/client.ts +5 -3
  319. package/src/integrations/oracledb/docs.manifest.json +5 -0
  320. package/src/integrations/oracledb/types.ts +3 -2
  321. package/src/integrations/pagerduty/README.md +2 -2
  322. package/src/integrations/pagerduty/docs.manifest.json +5 -0
  323. package/src/integrations/perplexity/README.md +39 -47
  324. package/src/integrations/perplexity/docs.manifest.json +5 -0
  325. package/src/integrations/postgres/client.ts +6 -4
  326. package/src/integrations/postgres/docs.manifest.json +5 -0
  327. package/src/integrations/postgres/types.ts +1 -0
  328. package/src/integrations/redshift/client.ts +5 -3
  329. package/src/integrations/redshift/docs.manifest.json +5 -0
  330. package/src/integrations/redshift/types.ts +1 -0
  331. package/src/integrations/registry.test.ts +2 -3
  332. package/src/integrations/registry.ts +69 -188
  333. package/src/integrations/restapiintegration/README.md +320 -0
  334. package/src/integrations/restapiintegration/docs.manifest.json +5 -0
  335. package/src/integrations/restapiintegration/types.ts +2 -8
  336. package/src/integrations/s3/client.ts +5 -3
  337. package/src/integrations/s3/docs.manifest.json +5 -0
  338. package/src/integrations/s3/types.ts +4 -1
  339. package/src/integrations/salesforce/README.md +11 -9
  340. package/src/integrations/salesforce/client.ts +3 -2
  341. package/src/integrations/salesforce/docs.manifest.json +5 -0
  342. package/src/integrations/salesforce/types.ts +1 -0
  343. package/src/integrations/segment/docs.manifest.json +5 -0
  344. package/src/integrations/sendgrid/README.md +2 -2
  345. package/src/integrations/sendgrid/docs.manifest.json +5 -0
  346. package/src/integrations/slack/README.md +62 -19
  347. package/src/integrations/slack/client.test.ts +553 -0
  348. package/src/integrations/slack/client.ts +92 -12
  349. package/src/integrations/slack/docs.manifest.json +5 -0
  350. package/src/integrations/slack/index.ts +6 -1
  351. package/src/integrations/slack/types.ts +142 -29
  352. package/src/integrations/smtp/README.md +220 -0
  353. package/src/integrations/smtp/client.ts +4 -2
  354. package/src/integrations/smtp/docs.manifest.json +5 -0
  355. package/src/integrations/snowflake/client.ts +7 -5
  356. package/src/integrations/snowflake/docs.manifest.json +5 -0
  357. package/src/integrations/snowflake/types.ts +1 -0
  358. package/src/integrations/snowflakecortex/README.md +167 -0
  359. package/src/integrations/snowflakecortex/client.ts +2 -3
  360. package/src/integrations/snowflakecortex/docs.manifest.json +5 -0
  361. package/src/integrations/snowflakecortex/types.ts +3 -11
  362. package/src/integrations/snowflakepostgres/README.md +233 -0
  363. package/src/integrations/snowflakepostgres/client.ts +1 -1
  364. package/src/integrations/snowflakepostgres/docs.manifest.json +5 -0
  365. package/src/integrations/snowflakepostgres/types.ts +1 -0
  366. package/src/integrations/stabilityai/README.md +2 -2
  367. package/src/integrations/stabilityai/docs.manifest.json +5 -0
  368. package/src/integrations/stripe/docs.manifest.json +5 -0
  369. package/src/integrations/superblocks-ocr/docs.manifest.json +5 -0
  370. package/src/integrations/twilio/docs.manifest.json +5 -0
  371. package/src/integrations/zendesk/docs.manifest.json +5 -0
  372. package/src/integrations/zoom/README.md +15 -15
  373. package/src/integrations/zoom/docs.manifest.json +5 -0
  374. package/src/runtime/context.ts +11 -11
  375. package/src/runtime/executor.ts +2 -2
  376. package/src/runtime/index.ts +1 -23
  377. package/src/types.ts +16 -6
  378. package/dist/api/streaming.d.ts +0 -229
  379. package/dist/api/streaming.d.ts.map +0 -1
  380. package/dist/api/streaming.js +0 -107
  381. package/dist/api/streaming.js.map +0 -1
  382. package/dist/api/streaming.test.d.ts +0 -5
  383. package/dist/api/streaming.test.d.ts.map +0 -1
  384. package/dist/api/streaming.test.js +0 -364
  385. package/dist/api/streaming.test.js.map +0 -1
  386. package/dist/integrations/couchbase/client.d.ts +0 -30
  387. package/dist/integrations/couchbase/client.d.ts.map +0 -1
  388. package/dist/integrations/couchbase/client.js +0 -154
  389. package/dist/integrations/couchbase/client.js.map +0 -1
  390. package/dist/integrations/couchbase/index.d.ts +0 -8
  391. package/dist/integrations/couchbase/index.d.ts.map +0 -1
  392. package/dist/integrations/couchbase/index.js +0 -7
  393. package/dist/integrations/couchbase/index.js.map +0 -1
  394. package/dist/integrations/couchbase/types.d.ts +0 -100
  395. package/dist/integrations/couchbase/types.d.ts.map +0 -1
  396. package/dist/integrations/couchbase/types.js +0 -5
  397. package/dist/integrations/couchbase/types.js.map +0 -1
  398. package/dist/integrations/kafka/client.d.ts +0 -25
  399. package/dist/integrations/kafka/client.d.ts.map +0 -1
  400. package/dist/integrations/kafka/client.js +0 -124
  401. package/dist/integrations/kafka/client.js.map +0 -1
  402. package/dist/integrations/kafka/index.d.ts +0 -8
  403. package/dist/integrations/kafka/index.d.ts.map +0 -1
  404. package/dist/integrations/kafka/index.js +0 -7
  405. package/dist/integrations/kafka/index.js.map +0 -1
  406. package/dist/integrations/kafka/types.d.ts +0 -113
  407. package/dist/integrations/kafka/types.d.ts.map +0 -1
  408. package/dist/integrations/kafka/types.js +0 -5
  409. package/dist/integrations/kafka/types.js.map +0 -1
  410. package/dist/integrations/kinesis/client.d.ts +0 -31
  411. package/dist/integrations/kinesis/client.d.ts.map +0 -1
  412. package/dist/integrations/kinesis/client.js +0 -101
  413. package/dist/integrations/kinesis/client.js.map +0 -1
  414. package/dist/integrations/kinesis/index.d.ts +0 -8
  415. package/dist/integrations/kinesis/index.d.ts.map +0 -1
  416. package/dist/integrations/kinesis/index.js +0 -7
  417. package/dist/integrations/kinesis/index.js.map +0 -1
  418. package/dist/integrations/kinesis/types.d.ts +0 -97
  419. package/dist/integrations/kinesis/types.d.ts.map +0 -1
  420. package/dist/integrations/kinesis/types.js +0 -7
  421. package/dist/integrations/kinesis/types.js.map +0 -1
  422. package/dist/integrations/python/client.d.ts +0 -42
  423. package/dist/integrations/python/client.d.ts.map +0 -1
  424. package/dist/integrations/python/client.js +0 -89
  425. package/dist/integrations/python/client.js.map +0 -1
  426. package/dist/integrations/python/client.test.d.ts +0 -5
  427. package/dist/integrations/python/client.test.d.ts.map +0 -1
  428. package/dist/integrations/python/client.test.js +0 -214
  429. package/dist/integrations/python/client.test.js.map +0 -1
  430. package/dist/integrations/python/index.d.ts +0 -6
  431. package/dist/integrations/python/index.d.ts.map +0 -1
  432. package/dist/integrations/python/index.js +0 -5
  433. package/dist/integrations/python/index.js.map +0 -1
  434. package/dist/integrations/python/types.d.ts +0 -85
  435. package/dist/integrations/python/types.d.ts.map +0 -1
  436. package/dist/integrations/python/types.js +0 -5
  437. package/dist/integrations/python/types.js.map +0 -1
  438. package/dist/integrations/redis/client.d.ts +0 -43
  439. package/dist/integrations/redis/client.d.ts.map +0 -1
  440. package/dist/integrations/redis/client.js +0 -142
  441. package/dist/integrations/redis/client.js.map +0 -1
  442. package/dist/integrations/redis/index.d.ts +0 -8
  443. package/dist/integrations/redis/index.d.ts.map +0 -1
  444. package/dist/integrations/redis/index.js +0 -7
  445. package/dist/integrations/redis/index.js.map +0 -1
  446. package/dist/integrations/redis/types.d.ts +0 -137
  447. package/dist/integrations/redis/types.d.ts.map +0 -1
  448. package/dist/integrations/redis/types.js +0 -5
  449. package/dist/integrations/redis/types.js.map +0 -1
  450. package/dist/runtime/execute.d.ts +0 -128
  451. package/dist/runtime/execute.d.ts.map +0 -1
  452. package/dist/runtime/execute.js +0 -84
  453. package/dist/runtime/execute.js.map +0 -1
  454. package/dist/runtime/streaming-context.d.ts +0 -49
  455. package/dist/runtime/streaming-context.d.ts.map +0 -1
  456. package/dist/runtime/streaming-context.js +0 -71
  457. package/dist/runtime/streaming-context.js.map +0 -1
  458. package/dist/runtime/streaming-executor.d.ts +0 -159
  459. package/dist/runtime/streaming-executor.d.ts.map +0 -1
  460. package/dist/runtime/streaming-executor.js +0 -229
  461. package/dist/runtime/streaming-executor.js.map +0 -1
  462. package/src/api/streaming.test.ts +0 -432
  463. package/src/api/streaming.ts +0 -302
  464. package/src/integrations/couchbase/README.md +0 -138
  465. package/src/integrations/couchbase/client.ts +0 -237
  466. package/src/integrations/couchbase/index.ts +0 -8
  467. package/src/integrations/couchbase/types.ts +0 -125
  468. package/src/integrations/kafka/README.md +0 -144
  469. package/src/integrations/kafka/client.ts +0 -215
  470. package/src/integrations/kafka/index.ts +0 -14
  471. package/src/integrations/kafka/types.ts +0 -127
  472. package/src/integrations/kinesis/README.md +0 -153
  473. package/src/integrations/kinesis/client.ts +0 -146
  474. package/src/integrations/kinesis/index.ts +0 -14
  475. package/src/integrations/kinesis/types.ts +0 -114
  476. package/src/integrations/python/README.md +0 -566
  477. package/src/integrations/python/client.test.ts +0 -340
  478. package/src/integrations/python/client.ts +0 -134
  479. package/src/integrations/python/index.ts +0 -6
  480. package/src/integrations/python/types.ts +0 -91
  481. package/src/integrations/redis/README.md +0 -200
  482. package/src/integrations/redis/client.ts +0 -207
  483. package/src/integrations/redis/index.ts +0 -8
  484. package/src/integrations/redis/types.ts +0 -166
  485. package/src/runtime/execute.ts +0 -221
  486. package/src/runtime/streaming-context.ts +0 -164
  487. package/src/runtime/streaming-executor.ts +0 -367
package/README.md CHANGED
@@ -83,12 +83,12 @@ type Output = z.infer<typeof myApi.outputSchema>; // { users: { id: string }[] }
83
83
 
84
84
  ### How APIs are Executed
85
85
 
86
- The `execute()` function runs a compiled API with the required inputs:
86
+ The `executeApi()` function runs a compiled API with the required inputs:
87
87
 
88
88
  ```typescript
89
- import { execute } from '@superblocksteam/sdk-api';
89
+ import { executeApi } from '@superblocksteam/sdk-api';
90
90
 
91
- const response = await execute(myApi, {
91
+ const response = await executeApi(myApi, {
92
92
  // Raw input data (will be validated against inputSchema)
93
93
  input: { limit: 10 },
94
94
 
@@ -158,33 +158,12 @@ This architecture means:
158
158
  - **Authentication is centralized** - The runtime handles all credentials
159
159
  - **Operations are auditable** - The runtime can log/trace all operations
160
160
 
161
- #### `executeStreamingQuery` Callback
162
-
163
- For streaming APIs (e.g., LLM token streaming), there's an additional callback:
164
-
165
- ```typescript
166
- // Inside AnthropicClient.streamApiRequest():
167
- const stream = executeStreamingQuery(
168
- 'prod-anthropic-id',
169
- {
170
- method: 'POST',
171
- path: '/v1/messages',
172
- body: { model: 'claude-3-5-sonnet', stream: true, messages: [...] }
173
- }
174
- );
175
-
176
- // Returns AsyncIterable<unknown> - each chunk is validated against the chunk schema
177
- for await (const chunk of stream) {
178
- yield transformChunk(chunk);
179
- }
180
- ```
181
-
182
161
  ### Execution Request Interface
183
162
 
184
- The complete request interface for `execute()`:
163
+ The complete request interface for `executeApi()`:
185
164
 
186
165
  ```typescript
187
- interface UnifiedExecuteApiRequest {
166
+ interface ExecuteApiRequest {
188
167
  /** Raw input data to be validated */
189
168
  input: unknown;
190
169
 
@@ -204,23 +183,14 @@ interface UnifiedExecuteApiRequest {
204
183
  executeQuery: (
205
184
  integrationId: string,
206
185
  request: Record<string, unknown>, // Plugin-specific request matching protobuf schema
207
- bindings?: Record<string, unknown>, // For language plugins (Python/JavaScript)
186
+ bindings?: Record<string, unknown>, // For language plugins (JavaScript)
208
187
  ) => Promise<unknown>;
209
-
210
- /**
211
- * Callback for streaming operations (optional).
212
- * Only needed for streaming APIs that use streaming integrations.
213
- */
214
- executeStreamingQuery?: (
215
- integrationId: string,
216
- request: Record<string, unknown>,
217
- ) => AsyncIterable<unknown>;
218
188
  }
219
189
  ```
220
190
 
221
191
  ### Execution Response
222
192
 
223
- Regular APIs return a discriminated union:
193
+ `executeApi()` returns a discriminated union:
224
194
 
225
195
  ```typescript
226
196
  type ExecuteApiResponse<TOutput> =
@@ -231,17 +201,6 @@ type ExecuteApiResponse<TOutput> =
231
201
  };
232
202
  ```
233
203
 
234
- Streaming APIs return an `AsyncGenerator`:
235
-
236
- ```typescript
237
- const stream: AsyncGenerator<TChunk> = execute(streamingApi, request);
238
-
239
- for await (const chunk of stream) {
240
- // Each chunk is validated against the chunk schema
241
- console.log(chunk);
242
- }
243
- ```
244
-
245
204
  ### Integration Configuration
246
205
 
247
206
  Each integration in the `integrations` array has this structure:
@@ -317,23 +276,58 @@ export default api({
317
276
  });
318
277
  ```
319
278
 
279
+ ### Export style (default vs named exports)
280
+
281
+ **Default export** — one API per file. **Named exports** — several `api({ ... })` values in one module; import them by name into `server/apis/index.ts`. `useApi("X")` matches the **key** on the registry object; align `api({ name: "X" })` with that when practical.
282
+
283
+ ```typescript
284
+ // server/apis/users/pair.ts
285
+ import { api, z } from "@superblocksteam/sdk-api";
286
+
287
+ export const ListProfiles = api({
288
+ name: "ListProfiles",
289
+ input: z.object({ orgId: z.string() }),
290
+ output: z.object({ profiles: z.array(z.object({ id: z.string() })) }),
291
+ async run() {
292
+ return { profiles: [] };
293
+ },
294
+ });
295
+
296
+ export const UpdateProfile = api({
297
+ name: "UpdateProfile",
298
+ input: z.object({ userId: z.string() }),
299
+ output: z.object({ ok: z.literal(true) }),
300
+ async run() {
301
+ return { ok: true as const };
302
+ },
303
+ });
304
+ ```
305
+
306
+ ```typescript
307
+ // server/apis/index.ts
308
+ import { ListProfiles, UpdateProfile } from "./users/pair.js";
309
+
310
+ const apis = { ListProfiles, UpdateProfile } as const;
311
+ export default apis;
312
+ export type ApiRegistry = typeof apis;
313
+ ```
314
+
320
315
  ## API Reference
321
316
 
322
317
  ### `api(config)`
323
318
 
324
319
  Defines a TypeScript-based API with input/output validation. Returns a complete result when the `run` function completes.
325
320
 
326
- For streaming responses (e.g., LLM token streaming), see [`streamingApi()`](#streamingapiconfig) below.
327
-
328
321
  #### Required Fields
329
322
 
330
- | Field | Type | Description |
331
- | -------------- | --------------------------------- | ---------------------------------------------- |
332
- | `name` | `string` | **Required.** Unique identifier for the API |
333
- | `input` | `z.ZodType` | **Required.** Zod schema for input validation |
334
- | `output` | `z.ZodType` | **Required.** Zod schema for output validation |
335
- | `run` | `(ctx, input) => Promise<Output>` | **Required.** The implementation function |
336
- | `integrations` | `Record<string, IntegrationRef>` | Optional. Integration declarations for the API |
323
+ | Field | Type | Description |
324
+ | -------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
325
+ | `name` | `string` | **Required.** Unique identifier for the API |
326
+ | `description` | `string` | Optional. Plain-language summary of what this API does and which integrations it uses. Auto-generated by the AI agent when creating or editing an API. |
327
+ | `input` | `z.ZodType` | **Required.** Zod schema for input validation |
328
+ | `output` | `z.ZodType` | **Required.** Zod schema for output validation |
329
+ | `run` | `(ctx, input) => Promise<Output>` | **Required.** The implementation function |
330
+ | `integrations` | `Record<string, IntegrationRef>` | Optional. Integration declarations for the API |
337
331
 
338
332
  ```typescript
339
333
  import { api, z } from "@superblocksteam/sdk-api";
@@ -364,87 +358,11 @@ const myApi = api({
364
358
  });
365
359
  ```
366
360
 
367
- ### `streamingApi(config)`
368
-
369
- Defines a streaming API that yields chunks as they're generated. Ideal for LLM token streaming, real-time data feeds, and progressive responses.
370
-
371
- ```typescript
372
- import { streamingApi, z, anthropic } from "@superblocksteam/sdk-api";
373
-
374
- // Integration ID from the integrations panel
375
- const PROD_ANTHROPIC = "e5f6g7h8-1234-56ab-cdef-ghijklmnopqr";
376
-
377
- // Define the schema for each streamed chunk
378
- const TextChunkSchema = z.object({
379
- type: z.literal("text"),
380
- text: z.string(),
381
- });
382
-
383
- export default streamingApi({
384
- name: "StreamChatResponse",
385
-
386
- integrations: {
387
- ai: anthropic(PROD_ANTHROPIC),
388
- },
389
-
390
- input: z.object({
391
- prompt: z.string(),
392
- }),
393
-
394
- // Schema for each yielded chunk (not the final output)
395
- chunk: TextChunkSchema,
396
-
397
- // Generator function that yields chunks
398
- async *run(ctx, { prompt }) {
399
- // Use streamApiRequest for streaming HTTP responses
400
- const stream = ctx.integrations.ai.streamApiRequest(
401
- {
402
- method: "POST",
403
- path: "/v1/messages",
404
- body: {
405
- model: "claude-3-5-sonnet-20241022",
406
- max_tokens: 1024,
407
- stream: true, // Enable streaming
408
- messages: [{ role: "user", content: prompt }],
409
- },
410
- },
411
- { chunk: AnthropicStreamEventSchema },
412
- );
413
-
414
- // Process and yield each chunk
415
- for await (const event of stream) {
416
- if (
417
- event.type === "content_block_delta" &&
418
- event.delta?.type === "text_delta"
419
- ) {
420
- yield { type: "text" as const, text: event.delta.text };
421
- }
422
- }
423
- },
424
- });
425
- ```
426
-
427
- #### Streaming API Configuration
428
-
429
- | Property | Type | Description |
430
- | -------------- | ------------------------------------------ | ----------------------------------------------- |
431
- | `integrations` | `Record<string, IntegrationRef>` | Integration declarations (same as `api()`) |
432
- | `input` | `z.ZodType` | Zod schema for input validation |
433
- | `chunk` | `z.ZodType` | Zod schema for each yielded chunk |
434
- | `run` | `(ctx, input) => AsyncIterable<ChunkType>` | Generator function that yields validated chunks |
435
-
436
- #### Key Differences from `api()`
437
-
438
- - Uses `chunk` schema instead of `output` schema
439
- - The `run` function is a generator (`async *run`) that uses `yield`
440
- - Each yielded value is validated against the `chunk` schema
441
- - No final return value - all data is streamed via `yield`
442
-
443
361
  ### Context (`ctx`) and Input
444
362
 
445
363
  The `run` function receives two arguments:
446
364
 
447
- 1. **`ctx`** - Context object with integrations, logging, and environment
365
+ 1. **`ctx`** - Context object with integrations, logging, environment, and user information
448
366
  2. **`input`** - Typed, validated input data matching your input schema
449
367
 
450
368
  ```typescript
@@ -459,7 +377,7 @@ async run(ctx, { userId, options }) {
459
377
  Access typed integration clients via the **name (key)** you declared in the API config: `ctx.integrations.<name>`. For example, if you declared `integrations: { db: postgres(...), notifier: slack(...) }`, use `ctx.integrations.db` and `ctx.integrations.notifier` in your `run` function. Integrations must be declared upfront to enable type-safe access and pre-authentication.
460
378
 
461
379
  ```typescript
462
- import { api, z, postgres, slack, openai, anthropic, stripe, github, notion, python } from "@superblocksteam/sdk-api";
380
+ import { api, z, postgres, slack, openai, anthropic, stripe, github, notion } from "@superblocksteam/sdk-api";
463
381
 
464
382
  // Integration IDs from the integrations panel - store in constants
465
383
  const PROD_POSTGRES = "a1b2c3d4-5678-90ab-cdef-ghijklmnopqr";
@@ -469,7 +387,6 @@ const PROD_ANTHROPIC = "d4e5f6g7-8901-23ab-cdef-ghijklmnopqr";
469
387
  const PROD_STRIPE = "e5f6g7h8-9012-34ab-cdef-ghijklmnopqr";
470
388
  const PROD_GITHUB = "f6g7h8i9-0123-45ab-cdef-ghijklmnopqr";
471
389
  const PROD_NOTION = "g7h8i9j0-1234-56ab-cdef-ghijklmnopqr";
472
- const PYTHON_RUNTIME = "h8i9j0k1-2345-67ab-cdef-ghijklmnopqr";
473
390
 
474
391
  export default api({
475
392
  name: "ProcessUserWorkflow",
@@ -494,9 +411,6 @@ export default api({
494
411
 
495
412
  // Productivity
496
413
  wiki: notion(PROD_NOTION),
497
-
498
- // Code Execution
499
- runtime: python(PYTHON_RUNTIME),
500
414
  },
501
415
 
502
416
  input: z.object({ userId: z.string() }),
@@ -513,6 +427,22 @@ export default api({
513
427
  });
514
428
  ```
515
429
 
430
+ #### `ctx.user`
431
+
432
+ Access the current user's identity (from the Superblocks JWT). This is the server-side equivalent of the `Global` object available in the frontend.
433
+
434
+ ```typescript
435
+ async run(ctx, input) {
436
+ const userId = ctx.user.userId;
437
+ const email = ctx.user.email; // may be undefined
438
+ const name = ctx.user.name; // may be undefined
439
+ const groups = ctx.user.groups; // readonly string[]
440
+ const claims = ctx.user.customClaims; // custom JWT claims
441
+
442
+ ctx.log.info('Request from user', { userId, email });
443
+ }
444
+ ```
445
+
516
446
  #### `ctx.log`
517
447
 
518
448
  Structured logging utilities.
@@ -526,55 +456,253 @@ async run(ctx, { userId }) {
526
456
  }
527
457
  ```
528
458
 
459
+ #### `ctx.env`
460
+
461
+ Access environment variables configured for the application.
462
+
463
+ ```typescript
464
+ async run(ctx) {
465
+ const apiKey = ctx.env.EXTERNAL_API_KEY;
466
+ if (!apiKey) {
467
+ throw new Error("EXTERNAL_API_KEY environment variable is not configured");
468
+ }
469
+ const environment = ctx.env.NODE_ENV;
470
+ }
471
+ ```
472
+
473
+ #### `ctx.user`
474
+
475
+ User information extracted from the Superblocks JWT. This is the **secure, server-side** way to access the current user's identity in API implementations. Never pass user information from the frontend as API input — always use `ctx.user` instead.
476
+
477
+ ```typescript
478
+ interface ApiUser {
479
+ /** Unique user identifier from JWT */
480
+ readonly userId: string;
481
+
482
+ /** User's email address (if available) */
483
+ readonly email?: string;
484
+
485
+ /** User's display name (if available) */
486
+ readonly name?: string;
487
+
488
+ /** User's group memberships from JWT */
489
+ readonly groups: readonly string[];
490
+
491
+ /** Custom claims from JWT */
492
+ readonly customClaims: Readonly<Record<string, unknown>>;
493
+ }
494
+ ```
495
+
496
+ ##### Basic Usage
497
+
498
+ ```typescript
499
+ import { api, z, postgres } from "@superblocksteam/sdk-api";
500
+
501
+ const PROD_POSTGRES = "a1b2c3d4-5678-90ab-cdef-ghijklmnopqr";
502
+
503
+ export default api({
504
+ name: "GetMyProfile",
505
+ integrations: { db: postgres(PROD_POSTGRES) },
506
+ input: z.object({}),
507
+ output: z.object({
508
+ email: z.string(),
509
+ name: z.string(),
510
+ }),
511
+
512
+ async run(ctx) {
513
+ // Access user identity securely from the JWT — no frontend input needed
514
+ ctx.log.info("Fetching profile", { userId: ctx.user.userId });
515
+
516
+ const rows = await ctx.integrations.db.query(
517
+ "SELECT email, display_name FROM users WHERE id = $1",
518
+ z.object({ email: z.string(), display_name: z.string() }),
519
+ [ctx.user.userId],
520
+ );
521
+
522
+ if (rows.length === 0) {
523
+ throw new Error("User not found");
524
+ }
525
+
526
+ return { email: rows[0].email, name: rows[0].display_name };
527
+ },
528
+ });
529
+ ```
530
+
531
+ ##### Role-Based Access Control with Groups
532
+
533
+ Use `ctx.user.groups` to restrict API access based on the user's group memberships. Groups are populated from the user's identity provider (e.g., Okta, Azure AD) via the JWT.
534
+
535
+ ```typescript
536
+ import { api, z, postgres } from "@superblocksteam/sdk-api";
537
+
538
+ const PROD_POSTGRES = "a1b2c3d4-5678-90ab-cdef-ghijklmnopqr";
539
+
540
+ export default api({
541
+ name: "GetAdminDashboard",
542
+ integrations: { db: postgres(PROD_POSTGRES) },
543
+ input: z.object({}),
544
+ output: z.object({
545
+ stats: z.object({
546
+ totalUsers: z.number(),
547
+ activeUsers: z.number(),
548
+ }),
549
+ }),
550
+
551
+ async run(ctx) {
552
+ // Check group membership for authorization
553
+ if (!ctx.user.groups.includes("admin")) {
554
+ throw new Error("Access denied: admin group membership required");
555
+ }
556
+
557
+ const stats = await ctx.integrations.db.query(
558
+ `SELECT
559
+ COUNT(*) as total_users,
560
+ COUNT(*) FILTER (WHERE status = 'active') as active_users
561
+ FROM users`,
562
+ z.object({ total_users: z.number(), active_users: z.number() }),
563
+ );
564
+
565
+ return {
566
+ stats: {
567
+ totalUsers: stats[0].total_users,
568
+ activeUsers: stats[0].active_users,
569
+ },
570
+ };
571
+ },
572
+ });
573
+ ```
574
+
575
+ ##### Custom Claims
576
+
577
+ `ctx.user.customClaims` contains additional claims from the JWT, such as department, role, or tenant information configured in your identity provider.
578
+
579
+ **Important limitations:**
580
+
581
+ - Custom claims are only available when the user is in an **enterprise account that uses SSO**, OR when the application is **deployed and uses embed tokens with SSO claims**.
582
+ - In the editor, custom claims will be empty for non-SSO users.
583
+ - Always write defensive code that handles missing custom claims gracefully.
584
+
585
+ ```typescript
586
+ import { api, z, postgres } from "@superblocksteam/sdk-api";
587
+
588
+ const PROD_POSTGRES = "a1b2c3d4-5678-90ab-cdef-ghijklmnopqr";
589
+
590
+ export default api({
591
+ name: "GetTenantData",
592
+ integrations: { db: postgres(PROD_POSTGRES) },
593
+ input: z.object({}),
594
+ output: z.object({
595
+ tenantName: z.string(),
596
+ records: z.array(z.object({ id: z.string(), value: z.string() })),
597
+ }),
598
+
599
+ async run(ctx) {
600
+ // Access custom claims from the JWT — handle missing claims defensively
601
+ const tenantId = ctx.user.customClaims["tenant_id"];
602
+ if (typeof tenantId !== "string") {
603
+ throw new Error(
604
+ "Missing tenant_id claim. Custom claims require enterprise SSO or embed tokens with SSO claims.",
605
+ );
606
+ }
607
+
608
+ const department = ctx.user.customClaims["department"] as
609
+ | string
610
+ | undefined;
611
+
612
+ ctx.log.info("Fetching tenant data", {
613
+ userId: ctx.user.userId,
614
+ tenantId,
615
+ department: department ?? "unknown",
616
+ });
617
+
618
+ const records = await ctx.integrations.db.query(
619
+ "SELECT id, value FROM tenant_data WHERE tenant_id = $1",
620
+ z.object({ id: z.string(), value: z.string() }),
621
+ [tenantId],
622
+ );
623
+
624
+ const tenantNames = await ctx.integrations.db.query(
625
+ "SELECT name FROM tenants WHERE id = $1",
626
+ z.object({ name: z.string() }),
627
+ [tenantId],
628
+ );
629
+
630
+ return {
631
+ tenantName: tenantNames[0]?.name ?? "Unknown Tenant",
632
+ records,
633
+ };
634
+ },
635
+ });
636
+ ```
637
+
638
+ ##### Combining User Context for Row-Level Security
639
+
640
+ ```typescript
641
+ import { api, z, postgres } from "@superblocksteam/sdk-api";
642
+
643
+ const PROD_POSTGRES = "a1b2c3d4-5678-90ab-cdef-ghijklmnopqr";
644
+
645
+ export default api({
646
+ name: "GetMyOrders",
647
+ integrations: { db: postgres(PROD_POSTGRES) },
648
+ input: z.object({
649
+ status: z.enum(["pending", "completed", "cancelled"]).optional(),
650
+ }),
651
+ output: z.object({
652
+ orders: z.array(
653
+ z.object({
654
+ id: z.string(),
655
+ total: z.number(),
656
+ status: z.string(),
657
+ createdAt: z.string(),
658
+ }),
659
+ ),
660
+ }),
661
+
662
+ async run(ctx, { status }) {
663
+ // Use ctx.user for row-level security — users can only see their own orders
664
+ if (!ctx.user.email) {
665
+ throw new Error("User email is required to filter orders");
666
+ }
667
+ const params: unknown[] = [ctx.user.email];
668
+ let query =
669
+ "SELECT id, total, status, created_at FROM orders WHERE user_email = $1";
670
+
671
+ if (status) {
672
+ query += " AND status = $2";
673
+ params.push(status);
674
+ }
675
+
676
+ query += " ORDER BY created_at DESC LIMIT 50";
677
+
678
+ const orders = await ctx.integrations.db.query(
679
+ query,
680
+ z.object({
681
+ id: z.string(),
682
+ total: z.number(),
683
+ status: z.string(),
684
+ created_at: z.string(),
685
+ }),
686
+ params,
687
+ );
688
+
689
+ return {
690
+ orders: orders.map((o) => ({
691
+ id: o.id,
692
+ total: o.total,
693
+ status: o.status,
694
+ createdAt: o.created_at,
695
+ })),
696
+ };
697
+ },
698
+ });
699
+ ```
700
+
529
701
  ## Integration Clients
530
702
 
531
703
  ### Integration Client Methods Reference
532
704
 
533
- **IMPORTANT:** Before using any integration client, verify available methods below. Do NOT assume methods exist based on the external service's API.
534
-
535
- #### Method Availability by Client
536
-
537
- | Client | Available Methods | Notes |
538
- | ------------------------- | ------------------------------------------------------------------------------ | ------------------------------------------------------ |
539
- | **PostgresClient** | `query<T>(sql, schema, params?)`, `execute(sql, params?)` | Schema parameter is REQUIRED for query() |
540
- | **SnowflakeClient** | `query<T>(sql, schema, params?)`, `execute(sql, params?)` | Schema parameter is REQUIRED for query() |
541
- | **PythonClient** | `run<T>(code, schema, bindings?)` | Schema parameter is REQUIRED, bindings via {{}} syntax |
542
- | **AirtableClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
543
- | **AnthropicClient** | `apiRequest(options, schema)`, `streamApiRequest(options, schema)` | Supports streaming for real-time token output |
544
- | **AsanaClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
545
- | **BitbucketClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
546
- | **BoxClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
547
- | **CircleCIClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
548
- | **CohereClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
549
- | **ConfluenceClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
550
- | **DatadogClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
551
- | **DropboxClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
552
- | **ElasticSearchClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
553
- | **FireworksClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
554
- | **FrontClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
555
- | **GeminiClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
556
- | **GitHubClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest - no createIssue, etc. |
557
- | **GoogleAnalyticsClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
558
- | **GoogleDriveClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
559
- | **GraphQLClient** | `query(query, variables?, schema?)`, `mutation(mutation, variables?, schema?)` | GraphQL-specific methods |
560
- | **GroqClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
561
- | **HubSpotClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
562
- | **IntercomClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
563
- | **JiraClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
564
- | **LaunchDarklyClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
565
- | **MistralClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
566
- | **NotionClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest - no queryDatabase, etc. |
567
- | **OpenAIClient** | `apiRequest(options, schema)`, `streamApiRequest(options, schema)` | Supports streaming for real-time token output |
568
- | **PagerDutyClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
569
- | **PerplexityClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
570
- | **SegmentClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
571
- | **SendGridClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
572
- | **SlackClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest - no specialized methods |
573
- | **StabilityAIClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
574
- | **StripeClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest - no createCustomer, etc. |
575
- | **TwilioClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
576
- | **ZendeskClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
577
- | **ZoomClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
705
+ **IMPORTANT:** Before using any integration client, verify available methods. Do NOT assume methods exist based on the external service's API.
578
706
 
579
707
  #### Common Mistakes to Avoid
580
708
 
@@ -588,6 +716,7 @@ await openai.createChatCompletion({ ... });
588
716
  await anthropic.createMessage({ ... });
589
717
  await stripe.createCustomer({ ... });
590
718
  await github.createIssue({ ... });
719
+ await myApi.request({ ... }); // .request() does NOT exist on any client
591
720
  ```
592
721
 
593
722
  **CORRECT - Use apiRequest:**
@@ -595,7 +724,7 @@ await github.createIssue({ ... });
595
724
  ```typescript
596
725
  // Use the generic apiRequest method
597
726
  await openai.apiRequest(
598
- { method: 'POST', path: '/v1/chat/completions', body: { ... } },
727
+ { method: 'POST', path: '/chat/completions', body: { ... } },
599
728
  { response: ResponseSchema }
600
729
  );
601
730
  ```
@@ -623,89 +752,9 @@ const users = await ctx.integrations.db.query(
623
752
  );
624
753
  ```
625
754
 
626
- #### Finding Type Definitions
627
-
628
- To verify available methods and signatures:
629
-
630
- - **README**: This document contains complete method signatures for all clients
631
- - **Type files**: Check `node_modules/@superblocksteam/sdk-api/src/integrations/<client>/types.ts`
632
- - **API Context**: See `node_modules/@superblocksteam/sdk-api/src/types.ts` for the ApiContext interface
633
-
634
- ### Integration Documentation
635
-
636
- Each integration client has detailed documentation with examples and common pitfalls. Click on an integration below for its full README:
637
-
638
- #### SQL Databases
639
-
640
- - [PostgreSQL](./src/integrations/postgres/README.md) - Query PostgreSQL databases with schema validation
641
- - [Snowflake](./src/integrations/snowflake/README.md) - Query Snowflake data warehouses
642
-
643
- #### GraphQL
644
-
645
- - [GraphQL](./src/integrations/graphql/README.md) - Execute queries and mutations against GraphQL endpoints
646
-
647
- #### AI/LLM
648
-
649
- - [OpenAI](./src/integrations/openai_v2/README.md) - Chat completions, embeddings, DALL-E, and more
650
- - [Anthropic](./src/integrations/anthropic/README.md) - Claude models for chat and analysis
651
- - [Cohere](./src/integrations/cohere/README.md) - Text generation, embeddings, classification
652
- - [Gemini](./src/integrations/gemini/README.md) - Google's multimodal AI models
653
- - [Groq](./src/integrations/groq/README.md) - Fast inference for LLM completions
654
- - [Mistral](./src/integrations/mistral/README.md) - Open-weight language models
655
- - [Perplexity](./src/integrations/perplexity/README.md) - Search-augmented AI responses
656
- - [Fireworks](./src/integrations/fireworks/README.md) - Fast model inference
657
-
658
- #### Messaging & Communication
659
-
660
- - [Slack](./src/integrations/slack/README.md) - Send messages, manage channels, Block Kit
661
- - [Twilio](./src/integrations/twilio/README.md) - SMS, voice calls, phone lookups
662
- - [SendGrid](./src/integrations/sendgrid/README.md) - Transactional and marketing emails
663
- - [Intercom](./src/integrations/intercom/README.md) - Customer messaging and support
664
- - [Front](./src/integrations/front/README.md) - Shared inbox and team communication
665
-
666
- #### Productivity & Collaboration
755
+ ### Streaming / SSE
667
756
 
668
- - [Notion](./src/integrations/notion/README.md) - Databases, pages, and blocks
669
- - [Airtable](./src/integrations/airtable/README.md) - Spreadsheet-database hybrid
670
- - [Asana](./src/integrations/asana/README.md) - Project and task management
671
- - [Jira](./src/integrations/jira/README.md) - Issue tracking and project management
672
- - [Confluence](./src/integrations/confluence/README.md) - Team wikis and documentation
673
- - [Zoom](./src/integrations/zoom/README.md) - Video meetings and webinars
674
-
675
- #### Developer Tools
676
-
677
- - [GitHub](./src/integrations/github/README.md) - Repositories, issues, pull requests
678
- - [Bitbucket](./src/integrations/bitbucket/README.md) - Git repositories and pipelines
679
- - [CircleCI](./src/integrations/circleci/README.md) - CI/CD pipelines and jobs
680
-
681
- #### Business & Enterprise
682
-
683
- - [Stripe](./src/integrations/stripe/README.md) - Payments, subscriptions, invoicing
684
- - [HubSpot](./src/integrations/hubspot/README.md) - CRM, contacts, deals
685
- - [Zendesk](./src/integrations/zendesk/README.md) - Support tickets and customer service
686
- - [PagerDuty](./src/integrations/pagerduty/README.md) - Incident management and on-call
687
- - [LaunchDarkly](./src/integrations/launchdarkly/README.md) - Feature flags and experimentation
688
-
689
- #### Analytics & Monitoring
690
-
691
- - [Google Analytics](./src/integrations/googleanalytics/README.md) - GA4 reports and real-time data
692
- - [Datadog](./src/integrations/datadog/README.md) - Metrics, monitors, and logs
693
- - [Segment](./src/integrations/segment/README.md) - Customer data platform
694
-
695
- #### Cloud Storage
696
-
697
- - [Google Drive](./src/integrations/googledrive/README.md) - Files, folders, and sharing
698
- - [Dropbox](./src/integrations/dropbox/README.md) - Cloud file storage
699
- - [Box](./src/integrations/box/README.md) - Enterprise content management
700
-
701
- #### Code Execution
702
-
703
- - [Python](./src/integrations/python/README.md) - Execute Python scripts with type-safe inputs and outputs
704
-
705
- #### Other
706
-
707
- - [Elasticsearch](./src/integrations/elasticsearch/README.md) - Search and analytics engine
708
- - [Stability AI](./src/integrations/stabilityai/README.md) - Image generation and editing
757
+ > **Note:** The SDK's `apiRequest()` method does **not** support streaming or Server-Sent Events (SSE) responses. All AI provider calls (OpenAI, Anthropic, Gemini, Groq, Mistral, Cohere, Perplexity, Fireworks) return complete responses — the SDK waits for the full response before returning. If you are building a chat interface that needs real-time token streaming, you will need to handle streaming at the frontend/UI layer rather than through the SDK.
709
758
 
710
759
  ## Generic API Requests
711
760
 
@@ -736,7 +785,6 @@ export default api({
736
785
  });
737
786
 
738
787
  const PostMessageResponseSchema = z.object({
739
- ok: z.boolean(),
740
788
  ts: z.string(),
741
789
  channel: z.string(),
742
790
  });
@@ -757,7 +805,11 @@ export default api({
757
805
  },
758
806
  );
759
807
 
760
- // result is fully typed as PostMessageResponse
808
+ if (!result.ok) {
809
+ throw new Error(`Slack API error: ${result.error}`);
810
+ }
811
+
812
+ // result is fully typed as { ok: true } & PostMessageResponseSchema
761
813
  return { ts: result.ts };
762
814
  },
763
815
  });
@@ -780,99 +832,6 @@ export default api({
780
832
  | `body?` | `z.ZodSchema<TBody>` | Optional Zod schema for request body validation (required if body is provided) |
781
833
  | `response` | `z.ZodSchema<TResponse>` | **Required** Zod schema for response validation |
782
834
 
783
- ## Streaming API Requests
784
-
785
- For real-time streaming responses (e.g., LLM token streaming), use `streamApiRequest()`. This method returns an `AsyncIterable` that yields validated chunks as they arrive.
786
-
787
- ```typescript
788
- import { streamingApi, z, anthropic } from "@superblocksteam/sdk-api";
789
-
790
- // Integration ID from the integrations panel
791
- const PROD_ANTHROPIC = "d4e5f6g7-8901-23ab-cdef-ghijklmnopqr";
792
-
793
- // Define schema for Anthropic SSE events
794
- const AnthropicStreamEventSchema = z.discriminatedUnion("type", [
795
- z.object({
796
- type: z.literal("content_block_delta"),
797
- index: z.number(),
798
- delta: z.object({
799
- type: z.literal("text_delta"),
800
- text: z.string(),
801
- }),
802
- }),
803
- z.object({ type: z.literal("message_start"), message: z.any() }),
804
- z.object({
805
- type: z.literal("content_block_start"),
806
- index: z.number(),
807
- content_block: z.any(),
808
- }),
809
- z.object({ type: z.literal("content_block_stop"), index: z.number() }),
810
- z.object({
811
- type: z.literal("message_delta"),
812
- delta: z.any(),
813
- usage: z.any(),
814
- }),
815
- z.object({ type: z.literal("message_stop") }),
816
- z.object({ type: z.literal("ping") }),
817
- ]);
818
-
819
- export default streamingApi({
820
- name: "StreamAnthropicChat",
821
-
822
- integrations: {
823
- ai: anthropic(PROD_ANTHROPIC),
824
- },
825
-
826
- input: z.object({ prompt: z.string() }),
827
- chunk: z.object({ type: z.literal("text"), text: z.string() }),
828
-
829
- async *run(ctx, { prompt }) {
830
- const stream = ctx.integrations.ai.streamApiRequest(
831
- {
832
- method: "POST",
833
- path: "/v1/messages",
834
- body: {
835
- model: "claude-3-5-sonnet-20241022",
836
- max_tokens: 1024,
837
- stream: true,
838
- messages: [{ role: "user", content: prompt }],
839
- },
840
- },
841
- { chunk: AnthropicStreamEventSchema },
842
- );
843
-
844
- for await (const event of stream) {
845
- if (event.type === "content_block_delta") {
846
- yield { type: "text" as const, text: event.delta.text };
847
- }
848
- }
849
- },
850
- });
851
- ```
852
-
853
- ### StreamApiRequestOptions
854
-
855
- Same as `ApiRequestOptions` - see above.
856
-
857
- ### StreamApiRequestSchema
858
-
859
- | Property | Type | Description |
860
- | -------- | --------------------- | ------------------------------------------------------------------------------ |
861
- | `body?` | `z.ZodSchema<TBody>` | Optional Zod schema for request body validation (required if body is provided) |
862
- | `chunk` | `z.ZodSchema<TChunk>` | **Required** Zod schema for validating each streamed chunk |
863
-
864
- ### Supported Integrations
865
-
866
- Streaming is supported by REST API-based integrations that connect to services with SSE (Server-Sent Events) endpoints:
867
-
868
- - **AnthropicClient** - Claude streaming messages
869
- - **OpenAIClient** - GPT streaming chat completions
870
- - **CohereClient** - Streaming text generation
871
- - **GroqClient** - Streaming completions
872
- - **MistralClient** - Streaming chat
873
- - **FireworksClient** - Streaming inference
874
- - **PerplexityClient** - Streaming search responses
875
-
876
835
  ## Trace Metadata
877
836
 
878
837
  All integration client methods accept an optional `metadata` parameter as their last argument. When `includeDiagnostics` is enabled, this metadata is captured in the trace view alongside timing and request/response data.
@@ -910,14 +869,14 @@ await ctx.integrations.db.execute(
910
869
  { label: "Update last login" },
911
870
  );
912
871
 
913
- // REST API clients (apiRequest, streamApiRequest)
872
+ // REST API clients (apiRequest)
914
873
  const result = await ctx.integrations.slack.apiRequest(
915
874
  { method: "POST", path: "/chat.postMessage", body: { channel, text } },
916
875
  { body: BodySchema, response: ResponseSchema },
917
876
  { label: "Send alert to Slack" },
918
877
  );
919
878
 
920
- // Other clients (MongoDB, Redis, S3, etc.)
879
+ // Other clients (MongoDB, S3, etc.)
921
880
  const doc = await ctx.integrations.mongo.run(
922
881
  "users",
923
882
  "findOne",
@@ -925,10 +884,6 @@ const doc = await ctx.integrations.mongo.run(
925
884
  { filter: { _id: userId } },
926
885
  { label: "Look up user by ID" },
927
886
  );
928
-
929
- await ctx.integrations.cache.get("session:" + sessionId, {
930
- label: "Check session cache",
931
- });
932
887
  ```
933
888
 
934
889
  ### When to Use
@@ -951,23 +906,22 @@ import {
951
906
  OutputValidationError,
952
907
  QueryValidationError,
953
908
  RestApiValidationError,
954
- StreamChunkValidationError,
955
909
  IntegrationNotFoundError,
910
+ IntegrationError,
956
911
  ExecutionError,
957
912
  ErrorCode,
958
913
  } from "@superblocksteam/sdk-api";
959
914
  ```
960
915
 
961
- | Error Type | Code | Description |
962
- | ---------------------------- | ----------------------- | -------------------------------------------------- |
963
- | `InputValidationError` | `INPUT_VALIDATION` | Input failed Zod validation |
964
- | `OutputValidationError` | `OUTPUT_VALIDATION` | Output failed Zod validation |
965
- | `QueryValidationError` | N/A | Database query result validation failed (Postgres) |
966
- | `RestApiValidationError` | N/A | REST API request/response validation failed |
967
- | `StreamChunkValidationError` | N/A | Streaming chunk failed schema validation |
968
- | `IntegrationNotFoundError` | `INTEGRATION_NOT_FOUND` | Integration not configured |
969
- | `IntegrationError` | `INTEGRATION_ERROR` | Integration operation failed |
970
- | `ExecutionError` | `EXECUTION_ERROR` | User code threw an error |
916
+ | Error Type | Code | Description |
917
+ | -------------------------- | ----------------------- | -------------------------------------------------- |
918
+ | `InputValidationError` | `INPUT_VALIDATION` | Input failed Zod validation |
919
+ | `OutputValidationError` | `OUTPUT_VALIDATION` | Output failed Zod validation |
920
+ | `QueryValidationError` | N/A | Database query result validation failed (Postgres) |
921
+ | `RestApiValidationError` | N/A | REST API request/response validation failed |
922
+ | `IntegrationNotFoundError` | `INTEGRATION_NOT_FOUND` | Integration not configured |
923
+ | `IntegrationError` | `INTEGRATION_ERROR` | Integration operation failed |
924
+ | `ExecutionError` | `EXECUTION_ERROR` | User code threw an error |
971
925
 
972
926
  ### QueryValidationError (Postgres)
973
927
 
@@ -996,7 +950,7 @@ Thrown when REST API request bodies or responses fail schema validation. Include
996
950
  ```typescript
997
951
  try {
998
952
  const result = await ctx.integrations.ai.apiRequest(
999
- { method: 'POST', path: '/v1/chat/completions', body: { ... } },
953
+ { method: 'POST', path: '/chat/completions', body: { ... } },
1000
954
  { body: RequestSchema, response: ResponseSchema }
1001
955
  );
1002
956
  } catch (error) {
@@ -1024,33 +978,6 @@ The `RestApiValidationError` provides complete context for debugging:
1024
978
  - **The actual data** that failed validation
1025
979
  - **Utility methods** like `format()` and `flatten()` for different error representations
1026
980
 
1027
- ### StreamChunkValidationError
1028
-
1029
- Thrown when a streamed chunk fails schema validation. Includes the chunk index, the raw chunk data, and the Zod error.
1030
-
1031
- ```typescript
1032
- import { execute, StreamChunkValidationError } from "@superblocksteam/sdk-api";
1033
-
1034
- try {
1035
- // execute() returns an AsyncGenerator for streaming APIs
1036
- for await (const chunk of execute(streamingApi, request)) {
1037
- // Process chunk
1038
- }
1039
- } catch (error) {
1040
- if (error instanceof StreamChunkValidationError) {
1041
- console.error("Chunk index:", error.details.chunkIndex);
1042
- console.error("Raw chunk:", error.details.chunk);
1043
- console.error("Validation error:", error.details.zodError);
1044
- }
1045
- }
1046
- ```
1047
-
1048
- The `StreamChunkValidationError` provides:
1049
-
1050
- - **Chunk index** (`chunkIndex`) - Which chunk in the stream failed
1051
- - **Raw chunk data** (`chunk`) - The actual data that failed validation
1052
- - **Full Zod error** (`zodError`) - Complete validation error details
1053
-
1054
981
  ## Best Practices
1055
982
 
1056
983
  ### Push Filtering Down to the Data Source
@@ -1313,28 +1240,20 @@ The app template provides automatic type inference for API calls using a tRPC-st
1313
1240
 
1314
1241
  ### Adding a New API (2 Steps)
1315
1242
 
1316
- **Step 1**: Create your API file (e.g., `server/apis/GetUsers/api.ts`)
1317
-
1318
- **Step 2**: Add it to the registry at `server/apis/index.ts`:
1243
+ 1. Add a module under `server/apis/` (any layout; see [export styles](#export-style-default-vs-named-exports)).
1244
+ 2. Register it in `server/apis/index.ts` (`.js` specifiers for ESM):
1319
1245
 
1320
1246
  ```typescript
1321
- import GetUsers from "./GetUsers/api.js";
1322
- import CreateOrder from "./CreateOrder/api.js";
1247
+ import CreateOrder from "./orders/create-order.js";
1248
+ import GetUsers from "./users/get-users.js";
1249
+ import { ListProfiles, UpdateProfile } from "./users/pair.js";
1323
1250
 
1324
- const apis = {
1325
- GetUsers,
1326
- CreateOrder,
1327
- // Add new APIs here
1328
- } as const;
1251
+ const apis = { CreateOrder, GetUsers, ListProfiles, UpdateProfile } as const;
1329
1252
 
1330
1253
  export default apis;
1331
1254
  export type ApiRegistry = typeof apis;
1332
1255
  ```
1333
1256
 
1334
- That's it! Types automatically flow to the frontend.
1335
-
1336
- > **Note**: Always use `.js` extension in imports (required for ESM module resolution).
1337
-
1338
1257
  ### Calling APIs from React Components
1339
1258
 
1340
1259
  Import `useApi` from the template's pre-configured hook:
@@ -1377,13 +1296,15 @@ The hook uses `import type` to pull in only the type information from the regist
1377
1296
 
1378
1297
  ### Alternative: Explicit Type Parameter
1379
1298
 
1380
- For testing or when the registry isn't available:
1299
+ When you cannot use the registry hook, pass the compiled API type:
1381
1300
 
1382
1301
  ```typescript
1383
1302
  import { useApi } from "@superblocksteam/library";
1384
- import type GetUsersApi from "../../server/apis/GetUsers/api.js";
1303
+ import type GetUsersApi from "../../server/apis/users/get-users.js";
1304
+ import type { ListProfiles } from "../../server/apis/users/pair.js";
1385
1305
 
1386
- const { run } = useApi<typeof GetUsersApi>("GetUsers");
1306
+ const getUsers = useApi<typeof GetUsersApi>("GetUsers");
1307
+ const listProfiles = useApi<typeof ListProfiles>("ListProfiles");
1387
1308
  ```
1388
1309
 
1389
1310
  ## Complete Example
@@ -1428,7 +1349,6 @@ const CustomerSchema = z.object({
1428
1349
  });
1429
1350
 
1430
1351
  const SlackPostMessageResponseSchema = z.object({
1431
- ok: z.boolean(),
1432
1352
  ts: z.string().optional(),
1433
1353
  });
1434
1354
 
@@ -1485,7 +1405,7 @@ export default api({
1485
1405
  const orderId = `ord_${Date.now()}`;
1486
1406
 
1487
1407
  // Notify via Slack
1488
- await ctx.integrations.notifier.apiRequest(
1408
+ const slackResult = await ctx.integrations.notifier.apiRequest(
1489
1409
  {
1490
1410
  method: "POST",
1491
1411
  path: "/chat.postMessage",
@@ -1497,13 +1417,17 @@ export default api({
1497
1417
  { response: SlackPostMessageResponseSchema },
1498
1418
  );
1499
1419
 
1420
+ if (!slackResult.ok) {
1421
+ throw new Error(`Slack API error: ${slackResult.error}`);
1422
+ }
1423
+
1500
1424
  // Generate AI summary if requested
1501
1425
  let aiSummary: string | undefined;
1502
1426
  if (sendAiSummary) {
1503
1427
  const completion = await ctx.integrations.ai.apiRequest(
1504
1428
  {
1505
1429
  method: "POST",
1506
- path: "/v1/chat/completions",
1430
+ path: "/chat/completions",
1507
1431
  body: {
1508
1432
  model: "gpt-4",
1509
1433
  messages: [