@superblocksteam/sdk-api 2.0.104 → 2.0.105-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/README.md +202 -86
  2. package/dist/api/definition.d.ts +11 -6
  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/errors.d.ts +1 -1
  9. package/dist/errors.js +1 -1
  10. package/dist/index.d.ts +10 -10
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +9 -5
  13. package/dist/index.js.map +1 -1
  14. package/dist/integrations/base/index.d.ts +2 -1
  15. package/dist/integrations/base/index.d.ts.map +1 -1
  16. package/dist/integrations/base/index.js +1 -0
  17. package/dist/integrations/base/index.js.map +1 -1
  18. package/dist/integrations/base/rest-api-client-base.d.ts +48 -0
  19. package/dist/integrations/base/rest-api-client-base.d.ts.map +1 -0
  20. package/dist/integrations/base/rest-api-client-base.js +98 -0
  21. package/dist/integrations/base/rest-api-client-base.js.map +1 -0
  22. package/dist/integrations/base/rest-api-integration-client.d.ts +10 -20
  23. package/dist/integrations/base/rest-api-integration-client.d.ts.map +1 -1
  24. package/dist/integrations/base/rest-api-integration-client.js +10 -65
  25. package/dist/integrations/base/rest-api-integration-client.js.map +1 -1
  26. package/dist/integrations/box/types.d.ts +1 -1
  27. package/dist/integrations/declarations.d.ts +5 -63
  28. package/dist/integrations/declarations.d.ts.map +1 -1
  29. package/dist/integrations/declarations.js +5 -59
  30. package/dist/integrations/declarations.js.map +1 -1
  31. package/dist/integrations/documentation.test.js +0 -2
  32. package/dist/integrations/documentation.test.js.map +1 -1
  33. package/dist/integrations/googledrive/types.d.ts +1 -1
  34. package/dist/integrations/index.d.ts +1 -9
  35. package/dist/integrations/index.d.ts.map +1 -1
  36. package/dist/integrations/index.js +1 -6
  37. package/dist/integrations/index.js.map +1 -1
  38. package/dist/integrations/registry.d.ts +1 -10
  39. package/dist/integrations/registry.d.ts.map +1 -1
  40. package/dist/integrations/registry.js +0 -25
  41. package/dist/integrations/registry.js.map +1 -1
  42. package/dist/integrations/slack/client.d.ts +13 -9
  43. package/dist/integrations/slack/client.d.ts.map +1 -1
  44. package/dist/integrations/slack/client.js +60 -8
  45. package/dist/integrations/slack/client.js.map +1 -1
  46. package/dist/integrations/slack/client.test.d.ts +11 -0
  47. package/dist/integrations/slack/client.test.d.ts.map +1 -0
  48. package/dist/integrations/slack/client.test.js +368 -0
  49. package/dist/integrations/slack/client.test.js.map +1 -0
  50. package/dist/integrations/slack/index.d.ts +2 -1
  51. package/dist/integrations/slack/index.d.ts.map +1 -1
  52. package/dist/integrations/slack/index.js +1 -0
  53. package/dist/integrations/slack/index.js.map +1 -1
  54. package/dist/integrations/slack/types.d.ts +127 -28
  55. package/dist/integrations/slack/types.d.ts.map +1 -1
  56. package/dist/integrations/slack/types.js +27 -1
  57. package/dist/integrations/slack/types.js.map +1 -1
  58. package/dist/integrations/snowflake/client.d.ts +2 -2
  59. package/dist/integrations/snowflake/client.js +2 -2
  60. package/dist/runtime/context.d.ts +1 -1
  61. package/dist/runtime/executor.d.ts +2 -2
  62. package/dist/types.d.ts +14 -5
  63. package/dist/types.d.ts.map +1 -1
  64. package/package.json +2 -2
  65. package/src/api/definition.test.ts +40 -15
  66. package/src/api/definition.ts +19 -12
  67. package/src/errors.ts +1 -1
  68. package/src/index.ts +13 -30
  69. package/src/integrations/asana/README.md +12 -12
  70. package/src/integrations/base/index.ts +2 -1
  71. package/src/integrations/base/rest-api-client-base.ts +134 -0
  72. package/src/integrations/base/rest-api-integration-client.ts +12 -89
  73. package/src/integrations/bitbucket/README.md +19 -19
  74. package/src/integrations/box/README.md +24 -24
  75. package/src/integrations/box/types.ts +1 -1
  76. package/src/integrations/circleci/README.md +18 -18
  77. package/src/integrations/declarations.ts +5 -91
  78. package/src/integrations/documentation.test.ts +0 -2
  79. package/src/integrations/googledrive/README.md +25 -22
  80. package/src/integrations/googledrive/types.ts +1 -1
  81. package/src/integrations/graphql/README.md +2 -2
  82. package/src/integrations/index.ts +0 -45
  83. package/src/integrations/registry.ts +1 -34
  84. package/src/integrations/salesforce/README.md +11 -9
  85. package/src/integrations/slack/README.md +62 -19
  86. package/src/integrations/slack/client.test.ts +553 -0
  87. package/src/integrations/slack/client.ts +92 -12
  88. package/src/integrations/slack/index.ts +6 -1
  89. package/src/integrations/slack/types.ts +142 -29
  90. package/src/integrations/snowflake/client.ts +2 -2
  91. package/src/integrations/zoom/README.md +15 -15
  92. package/src/runtime/context.ts +1 -1
  93. package/src/runtime/executor.ts +2 -2
  94. package/src/types.ts +14 -5
  95. package/dist/integrations/couchbase/client.d.ts +0 -36
  96. package/dist/integrations/couchbase/client.d.ts.map +0 -1
  97. package/dist/integrations/couchbase/client.js +0 -148
  98. package/dist/integrations/couchbase/client.js.map +0 -1
  99. package/dist/integrations/couchbase/index.d.ts +0 -8
  100. package/dist/integrations/couchbase/index.d.ts.map +0 -1
  101. package/dist/integrations/couchbase/index.js +0 -7
  102. package/dist/integrations/couchbase/index.js.map +0 -1
  103. package/dist/integrations/couchbase/types.d.ts +0 -100
  104. package/dist/integrations/couchbase/types.d.ts.map +0 -1
  105. package/dist/integrations/couchbase/types.js +0 -5
  106. package/dist/integrations/couchbase/types.js.map +0 -1
  107. package/dist/integrations/kafka/client.d.ts +0 -25
  108. package/dist/integrations/kafka/client.d.ts.map +0 -1
  109. package/dist/integrations/kafka/client.js +0 -124
  110. package/dist/integrations/kafka/client.js.map +0 -1
  111. package/dist/integrations/kafka/index.d.ts +0 -8
  112. package/dist/integrations/kafka/index.d.ts.map +0 -1
  113. package/dist/integrations/kafka/index.js +0 -7
  114. package/dist/integrations/kafka/index.js.map +0 -1
  115. package/dist/integrations/kafka/types.d.ts +0 -113
  116. package/dist/integrations/kafka/types.d.ts.map +0 -1
  117. package/dist/integrations/kafka/types.js +0 -5
  118. package/dist/integrations/kafka/types.js.map +0 -1
  119. package/dist/integrations/kinesis/client.d.ts +0 -31
  120. package/dist/integrations/kinesis/client.d.ts.map +0 -1
  121. package/dist/integrations/kinesis/client.js +0 -101
  122. package/dist/integrations/kinesis/client.js.map +0 -1
  123. package/dist/integrations/kinesis/index.d.ts +0 -8
  124. package/dist/integrations/kinesis/index.d.ts.map +0 -1
  125. package/dist/integrations/kinesis/index.js +0 -7
  126. package/dist/integrations/kinesis/index.js.map +0 -1
  127. package/dist/integrations/kinesis/types.d.ts +0 -97
  128. package/dist/integrations/kinesis/types.d.ts.map +0 -1
  129. package/dist/integrations/kinesis/types.js +0 -7
  130. package/dist/integrations/kinesis/types.js.map +0 -1
  131. package/dist/integrations/python/client.d.ts +0 -42
  132. package/dist/integrations/python/client.d.ts.map +0 -1
  133. package/dist/integrations/python/client.js +0 -89
  134. package/dist/integrations/python/client.js.map +0 -1
  135. package/dist/integrations/python/client.test.d.ts +0 -5
  136. package/dist/integrations/python/client.test.d.ts.map +0 -1
  137. package/dist/integrations/python/client.test.js +0 -214
  138. package/dist/integrations/python/client.test.js.map +0 -1
  139. package/dist/integrations/python/index.d.ts +0 -6
  140. package/dist/integrations/python/index.d.ts.map +0 -1
  141. package/dist/integrations/python/index.js +0 -5
  142. package/dist/integrations/python/index.js.map +0 -1
  143. package/dist/integrations/python/types.d.ts +0 -85
  144. package/dist/integrations/python/types.d.ts.map +0 -1
  145. package/dist/integrations/python/types.js +0 -5
  146. package/dist/integrations/python/types.js.map +0 -1
  147. package/src/integrations/couchbase/README.md +0 -138
  148. package/src/integrations/couchbase/client.ts +0 -225
  149. package/src/integrations/couchbase/index.ts +0 -8
  150. package/src/integrations/couchbase/types.ts +0 -126
  151. package/src/integrations/kafka/README.md +0 -144
  152. package/src/integrations/kafka/client.ts +0 -216
  153. package/src/integrations/kafka/index.ts +0 -14
  154. package/src/integrations/kafka/types.ts +0 -128
  155. package/src/integrations/kinesis/README.md +0 -153
  156. package/src/integrations/kinesis/client.ts +0 -146
  157. package/src/integrations/kinesis/index.ts +0 -14
  158. package/src/integrations/kinesis/types.ts +0 -114
  159. package/src/integrations/python/README.md +0 -566
  160. package/src/integrations/python/client.test.ts +0 -341
  161. package/src/integrations/python/client.ts +0 -136
  162. package/src/integrations/python/index.ts +0 -6
  163. package/src/integrations/python/types.ts +0 -92
