@superblocksteam/sdk-api 2.0.103-next.0 → 2.0.104-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 +58 -299
- package/dist/api/definition.js +1 -1
- package/dist/api/definition.js.map +1 -1
- package/dist/api/index.d.ts +0 -2
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +0 -2
- package/dist/api/index.js.map +1 -1
- package/dist/errors.d.ts +0 -44
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +0 -32
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -9
- package/dist/index.js.map +1 -1
- package/dist/integrations/anthropic/types.d.ts +3 -22
- package/dist/integrations/anthropic/types.d.ts.map +1 -1
- package/dist/integrations/base/index.d.ts +1 -1
- package/dist/integrations/base/index.d.ts.map +1 -1
- package/dist/integrations/base/rest-api-integration-client.d.ts +4 -48
- package/dist/integrations/base/rest-api-integration-client.d.ts.map +1 -1
- package/dist/integrations/base/rest-api-integration-client.js +2 -110
- package/dist/integrations/base/rest-api-integration-client.js.map +1 -1
- package/dist/integrations/base/types.d.ts +1 -67
- package/dist/integrations/base/types.d.ts.map +1 -1
- package/dist/integrations/index.d.ts +1 -1
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/index.js.map +1 -1
- package/dist/integrations/openai_v2/types.d.ts +4 -22
- package/dist/integrations/openai_v2/types.d.ts.map +1 -1
- package/dist/integrations/registry.d.ts +0 -16
- package/dist/integrations/registry.d.ts.map +1 -1
- package/dist/integrations/registry.js +38 -38
- package/dist/integrations/registry.js.map +1 -1
- package/dist/integrations/registry.test.js +1 -3
- package/dist/integrations/registry.test.js.map +1 -1
- package/dist/integrations/restapiintegration/types.d.ts +2 -2
- package/dist/integrations/restapiintegration/types.d.ts.map +1 -1
- package/dist/integrations/snowflakecortex/client.d.ts +1 -2
- package/dist/integrations/snowflakecortex/client.d.ts.map +1 -1
- package/dist/integrations/snowflakecortex/client.js +1 -2
- package/dist/integrations/snowflakecortex/client.js.map +1 -1
- package/dist/integrations/snowflakecortex/types.d.ts +3 -4
- package/dist/integrations/snowflakecortex/types.d.ts.map +1 -1
- package/dist/runtime/index.d.ts +0 -3
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +1 -6
- package/dist/runtime/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/definition.ts +1 -1
- package/src/api/index.ts +0 -4
- package/src/errors.ts +0 -48
- package/src/index.ts +2 -28
- package/src/integrations/anthropic/README.md +5 -101
- package/src/integrations/anthropic/types.ts +3 -29
- package/src/integrations/base/index.ts +0 -2
- package/src/integrations/base/rest-api-integration-client.ts +4 -153
- package/src/integrations/base/types.ts +3 -74
- package/src/integrations/cohere/README.md +11 -11
- package/src/integrations/fireworks/README.md +43 -17
- package/src/integrations/googleanalytics/README.md +2 -2
- package/src/integrations/googledrive/README.md +2 -2
- package/src/integrations/groq/README.md +41 -34
- package/src/integrations/gsheets/README.md +2 -2
- package/src/integrations/index.ts +0 -1
- package/src/integrations/launchdarkly/README.md +2 -2
- package/src/integrations/mistral/README.md +39 -13
- package/src/integrations/openai_v2/README.md +44 -116
- package/src/integrations/openai_v2/types.ts +4 -29
- package/src/integrations/pagerduty/README.md +2 -2
- package/src/integrations/perplexity/README.md +2 -1
- package/src/integrations/registry.test.ts +1 -3
- package/src/integrations/registry.ts +38 -127
- package/src/integrations/restapiintegration/README.md +4 -43
- package/src/integrations/restapiintegration/types.ts +2 -8
- package/src/integrations/sendgrid/README.md +2 -2
- package/src/integrations/snowflakecortex/README.md +4 -53
- package/src/integrations/snowflakecortex/client.ts +2 -3
- package/src/integrations/snowflakecortex/types.ts +3 -11
- package/src/integrations/stabilityai/README.md +2 -2
- package/src/runtime/index.ts +1 -23
- package/dist/api/streaming.d.ts +0 -229
- package/dist/api/streaming.d.ts.map +0 -1
- package/dist/api/streaming.js +0 -107
- package/dist/api/streaming.js.map +0 -1
- package/dist/api/streaming.test.d.ts +0 -5
- package/dist/api/streaming.test.d.ts.map +0 -1
- package/dist/api/streaming.test.js +0 -364
- package/dist/api/streaming.test.js.map +0 -1
- package/dist/runtime/execute.d.ts +0 -128
- package/dist/runtime/execute.d.ts.map +0 -1
- package/dist/runtime/execute.js +0 -84
- package/dist/runtime/execute.js.map +0 -1
- package/dist/runtime/streaming-context.d.ts +0 -49
- package/dist/runtime/streaming-context.d.ts.map +0 -1
- package/dist/runtime/streaming-context.js +0 -71
- package/dist/runtime/streaming-context.js.map +0 -1
- package/dist/runtime/streaming-executor.d.ts +0 -159
- package/dist/runtime/streaming-executor.d.ts.map +0 -1
- package/dist/runtime/streaming-executor.js +0 -229
- package/dist/runtime/streaming-executor.js.map +0 -1
- package/src/api/streaming.test.ts +0 -433
- package/src/api/streaming.ts +0 -303
- package/src/runtime/execute.ts +0 -221
- package/src/runtime/streaming-context.ts +0 -164
- 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 `
|
|
86
|
+
The `executeApi()` function runs a compiled API with the required inputs:
|
|
87
87
|
|
|
88
88
|
```typescript
|
|
89
|
-
import {
|
|
89
|
+
import { executeApi } from '@superblocksteam/sdk-api';
|
|
90
90
|
|
|
91
|
-
const response = await
|
|
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 `
|
|
163
|
+
The complete request interface for `executeApi()`:
|
|
185
164
|
|
|
186
165
|
```typescript
|
|
187
|
-
interface
|
|
166
|
+
interface ExecuteApiRequest {
|
|
188
167
|
/** Raw input data to be validated */
|
|
189
168
|
input: unknown;
|
|
190
169
|
|
|
@@ -206,21 +185,12 @@ interface UnifiedExecuteApiRequest {
|
|
|
206
185
|
request: Record<string, unknown>, // Plugin-specific request matching protobuf schema
|
|
207
186
|
bindings?: Record<string, unknown>, // For language plugins (Python/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
|
-
|
|
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:
|
|
@@ -323,8 +282,6 @@ export default api({
|
|
|
323
282
|
|
|
324
283
|
Defines a TypeScript-based API with input/output validation. Returns a complete result when the `run` function completes.
|
|
325
284
|
|
|
326
|
-
For streaming responses (e.g., LLM token streaming), see [`streamingApi()`](#streamingapiconfig) below.
|
|
327
|
-
|
|
328
285
|
#### Required Fields
|
|
329
286
|
|
|
330
287
|
| Field | Type | Description |
|
|
@@ -364,82 +321,6 @@ const myApi = api({
|
|
|
364
321
|
});
|
|
365
322
|
```
|
|
366
323
|
|
|
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
324
|
### Context (`ctx`) and Input
|
|
444
325
|
|
|
445
326
|
The `run` function receives two arguments:
|
|
@@ -534,48 +415,48 @@ async run(ctx, { userId }) {
|
|
|
534
415
|
|
|
535
416
|
#### Method Availability by Client
|
|
536
417
|
|
|
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)
|
|
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)
|
|
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
|
|
578
|
-
| **RestApiIntegrationPluginClient** | `apiRequest(options, schema)
|
|
418
|
+
| Client | Available Methods | Notes |
|
|
419
|
+
| ---------------------------------- | ------------------------------------------------------------------------------ | ------------------------------------------------------------------ |
|
|
420
|
+
| **PostgresClient** | `query<T>(sql, schema, params?)`, `execute(sql, params?)` | Schema parameter is REQUIRED for query() |
|
|
421
|
+
| **SnowflakeClient** | `query<T>(sql, schema, params?)`, `execute(sql, params?)` | Schema parameter is REQUIRED for query() |
|
|
422
|
+
| **PythonClient** | `run<T>(code, schema, bindings?)` | Schema parameter is REQUIRED, bindings via {{}} syntax |
|
|
423
|
+
| **AirtableClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
424
|
+
| **AnthropicClient** | `apiRequest(options, schema)` | Claude AI models |
|
|
425
|
+
| **AsanaClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
426
|
+
| **BitbucketClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
427
|
+
| **BoxClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
428
|
+
| **CircleCIClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
429
|
+
| **CohereClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
430
|
+
| **ConfluenceClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
431
|
+
| **DatadogClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
432
|
+
| **DropboxClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
433
|
+
| **ElasticSearchClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
434
|
+
| **FireworksClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
435
|
+
| **FrontClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
436
|
+
| **GeminiClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
437
|
+
| **GitHubClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest - no createIssue, etc. |
|
|
438
|
+
| **GoogleAnalyticsClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
439
|
+
| **GoogleDriveClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
440
|
+
| **GraphQLClient** | `query(query, variables?, schema?)`, `mutation(mutation, variables?, schema?)` | GraphQL-specific methods |
|
|
441
|
+
| **GroqClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
442
|
+
| **HubSpotClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
443
|
+
| **IntercomClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
444
|
+
| **JiraClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
445
|
+
| **LaunchDarklyClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
446
|
+
| **MistralClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
447
|
+
| **NotionClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest - no queryDatabase, etc. |
|
|
448
|
+
| **OpenAIClient** | `apiRequest(options, schema)` | GPT AI models |
|
|
449
|
+
| **PagerDutyClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
450
|
+
| **PerplexityClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
451
|
+
| **SegmentClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
452
|
+
| **SendGridClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
453
|
+
| **SlackClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest - no specialized methods |
|
|
454
|
+
| **StabilityAIClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
455
|
+
| **StripeClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest - no createCustomer, etc. |
|
|
456
|
+
| **TwilioClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
457
|
+
| **ZendeskClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
458
|
+
| **ZoomClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
459
|
+
| **RestApiIntegrationPluginClient** | `apiRequest(options, schema)` | Generic REST API Integration - works with any configured HTTP API. |
|
|
579
460
|
|
|
580
461
|
#### Common Mistakes to Avoid
|
|
581
462
|
|
|
@@ -786,99 +667,6 @@ export default api({
|
|
|
786
667
|
| `body?` | `z.ZodSchema<TBody>` | Optional Zod schema for request body validation (required if body is provided) |
|
|
787
668
|
| `response` | `z.ZodSchema<TResponse>` | **Required** Zod schema for response validation |
|
|
788
669
|
|
|
789
|
-
## Streaming API Requests
|
|
790
|
-
|
|
791
|
-
For real-time streaming responses (e.g., LLM token streaming), use `streamApiRequest()`. This method returns an `AsyncIterable` that yields validated chunks as they arrive.
|
|
792
|
-
|
|
793
|
-
```typescript
|
|
794
|
-
import { streamingApi, z, anthropic } from "@superblocksteam/sdk-api";
|
|
795
|
-
|
|
796
|
-
// Integration ID from the integrations panel
|
|
797
|
-
const PROD_ANTHROPIC = "d4e5f6g7-8901-23ab-cdef-ghijklmnopqr";
|
|
798
|
-
|
|
799
|
-
// Define schema for Anthropic SSE events
|
|
800
|
-
const AnthropicStreamEventSchema = z.discriminatedUnion("type", [
|
|
801
|
-
z.object({
|
|
802
|
-
type: z.literal("content_block_delta"),
|
|
803
|
-
index: z.number(),
|
|
804
|
-
delta: z.object({
|
|
805
|
-
type: z.literal("text_delta"),
|
|
806
|
-
text: z.string(),
|
|
807
|
-
}),
|
|
808
|
-
}),
|
|
809
|
-
z.object({ type: z.literal("message_start"), message: z.any() }),
|
|
810
|
-
z.object({
|
|
811
|
-
type: z.literal("content_block_start"),
|
|
812
|
-
index: z.number(),
|
|
813
|
-
content_block: z.any(),
|
|
814
|
-
}),
|
|
815
|
-
z.object({ type: z.literal("content_block_stop"), index: z.number() }),
|
|
816
|
-
z.object({
|
|
817
|
-
type: z.literal("message_delta"),
|
|
818
|
-
delta: z.any(),
|
|
819
|
-
usage: z.any(),
|
|
820
|
-
}),
|
|
821
|
-
z.object({ type: z.literal("message_stop") }),
|
|
822
|
-
z.object({ type: z.literal("ping") }),
|
|
823
|
-
]);
|
|
824
|
-
|
|
825
|
-
export default streamingApi({
|
|
826
|
-
name: "StreamAnthropicChat",
|
|
827
|
-
|
|
828
|
-
integrations: {
|
|
829
|
-
ai: anthropic(PROD_ANTHROPIC),
|
|
830
|
-
},
|
|
831
|
-
|
|
832
|
-
input: z.object({ prompt: z.string() }),
|
|
833
|
-
chunk: z.object({ type: z.literal("text"), text: z.string() }),
|
|
834
|
-
|
|
835
|
-
async *run(ctx, { prompt }) {
|
|
836
|
-
const stream = ctx.integrations.ai.streamApiRequest(
|
|
837
|
-
{
|
|
838
|
-
method: "POST",
|
|
839
|
-
path: "/v1/messages",
|
|
840
|
-
body: {
|
|
841
|
-
model: "claude-3-5-sonnet-20241022",
|
|
842
|
-
max_tokens: 1024,
|
|
843
|
-
stream: true,
|
|
844
|
-
messages: [{ role: "user", content: prompt }],
|
|
845
|
-
},
|
|
846
|
-
},
|
|
847
|
-
{ chunk: AnthropicStreamEventSchema },
|
|
848
|
-
);
|
|
849
|
-
|
|
850
|
-
for await (const event of stream) {
|
|
851
|
-
if (event.type === "content_block_delta") {
|
|
852
|
-
yield { type: "text" as const, text: event.delta.text };
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
},
|
|
856
|
-
});
|
|
857
|
-
```
|
|
858
|
-
|
|
859
|
-
### StreamApiRequestOptions
|
|
860
|
-
|
|
861
|
-
Same as `ApiRequestOptions` - see above.
|
|
862
|
-
|
|
863
|
-
### StreamApiRequestSchema
|
|
864
|
-
|
|
865
|
-
| Property | Type | Description |
|
|
866
|
-
| -------- | --------------------- | ------------------------------------------------------------------------------ |
|
|
867
|
-
| `body?` | `z.ZodSchema<TBody>` | Optional Zod schema for request body validation (required if body is provided) |
|
|
868
|
-
| `chunk` | `z.ZodSchema<TChunk>` | **Required** Zod schema for validating each streamed chunk |
|
|
869
|
-
|
|
870
|
-
### Supported Integrations
|
|
871
|
-
|
|
872
|
-
Streaming is supported by REST API-based integrations that connect to services with SSE (Server-Sent Events) endpoints:
|
|
873
|
-
|
|
874
|
-
- **AnthropicClient** - Claude streaming messages
|
|
875
|
-
- **OpenAIClient** - GPT streaming chat completions
|
|
876
|
-
- **CohereClient** - Streaming text generation
|
|
877
|
-
- **GroqClient** - Streaming completions
|
|
878
|
-
- **MistralClient** - Streaming chat
|
|
879
|
-
- **FireworksClient** - Streaming inference
|
|
880
|
-
- **PerplexityClient** - Streaming search responses
|
|
881
|
-
|
|
882
670
|
## Trace Metadata
|
|
883
671
|
|
|
884
672
|
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.
|
|
@@ -916,7 +704,7 @@ await ctx.integrations.db.execute(
|
|
|
916
704
|
{ label: "Update last login" },
|
|
917
705
|
);
|
|
918
706
|
|
|
919
|
-
// REST API clients (apiRequest
|
|
707
|
+
// REST API clients (apiRequest)
|
|
920
708
|
const result = await ctx.integrations.slack.apiRequest(
|
|
921
709
|
{ method: "POST", path: "/chat.postMessage", body: { channel, text } },
|
|
922
710
|
{ body: BodySchema, response: ResponseSchema },
|
|
@@ -957,23 +745,21 @@ import {
|
|
|
957
745
|
OutputValidationError,
|
|
958
746
|
QueryValidationError,
|
|
959
747
|
RestApiValidationError,
|
|
960
|
-
StreamChunkValidationError,
|
|
961
748
|
IntegrationNotFoundError,
|
|
962
749
|
ExecutionError,
|
|
963
750
|
ErrorCode,
|
|
964
751
|
} from "@superblocksteam/sdk-api";
|
|
965
752
|
```
|
|
966
753
|
|
|
967
|
-
| Error Type
|
|
968
|
-
|
|
|
969
|
-
| `InputValidationError`
|
|
970
|
-
| `OutputValidationError`
|
|
971
|
-
| `QueryValidationError`
|
|
972
|
-
| `RestApiValidationError`
|
|
973
|
-
| `
|
|
974
|
-
| `
|
|
975
|
-
| `
|
|
976
|
-
| `ExecutionError` | `EXECUTION_ERROR` | User code threw an error |
|
|
754
|
+
| Error Type | Code | Description |
|
|
755
|
+
| -------------------------- | ----------------------- | -------------------------------------------------- |
|
|
756
|
+
| `InputValidationError` | `INPUT_VALIDATION` | Input failed Zod validation |
|
|
757
|
+
| `OutputValidationError` | `OUTPUT_VALIDATION` | Output failed Zod validation |
|
|
758
|
+
| `QueryValidationError` | N/A | Database query result validation failed (Postgres) |
|
|
759
|
+
| `RestApiValidationError` | N/A | REST API request/response validation failed |
|
|
760
|
+
| `IntegrationNotFoundError` | `INTEGRATION_NOT_FOUND` | Integration not configured |
|
|
761
|
+
| `IntegrationError` | `INTEGRATION_ERROR` | Integration operation failed |
|
|
762
|
+
| `ExecutionError` | `EXECUTION_ERROR` | User code threw an error |
|
|
977
763
|
|
|
978
764
|
### QueryValidationError (Postgres)
|
|
979
765
|
|
|
@@ -1030,33 +816,6 @@ The `RestApiValidationError` provides complete context for debugging:
|
|
|
1030
816
|
- **The actual data** that failed validation
|
|
1031
817
|
- **Utility methods** like `format()` and `flatten()` for different error representations
|
|
1032
818
|
|
|
1033
|
-
### StreamChunkValidationError
|
|
1034
|
-
|
|
1035
|
-
Thrown when a streamed chunk fails schema validation. Includes the chunk index, the raw chunk data, and the Zod error.
|
|
1036
|
-
|
|
1037
|
-
```typescript
|
|
1038
|
-
import { execute, StreamChunkValidationError } from "@superblocksteam/sdk-api";
|
|
1039
|
-
|
|
1040
|
-
try {
|
|
1041
|
-
// execute() returns an AsyncGenerator for streaming APIs
|
|
1042
|
-
for await (const chunk of execute(streamingApi, request)) {
|
|
1043
|
-
// Process chunk
|
|
1044
|
-
}
|
|
1045
|
-
} catch (error) {
|
|
1046
|
-
if (error instanceof StreamChunkValidationError) {
|
|
1047
|
-
console.error("Chunk index:", error.details.chunkIndex);
|
|
1048
|
-
console.error("Raw chunk:", error.details.chunk);
|
|
1049
|
-
console.error("Validation error:", error.details.zodError);
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
```
|
|
1053
|
-
|
|
1054
|
-
The `StreamChunkValidationError` provides:
|
|
1055
|
-
|
|
1056
|
-
- **Chunk index** (`chunkIndex`) - Which chunk in the stream failed
|
|
1057
|
-
- **Raw chunk data** (`chunk`) - The actual data that failed validation
|
|
1058
|
-
- **Full Zod error** (`zodError`) - Complete validation error details
|
|
1059
|
-
|
|
1060
819
|
## Best Practices
|
|
1061
820
|
|
|
1062
821
|
### Push Filtering Down to the Data Source
|
package/dist/api/definition.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { extractIntegrationDeclarations, } from "../integrations/declarations.js";
|
|
8
8
|
// ---------------------------------------------------------------------------
|
|
9
9
|
// Entry point setter — used by the Vite plugin to stamp the source file path
|
|
10
|
-
// onto the next api()
|
|
10
|
+
// onto the next api() call. ESM top-level execution is
|
|
11
11
|
// synchronous, so the prepended __setEntryPoint() always runs before api().
|
|
12
12
|
// ---------------------------------------------------------------------------
|
|
13
13
|
let __pendingEntryPoint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../src/api/definition.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAyCH,OAAO,EACL,8BAA8B,GAE/B,MAAM,iCAAiC,CAAC;AAGzC,8EAA8E;AAC9E,6EAA6E;AAC7E,
|
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../src/api/definition.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAyCH,OAAO,EACL,8BAA8B,GAE/B,MAAM,iCAAiC,CAAC;AAGzC,8EAA8E;AAC9E,6EAA6E;AAC7E,uDAAuD;AACvD,4EAA4E;AAC5E,8EAA8E;AAE9E,IAAI,mBAAuC,CAAC;AAE5C,gFAAgF;AAChF,MAAM,UAAU,eAAe,CAAC,UAAkB;IAChD,mBAAmB,GAAG,UAAU,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,MAAM,EAAE,GAAG,mBAAmB,CAAC;IAC/B,mBAAmB,GAAG,SAAS,CAAC;IAChC,OAAO,EAAE,CAAC;AACZ,CAAC;AA2DD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,MAAM,UAAU,GAAG,CAQjB,MAAiD;IAEjD,oDAAoD;IACpD,MAAM,YAAY,GAAG,8BAA8B,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAEzE,MAAM,QAAQ,GAAmD;QAC/D,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,UAAU,EAAE,iBAAiB,EAAE;QAC/B,WAAW,EAAE,MAAM,CAAC,KAAK;QACzB,YAAY,EAAE,MAAM,CAAC,MAAM;QAC3B,GAAG,EAAE,MAAM,CAAC,GAGkB;QAC9B,YAAY;KACb,CAAC;IAEF,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/api/index.d.ts
CHANGED
|
@@ -3,6 +3,4 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { api, __setEntryPoint } from "./definition.js";
|
|
5
5
|
export type { CompiledApi } from "./definition.js";
|
|
6
|
-
export { streamingApi, isStreamingApi } from "./streaming.js";
|
|
7
|
-
export type { StreamingApiConfig, CompiledStreamingApi } from "./streaming.js";
|
|
8
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/api/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/api/index.js
CHANGED
package/dist/api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -84,48 +84,4 @@ export declare class CodeExecutionError extends Error {
|
|
|
84
84
|
originalError?: unknown;
|
|
85
85
|
} | undefined);
|
|
86
86
|
}
|
|
87
|
-
/**
|
|
88
|
-
* Error thrown when a streamed chunk fails validation.
|
|
89
|
-
*
|
|
90
|
-
* Contains information about the chunk index, the raw chunk data,
|
|
91
|
-
* and the Zod validation error details.
|
|
92
|
-
*/
|
|
93
|
-
export declare class StreamChunkValidationError extends Error {
|
|
94
|
-
readonly details: {
|
|
95
|
-
/** Index of the chunk that failed validation (0-based) */
|
|
96
|
-
chunkIndex: number;
|
|
97
|
-
/** The raw chunk data that failed validation */
|
|
98
|
-
chunk: unknown;
|
|
99
|
-
/** The complete Zod error object with all validation information */
|
|
100
|
-
zodError: z.ZodError;
|
|
101
|
-
};
|
|
102
|
-
constructor(message: string, details: {
|
|
103
|
-
/** Index of the chunk that failed validation (0-based) */
|
|
104
|
-
chunkIndex: number;
|
|
105
|
-
/** The raw chunk data that failed validation */
|
|
106
|
-
chunk: unknown;
|
|
107
|
-
/** The complete Zod error object with all validation information */
|
|
108
|
-
zodError: z.ZodError;
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Error thrown when a streaming API encounters an error mid-stream.
|
|
113
|
-
*
|
|
114
|
-
* This error indicates that the stream was interrupted before completion.
|
|
115
|
-
* Contains context about where in the stream the error occurred.
|
|
116
|
-
*/
|
|
117
|
-
export declare class StreamError extends Error {
|
|
118
|
-
readonly details?: {
|
|
119
|
-
/** Number of chunks successfully received before the error */
|
|
120
|
-
chunksReceived?: number;
|
|
121
|
-
/** The original error that caused the stream to fail */
|
|
122
|
-
originalError?: unknown;
|
|
123
|
-
} | undefined;
|
|
124
|
-
constructor(message: string, details?: {
|
|
125
|
-
/** Number of chunks successfully received before the error */
|
|
126
|
-
chunksReceived?: number;
|
|
127
|
-
/** The original error that caused the stream to fail */
|
|
128
|
-
originalError?: unknown;
|
|
129
|
-
} | undefined);
|
|
130
|
-
}
|
|
131
87
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B;;;;;GAKG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;aAG7B,OAAO,EAAE;QACvB,oEAAoE;QACpE,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC;QACrB,wEAAwE;QACxE,IAAI,EAAE,OAAO,CAAC;KACf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AE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QAC9D,8CAA8C;QAC9C,GAAG,EAAE,OAAO,CAAC;KACd;CAOJ;AAED;;;;;GAKG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;aAGzB,OAAO,CAAC,EAAE;QACxB,iCAAiC;QACjC,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,4CAA4C;QAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACnC,+CAA+C;QAC/C,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,gDAAgD;QAChD,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC;QACtB,gDAAgD;QAChD,aAAa,CAAC,EAAE,OAAO,CAAC;KACzB;gBAZD,OAAO,EAAE,MAAM,EACC,OAAO,CAAC,EAAE;QACxB,iCAAiC;QACjC,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,4CAA4C;QAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACnC,+CAA+C;QAC/C,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,gDAAgD;QAChD,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC;QACtB,gDAAgD;QAChD,aAAa,CAAC,EAAE,OAAO,CAAC;KACzB,YAAA;CAOJ"}
|
package/dist/errors.js
CHANGED
|
@@ -49,36 +49,4 @@ export class CodeExecutionError extends Error {
|
|
|
49
49
|
Object.setPrototypeOf(this, CodeExecutionError.prototype);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Error thrown when a streamed chunk fails validation.
|
|
54
|
-
*
|
|
55
|
-
* Contains information about the chunk index, the raw chunk data,
|
|
56
|
-
* and the Zod validation error details.
|
|
57
|
-
*/
|
|
58
|
-
export class StreamChunkValidationError extends Error {
|
|
59
|
-
details;
|
|
60
|
-
constructor(message, details) {
|
|
61
|
-
super(message);
|
|
62
|
-
this.details = details;
|
|
63
|
-
this.name = "StreamChunkValidationError";
|
|
64
|
-
// Ensure proper prototype chain for instanceof checks
|
|
65
|
-
Object.setPrototypeOf(this, StreamChunkValidationError.prototype);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Error thrown when a streaming API encounters an error mid-stream.
|
|
70
|
-
*
|
|
71
|
-
* This error indicates that the stream was interrupted before completion.
|
|
72
|
-
* Contains context about where in the stream the error occurred.
|
|
73
|
-
*/
|
|
74
|
-
export class StreamError extends Error {
|
|
75
|
-
details;
|
|
76
|
-
constructor(message, details) {
|
|
77
|
-
super(message);
|
|
78
|
-
this.details = details;
|
|
79
|
-
this.name = "StreamError";
|
|
80
|
-
// Ensure proper prototype chain for instanceof checks
|
|
81
|
-
Object.setPrototypeOf(this, StreamError.prototype);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
52
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;;GAKG;AACH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAG7B;IAFlB,YACE,OAAe,EACC,OAKf;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QAPC,YAAO,GAAP,OAAO,CAKtB;QAGD,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;QACrC,sDAAsD;QACtD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAChE,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAG3B;IAFlB,YACE,OAAe,EACC,OAOf;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QATC,YAAO,GAAP,OAAO,CAOtB;QA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Ae,EACC,OAWf;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QAbC,YAAO,GAAP,OAAO,CAWtB;QAGD,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,sDAAsD;QACtD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC5D,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
export { z } from "zod";
|
|
54
54
|
export { fileRefSchema, readableFileSchema } from "./files.js";
|
|
55
55
|
export type { FileRef, ReadableFile } from "./files.js";
|
|
56
|
-
export { api, __setEntryPoint, type CompiledApi
|
|
56
|
+
export { api, __setEntryPoint, type CompiledApi } from "./api/index.js";
|
|
57
57
|
export type { ExtractApiInput, ExtractApiOutput } from "./api/definition.js";
|
|
58
58
|
export type { ApiConfig, ApiContext, ApiUser, Logger, BaseIntegrationClient, IntegrationRef, AnyIntegrationRef, IntegrationsMap, } from "./types.js";
|
|
59
59
|
export { postgres, slack, openai, anthropic, stripe, github, notion, snowflake, snowflakeCortex, airtable, asana, bitbucket, box, circleci, cohere, confluence, datadog, dropbox, elasticsearch, fireworks, front, gemini, googleAnalytics, googleDrive, groq, hubspot, intercom, jira, launchDarkly, mistral, pagerDuty, perplexity, segment, sendGrid, stabilityAI, twilio, zendesk, zoom, graphql, mysql, mariadb, mssql, cockroachdb, oracledb, redshift, athena, databricks, bigquery, mongodb, dynamodb, cosmosdb, couchbase, s3, gcs, googleSheets, kafka, kinesis, salesforce, redis, superblocksOcr, python, restApiIntegration, getIntegrationDeclarations, confluent, redpanda, lakebase, snowflakePostgres, smtp, type IntegrationDeclaration, type PostgresRef, type SlackRef, type OpenAIRef, type AnthropicRef, type StripeRef, type GitHubRef, type NotionRef, type SnowflakeRef, type SnowflakeCortexRef, type AirtableRef, type AsanaRef, type BitbucketRef, type BoxRef, type CircleCIRef, type CohereRef, type ConfluenceRef, type DatadogRef, type DropboxRef, type ElasticSearchRef, type FireworksRef, type FrontRef, type GeminiRef, type GoogleAnalyticsRef, type GoogleDriveRef, type GroqRef, type HubSpotRef, type IntercomRef, type JiraRef, type LaunchDarklyRef, type MistralRef, type PagerDutyRef, type PerplexityRef, type SegmentRef, type SendGridRef, type StabilityAIRef, type TwilioRef, type ZendeskRef, type ZoomRef, type GraphQLRef, type MySQLRef, type MariaDBRef, type MSSQLRef, type CockroachDBRef, type OracleDBRef, type RedshiftRef, type AthenaRef, type DatabricksRef, type BigQueryRef, type MongoDBRef, type DynamoDBRef, type CosmosDBRef, type CouchbaseRef, type S3Ref, type GCSRef, type GoogleSheetsRef, type KafkaRef, type KinesisRef, type SalesforceRef, type RedisRef, type SuperblocksOCRRef, type PythonRef, type RestApiIntegrationRef, type ConfluentRef, type RedpandaRef, type LakebaseRef, type SnowflakePostgresRef, type SmtpRef, } from "./integrations/index.js";
|
|
@@ -107,9 +107,9 @@ export type { RestApiIntegrationPluginClient } from "./integrations/restapiinteg
|
|
|
107
107
|
export type { LakebaseClient } from "./integrations/lakebase/index.js";
|
|
108
108
|
export type { SnowflakePostgresClient } from "./integrations/snowflakepostgres/index.js";
|
|
109
109
|
export type { SmtpClient, SmtpSendOptions } from "./integrations/smtp/index.js";
|
|
110
|
-
export {
|
|
111
|
-
export type {
|
|
110
|
+
export { executeApi, createApiContext, SdkError, InputValidationError, OutputValidationError, IntegrationNotFoundError, IntegrationError, ExecutionError, ErrorCode, } from "./runtime/index.js";
|
|
111
|
+
export type { ExecuteApiRequest, ExecuteApiResponse, ExecuteApiSuccessResponse, ExecuteApiErrorResponse, CreateContextOptions, ErrorCodeType, } from "./runtime/index.js";
|
|
112
112
|
export { createClient, isPluginSupported, SUPPORTED_PLUGINS, } from "./integrations/index.js";
|
|
113
|
-
export type { IntegrationConfig, IntegrationClientImpl, SupportedPluginId, QueryExecutor,
|
|
114
|
-
export { RestApiValidationError, QueryValidationError, CodeExecutionError,
|
|
113
|
+
export type { IntegrationConfig, IntegrationClientImpl, SupportedPluginId, QueryExecutor, TraceMetadata, CreateClientOptions, } from "./integrations/index.js";
|
|
114
|
+
export { RestApiValidationError, QueryValidationError, CodeExecutionError, } from "./errors.js";
|
|
115
115
|
//# sourceMappingURL=index.d.ts.map
|