@superblocksteam/sdk-api 2.0.105-next.0 → 2.0.105-next.2
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 +202 -86
- 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 -10
- 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 -63
- package/dist/integrations/declarations.d.ts.map +1 -1
- package/dist/integrations/declarations.js +5 -59
- 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 -9
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/index.js +1 -6
- package/dist/integrations/index.js.map +1 -1
- package/dist/integrations/registry.d.ts +1 -10
- package/dist/integrations/registry.d.ts.map +1 -1
- package/dist/integrations/registry.js +0 -25
- 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 +14 -5
- 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 -30
- 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 -91
- 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/index.ts +0 -45
- package/src/integrations/registry.ts +1 -34
- 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 +14 -5
- 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/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
|
@@ -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
|
|
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", [
|
|
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)
|