@@ -24,7 +24,7 @@ import type { SupportsApiRequest } from "../base/index.js";
24
24
  * const result = await googleDrive.apiRequest(
25
25
  * {
26
26
  * method: 'GET',
27
- * path: '/drive/v3/files',
27
+ * path: '/files',
28
28
  * },
29
29
  * { response: ResponseSchema }
30
30
  * );
@@ -112,7 +112,7 @@ const CreateUserResponseSchema = z.object({
112
112
  }),
113
113
  });
114
114
 
115
- const result = await graphql.mutation(
115
+ const result = await ctx.integrations.graphql.mutation(
116
116
  `mutation CreateUser($input: CreateUserInput!) {
117
117
  createUser(input: $input) {
118
118
  id
@@ -150,7 +150,7 @@ const UpdateOrderResponseSchema = z.object({
150
150
  }),
151
151
  });
152
152
 
153
- const result = await graphql.mutation(
153
+ const result = await ctx.integrations.graphql.mutation(
154
154
  `mutation UpdateOrder($id: ID!, $input: UpdateOrderInput!) {
155
155
  updateOrder(id: $id, input: $input) {
156
156
  id
@@ -66,18 +66,12 @@ export {
66
66
  mongodb,
67
67
  dynamodb,
68
68
  cosmosdb,
69
- couchbase,
70
69
  s3,
71
70
  gcs,
72
71
  googleSheets,
73
- kafka,
74
- kinesis,
75
72
  salesforce,
76
73
  redis,
77
74
  superblocksOcr,
78
- python,
79
- confluent,
80
- redpanda,
81
75
  lakebase,
82
76
  snowflakePostgres,
83
77
  smtp,
@@ -143,18 +137,12 @@ export {
143
137
  type MongoDBRef,
144
138
  type DynamoDBRef,
145
139
  type CosmosDBRef,
146
- type CouchbaseRef,
147
140
  type S3Ref,
148
141
  type GCSRef,
149
142
  type GoogleSheetsRef,
150
- type KafkaRef,
151
- type KinesisRef,
152
143
  type SalesforceRef,
153
144
  type RedisRef,
154
145
  type SuperblocksOCRRef,
155
- type PythonRef,
156
- type ConfluentRef,
157
- type RedpandaRef,
158
146
  type LakebaseRef,
159
147
  type SnowflakePostgresRef,
160
148
  type SmtpRef,
@@ -383,13 +371,6 @@ export { DynamoDBClientImpl } from "./dynamodb/index.js";
383
371
  export type { CosmosDBClient, CosmosDBQueryOptions } from "./cosmosdb/index.js";
384
372
  export { CosmosDBClientImpl } from "./cosmosdb/index.js";
385
373
 
386
- // Couchbase client
387
- export type {
388
- CouchbaseClient,
389
- CouchbaseIdentifier,
390
- } from "./couchbase/index.js";
391
- export { CouchbaseClientImpl } from "./couchbase/index.js";
392
-
393
374
  // S3 client
394
375
  export type {
395
376
  S3Client,
@@ -416,26 +397,6 @@ export type {
416
397
  } from "./gsheets/index.js";
417
398
  export { GoogleSheetsClientImpl } from "./gsheets/index.js";
418
399
 
419
- // Kafka client
420
- export type {
421
- KafkaClient,
422
- KafkaOperation,
423
- KafkaSeek,
424
- KafkaConsumeParams,
425
- KafkaProduceParams,
426
- } from "./kafka/index.js";
427
- export { KafkaClientImpl } from "./kafka/index.js";
428
-
429
- // Kinesis client
430
- export type {
431
- KinesisClient,
432
- KinesisPutParams,
433
- KinesisGetParams,
434
- KinesisStreamIdentifier,
435
- KinesisShardIteratorType,
436
- } from "./kinesis/index.js";
437
- export { KinesisClientImpl } from "./kinesis/index.js";
438
-
439
400
  // Salesforce client
440
401
  export type {
441
402
  SalesforceClient,
@@ -452,10 +413,6 @@ export { RedisClientImpl } from "./redis/index.js";
452
413
  export type { SuperblocksOCRClient } from "./superblocks-ocr/index.js";
453
414
  export { SuperblocksOCRClientImpl } from "./superblocks-ocr/index.js";
454
415
 
455
- // Python client
456
- export type { PythonClient } from "./python/index.js";
457
- export { PythonClientImpl } from "./python/index.js";
458
-
459
416
  // Lakebase client
460
417
  export type { LakebaseClient } from "./lakebase/index.js";
461
418
  export { LakebaseClientImpl } from "./lakebase/index.js";
@@ -471,5 +428,3 @@ export { SmtpClientImpl } from "./smtp/index.js";
471
428
  // REST API Integration client
472
429
  export type { RestApiIntegrationPluginClient } from "./restapiintegration/index.js";
473
430
  export { RestApiIntegrationPluginClientImpl } from "./restapiintegration/index.js";
474
-
475
- // Confluent and Redpanda reuse the Kafka client (same proto)
@@ -57,12 +57,9 @@ import { OracleDBClientImpl } from "./oracledb/index.js";
57
57
  import { RedshiftClientImpl } from "./redshift/index.js";
58
58
  // REST API clients
59
59
  import { CosmosDBClientImpl } from "./cosmosdb/index.js";
60
- import { CouchbaseClientImpl } from "./couchbase/index.js";
61
60
  import { DynamoDBClientImpl } from "./dynamodb/index.js";
62
61
  import { GCSClientImpl } from "./gcs/index.js";
63
62
  import { GoogleSheetsClientImpl } from "./gsheets/index.js";
64
- import { KafkaClientImpl } from "./kafka/index.js";
65
- import { KinesisClientImpl } from "./kinesis/index.js";
66
63
  import { LakebaseClientImpl } from "./lakebase/index.js";
67
64
  import { MongoDBClientImpl } from "./mongodb/index.js";
68
65
  import { RedisClientImpl } from "./redis/index.js";
@@ -73,8 +70,6 @@ import { SnowflakePostgresClientImpl } from "./snowflakepostgres/index.js";
73
70
  import { SuperblocksOCRClientImpl } from "./superblocks-ocr/index.js";
74
71
  // REST API plugins
75
72
  import { RestApiIntegrationPluginClientImpl } from "./restapiintegration/index.js";
76
- // Code execution clients
77
- import { PythonClientImpl } from "./python/index.js";
78
73
 
79
74
  /**
80
75
  * Supported plugin IDs mapped to their client constructors.
@@ -133,18 +128,12 @@ export const SUPPORTED_PLUGINS = {
133
128
  mongodb: "mongodb",
134
129
  dynamodb: "dynamodb",
135
130
  cosmosdb: "cosmosdb",
136
- couchbase: "couchbase",
137
131
  s3: "s3",
138
132
  gcs: "gcs",
139
133
  gsheets: "gsheets",
140
- kafka: "kafka",
141
- kinesis: "kinesis",
142
134
  salesforce: "salesforce",
143
135
  redis: "redis",
144
136
  "superblocks-ocr": "superblocks-ocr",
145
- // Kafka-compatible streaming
146
- confluent: "confluent",
147
- redpanda: "redpanda",
148
137
  // SQL databases (continued)
149
138
  lakebase: "lakebase",
150
139
  snowflakepostgres: "snowflakepostgres",
@@ -152,8 +141,6 @@ export const SUPPORTED_PLUGINS = {
152
141
  smtp: "smtp",
153
142
  // REST API plugins
154
143
  restapiintegration: "restapiintegration",
155
- // Code execution
156
- python: "python",
157
144
  } as const;
158
145
 
159
146
  export type SupportedPluginId =
@@ -183,11 +170,8 @@ export interface TraceMetadata {
183
170
  * Accepts a plugin request object that matches the protobuf Plugin definition
184
171
  * for the specific integration type (e.g., postgresql.v1.Plugin, restapi.v1.Plugin).
185
172
  *
186
- * For language plugins (Python, JavaScript), the bindings parameter should be passed
187
- * to the API execution request as `input` or `inputs` field for binding resolution.
188
- *
189
173
  * @param request - Plugin-specific request object matching the proto schema
190
- * @param bindings - Optional bindings data for binding resolution (e.g., Python/JavaScript bindings)
174
+ * @param bindings - Optional bindings data for binding resolution
191
175
  * @param metadata - Optional trace metadata (label, description) for diagnostics
192
176
  * @returns Promise resolving to the operation result
193
177
  */
@@ -392,9 +376,6 @@ export function createClient(
392
376
  case SUPPORTED_PLUGINS.cosmosdb:
393
377
  return new CosmosDBClientImpl(config, executeQuery);
394
378
 
395
- case SUPPORTED_PLUGINS.couchbase:
396
- return new CouchbaseClientImpl(config, executeQuery);
397
-
398
379
  case SUPPORTED_PLUGINS.s3:
399
380
  return new S3ClientImpl(config, executeQuery);
400
381
 
@@ -404,12 +385,6 @@ export function createClient(
404
385
  case SUPPORTED_PLUGINS.gsheets:
405
386
  return new GoogleSheetsClientImpl(config, executeQuery);
406
387
 
407
- case SUPPORTED_PLUGINS.kafka:
408
- return new KafkaClientImpl(config, executeQuery);
409
-
410
- case SUPPORTED_PLUGINS.kinesis:
411
- return new KinesisClientImpl(config, executeQuery);
412
-
413
388
  case SUPPORTED_PLUGINS.salesforce:
414
389
  return new SalesforceClientImpl(config, executeQuery);
415
390
 
@@ -419,11 +394,6 @@ export function createClient(
419
394
  case SUPPORTED_PLUGINS["superblocks-ocr"]:
420
395
  return new SuperblocksOCRClientImpl(config, executeQuery);
421
396
 
422
- // Confluent and Redpanda use the same Kafka plugin proto
423
- case SUPPORTED_PLUGINS.confluent:
424
- case SUPPORTED_PLUGINS.redpanda:
425
- return new KafkaClientImpl(config, executeQuery);
426
-
427
397
  case SUPPORTED_PLUGINS.lakebase:
428
398
  return new LakebaseClientImpl(config, executeQuery);
429
399
 
@@ -436,9 +406,6 @@ export function createClient(
436
406
  case SUPPORTED_PLUGINS.restapiintegration:
437
407
  return new RestApiIntegrationPluginClientImpl(config, executeQuery);
438
408
 
439
- case SUPPORTED_PLUGINS.python:
440
- return new PythonClientImpl(config, executeQuery);
441
-
442
409
  default:
443
410
  throw new Error(
444
411
  `Unsupported plugin: ${config.pluginId}. ` +
@@ -77,7 +77,7 @@ const opportunities = await ctx.integrations.salesforce.query(
77
77
  ### Create a Record
78
78
 
79
79
  ```typescript
80
- await salesforce.create("Account", {
80
+ await ctx.integrations.salesforce.create("Account", {
81
81
  Name: "Acme Corp",
82
82
  Industry: "Technology",
83
83
  Website: "https://acme.example.com",
@@ -87,7 +87,7 @@ await salesforce.create("Account", {
87
87
  ### Read a Record by ID
88
88
 
89
89
  ```typescript
90
- const account = await salesforce.read(
90
+ const account = await ctx.integrations.salesforce.read(
91
91
  "Account",
92
92
  "001xx000003DGb2AAG",
93
93
  z.object({
@@ -101,7 +101,7 @@ const account = await salesforce.read(
101
101
  ### Update a Record
102
102
 
103
103
  ```typescript
104
- await salesforce.update("Account", "001xx000003DGb2AAG", {
104
+ await ctx.integrations.salesforce.update("Account", "001xx000003DGb2AAG", {
105
105
  Name: "Acme Corp (Updated)",
106
106
  Industry: "Software",
107
107
  });
@@ -116,7 +116,7 @@ await ctx.integrations.salesforce.remove("Account", "001xx000003DGb2AAG");
116
116
  ### Bulk Create
117
117
 
118
118
  ```typescript
119
- await salesforce.bulkCreate("Contact", [
119
+ await ctx.integrations.salesforce.bulkCreate("Contact", [
120
120
  { FirstName: "Alice", LastName: "Smith", Email: "alice@example.com" },
121
121
  { FirstName: "Bob", LastName: "Jones", Email: "bob@example.com" },
122
122
  { FirstName: "Charlie", LastName: "Lee", Email: "charlie@example.com" },
@@ -126,7 +126,7 @@ await salesforce.bulkCreate("Contact", [
126
126
  ### Bulk Update
127
127
 
128
128
  ```typescript
129
- await salesforce.bulkUpdate("Contact", [
129
+ await ctx.integrations.salesforce.bulkUpdate("Contact", [
130
130
  { Id: "003xx000004TmiQAAS", Email: "alice-new@example.com" },
131
131
  { Id: "003xx000004TmiRAAS", Email: "bob-new@example.com" },
132
132
  ]);
@@ -135,7 +135,7 @@ await salesforce.bulkUpdate("Contact", [
135
135
  ### Bulk Delete
136
136
 
137
137
  ```typescript
138
- await salesforce.bulkDelete("Contact", [
138
+ await ctx.integrations.salesforce.bulkDelete("Contact", [
139
139
  { Id: "003xx000004TmiQAAS" },
140
140
  { Id: "003xx000004TmiRAAS" },
141
141
  ]);
@@ -144,7 +144,7 @@ await salesforce.bulkDelete("Contact", [
144
144
  ### Bulk Upsert
145
145
 
146
146
  ```typescript
147
- await salesforce.bulkUpsert(
147
+ await ctx.integrations.salesforce.bulkUpsert(
148
148
  "Account",
149
149
  [
150
150
  { ExternalId__c: "EXT-001", Name: "Acme Corp", Industry: "Tech" },
@@ -198,12 +198,14 @@ Bulk update and delete records must include the `Id` field:
198
198
 
199
199
  ```typescript
200
200
  // CORRECT
201
- await salesforce.bulkUpdate("Contact", [
201
+ await ctx.integrations.salesforce.bulkUpdate("Contact", [
202
202
  { Id: "003xx000004TmiQAAS", Email: "new@example.com" },
203
203
  ]);
204
204
 
205
205
  // WRONG - Missing Id field
206
- await salesforce.bulkUpdate("Contact", [{ Email: "new@example.com" }]);
206
+ await ctx.integrations.salesforce.bulkUpdate("Contact", [
207
+ { Email: "new@example.com" },
208
+ ]);
207
209
  ```
208
210
 
209
211
  ## Error Handling
@@ -16,7 +16,6 @@ Send messages, manage channels, and interact with Slack workspaces.
16
16
  import { api, z, slack } from "@superblocksteam/sdk-api";
17
17
 
18
18
  const PostMessageResponseSchema = z.object({
19
- ok: z.boolean(),
20
19
  channel: z.string(),
21
20
  ts: z.string(), // Message timestamp (unique ID)
22
21
  message: z.object({
@@ -55,6 +54,10 @@ export default api({
55
54
  { response: PostMessageResponseSchema },
56
55
  );
57
56
 
57
+ if (!result.ok) {
58
+ throw new Error(`Slack API error: ${result.error}`);
59
+ }
60
+
58
61
  return { messageId: result.ts };
59
62
  },
60
63
  });
@@ -106,7 +109,6 @@ const result = await ctx.integrations.slack.apiRequest(
106
109
 
107
110
  ```typescript
108
111
  const ListChannelsResponseSchema = z.object({
109
- ok: z.boolean(),
110
112
  channels: z.array(
111
113
  z.object({
112
114
  id: z.string(),
@@ -135,6 +137,10 @@ const result = await ctx.integrations.slack.apiRequest(
135
137
  { response: ListChannelsResponseSchema },
136
138
  );
137
139
 
140
+ if (!result.ok) {
141
+ throw new Error(`Slack API error: ${result.error}`);
142
+ }
143
+
138
144
  result.channels.forEach((channel) => {
139
145
  console.log(`#${channel.name} (${channel.id})`);
140
146
  });
@@ -144,7 +150,6 @@ result.channels.forEach((channel) => {
144
150
 
145
151
  ```typescript
146
152
  const UserInfoResponseSchema = z.object({
147
- ok: z.boolean(),
148
153
  user: z.object({
149
154
  id: z.string(),
150
155
  name: z.string(),
@@ -167,6 +172,10 @@ const result = await ctx.integrations.slack.apiRequest(
167
172
  { response: UserInfoResponseSchema },
168
173
  );
169
174
 
175
+ if (!result.ok) {
176
+ throw new Error(`Slack API error: ${result.error}`);
177
+ }
178
+
170
179
  console.log(`User: ${result.user.real_name} (${result.user.profile.email})`);
171
180
  ```
172
181
 
@@ -174,7 +183,6 @@ console.log(`User: ${result.user.real_name} (${result.user.profile.email})`);
174
183
 
175
184
  ```typescript
176
185
  const FileUploadResponseSchema = z.object({
177
- ok: z.boolean(),
178
186
  file: z.object({
179
187
  id: z.string(),
180
188
  name: z.string(),
@@ -197,6 +205,10 @@ const result = await ctx.integrations.slack.apiRequest(
197
205
  { response: FileUploadResponseSchema },
198
206
  );
199
207
 
208
+ if (!result.ok) {
209
+ throw new Error(`Slack API error: ${result.error}`);
210
+ }
211
+
200
212
  console.log(`File uploaded: ${result.file.permalink}`);
201
213
  ```
202
214
 
@@ -221,7 +233,6 @@ const result = await ctx.integrations.slack.apiRequest(
221
233
 
222
234
  ```typescript
223
235
  const UpdateMessageResponseSchema = z.object({
224
- ok: z.boolean(),
225
236
  channel: z.string(),
226
237
  ts: z.string(),
227
238
  text: z.string(),
@@ -333,6 +344,10 @@ async function getAllChannels(slack: SlackClient) {
333
344
  { response: ListChannelsResponseSchema },
334
345
  );
335
346
 
347
+ if (!result.ok) {
348
+ throw new Error(`Slack API error: ${result.error}`);
349
+ }
350
+
336
351
  allChannels.push(...result.channels);
337
352
  cursor = result.response_metadata?.next_cursor;
338
353
  } while (cursor);
@@ -371,30 +386,58 @@ Code block
371
386
 
372
387
  ## Error Handling
373
388
 
389
+ Slack returns API errors as HTTP 200 with `{ ok: false, error: "error_code" }` instead of HTTP error status codes. The SDK surfaces these as the `SlackErrorResponse` branch of a discriminated union (`SlackResponse<T>`) — no exceptions, just check `result.ok`:
390
+
374
391
  ```typescript
375
- import { RestApiValidationError } from "@superblocksteam/sdk-api";
392
+ import type { SlackResponse } from "@superblocksteam/sdk-api";
393
+
394
+ const result = await ctx.integrations.slack.apiRequest(
395
+ { method: "POST", path: "/chat.postMessage", body: { channel, text } },
396
+ { response: PostMessageResponseSchema },
397
+ );
376
398
 
377
- try {
378
- const result = await ctx.integrations.slack.apiRequest(
379
- { method: "POST", path: "/chat.postMessage", body: { ... } },
380
- { response: PostMessageResponseSchema }
381
- );
399
+ if (!result.ok) {
400
+ // TypeScript narrows to SlackErrorResponse
401
+ console.error(`Slack error: ${result.error}`);
402
+ // e.g. "missing_scope", "channel_not_found", "not_authed"
382
403
 
383
- // Slack returns ok: false for API errors (not HTTP errors)
384
- if (!result.ok) {
385
- console.error("Slack API error");
386
- }
387
- } catch (error) {
388
- if (error instanceof RestApiValidationError) {
389
- console.error("Validation failed:", error.details.zodError);
404
+ if (result.needed) {
405
+ console.error(`Required scopes: ${result.needed}`);
406
+ // e.g. "chat:write"
390
407
  }
408
+ return;
391
409
  }
410
+
411
+ // TypeScript narrows to T & { ok: true } — all success fields accessible
412
+ console.log(`Sent message: ${result.ts}`);
392
413
  ```
393
414
 
415
+ ### SlackResponse\<T\>
416
+
417
+ Every `apiRequest` call returns `SlackResponse<T>`, a discriminated union:
418
+
419
+ | Branch | Shape | When |
420
+ | ------- | -------------------- | -------------------------------------------------------------------------- |
421
+ | Success | `T & { ok: true }` | Slack returned `ok: true`; response validated against your Zod schema |
422
+ | Error | `SlackErrorResponse` | Slack returned `ok: false`; contains `error`, optional `needed`/`provided` |
423
+
424
+ `T` is your payload schema output. Define payload fields only (do not include `ok` in your response schema) and the SDK injects `ok: true` for the discriminant on success.
425
+
426
+ **`SlackErrorResponse` fields:**
427
+
428
+ | Field | Type | Description |
429
+ | ---------- | --------- | ------------------------------------------------------------ |
430
+ | `ok` | `false` | Discriminant |
431
+ | `error` | `string` | Slack error code (e.g. `missing_scope`, `channel_not_found`) |
432
+ | `needed` | `string?` | Required OAuth scopes (present on `missing_scope` errors) |
433
+ | `provided` | `string?` | Current token scopes (present on `missing_scope` errors) |
434
+
435
+ Schema validation errors (Zod mismatch on a _success_ response) still throw `RestApiValidationError`. Body validation errors also throw. Only Slack's own `ok: false` errors are returned as values.
436
+
394
437
  ## API Reference
395
438
 
396
439
  - [Slack API Documentation](https://api.slack.com/methods)
397
440
  - [chat.postMessage](https://api.slack.com/methods/chat.postMessage)
398
441
  - [conversations.list](https://api.slack.com/methods/conversations.list)
399
- - [Block Kit Builder](https://app.slack.com/block-kit-builder)
400
442
  - [OAuth Scopes](https://api.slack.com/scopes)
443
+ - [Block Kit Builder](https://app.slack.com/block-kit-builder)