@superblocksteam/sdk-api 2.0.103 → 2.0.104-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/athena/types.d.ts +2 -2
- 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/bigquery/types.d.ts +3 -3
- package/dist/integrations/databricks/types.d.ts +3 -3
- package/dist/integrations/documentation.test.d.ts +2 -0
- package/dist/integrations/documentation.test.d.ts.map +1 -0
- package/dist/integrations/documentation.test.js +83 -0
- package/dist/integrations/documentation.test.js.map +1 -0
- 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/lakebase/types.d.ts +4 -4
- package/dist/integrations/mariadb/types.d.ts +2 -2
- package/dist/integrations/mssql/types.d.ts +2 -2
- package/dist/integrations/mysql/types.d.ts +4 -4
- package/dist/integrations/openai_v2/types.d.ts +4 -22
- package/dist/integrations/openai_v2/types.d.ts.map +1 -1
- package/dist/integrations/oracledb/types.d.ts +2 -2
- 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/athena/README.md +4 -4
- package/src/integrations/athena/types.ts +2 -2
- 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/bigquery/README.md +28 -3
- package/src/integrations/bigquery/types.ts +3 -3
- package/src/integrations/cohere/README.md +11 -11
- package/src/integrations/databricks/README.md +29 -4
- package/src/integrations/databricks/types.ts +3 -3
- package/src/integrations/documentation.test.ts +122 -0
- 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/lakebase/types.ts +4 -4
- package/src/integrations/launchdarkly/README.md +2 -2
- package/src/integrations/mariadb/README.md +3 -3
- package/src/integrations/mariadb/types.ts +2 -2
- package/src/integrations/mistral/README.md +39 -13
- package/src/integrations/mssql/README.md +3 -3
- package/src/integrations/mssql/types.ts +2 -2
- package/src/integrations/mysql/README.md +4 -4
- package/src/integrations/mysql/types.ts +4 -4
- package/src/integrations/openai_v2/README.md +44 -116
- package/src/integrations/openai_v2/types.ts +4 -29
- package/src/integrations/oracledb/README.md +3 -3
- package/src/integrations/oracledb/types.ts +2 -2
- 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
|
@@ -4,14 +4,15 @@ Interact with OpenAI's APIs for chat completions, embeddings, image generation,
|
|
|
4
4
|
|
|
5
5
|
## Methods
|
|
6
6
|
|
|
7
|
-
| Method
|
|
8
|
-
|
|
|
9
|
-
| `apiRequest(options, schema, metadata?)`
|
|
10
|
-
| `streamApiRequest(options, schema, metadata?)` | Stream responses with real-time chunk validation |
|
|
7
|
+
| Method | Description |
|
|
8
|
+
| ---------------------------------------- | -------------------------------------------------- |
|
|
9
|
+
| `apiRequest(options, schema, metadata?)` | Make any OpenAI API request with schema validation |
|
|
11
10
|
|
|
12
11
|
## Usage
|
|
13
12
|
|
|
14
|
-
###
|
|
13
|
+
### Step 1: List Available Models
|
|
14
|
+
|
|
15
|
+
Model availability depends on your OpenAI account and API tier. Before making requests, validate which models you can access:
|
|
15
16
|
|
|
16
17
|
```typescript
|
|
17
18
|
import { api, z, openai } from "@superblocksteam/sdk-api";
|
|
@@ -19,6 +20,30 @@ import { api, z, openai } from "@superblocksteam/sdk-api";
|
|
|
19
20
|
// Integration ID from the integrations panel
|
|
20
21
|
const PROD_OPENAI = "a1b2c3d4-5678-90ab-cdef-333333333333";
|
|
21
22
|
|
|
23
|
+
const ModelsResponseSchema = z.object({
|
|
24
|
+
data: z.array(
|
|
25
|
+
z.object({
|
|
26
|
+
id: z.string(),
|
|
27
|
+
object: z.string(),
|
|
28
|
+
}),
|
|
29
|
+
),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const models = await ctx.integrations.ai.apiRequest(
|
|
33
|
+
{
|
|
34
|
+
method: "GET",
|
|
35
|
+
path: "/models",
|
|
36
|
+
},
|
|
37
|
+
{ response: ModelsResponseSchema },
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
// Use a model ID from the response in subsequent requests
|
|
41
|
+
const availableModelId = models.data[0]?.id;
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Chat Completion
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
22
47
|
const ChatCompletionResponseSchema = z.object({
|
|
23
48
|
id: z.string(),
|
|
24
49
|
object: z.literal("chat.completion"),
|
|
@@ -56,7 +81,7 @@ export default api({
|
|
|
56
81
|
const result = await ctx.integrations.ai.apiRequest(
|
|
57
82
|
{
|
|
58
83
|
method: "POST",
|
|
59
|
-
path: "/
|
|
84
|
+
path: "/chat/completions",
|
|
60
85
|
body: {
|
|
61
86
|
model: "gpt-4",
|
|
62
87
|
messages: [
|
|
@@ -105,7 +130,7 @@ const FunctionCallResponseSchema = z.object({
|
|
|
105
130
|
const result = await ctx.integrations.ai.apiRequest(
|
|
106
131
|
{
|
|
107
132
|
method: "POST",
|
|
108
|
-
path: "/
|
|
133
|
+
path: "/chat/completions",
|
|
109
134
|
body: {
|
|
110
135
|
model: "gpt-4",
|
|
111
136
|
messages: [
|
|
@@ -161,7 +186,7 @@ const EmbeddingsResponseSchema = z.object({
|
|
|
161
186
|
const embeddings = await ctx.integrations.ai.apiRequest(
|
|
162
187
|
{
|
|
163
188
|
method: "POST",
|
|
164
|
-
path: "/
|
|
189
|
+
path: "/embeddings",
|
|
165
190
|
body: {
|
|
166
191
|
model: "text-embedding-3-small",
|
|
167
192
|
input: ["Hello world", "How are you?"],
|
|
@@ -192,7 +217,7 @@ const ImageResponseSchema = z.object({
|
|
|
192
217
|
const images = await ctx.integrations.ai.apiRequest(
|
|
193
218
|
{
|
|
194
219
|
method: "POST",
|
|
195
|
-
path: "/
|
|
220
|
+
path: "/images/generations",
|
|
196
221
|
body: {
|
|
197
222
|
model: "dall-e-3",
|
|
198
223
|
prompt: "A serene mountain landscape at sunset",
|
|
@@ -215,7 +240,7 @@ const imageUrl = images.data[0]?.url;
|
|
|
215
240
|
const ttsResult = await ctx.integrations.ai.apiRequest(
|
|
216
241
|
{
|
|
217
242
|
method: "POST",
|
|
218
|
-
path: "/
|
|
243
|
+
path: "/audio/speech",
|
|
219
244
|
body: {
|
|
220
245
|
model: "tts-1",
|
|
221
246
|
input: "Hello, how are you today?",
|
|
@@ -226,91 +251,6 @@ const ttsResult = await ctx.integrations.ai.apiRequest(
|
|
|
226
251
|
);
|
|
227
252
|
```
|
|
228
253
|
|
|
229
|
-
### Streaming Chat Completions
|
|
230
|
-
|
|
231
|
-
For real-time token streaming, use `streamApiRequest()` with `stream: true`:
|
|
232
|
-
|
|
233
|
-
```typescript
|
|
234
|
-
import { streamingApi, z, openai } from "@superblocksteam/sdk-api";
|
|
235
|
-
|
|
236
|
-
// Integration ID from the integrations panel
|
|
237
|
-
const PROD_OPENAI = "a1b2c3d4-5678-90ab-cdef-333333333333";
|
|
238
|
-
|
|
239
|
-
// Schema for OpenAI's streaming SSE chunks
|
|
240
|
-
const OpenAIStreamChunkSchema = z.object({
|
|
241
|
-
id: z.string(),
|
|
242
|
-
object: z.literal("chat.completion.chunk"),
|
|
243
|
-
created: z.number(),
|
|
244
|
-
model: z.string(),
|
|
245
|
-
choices: z.array(
|
|
246
|
-
z.object({
|
|
247
|
-
index: z.number(),
|
|
248
|
-
delta: z.object({
|
|
249
|
-
role: z.string().optional(),
|
|
250
|
-
content: z.string().optional(),
|
|
251
|
-
}),
|
|
252
|
-
finish_reason: z.string().nullable(),
|
|
253
|
-
}),
|
|
254
|
-
),
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
export default streamingApi({
|
|
258
|
-
integrations: {
|
|
259
|
-
ai: openai(PROD_OPENAI),
|
|
260
|
-
},
|
|
261
|
-
|
|
262
|
-
input: z.object({ prompt: z.string() }),
|
|
263
|
-
chunk: z.object({ type: z.literal("text"), text: z.string() }),
|
|
264
|
-
|
|
265
|
-
async *run(ctx, { prompt }) {
|
|
266
|
-
const stream = ctx.integrations.ai.streamApiRequest(
|
|
267
|
-
{
|
|
268
|
-
method: "POST",
|
|
269
|
-
path: "/v1/chat/completions",
|
|
270
|
-
body: {
|
|
271
|
-
model: "gpt-4",
|
|
272
|
-
stream: true, // Enable streaming
|
|
273
|
-
messages: [
|
|
274
|
-
{ role: "system", content: "You are a helpful assistant." },
|
|
275
|
-
{ role: "user", content: prompt },
|
|
276
|
-
],
|
|
277
|
-
},
|
|
278
|
-
},
|
|
279
|
-
{ chunk: OpenAIStreamChunkSchema },
|
|
280
|
-
);
|
|
281
|
-
|
|
282
|
-
// Yield text chunks as they arrive
|
|
283
|
-
for await (const chunk of stream) {
|
|
284
|
-
const content = chunk.choices[0]?.delta?.content;
|
|
285
|
-
if (content) {
|
|
286
|
-
yield { type: "text" as const, text: content };
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
},
|
|
290
|
-
});
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
#### Streaming Chunk Structure
|
|
294
|
-
|
|
295
|
-
OpenAI's streaming chunks have this structure:
|
|
296
|
-
|
|
297
|
-
```typescript
|
|
298
|
-
{
|
|
299
|
-
id: "chatcmpl-...",
|
|
300
|
-
object: "chat.completion.chunk",
|
|
301
|
-
created: 1234567890,
|
|
302
|
-
model: "gpt-4",
|
|
303
|
-
choices: [{
|
|
304
|
-
index: 0,
|
|
305
|
-
delta: {
|
|
306
|
-
role: "assistant", // Only in first chunk
|
|
307
|
-
content: "Hello" // Incremental text
|
|
308
|
-
},
|
|
309
|
-
finish_reason: null // "stop" in final chunk
|
|
310
|
-
}]
|
|
311
|
-
}
|
|
312
|
-
```
|
|
313
|
-
|
|
314
254
|
## Trace Metadata
|
|
315
255
|
|
|
316
256
|
All methods accept an optional `metadata` parameter as the last argument for diagnostics labeling. See the [root SDK README](../../../README.md#trace-metadata) for details.
|
|
@@ -319,7 +259,7 @@ All methods accept an optional `metadata` parameter as the last argument for dia
|
|
|
319
259
|
|
|
320
260
|
### No Specialized Methods
|
|
321
261
|
|
|
322
|
-
The OpenAI client only provides `apiRequest()`. There are no
|
|
262
|
+
The OpenAI client only provides `apiRequest()`. There are no other specialized methods:
|
|
323
263
|
|
|
324
264
|
```typescript
|
|
325
265
|
// WRONG - These methods do not exist
|
|
@@ -328,7 +268,7 @@ await openai.createEmbedding({ ... });
|
|
|
328
268
|
|
|
329
269
|
// CORRECT - Use apiRequest for all operations
|
|
330
270
|
await ctx.integrations.ai.apiRequest(
|
|
331
|
-
{ method: "POST", path: "/
|
|
271
|
+
{ method: "POST", path: "/chat/completions", body: { ... } },
|
|
332
272
|
{ response: ResponseSchema }
|
|
333
273
|
);
|
|
334
274
|
```
|
|
@@ -341,13 +281,13 @@ You must always provide a response schema:
|
|
|
341
281
|
// WRONG - Missing response schema
|
|
342
282
|
const result = await ctx.integrations.ai.apiRequest({
|
|
343
283
|
method: "POST",
|
|
344
|
-
path: "/
|
|
284
|
+
path: "/chat/completions",
|
|
345
285
|
body: { ... },
|
|
346
286
|
});
|
|
347
287
|
|
|
348
288
|
// CORRECT - Include response schema
|
|
349
289
|
const result = await ctx.integrations.ai.apiRequest(
|
|
350
|
-
{ method: "POST", path: "/
|
|
290
|
+
{ method: "POST", path: "/chat/completions", body: { ... } },
|
|
351
291
|
{ response: ChatCompletionResponseSchema }
|
|
352
292
|
);
|
|
353
293
|
```
|
|
@@ -389,7 +329,7 @@ Some features require beta headers:
|
|
|
389
329
|
const result = await ctx.integrations.ai.apiRequest(
|
|
390
330
|
{
|
|
391
331
|
method: "POST",
|
|
392
|
-
path: "/
|
|
332
|
+
path: "/assistants",
|
|
393
333
|
body: { ... },
|
|
394
334
|
headers: {
|
|
395
335
|
"OpenAI-Beta": "assistants=v2",
|
|
@@ -419,7 +359,7 @@ async function withRetry<T>(fn: () => Promise<T>, maxRetries = 3): Promise<T> {
|
|
|
419
359
|
|
|
420
360
|
const result = await withRetry(() =>
|
|
421
361
|
ctx.integrations.ai.apiRequest(
|
|
422
|
-
{ method: "POST", path: "/
|
|
362
|
+
{ method: "POST", path: "/chat/completions", body: { ... } },
|
|
423
363
|
{ response: ChatCompletionResponseSchema }
|
|
424
364
|
)
|
|
425
365
|
);
|
|
@@ -441,7 +381,7 @@ Be aware of model token limits:
|
|
|
441
381
|
const result = await ctx.integrations.ai.apiRequest(
|
|
442
382
|
{
|
|
443
383
|
method: "POST",
|
|
444
|
-
path: "/
|
|
384
|
+
path: "/chat/completions",
|
|
445
385
|
body: {
|
|
446
386
|
model: "gpt-4",
|
|
447
387
|
messages: [...],
|
|
@@ -455,11 +395,11 @@ const result = await ctx.integrations.ai.apiRequest(
|
|
|
455
395
|
## Error Handling
|
|
456
396
|
|
|
457
397
|
```typescript
|
|
458
|
-
import { RestApiValidationError
|
|
398
|
+
import { RestApiValidationError } from "@superblocksteam/sdk-api";
|
|
459
399
|
|
|
460
400
|
try {
|
|
461
401
|
const result = await ctx.integrations.ai.apiRequest(
|
|
462
|
-
{ method: "POST", path: "/
|
|
402
|
+
{ method: "POST", path: "/chat/completions", body: { ... } },
|
|
463
403
|
{ response: ChatCompletionResponseSchema }
|
|
464
404
|
);
|
|
465
405
|
} catch (error) {
|
|
@@ -468,18 +408,6 @@ try {
|
|
|
468
408
|
console.error("Actual response:", error.details.data);
|
|
469
409
|
}
|
|
470
410
|
}
|
|
471
|
-
|
|
472
|
-
// For streaming requests
|
|
473
|
-
try {
|
|
474
|
-
for await (const chunk of stream) {
|
|
475
|
-
// Process chunk
|
|
476
|
-
}
|
|
477
|
-
} catch (error) {
|
|
478
|
-
if (error instanceof StreamChunkValidationError) {
|
|
479
|
-
console.error("Chunk validation failed at index:", error.details.chunkIndex);
|
|
480
|
-
console.error("Raw chunk:", error.details.chunk);
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
411
|
```
|
|
484
412
|
|
|
485
413
|
## API Reference
|
|
@@ -3,16 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type { BaseIntegrationClient } from "../../types.js";
|
|
6
|
-
import type {
|
|
7
|
-
SupportsApiRequest,
|
|
8
|
-
SupportsStreamingApiRequest,
|
|
9
|
-
} from "../base/index.js";
|
|
6
|
+
import type { SupportsApiRequest } from "../base/index.js";
|
|
10
7
|
|
|
11
8
|
/**
|
|
12
9
|
* OpenAI client for AI model interactions.
|
|
13
10
|
*
|
|
14
|
-
* Provides the generic apiRequest() method for any OpenAI API endpoint
|
|
15
|
-
* and streamApiRequest() for streaming responses.
|
|
11
|
+
* Provides the generic apiRequest() method for any OpenAI API endpoint.
|
|
16
12
|
* Use this to interact with OpenAI's chat completions, embeddings, and other endpoints.
|
|
17
13
|
*
|
|
18
14
|
* @example
|
|
@@ -45,7 +41,7 @@ import type {
|
|
|
45
41
|
* const completion = await ctx.integrations.ai.apiRequest(
|
|
46
42
|
* {
|
|
47
43
|
* method: 'POST',
|
|
48
|
-
* path: '/
|
|
44
|
+
* path: '/chat/completions',
|
|
49
45
|
* body: {
|
|
50
46
|
* model: 'gpt-4',
|
|
51
47
|
* messages: [{ role: 'user', content: 'Hello!' }],
|
|
@@ -57,30 +53,9 @@ import type {
|
|
|
57
53
|
* }
|
|
58
54
|
* );
|
|
59
55
|
*
|
|
60
|
-
* // Or use streaming for real-time responses
|
|
61
|
-
* const stream = openai.streamApiRequest(
|
|
62
|
-
* {
|
|
63
|
-
* method: 'POST',
|
|
64
|
-
* path: '/v1/chat/completions',
|
|
65
|
-
* body: {
|
|
66
|
-
* model: 'gpt-4',
|
|
67
|
-
* stream: true,
|
|
68
|
-
* messages: [{ role: 'user', content: 'Hello!' }],
|
|
69
|
-
* },
|
|
70
|
-
* },
|
|
71
|
-
* { chunk: StreamChunkSchema }
|
|
72
|
-
* );
|
|
73
|
-
*
|
|
74
|
-
* for await (const chunk of stream) {
|
|
75
|
-
* // Handle streaming chunks
|
|
76
|
-
* }
|
|
77
56
|
* ```
|
|
78
57
|
*/
|
|
79
58
|
export interface OpenAIClient
|
|
80
|
-
extends
|
|
81
|
-
BaseIntegrationClient,
|
|
82
|
-
SupportsApiRequest,
|
|
83
|
-
SupportsStreamingApiRequest {
|
|
59
|
+
extends BaseIntegrationClient, SupportsApiRequest {
|
|
84
60
|
// apiRequest() method inherited from SupportsApiRequest
|
|
85
|
-
// streamApiRequest() method inherited from SupportsStreamingApiRequest
|
|
86
61
|
}
|
|
@@ -39,7 +39,7 @@ export default api({
|
|
|
39
39
|
}),
|
|
40
40
|
async run(ctx, { status }) {
|
|
41
41
|
const users = await ctx.integrations.oracledb.query(
|
|
42
|
-
"SELECT ID, NAME, EMAIL, CREATED_AT FROM USERS WHERE STATUS =
|
|
42
|
+
"SELECT ID, NAME, EMAIL, CREATED_AT FROM USERS WHERE STATUS = :1",
|
|
43
43
|
UserSchema,
|
|
44
44
|
[status],
|
|
45
45
|
);
|
|
@@ -54,13 +54,13 @@ export default api({
|
|
|
54
54
|
```typescript
|
|
55
55
|
// INSERT
|
|
56
56
|
await ctx.integrations.oracledb.execute(
|
|
57
|
-
"INSERT INTO USERS (NAME, EMAIL) VALUES (
|
|
57
|
+
"INSERT INTO USERS (NAME, EMAIL) VALUES (:1, :2)",
|
|
58
58
|
["John Doe", "john@example.com"],
|
|
59
59
|
);
|
|
60
60
|
|
|
61
61
|
// UPDATE
|
|
62
62
|
const updateResult = await ctx.integrations.oracledb.execute(
|
|
63
|
-
"UPDATE USERS SET LAST_LOGIN = SYSDATE WHERE ID =
|
|
63
|
+
"UPDATE USERS SET LAST_LOGIN = SYSDATE WHERE ID = :1",
|
|
64
64
|
[userId],
|
|
65
65
|
);
|
|
66
66
|
console.log(`Updated ${updateResult.rowCount} rows`);
|
|
@@ -25,7 +25,7 @@ import type { TraceMetadata } from "../registry.js";
|
|
|
25
25
|
* });
|
|
26
26
|
*
|
|
27
27
|
* const users = await oracledb.query(
|
|
28
|
-
* 'SELECT * FROM users WHERE status =
|
|
28
|
+
* 'SELECT * FROM users WHERE status = :1',
|
|
29
29
|
* UserSchema,
|
|
30
30
|
* ['active']
|
|
31
31
|
* );
|
|
@@ -35,7 +35,7 @@ export interface OracleDBClient extends BaseIntegrationClient {
|
|
|
35
35
|
/**
|
|
36
36
|
* Execute a SQL query and validate results against a Zod schema.
|
|
37
37
|
*
|
|
38
|
-
* @param sql - SQL query string (use
|
|
38
|
+
* @param sql - SQL query string (use :1, :2, etc. for parameters)
|
|
39
39
|
* @param schema - Zod schema to validate the query results
|
|
40
40
|
* @param params - Optional query parameters
|
|
41
41
|
* @returns Promise resolving to validated query results
|
|
@@ -13,7 +13,7 @@ Create incidents, manage services, and interact with PagerDuty's incident manage
|
|
|
13
13
|
### Create an Incident
|
|
14
14
|
|
|
15
15
|
```typescript
|
|
16
|
-
import { api, z,
|
|
16
|
+
import { api, z, pagerDuty } from "@superblocksteam/sdk-api";
|
|
17
17
|
|
|
18
18
|
// Integration ID from the integrations panel
|
|
19
19
|
const PROD_PAGERDUTY = "a1b2c3d4-5678-90ab-cdef-pagerdu00001";
|
|
@@ -52,7 +52,7 @@ const CreateIncidentResponseSchema = z.object({
|
|
|
52
52
|
|
|
53
53
|
export default api({
|
|
54
54
|
integrations: {
|
|
55
|
-
pagerduty:
|
|
55
|
+
pagerduty: pagerDuty(PROD_PAGERDUTY),
|
|
56
56
|
},
|
|
57
57
|
name: "PagerDutyExample",
|
|
58
58
|
input: z.object({
|
|
@@ -231,10 +231,11 @@ if (sources.length === 0) {
|
|
|
231
231
|
|
|
232
232
|
### Model Naming Convention
|
|
233
233
|
|
|
234
|
-
Perplexity models follow a specific naming pattern:
|
|
234
|
+
Perplexity models follow a specific naming pattern. Note that available models change over time — check the [Perplexity model cards](https://docs.perplexity.ai/docs/model-cards) for current options:
|
|
235
235
|
|
|
236
236
|
```typescript
|
|
237
237
|
// Pattern: llama-3.1-sonar-{size}-{context}-{type}
|
|
238
|
+
// These are examples — verify current model names in the Perplexity docs
|
|
238
239
|
const models = [
|
|
239
240
|
"llama-3.1-sonar-small-128k-online", // Small, online search
|
|
240
241
|
"llama-3.1-sonar-small-128k-chat", // Small, no search
|
|
@@ -13,9 +13,8 @@ describe("integration registry", () => {
|
|
|
13
13
|
expect(isPluginSupported(SUPPORTED_PLUGINS.snowflakecortex)).toBe(true);
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
it("creates a SnowflakeCortex client
|
|
16
|
+
it("creates a SnowflakeCortex client", () => {
|
|
17
17
|
const executeQuery = vi.fn();
|
|
18
|
-
const executeStreamingQuery = vi.fn();
|
|
19
18
|
|
|
20
19
|
const client = createClient({
|
|
21
20
|
config: {
|
|
@@ -25,7 +24,6 @@ describe("integration registry", () => {
|
|
|
25
24
|
configuration: {},
|
|
26
25
|
},
|
|
27
26
|
executeQuery,
|
|
28
|
-
executeStreamingQuery,
|
|
29
27
|
});
|
|
30
28
|
|
|
31
29
|
expect(client).toBeInstanceOf(SnowflakeCortexClientImpl);
|