@superblocksteam/sdk-api 2.0.105 → 2.0.106-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +439 -89
- package/dist/api/definition.d.ts +11 -6
- package/dist/api/definition.d.ts.map +1 -1
- package/dist/api/definition.js +19 -12
- package/dist/api/definition.js.map +1 -1
- package/dist/api/definition.test.js +39 -15
- package/dist/api/definition.test.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +1 -1
- package/dist/index.d.ts +10 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/integrations/base/index.d.ts +2 -1
- package/dist/integrations/base/index.d.ts.map +1 -1
- package/dist/integrations/base/index.js +1 -0
- package/dist/integrations/base/index.js.map +1 -1
- package/dist/integrations/base/rest-api-client-base.d.ts +48 -0
- package/dist/integrations/base/rest-api-client-base.d.ts.map +1 -0
- package/dist/integrations/base/rest-api-client-base.js +98 -0
- package/dist/integrations/base/rest-api-client-base.js.map +1 -0
- package/dist/integrations/base/rest-api-integration-client.d.ts +10 -20
- package/dist/integrations/base/rest-api-integration-client.d.ts.map +1 -1
- package/dist/integrations/base/rest-api-integration-client.js +10 -65
- package/dist/integrations/base/rest-api-integration-client.js.map +1 -1
- package/dist/integrations/box/types.d.ts +1 -1
- package/dist/integrations/declarations.d.ts +5 -73
- package/dist/integrations/declarations.d.ts.map +1 -1
- package/dist/integrations/declarations.js +5 -68
- package/dist/integrations/declarations.js.map +1 -1
- package/dist/integrations/documentation.test.js +0 -2
- package/dist/integrations/documentation.test.js.map +1 -1
- package/dist/integrations/googledrive/types.d.ts +1 -1
- package/dist/integrations/index.d.ts +1 -11
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/index.js +1 -7
- package/dist/integrations/index.js.map +1 -1
- package/dist/integrations/registry.d.ts +1 -11
- package/dist/integrations/registry.d.ts.map +1 -1
- package/dist/integrations/registry.js +0 -29
- package/dist/integrations/registry.js.map +1 -1
- package/dist/integrations/slack/client.d.ts +13 -9
- package/dist/integrations/slack/client.d.ts.map +1 -1
- package/dist/integrations/slack/client.js +60 -8
- package/dist/integrations/slack/client.js.map +1 -1
- package/dist/integrations/slack/client.test.d.ts +11 -0
- package/dist/integrations/slack/client.test.d.ts.map +1 -0
- package/dist/integrations/slack/client.test.js +368 -0
- package/dist/integrations/slack/client.test.js.map +1 -0
- package/dist/integrations/slack/index.d.ts +2 -1
- package/dist/integrations/slack/index.d.ts.map +1 -1
- package/dist/integrations/slack/index.js +1 -0
- package/dist/integrations/slack/index.js.map +1 -1
- package/dist/integrations/slack/types.d.ts +127 -28
- package/dist/integrations/slack/types.d.ts.map +1 -1
- package/dist/integrations/slack/types.js +27 -1
- package/dist/integrations/slack/types.js.map +1 -1
- package/dist/integrations/snowflake/client.d.ts +2 -2
- package/dist/integrations/snowflake/client.js +2 -2
- package/dist/runtime/context.d.ts +1 -1
- package/dist/runtime/executor.d.ts +2 -2
- package/dist/types.d.ts +15 -6
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/api/definition.test.ts +40 -15
- package/src/api/definition.ts +19 -12
- package/src/errors.ts +1 -1
- package/src/index.ts +13 -33
- package/src/integrations/asana/README.md +12 -12
- package/src/integrations/base/index.ts +2 -1
- package/src/integrations/base/rest-api-client-base.ts +134 -0
- package/src/integrations/base/rest-api-integration-client.ts +12 -89
- package/src/integrations/bitbucket/README.md +19 -19
- package/src/integrations/box/README.md +24 -24
- package/src/integrations/box/types.ts +1 -1
- package/src/integrations/circleci/README.md +18 -18
- package/src/integrations/declarations.ts +5 -105
- package/src/integrations/documentation.test.ts +0 -2
- package/src/integrations/googledrive/README.md +25 -22
- package/src/integrations/googledrive/types.ts +1 -1
- package/src/integrations/graphql/README.md +2 -2
- package/src/integrations/groq/README.md +8 -8
- package/src/integrations/index.ts +0 -51
- package/src/integrations/perplexity/README.md +39 -48
- package/src/integrations/registry.ts +1 -39
- package/src/integrations/salesforce/README.md +11 -9
- package/src/integrations/slack/README.md +62 -19
- package/src/integrations/slack/client.test.ts +553 -0
- package/src/integrations/slack/client.ts +92 -12
- package/src/integrations/slack/index.ts +6 -1
- package/src/integrations/slack/types.ts +142 -29
- package/src/integrations/snowflake/client.ts +2 -2
- package/src/integrations/zoom/README.md +15 -15
- package/src/runtime/context.ts +1 -1
- package/src/runtime/executor.ts +2 -2
- package/src/types.ts +15 -6
- package/dist/integrations/couchbase/client.d.ts +0 -36
- package/dist/integrations/couchbase/client.d.ts.map +0 -1
- package/dist/integrations/couchbase/client.js +0 -148
- package/dist/integrations/couchbase/client.js.map +0 -1
- package/dist/integrations/couchbase/index.d.ts +0 -8
- package/dist/integrations/couchbase/index.d.ts.map +0 -1
- package/dist/integrations/couchbase/index.js +0 -7
- package/dist/integrations/couchbase/index.js.map +0 -1
- package/dist/integrations/couchbase/types.d.ts +0 -100
- package/dist/integrations/couchbase/types.d.ts.map +0 -1
- package/dist/integrations/couchbase/types.js +0 -5
- package/dist/integrations/couchbase/types.js.map +0 -1
- package/dist/integrations/kafka/client.d.ts +0 -25
- package/dist/integrations/kafka/client.d.ts.map +0 -1
- package/dist/integrations/kafka/client.js +0 -124
- package/dist/integrations/kafka/client.js.map +0 -1
- package/dist/integrations/kafka/index.d.ts +0 -8
- package/dist/integrations/kafka/index.d.ts.map +0 -1
- package/dist/integrations/kafka/index.js +0 -7
- package/dist/integrations/kafka/index.js.map +0 -1
- package/dist/integrations/kafka/types.d.ts +0 -113
- package/dist/integrations/kafka/types.d.ts.map +0 -1
- package/dist/integrations/kafka/types.js +0 -5
- package/dist/integrations/kafka/types.js.map +0 -1
- package/dist/integrations/kinesis/client.d.ts +0 -31
- package/dist/integrations/kinesis/client.d.ts.map +0 -1
- package/dist/integrations/kinesis/client.js +0 -101
- package/dist/integrations/kinesis/client.js.map +0 -1
- package/dist/integrations/kinesis/index.d.ts +0 -8
- package/dist/integrations/kinesis/index.d.ts.map +0 -1
- package/dist/integrations/kinesis/index.js +0 -7
- package/dist/integrations/kinesis/index.js.map +0 -1
- package/dist/integrations/kinesis/types.d.ts +0 -97
- package/dist/integrations/kinesis/types.d.ts.map +0 -1
- package/dist/integrations/kinesis/types.js +0 -7
- package/dist/integrations/kinesis/types.js.map +0 -1
- package/dist/integrations/python/client.d.ts +0 -42
- package/dist/integrations/python/client.d.ts.map +0 -1
- package/dist/integrations/python/client.js +0 -89
- package/dist/integrations/python/client.js.map +0 -1
- package/dist/integrations/python/client.test.d.ts +0 -5
- package/dist/integrations/python/client.test.d.ts.map +0 -1
- package/dist/integrations/python/client.test.js +0 -214
- package/dist/integrations/python/client.test.js.map +0 -1
- package/dist/integrations/python/index.d.ts +0 -6
- package/dist/integrations/python/index.d.ts.map +0 -1
- package/dist/integrations/python/index.js +0 -5
- package/dist/integrations/python/index.js.map +0 -1
- package/dist/integrations/python/types.d.ts +0 -85
- package/dist/integrations/python/types.d.ts.map +0 -1
- package/dist/integrations/python/types.js +0 -5
- package/dist/integrations/python/types.js.map +0 -1
- package/dist/integrations/redis/client.d.ts +0 -43
- package/dist/integrations/redis/client.d.ts.map +0 -1
- package/dist/integrations/redis/client.js +0 -142
- package/dist/integrations/redis/client.js.map +0 -1
- package/dist/integrations/redis/index.d.ts +0 -8
- package/dist/integrations/redis/index.d.ts.map +0 -1
- package/dist/integrations/redis/index.js +0 -7
- package/dist/integrations/redis/index.js.map +0 -1
- package/dist/integrations/redis/types.d.ts +0 -137
- package/dist/integrations/redis/types.d.ts.map +0 -1
- package/dist/integrations/redis/types.js +0 -5
- package/dist/integrations/redis/types.js.map +0 -1
- package/src/integrations/couchbase/README.md +0 -138
- package/src/integrations/couchbase/client.ts +0 -225
- package/src/integrations/couchbase/index.ts +0 -8
- package/src/integrations/couchbase/types.ts +0 -126
- package/src/integrations/kafka/README.md +0 -144
- package/src/integrations/kafka/client.ts +0 -216
- package/src/integrations/kafka/index.ts +0 -14
- package/src/integrations/kafka/types.ts +0 -128
- package/src/integrations/kinesis/README.md +0 -153
- package/src/integrations/kinesis/client.ts +0 -146
- package/src/integrations/kinesis/index.ts +0 -14
- package/src/integrations/kinesis/types.ts +0 -114
- package/src/integrations/python/README.md +0 -566
- package/src/integrations/python/client.test.ts +0 -341
- package/src/integrations/python/client.ts +0 -136
- package/src/integrations/python/index.ts +0 -6
- package/src/integrations/python/types.ts +0 -92
- package/src/integrations/redis/README.md +0 -200
- package/src/integrations/redis/client.ts +0 -208
- package/src/integrations/redis/index.ts +0 -8
- package/src/integrations/redis/types.ts +0 -167
|
@@ -58,7 +58,7 @@ export default api({
|
|
|
58
58
|
method: "POST",
|
|
59
59
|
path: "/chat/completions",
|
|
60
60
|
body: {
|
|
61
|
-
model: "
|
|
61
|
+
model: "sonar-pro",
|
|
62
62
|
messages: [
|
|
63
63
|
{
|
|
64
64
|
role: "system",
|
|
@@ -82,40 +82,40 @@ export default api({
|
|
|
82
82
|
### Using Different Models
|
|
83
83
|
|
|
84
84
|
```typescript
|
|
85
|
-
//
|
|
86
|
-
const
|
|
85
|
+
// Standard search model - Fast, lightweight
|
|
86
|
+
const result = await ctx.integrations.perplexity.apiRequest(
|
|
87
87
|
{
|
|
88
88
|
method: "POST",
|
|
89
89
|
path: "/chat/completions",
|
|
90
90
|
body: {
|
|
91
|
-
model: "
|
|
91
|
+
model: "sonar", // Fast search
|
|
92
92
|
messages: [{ role: "user", content: "What's the latest news about AI?" }],
|
|
93
93
|
},
|
|
94
94
|
},
|
|
95
95
|
{ response: ChatCompletionResponseSchema },
|
|
96
96
|
);
|
|
97
97
|
|
|
98
|
-
//
|
|
99
|
-
const
|
|
98
|
+
// Pro search model - Deeper content understanding
|
|
99
|
+
const proResult = await ctx.integrations.perplexity.apiRequest(
|
|
100
100
|
{
|
|
101
101
|
method: "POST",
|
|
102
102
|
path: "/chat/completions",
|
|
103
103
|
body: {
|
|
104
|
-
model: "
|
|
104
|
+
model: "sonar-pro", // Advanced search
|
|
105
105
|
messages: [{ role: "user", content: "Explain quantum computing" }],
|
|
106
106
|
},
|
|
107
107
|
},
|
|
108
108
|
{ response: ChatCompletionResponseSchema },
|
|
109
109
|
);
|
|
110
110
|
|
|
111
|
-
//
|
|
112
|
-
const
|
|
111
|
+
// Reasoning model - Multi-step Chain-of-Thought
|
|
112
|
+
const reasoningResult = await ctx.integrations.perplexity.apiRequest(
|
|
113
113
|
{
|
|
114
114
|
method: "POST",
|
|
115
115
|
path: "/chat/completions",
|
|
116
116
|
body: {
|
|
117
|
-
model: "
|
|
118
|
-
messages: [{ role: "user", content: "
|
|
117
|
+
model: "sonar-reasoning-pro",
|
|
118
|
+
messages: [{ role: "user", content: "Analyze the pros and cons of..." }],
|
|
119
119
|
},
|
|
120
120
|
},
|
|
121
121
|
{ response: ChatCompletionResponseSchema },
|
|
@@ -130,7 +130,7 @@ const result = await ctx.integrations.perplexity.apiRequest(
|
|
|
130
130
|
method: "POST",
|
|
131
131
|
path: "/chat/completions",
|
|
132
132
|
body: {
|
|
133
|
-
model: "
|
|
133
|
+
model: "sonar-pro",
|
|
134
134
|
messages: [
|
|
135
135
|
{
|
|
136
136
|
role: "user",
|
|
@@ -152,7 +152,7 @@ const result = await ctx.integrations.perplexity.apiRequest(
|
|
|
152
152
|
method: "POST",
|
|
153
153
|
path: "/chat/completions",
|
|
154
154
|
body: {
|
|
155
|
-
model: "
|
|
155
|
+
model: "sonar-pro",
|
|
156
156
|
messages: [
|
|
157
157
|
{ role: "user", content: "Recent developments in electric vehicles" },
|
|
158
158
|
],
|
|
@@ -171,7 +171,7 @@ const result = await ctx.integrations.perplexity.apiRequest(
|
|
|
171
171
|
method: "POST",
|
|
172
172
|
path: "/chat/completions",
|
|
173
173
|
body: {
|
|
174
|
-
model: "
|
|
174
|
+
model: "sonar",
|
|
175
175
|
messages: [
|
|
176
176
|
{ role: "user", content: "What is the capital of France?" },
|
|
177
177
|
{ role: "assistant", content: "The capital of France is Paris." },
|
|
@@ -203,16 +203,22 @@ await ctx.integrations.perplexity.apiRequest(
|
|
|
203
203
|
);
|
|
204
204
|
```
|
|
205
205
|
|
|
206
|
-
###
|
|
206
|
+
### Model Selection
|
|
207
207
|
|
|
208
|
-
|
|
208
|
+
Choose the right model for your use case:
|
|
209
209
|
|
|
210
210
|
```typescript
|
|
211
|
-
// For
|
|
212
|
-
const model = "
|
|
211
|
+
// For quick answers with web search
|
|
212
|
+
const model = "sonar";
|
|
213
|
+
|
|
214
|
+
// For complex queries requiring deeper understanding
|
|
215
|
+
const model = "sonar-pro";
|
|
213
216
|
|
|
214
|
-
// For
|
|
215
|
-
const model = "
|
|
217
|
+
// For multi-step reasoning tasks
|
|
218
|
+
const model = "sonar-reasoning-pro";
|
|
219
|
+
|
|
220
|
+
// For in-depth research
|
|
221
|
+
const model = "sonar-deep-research";
|
|
216
222
|
```
|
|
217
223
|
|
|
218
224
|
### Citations May Be Empty
|
|
@@ -229,47 +235,32 @@ if (sources.length === 0) {
|
|
|
229
235
|
}
|
|
230
236
|
```
|
|
231
237
|
|
|
232
|
-
###
|
|
238
|
+
### Available Models
|
|
233
239
|
|
|
234
|
-
Perplexity
|
|
240
|
+
Perplexity offers the following Sonar models. Check the [Perplexity models page](https://docs.perplexity.ai/docs/sonar/models) for the latest options:
|
|
235
241
|
|
|
236
242
|
```typescript
|
|
237
|
-
// Pattern: llama-3.1-sonar-{size}-{context}-{type}
|
|
238
|
-
// These are examples — verify current model names in the Perplexity docs
|
|
239
243
|
const models = [
|
|
240
|
-
"
|
|
241
|
-
"
|
|
242
|
-
"
|
|
243
|
-
"
|
|
244
|
+
"sonar", // Fast, lightweight search
|
|
245
|
+
"sonar-pro", // Advanced search with deeper understanding
|
|
246
|
+
"sonar-reasoning-pro", // Multi-step Chain-of-Thought reasoning
|
|
247
|
+
"sonar-deep-research", // In-depth research for complex queries
|
|
244
248
|
];
|
|
245
249
|
```
|
|
246
250
|
|
|
247
|
-
### Search Parameters
|
|
251
|
+
### Search Parameters
|
|
248
252
|
|
|
249
|
-
|
|
250
|
-
// WRONG - search_domain_filter with chat model
|
|
251
|
-
await ctx.integrations.perplexity.apiRequest(
|
|
252
|
-
{
|
|
253
|
-
method: "POST",
|
|
254
|
-
path: "/chat/completions",
|
|
255
|
-
body: {
|
|
256
|
-
model: "llama-3.1-sonar-large-128k-chat", // Chat model
|
|
257
|
-
messages: [...],
|
|
258
|
-
search_domain_filter: ["example.com"], // Ignored!
|
|
259
|
-
},
|
|
260
|
-
},
|
|
261
|
-
{ response: schema }
|
|
262
|
-
);
|
|
253
|
+
All Sonar models support search by default. You can use search filters to refine results:
|
|
263
254
|
|
|
264
|
-
|
|
255
|
+
```typescript
|
|
265
256
|
await ctx.integrations.perplexity.apiRequest(
|
|
266
257
|
{
|
|
267
258
|
method: "POST",
|
|
268
259
|
path: "/chat/completions",
|
|
269
260
|
body: {
|
|
270
|
-
model: "
|
|
261
|
+
model: "sonar-pro",
|
|
271
262
|
messages: [...],
|
|
272
|
-
search_domain_filter: ["example.com"], //
|
|
263
|
+
search_domain_filter: ["example.com"], // Limit search to specific domains
|
|
273
264
|
},
|
|
274
265
|
},
|
|
275
266
|
{ response: schema }
|
|
@@ -296,5 +287,5 @@ try {
|
|
|
296
287
|
## API Reference
|
|
297
288
|
|
|
298
289
|
- [Perplexity API Documentation](https://docs.perplexity.ai/)
|
|
299
|
-
- [
|
|
300
|
-
- [Models](https://docs.perplexity.ai/docs/
|
|
290
|
+
- [Sonar API](https://docs.perplexity.ai/api-reference/sonar-post)
|
|
291
|
+
- [Models](https://docs.perplexity.ai/docs/sonar/models)
|
|
@@ -57,15 +57,11 @@ 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
|
-
import { RedisClientImpl } from "./redis/index.js";
|
|
69
65
|
import { S3ClientImpl } from "./s3/index.js";
|
|
70
66
|
import { SalesforceClientImpl } from "./salesforce/index.js";
|
|
71
67
|
import { SmtpClientImpl } from "./smtp/index.js";
|
|
@@ -73,8 +69,6 @@ import { SnowflakePostgresClientImpl } from "./snowflakepostgres/index.js";
|
|
|
73
69
|
import { SuperblocksOCRClientImpl } from "./superblocks-ocr/index.js";
|
|
74
70
|
// REST API plugins
|
|
75
71
|
import { RestApiIntegrationPluginClientImpl } from "./restapiintegration/index.js";
|
|
76
|
-
// Code execution clients
|
|
77
|
-
import { PythonClientImpl } from "./python/index.js";
|
|
78
72
|
|
|
79
73
|
/**
|
|
80
74
|
* Supported plugin IDs mapped to their client constructors.
|
|
@@ -133,18 +127,11 @@ export const SUPPORTED_PLUGINS = {
|
|
|
133
127
|
mongodb: "mongodb",
|
|
134
128
|
dynamodb: "dynamodb",
|
|
135
129
|
cosmosdb: "cosmosdb",
|
|
136
|
-
couchbase: "couchbase",
|
|
137
130
|
s3: "s3",
|
|
138
131
|
gcs: "gcs",
|
|
139
132
|
gsheets: "gsheets",
|
|
140
|
-
kafka: "kafka",
|
|
141
|
-
kinesis: "kinesis",
|
|
142
133
|
salesforce: "salesforce",
|
|
143
|
-
redis: "redis",
|
|
144
134
|
"superblocks-ocr": "superblocks-ocr",
|
|
145
|
-
// Kafka-compatible streaming
|
|
146
|
-
confluent: "confluent",
|
|
147
|
-
redpanda: "redpanda",
|
|
148
135
|
// SQL databases (continued)
|
|
149
136
|
lakebase: "lakebase",
|
|
150
137
|
snowflakepostgres: "snowflakepostgres",
|
|
@@ -152,8 +139,6 @@ export const SUPPORTED_PLUGINS = {
|
|
|
152
139
|
smtp: "smtp",
|
|
153
140
|
// REST API plugins
|
|
154
141
|
restapiintegration: "restapiintegration",
|
|
155
|
-
// Code execution
|
|
156
|
-
python: "python",
|
|
157
142
|
} as const;
|
|
158
143
|
|
|
159
144
|
export type SupportedPluginId =
|
|
@@ -183,11 +168,8 @@ export interface TraceMetadata {
|
|
|
183
168
|
* Accepts a plugin request object that matches the protobuf Plugin definition
|
|
184
169
|
* for the specific integration type (e.g., postgresql.v1.Plugin, restapi.v1.Plugin).
|
|
185
170
|
*
|
|
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
171
|
* @param request - Plugin-specific request object matching the proto schema
|
|
190
|
-
* @param bindings - Optional bindings data for binding resolution
|
|
172
|
+
* @param bindings - Optional bindings data for binding resolution
|
|
191
173
|
* @param metadata - Optional trace metadata (label, description) for diagnostics
|
|
192
174
|
* @returns Promise resolving to the operation result
|
|
193
175
|
*/
|
|
@@ -392,9 +374,6 @@ export function createClient(
|
|
|
392
374
|
case SUPPORTED_PLUGINS.cosmosdb:
|
|
393
375
|
return new CosmosDBClientImpl(config, executeQuery);
|
|
394
376
|
|
|
395
|
-
case SUPPORTED_PLUGINS.couchbase:
|
|
396
|
-
return new CouchbaseClientImpl(config, executeQuery);
|
|
397
|
-
|
|
398
377
|
case SUPPORTED_PLUGINS.s3:
|
|
399
378
|
return new S3ClientImpl(config, executeQuery);
|
|
400
379
|
|
|
@@ -404,26 +383,12 @@ export function createClient(
|
|
|
404
383
|
case SUPPORTED_PLUGINS.gsheets:
|
|
405
384
|
return new GoogleSheetsClientImpl(config, executeQuery);
|
|
406
385
|
|
|
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
386
|
case SUPPORTED_PLUGINS.salesforce:
|
|
414
387
|
return new SalesforceClientImpl(config, executeQuery);
|
|
415
388
|
|
|
416
|
-
case SUPPORTED_PLUGINS.redis:
|
|
417
|
-
return new RedisClientImpl(config, executeQuery);
|
|
418
|
-
|
|
419
389
|
case SUPPORTED_PLUGINS["superblocks-ocr"]:
|
|
420
390
|
return new SuperblocksOCRClientImpl(config, executeQuery);
|
|
421
391
|
|
|
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
392
|
case SUPPORTED_PLUGINS.lakebase:
|
|
428
393
|
return new LakebaseClientImpl(config, executeQuery);
|
|
429
394
|
|
|
@@ -436,9 +401,6 @@ export function createClient(
|
|
|
436
401
|
case SUPPORTED_PLUGINS.restapiintegration:
|
|
437
402
|
return new RestApiIntegrationPluginClientImpl(config, executeQuery);
|
|
438
403
|
|
|
439
|
-
case SUPPORTED_PLUGINS.python:
|
|
440
|
-
return new PythonClientImpl(config, executeQuery);
|
|
441
|
-
|
|
442
404
|
default:
|
|
443
405
|
throw new Error(
|
|
444
406
|
`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", [
|
|
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 {
|
|
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
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
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
|
-
|
|
384
|
-
|
|
385
|
-
|
|
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)
|