@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
package/README.md
CHANGED
|
@@ -183,7 +183,7 @@ interface ExecuteApiRequest {
|
|
|
183
183
|
executeQuery: (
|
|
184
184
|
integrationId: string,
|
|
185
185
|
request: Record<string, unknown>, // Plugin-specific request matching protobuf schema
|
|
186
|
-
bindings?: Record<string, unknown>, // For language plugins (
|
|
186
|
+
bindings?: Record<string, unknown>, // For language plugins (JavaScript)
|
|
187
187
|
) => Promise<unknown>;
|
|
188
188
|
}
|
|
189
189
|
```
|
|
@@ -276,6 +276,42 @@ export default api({
|
|
|
276
276
|
});
|
|
277
277
|
```
|
|
278
278
|
|
|
279
|
+
### Export style (default vs named exports)
|
|
280
|
+
|
|
281
|
+
**Default export** — one API per file. **Named exports** — several `api({ ... })` values in one module; import them by name into `server/apis/index.ts`. `useApi("X")` matches the **key** on the registry object; align `api({ name: "X" })` with that when practical.
|
|
282
|
+
|
|
283
|
+
```typescript
|
|
284
|
+
// server/apis/users/pair.ts
|
|
285
|
+
import { api, z } from "@superblocksteam/sdk-api";
|
|
286
|
+
|
|
287
|
+
export const ListProfiles = api({
|
|
288
|
+
name: "ListProfiles",
|
|
289
|
+
input: z.object({ orgId: z.string() }),
|
|
290
|
+
output: z.object({ profiles: z.array(z.object({ id: z.string() })) }),
|
|
291
|
+
async run() {
|
|
292
|
+
return { profiles: [] };
|
|
293
|
+
},
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
export const UpdateProfile = api({
|
|
297
|
+
name: "UpdateProfile",
|
|
298
|
+
input: z.object({ userId: z.string() }),
|
|
299
|
+
output: z.object({ ok: z.literal(true) }),
|
|
300
|
+
async run() {
|
|
301
|
+
return { ok: true as const };
|
|
302
|
+
},
|
|
303
|
+
});
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
```typescript
|
|
307
|
+
// server/apis/index.ts
|
|
308
|
+
import { ListProfiles, UpdateProfile } from "./users/pair.js";
|
|
309
|
+
|
|
310
|
+
const apis = { ListProfiles, UpdateProfile } as const;
|
|
311
|
+
export default apis;
|
|
312
|
+
export type ApiRegistry = typeof apis;
|
|
313
|
+
```
|
|
314
|
+
|
|
279
315
|
## API Reference
|
|
280
316
|
|
|
281
317
|
### `api(config)`
|
|
@@ -284,13 +320,14 @@ Defines a TypeScript-based API with input/output validation. Returns a complete
|
|
|
284
320
|
|
|
285
321
|
#### Required Fields
|
|
286
322
|
|
|
287
|
-
| Field | Type | Description
|
|
288
|
-
| -------------- | --------------------------------- |
|
|
289
|
-
| `name` | `string` | **Required.** Unique identifier for the API
|
|
290
|
-
| `
|
|
291
|
-
| `
|
|
292
|
-
| `
|
|
293
|
-
| `
|
|
323
|
+
| Field | Type | Description |
|
|
324
|
+
| -------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
325
|
+
| `name` | `string` | **Required.** Unique identifier for the API |
|
|
326
|
+
| `description` | `string` | Optional. Plain-language summary of what this API does and which integrations it uses. Auto-generated by the AI agent when creating or editing an API. |
|
|
327
|
+
| `input` | `z.ZodType` | **Required.** Zod schema for input validation |
|
|
328
|
+
| `output` | `z.ZodType` | **Required.** Zod schema for output validation |
|
|
329
|
+
| `run` | `(ctx, input) => Promise<Output>` | **Required.** The implementation function |
|
|
330
|
+
| `integrations` | `Record<string, IntegrationRef>` | Optional. Integration declarations for the API |
|
|
294
331
|
|
|
295
332
|
```typescript
|
|
296
333
|
import { api, z } from "@superblocksteam/sdk-api";
|
|
@@ -340,7 +377,7 @@ async run(ctx, { userId, options }) {
|
|
|
340
377
|
Access typed integration clients via the **name (key)** you declared in the API config: `ctx.integrations.<name>`. For example, if you declared `integrations: { db: postgres(...), notifier: slack(...) }`, use `ctx.integrations.db` and `ctx.integrations.notifier` in your `run` function. Integrations must be declared upfront to enable type-safe access and pre-authentication.
|
|
341
378
|
|
|
342
379
|
```typescript
|
|
343
|
-
import { api, z, postgres, slack, openai, anthropic, stripe, github, notion
|
|
380
|
+
import { api, z, postgres, slack, openai, anthropic, stripe, github, notion } from "@superblocksteam/sdk-api";
|
|
344
381
|
|
|
345
382
|
// Integration IDs from the integrations panel - store in constants
|
|
346
383
|
const PROD_POSTGRES = "a1b2c3d4-5678-90ab-cdef-ghijklmnopqr";
|
|
@@ -350,7 +387,6 @@ const PROD_ANTHROPIC = "d4e5f6g7-8901-23ab-cdef-ghijklmnopqr";
|
|
|
350
387
|
const PROD_STRIPE = "e5f6g7h8-9012-34ab-cdef-ghijklmnopqr";
|
|
351
388
|
const PROD_GITHUB = "f6g7h8i9-0123-45ab-cdef-ghijklmnopqr";
|
|
352
389
|
const PROD_NOTION = "g7h8i9j0-1234-56ab-cdef-ghijklmnopqr";
|
|
353
|
-
const PYTHON_RUNTIME = "h8i9j0k1-2345-67ab-cdef-ghijklmnopqr";
|
|
354
390
|
|
|
355
391
|
export default api({
|
|
356
392
|
name: "ProcessUserWorkflow",
|
|
@@ -375,9 +411,6 @@ export default api({
|
|
|
375
411
|
|
|
376
412
|
// Productivity
|
|
377
413
|
wiki: notion(PROD_NOTION),
|
|
378
|
-
|
|
379
|
-
// Code Execution
|
|
380
|
-
runtime: python(PYTHON_RUNTIME),
|
|
381
414
|
},
|
|
382
415
|
|
|
383
416
|
input: z.object({ userId: z.string() }),
|
|
@@ -394,6 +427,22 @@ export default api({
|
|
|
394
427
|
});
|
|
395
428
|
```
|
|
396
429
|
|
|
430
|
+
#### `ctx.user`
|
|
431
|
+
|
|
432
|
+
Access the current user's identity (from the Superblocks JWT). This is the server-side equivalent of the `Global` object available in the frontend.
|
|
433
|
+
|
|
434
|
+
```typescript
|
|
435
|
+
async run(ctx, input) {
|
|
436
|
+
const userId = ctx.user.userId;
|
|
437
|
+
const email = ctx.user.email; // may be undefined
|
|
438
|
+
const name = ctx.user.name; // may be undefined
|
|
439
|
+
const groups = ctx.user.groups; // readonly string[]
|
|
440
|
+
const claims = ctx.user.customClaims; // custom JWT claims
|
|
441
|
+
|
|
442
|
+
ctx.log.info('Request from user', { userId, email });
|
|
443
|
+
}
|
|
444
|
+
```
|
|
445
|
+
|
|
397
446
|
#### `ctx.log`
|
|
398
447
|
|
|
399
448
|
Structured logging utilities.
|
|
@@ -415,48 +464,74 @@ async run(ctx, { userId }) {
|
|
|
415
464
|
|
|
416
465
|
#### Method Availability by Client
|
|
417
466
|
|
|
418
|
-
| Client | Available Methods
|
|
419
|
-
| ---------------------------------- |
|
|
420
|
-
| **PostgresClient** | `query<T>(sql, schema, params?)`, `execute(sql, params?)`
|
|
421
|
-
| **SnowflakeClient** | `query<T>(sql, schema, params?)`, `execute(sql, params?)`
|
|
422
|
-
| **
|
|
423
|
-
| **
|
|
424
|
-
| **
|
|
425
|
-
| **
|
|
426
|
-
| **
|
|
427
|
-
| **
|
|
428
|
-
| **
|
|
429
|
-
| **
|
|
430
|
-
| **
|
|
431
|
-
| **
|
|
432
|
-
| **
|
|
433
|
-
| **
|
|
434
|
-
| **
|
|
435
|
-
| **
|
|
436
|
-
| **
|
|
437
|
-
| **
|
|
438
|
-
| **
|
|
439
|
-
| **
|
|
440
|
-
| **
|
|
441
|
-
| **
|
|
442
|
-
| **
|
|
443
|
-
| **
|
|
444
|
-
| **
|
|
445
|
-
| **
|
|
446
|
-
| **
|
|
447
|
-
| **
|
|
448
|
-
| **
|
|
449
|
-
| **
|
|
450
|
-
| **
|
|
451
|
-
| **
|
|
452
|
-
| **
|
|
453
|
-
| **
|
|
454
|
-
| **
|
|
455
|
-
| **
|
|
456
|
-
| **
|
|
457
|
-
| **
|
|
458
|
-
| **
|
|
459
|
-
| **
|
|
467
|
+
| Client | Available Methods | Notes |
|
|
468
|
+
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
|
|
469
|
+
| **PostgresClient** | `query<T>(sql, schema, params?)`, `execute(sql, params?)` | Schema parameter is REQUIRED for query() |
|
|
470
|
+
| **SnowflakeClient** | `query<T>(sql, schema, params?)`, `execute(sql, params?)` | Schema parameter is REQUIRED for query() |
|
|
471
|
+
| **AirtableClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
472
|
+
| **AnthropicClient** | `apiRequest(options, schema)` | Claude AI models (see [Streaming note](#streaming--sse)) |
|
|
473
|
+
| **AsanaClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
474
|
+
| **BitbucketClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
475
|
+
| **BoxClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
476
|
+
| **CircleCIClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
477
|
+
| **CohereClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
478
|
+
| **ConfluenceClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
479
|
+
| **DatadogClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
480
|
+
| **DropboxClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
481
|
+
| **ElasticSearchClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
482
|
+
| **FireworksClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
483
|
+
| **FrontClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
484
|
+
| **GeminiClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
485
|
+
| **GitHubClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest - no createIssue, etc. |
|
|
486
|
+
| **GoogleAnalyticsClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
487
|
+
| **GoogleDriveClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
488
|
+
| **GraphQLClient** | `query<T>(query, schema, variables?, metadata?)`, `mutation<T>(mutation, schema, variables?, metadata?)` | GraphQL-specific methods |
|
|
489
|
+
| **GroqClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
490
|
+
| **HubSpotClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
491
|
+
| **IntercomClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
492
|
+
| **JiraClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
493
|
+
| **LaunchDarklyClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
494
|
+
| **MistralClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
495
|
+
| **NotionClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest - no queryDatabase, etc. |
|
|
496
|
+
| **OpenAIClient** | `apiRequest(options, schema)` | GPT AI models (see [Streaming note](#streaming--sse)) |
|
|
497
|
+
| **PagerDutyClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
498
|
+
| **PerplexityClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
499
|
+
| **SegmentClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
500
|
+
| **SendGridClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
501
|
+
| **SlackClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest - no specialized methods |
|
|
502
|
+
| **StabilityAIClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
503
|
+
| **StripeClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest - no createCustomer, etc. |
|
|
504
|
+
| **TwilioClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
505
|
+
| **ZendeskClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
506
|
+
| **ZoomClient** | `apiRequest(options, schema?)` | ONLY generic apiRequest |
|
|
507
|
+
| **MySQLClient** | `query<T>(sql, schema, params?)`, `execute(sql, params?)` | Schema parameter is REQUIRED for query() |
|
|
508
|
+
| **MariaDBClient** | `query<T>(sql, schema, params?)`, `execute(sql, params?)` | Schema parameter is REQUIRED for query() |
|
|
509
|
+
| **MSSQLClient** | `query<T>(sql, schema, params?)`, `execute(sql, params?)` | Uses `@PARAM_1` placeholder syntax |
|
|
510
|
+
| **CockroachDBClient** | `query<T>(sql, schema, params?)`, `execute(sql, params?)` | Schema parameter is REQUIRED for query() |
|
|
511
|
+
| **OracleDBClient** | `query<T>(sql, schema, params?)`, `execute(sql, params?)` | Uses `:PARAM_1` placeholder syntax |
|
|
512
|
+
| **RedshiftClient** | `query<T>(sql, schema, params?)`, `execute(sql, params?)` | Schema parameter is REQUIRED for query() |
|
|
513
|
+
| **AthenaClient** | `query<T>(sql, schema, params?)`, `execute(sql, params?)` | Uses `?` placeholder syntax |
|
|
514
|
+
| **DatabricksClient** | `query<T>(sql, schema, params?)`, `execute(sql, params?)` | Uses `:param` placeholder syntax |
|
|
515
|
+
| **BigQueryClient** | `query<T>(sql, schema, params?)`, `execute(sql, params?)` | Uses `@param` placeholder syntax |
|
|
516
|
+
| **LakebaseClient** | `query<T>(sql, schema, params?)`, `execute(sql, params?)` | Schema parameter is REQUIRED for query() |
|
|
517
|
+
| **SnowflakePostgresClient** | `query<T>(sql, schema, params?)`, `execute(sql, params?)` | Schema parameter is REQUIRED for query() |
|
|
518
|
+
| **MongoDBClient** | `run(collection, action, schema, params, metadata?)` | 13 actions (find, insertOne, updateOne, etc.) |
|
|
519
|
+
| **DynamoDBClient** | `query<T>(sql, schema)`, `getItem(params, schema)`, `putItem(params)`, `updateItem(params)`, `deleteItem(params)`, `scan(params, schema)`, `queryTable(params, schema)`, `batchWriteItem(params)`, `listTables(schema)`, `describeTable(params, schema)`, `deleteTable(params)` | 11 methods — supports both PartiQL and native CRUD |
|
|
520
|
+
| **CosmosDBClient** | `apiRequest(options, schema?)` | Azure Cosmos DB — use custom headers for queries |
|
|
521
|
+
| **CouchbaseClient** | `query<T>(bucket, sql, schema, params?)`, `insert(key, value, identifier)`, `get<T>(key, schema, identifier)`, `remove(key, identifier)` | N1QL queries + key-value operations |
|
|
522
|
+
| **RedisClient** | `command(command, schema, metadata?)` | Execute raw Redis commands |
|
|
523
|
+
| **S3Client** | `listBuckets(schema)`, `listObjects(params, schema)`, `getObject(params, schema)`, `deleteObject(params)`, `uploadObject(params)`, `uploadMultipleObjects(params)`, `generatePresignedUrl(params, schema)` | 7 methods for AWS S3 bucket/object operations |
|
|
524
|
+
| **GCSClient** | `listBuckets(schema)`, `listObjects(params, schema)`, `getObject(params, schema)`, `deleteObject(params)`, `uploadObject(params)`, `uploadMultipleObjects(params)`, `generateSignedUrl(params, schema)` | 7 methods for Google Cloud Storage operations |
|
|
525
|
+
| **SalesforceClient** | `query<T>(soql, schema)`, `create(params)`, `read(params, schema)`, `update(params)`, `remove(params)`, `bulkCreate(params)`, `bulkUpdate(params)`, `bulkDelete(params)`, `bulkUpsert(params)` | 9 methods — SOQL queries + CRUD + bulk operations |
|
|
526
|
+
| **KinesisClient** | `putRecord(params)`, `getRecords(params)` | AWS Kinesis stream put/get |
|
|
527
|
+
| **GoogleSheetsClient** | `run(action, schema, params, metadata?)` | 6 actions (READ_SPREADSHEET, APPEND, etc.) |
|
|
528
|
+
| **KafkaClient** | `consume(schema, params, metadata?)`, `produce(schema, params, metadata?)` | Kafka message consumption and production |
|
|
529
|
+
| **ConfluentClient** | `consume(schema, params, metadata?)`, `produce(schema, params, metadata?)` | Confluent Kafka — same API as KafkaClient |
|
|
530
|
+
| **RedpandaClient** | `consume(schema, params, metadata?)`, `produce(schema, params, metadata?)` | Redpanda — same API as KafkaClient |
|
|
531
|
+
| **SmtpClient** | `send(params)` | Send emails via SMTP |
|
|
532
|
+
| **SuperblocksOCRClient** | `apiRequest(options, schema?)` | OCR document processing |
|
|
533
|
+
| **SnowflakeCortexClient** | `apiRequest(options, schema?)` | Snowflake Cortex AI |
|
|
534
|
+
| **RestApiIntegrationPluginClient** | `apiRequest(options, schema)` | Generic REST API Integration - works with any configured HTTP API. |
|
|
460
535
|
|
|
461
536
|
#### Common Mistakes to Avoid
|
|
462
537
|
|
|
@@ -478,7 +553,7 @@ await myApi.request({ ... }); // .request() does NOT exist on any client
|
|
|
478
553
|
```typescript
|
|
479
554
|
// Use the generic apiRequest method
|
|
480
555
|
await openai.apiRequest(
|
|
481
|
-
{ method: 'POST', path: '/
|
|
556
|
+
{ method: 'POST', path: '/chat/completions', body: { ... } },
|
|
482
557
|
{ response: ResponseSchema }
|
|
483
558
|
);
|
|
484
559
|
```
|
|
@@ -521,7 +596,18 @@ Each integration client has detailed documentation with examples and common pitf
|
|
|
521
596
|
#### SQL Databases
|
|
522
597
|
|
|
523
598
|
- [PostgreSQL](./src/integrations/postgres/README.md) - Query PostgreSQL databases with schema validation
|
|
599
|
+
- [MySQL](./src/integrations/mysql/README.md) - Query MySQL databases
|
|
600
|
+
- [MariaDB](./src/integrations/mariadb/README.md) - Query MariaDB databases
|
|
601
|
+
- [MSSQL](./src/integrations/mssql/README.md) - Query Microsoft SQL Server databases
|
|
602
|
+
- [CockroachDB](./src/integrations/cockroachdb/README.md) - Query CockroachDB databases
|
|
603
|
+
- [OracleDB](./src/integrations/oracledb/README.md) - Query Oracle databases
|
|
524
604
|
- [Snowflake](./src/integrations/snowflake/README.md) - Query Snowflake data warehouses
|
|
605
|
+
- [Redshift](./src/integrations/redshift/README.md) - Query Amazon Redshift
|
|
606
|
+
- [BigQuery](./src/integrations/bigquery/README.md) - Query Google BigQuery
|
|
607
|
+
- [Databricks](./src/integrations/databricks/README.md) - Query Databricks SQL warehouses
|
|
608
|
+
- [Athena](./src/integrations/athena/README.md) - Query Amazon Athena
|
|
609
|
+
- [Lakebase](./src/integrations/lakebase/README.md) - Query Lakebase databases
|
|
610
|
+
- [SnowflakePostgres](./src/integrations/snowflakepostgres/README.md) - Query Snowflake via Postgres protocol
|
|
525
611
|
|
|
526
612
|
#### GraphQL
|
|
527
613
|
|
|
@@ -575,24 +661,51 @@ Each integration client has detailed documentation with examples and common pitf
|
|
|
575
661
|
- [Datadog](./src/integrations/datadog/README.md) - Metrics, monitors, and logs
|
|
576
662
|
- [Segment](./src/integrations/segment/README.md) - Customer data platform
|
|
577
663
|
|
|
664
|
+
#### NoSQL Databases
|
|
665
|
+
|
|
666
|
+
- [MongoDB](./src/integrations/mongodb/README.md) - Document database with 13 actions (find, insertOne, updateOne, etc.)
|
|
667
|
+
- [DynamoDB](./src/integrations/dynamodb/README.md) - AWS DynamoDB with PartiQL and native CRUD
|
|
668
|
+
- [CosmosDB](./src/integrations/cosmosdb/README.md) - Azure Cosmos DB via apiRequest
|
|
669
|
+
- [Couchbase](./src/integrations/couchbase/README.md) - N1QL queries and key-value operations
|
|
670
|
+
- [Redis](./src/integrations/redis/README.md) - Execute raw Redis commands
|
|
671
|
+
|
|
578
672
|
#### Cloud Storage
|
|
579
673
|
|
|
674
|
+
- [S3](./src/integrations/s3/README.md) - AWS S3 bucket and object operations
|
|
675
|
+
- [GCS](./src/integrations/gcs/README.md) - Google Cloud Storage operations
|
|
580
676
|
- [Google Drive](./src/integrations/googledrive/README.md) - Files, folders, and sharing
|
|
581
677
|
- [Dropbox](./src/integrations/dropbox/README.md) - Cloud file storage
|
|
582
678
|
- [Box](./src/integrations/box/README.md) - Enterprise content management
|
|
583
679
|
|
|
584
|
-
#### Code Execution
|
|
585
|
-
|
|
586
|
-
- [Python](./src/integrations/python/README.md) - Execute Python scripts with type-safe inputs and outputs
|
|
587
|
-
|
|
588
680
|
#### Generic HTTP
|
|
589
681
|
|
|
590
682
|
- [REST API Integration](./src/integrations/restapiintegration/README.md) - Make HTTP requests to any configured REST API
|
|
591
683
|
|
|
684
|
+
#### CRM
|
|
685
|
+
|
|
686
|
+
- [Salesforce](./src/integrations/salesforce/README.md) - SOQL queries, CRUD, and bulk operations
|
|
687
|
+
|
|
688
|
+
#### Event Streaming
|
|
689
|
+
|
|
690
|
+
- [Kafka](./src/integrations/kafka/README.md) - Consume and produce Kafka messages
|
|
691
|
+
- [Kinesis](./src/integrations/kinesis/README.md) - AWS Kinesis stream put/get
|
|
692
|
+
- Confluent — same API as [Kafka](./src/integrations/kafka/README.md)
|
|
693
|
+
- Redpanda — same API as [Kafka](./src/integrations/kafka/README.md)
|
|
694
|
+
|
|
695
|
+
#### Email
|
|
696
|
+
|
|
697
|
+
- [SMTP](./src/integrations/smtp/README.md) - Send emails via SMTP
|
|
698
|
+
|
|
592
699
|
#### Other
|
|
593
700
|
|
|
594
701
|
- [Elasticsearch](./src/integrations/elasticsearch/README.md) - Search and analytics engine
|
|
595
702
|
- [Stability AI](./src/integrations/stabilityai/README.md) - Image generation and editing
|
|
703
|
+
- [Superblocks OCR](./src/integrations/superblocks-ocr/README.md) - OCR document processing
|
|
704
|
+
- [Snowflake Cortex](./src/integrations/snowflakecortex/README.md) - Snowflake Cortex AI
|
|
705
|
+
|
|
706
|
+
### Streaming / SSE
|
|
707
|
+
|
|
708
|
+
> **Note:** The SDK's `apiRequest()` method does **not** support streaming or Server-Sent Events (SSE) responses. All AI provider calls (OpenAI, Anthropic, Gemini, Groq, Mistral, Cohere, Perplexity, Fireworks) return complete responses — the SDK waits for the full response before returning. If you are building a chat interface that needs real-time token streaming, you will need to handle streaming at the frontend/UI layer rather than through the SDK.
|
|
596
709
|
|
|
597
710
|
## Generic API Requests
|
|
598
711
|
|
|
@@ -623,7 +736,6 @@ export default api({
|
|
|
623
736
|
});
|
|
624
737
|
|
|
625
738
|
const PostMessageResponseSchema = z.object({
|
|
626
|
-
ok: z.boolean(),
|
|
627
739
|
ts: z.string(),
|
|
628
740
|
channel: z.string(),
|
|
629
741
|
});
|
|
@@ -644,7 +756,11 @@ export default api({
|
|
|
644
756
|
},
|
|
645
757
|
);
|
|
646
758
|
|
|
647
|
-
|
|
759
|
+
if (!result.ok) {
|
|
760
|
+
throw new Error(`Slack API error: ${result.error}`);
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
// result is fully typed as { ok: true } & PostMessageResponseSchema
|
|
648
764
|
return { ts: result.ts };
|
|
649
765
|
},
|
|
650
766
|
});
|
|
@@ -720,9 +836,11 @@ const doc = await ctx.integrations.mongo.run(
|
|
|
720
836
|
{ label: "Look up user by ID" },
|
|
721
837
|
);
|
|
722
838
|
|
|
723
|
-
await ctx.integrations.cache.
|
|
724
|
-
|
|
725
|
-
|
|
839
|
+
await ctx.integrations.cache.command(
|
|
840
|
+
`GET session:${sessionId}`,
|
|
841
|
+
z.string().nullable(),
|
|
842
|
+
{ label: "Check session cache" },
|
|
843
|
+
);
|
|
726
844
|
```
|
|
727
845
|
|
|
728
846
|
### When to Use
|
|
@@ -746,6 +864,7 @@ import {
|
|
|
746
864
|
QueryValidationError,
|
|
747
865
|
RestApiValidationError,
|
|
748
866
|
IntegrationNotFoundError,
|
|
867
|
+
IntegrationError,
|
|
749
868
|
ExecutionError,
|
|
750
869
|
ErrorCode,
|
|
751
870
|
} from "@superblocksteam/sdk-api";
|
|
@@ -788,7 +907,7 @@ Thrown when REST API request bodies or responses fail schema validation. Include
|
|
|
788
907
|
```typescript
|
|
789
908
|
try {
|
|
790
909
|
const result = await ctx.integrations.ai.apiRequest(
|
|
791
|
-
{ method: 'POST', path: '/
|
|
910
|
+
{ method: 'POST', path: '/chat/completions', body: { ... } },
|
|
792
911
|
{ body: RequestSchema, response: ResponseSchema }
|
|
793
912
|
);
|
|
794
913
|
} catch (error) {
|
|
@@ -1078,28 +1197,20 @@ The app template provides automatic type inference for API calls using a tRPC-st
|
|
|
1078
1197
|
|
|
1079
1198
|
### Adding a New API (2 Steps)
|
|
1080
1199
|
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
**Step 2**: Add it to the registry at `server/apis/index.ts`:
|
|
1200
|
+
1. Add a module under `server/apis/` (any layout; see [export styles](#export-style-default-vs-named-exports)).
|
|
1201
|
+
2. Register it in `server/apis/index.ts` (`.js` specifiers for ESM):
|
|
1084
1202
|
|
|
1085
1203
|
```typescript
|
|
1086
|
-
import
|
|
1087
|
-
import
|
|
1204
|
+
import CreateOrder from "./orders/create-order.js";
|
|
1205
|
+
import GetUsers from "./users/get-users.js";
|
|
1206
|
+
import { ListProfiles, UpdateProfile } from "./users/pair.js";
|
|
1088
1207
|
|
|
1089
|
-
const apis = {
|
|
1090
|
-
GetUsers,
|
|
1091
|
-
CreateOrder,
|
|
1092
|
-
// Add new APIs here
|
|
1093
|
-
} as const;
|
|
1208
|
+
const apis = { CreateOrder, GetUsers, ListProfiles, UpdateProfile } as const;
|
|
1094
1209
|
|
|
1095
1210
|
export default apis;
|
|
1096
1211
|
export type ApiRegistry = typeof apis;
|
|
1097
1212
|
```
|
|
1098
1213
|
|
|
1099
|
-
That's it! Types automatically flow to the frontend.
|
|
1100
|
-
|
|
1101
|
-
> **Note**: Always use `.js` extension in imports (required for ESM module resolution).
|
|
1102
|
-
|
|
1103
1214
|
### Calling APIs from React Components
|
|
1104
1215
|
|
|
1105
1216
|
Import `useApi` from the template's pre-configured hook:
|
|
@@ -1142,13 +1253,15 @@ The hook uses `import type` to pull in only the type information from the regist
|
|
|
1142
1253
|
|
|
1143
1254
|
### Alternative: Explicit Type Parameter
|
|
1144
1255
|
|
|
1145
|
-
|
|
1256
|
+
When you cannot use the registry hook, pass the compiled API type:
|
|
1146
1257
|
|
|
1147
1258
|
```typescript
|
|
1148
1259
|
import { useApi } from "@superblocksteam/library";
|
|
1149
|
-
import type GetUsersApi from "../../server/apis/
|
|
1260
|
+
import type GetUsersApi from "../../server/apis/users/get-users.js";
|
|
1261
|
+
import type { ListProfiles } from "../../server/apis/users/pair.js";
|
|
1150
1262
|
|
|
1151
|
-
const
|
|
1263
|
+
const getUsers = useApi<typeof GetUsersApi>("GetUsers");
|
|
1264
|
+
const listProfiles = useApi<typeof ListProfiles>("ListProfiles");
|
|
1152
1265
|
```
|
|
1153
1266
|
|
|
1154
1267
|
## Complete Example
|
|
@@ -1193,7 +1306,6 @@ const CustomerSchema = z.object({
|
|
|
1193
1306
|
});
|
|
1194
1307
|
|
|
1195
1308
|
const SlackPostMessageResponseSchema = z.object({
|
|
1196
|
-
ok: z.boolean(),
|
|
1197
1309
|
ts: z.string().optional(),
|
|
1198
1310
|
});
|
|
1199
1311
|
|
|
@@ -1250,7 +1362,7 @@ export default api({
|
|
|
1250
1362
|
const orderId = `ord_${Date.now()}`;
|
|
1251
1363
|
|
|
1252
1364
|
// Notify via Slack
|
|
1253
|
-
await ctx.integrations.notifier.apiRequest(
|
|
1365
|
+
const slackResult = await ctx.integrations.notifier.apiRequest(
|
|
1254
1366
|
{
|
|
1255
1367
|
method: "POST",
|
|
1256
1368
|
path: "/chat.postMessage",
|
|
@@ -1262,13 +1374,17 @@ export default api({
|
|
|
1262
1374
|
{ response: SlackPostMessageResponseSchema },
|
|
1263
1375
|
);
|
|
1264
1376
|
|
|
1377
|
+
if (!slackResult.ok) {
|
|
1378
|
+
throw new Error(`Slack API error: ${slackResult.error}`);
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1265
1381
|
// Generate AI summary if requested
|
|
1266
1382
|
let aiSummary: string | undefined;
|
|
1267
1383
|
if (sendAiSummary) {
|
|
1268
1384
|
const completion = await ctx.integrations.ai.apiRequest(
|
|
1269
1385
|
{
|
|
1270
1386
|
method: "POST",
|
|
1271
|
-
path: "/
|
|
1387
|
+
path: "/chat/completions",
|
|
1272
1388
|
body: {
|
|
1273
1389
|
model: "gpt-4",
|
|
1274
1390
|
messages: [
|
package/dist/api/definition.d.ts
CHANGED
|
@@ -39,9 +39,14 @@ export type ExtractApiInput<T> = T extends CompiledApi<infer TInput, any> ? TInp
|
|
|
39
39
|
export type ExtractApiOutput<T> = T extends CompiledApi<any, infer TOutput> ? TOutput : never;
|
|
40
40
|
import { type IntegrationDeclaration } from "../integrations/declarations.js";
|
|
41
41
|
import type { ApiConfig, ApiContext, AnyIntegrationRef } from "../types.js";
|
|
42
|
-
/** Called by the Vite plugin to set the entry point for
|
|
42
|
+
/** Called by the Vite plugin to set the entry point for api() calls in this file. */
|
|
43
43
|
export declare function __setEntryPoint(entryPoint: string): void;
|
|
44
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Returns the current pending entry point without clearing it.
|
|
46
|
+
* This allows multiple api() calls within the same file to share the same
|
|
47
|
+
* entry point (e.g. named exports from a single module).
|
|
48
|
+
*/
|
|
49
|
+
export declare function getEntryPoint(): string | undefined;
|
|
45
50
|
/**
|
|
46
51
|
* A compiled API definition ready for execution.
|
|
47
52
|
*
|
|
@@ -134,10 +139,10 @@ export interface CompiledApi<TInput = unknown, TOutput = unknown> {
|
|
|
134
139
|
* throw new Error('User not found');
|
|
135
140
|
* }
|
|
136
141
|
*
|
|
137
|
-
* await ctx.integrations.notifier.
|
|
138
|
-
* channel: '#user-lookups',
|
|
139
|
-
*
|
|
140
|
-
*
|
|
142
|
+
* await ctx.integrations.notifier.apiRequest(
|
|
143
|
+
* { method: 'POST', path: '/chat.postMessage', body: { channel: '#user-lookups', text: `Fetched user ${user.name}` } },
|
|
144
|
+
* { response: z.object({ ok: z.boolean() }) }
|
|
145
|
+
* );
|
|
141
146
|
*
|
|
142
147
|
* return { user };
|
|
143
148
|
* },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/api/definition.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAE3B,CAAC,SAAS,WAAW,CAAC,MAAM,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,GAAG,KAAK,CAAC;AAE5D;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAE5B,CAAC,SAAS,WAAW,CAAC,GAAG,EAAE,MAAM,OAAO,CAAC,GAAG,OAAO,GAAG,KAAK,CAAC;AAC9D,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/api/definition.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAE3B,CAAC,SAAS,WAAW,CAAC,MAAM,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,GAAG,KAAK,CAAC;AAE5D;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAE5B,CAAC,SAAS,WAAW,CAAC,GAAG,EAAE,MAAM,OAAO,CAAC,GAAG,OAAO,GAAG,KAAK,CAAC;AAC9D,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAc5E,qFAAqF;AACrF,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAExD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,MAAM,GAAG,SAAS,CAElD;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO;IAC9D,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,mDAAmD;IACnD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAE7B,uCAAuC;IACvC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAExC,wCAAwC;IACxC,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAE1C;;;;;;OAMG;IACH,QAAQ,CAAC,GAAG,EAAE,CACZ,GAAG,EAAE,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,EAClD,KAAK,EAAE,MAAM,KACV,OAAO,CAAC,OAAO,CAAC,CAAC;IAEtB;;;;;;;;;;;;;;;;;OAiBG;IACH,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC,sBAAsB,CAAC,CAAC;CAC9D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,wBAAgB,GAAG,CACjB,MAAM,SAAS,CAAC,CAAC,OAAO,EACxB,OAAO,SAAS,CAAC,CAAC,OAAO,EACzB,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,MAAM,CAC9D,MAAM,EACN,KAAK,CACN,EAED,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,aAAa,CAAC,GAChD,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAkBhD"}
|
package/dist/api/definition.js
CHANGED
|
@@ -7,18 +7,25 @@
|
|
|
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
|
|
11
|
-
// synchronous, so the prepended __setEntryPoint() always runs before
|
|
10
|
+
// onto every api()/streamingApi() call in a module. ESM top-level execution
|
|
11
|
+
// is synchronous, so the prepended __setEntryPoint() always runs before any
|
|
12
|
+
// api() call in the same file. The value is intentionally NOT cleared after
|
|
13
|
+
// the first read so that multiple named-exported api() calls in a single file
|
|
14
|
+
// all receive the same entry point. The next file's __setEntryPoint() call
|
|
15
|
+
// naturally overwrites the value.
|
|
12
16
|
// ---------------------------------------------------------------------------
|
|
13
17
|
let __pendingEntryPoint;
|
|
14
|
-
/** Called by the Vite plugin to set the entry point for
|
|
18
|
+
/** Called by the Vite plugin to set the entry point for api() calls in this file. */
|
|
15
19
|
export function __setEntryPoint(entryPoint) {
|
|
16
20
|
__pendingEntryPoint = entryPoint;
|
|
17
21
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Returns the current pending entry point without clearing it.
|
|
24
|
+
* This allows multiple api() calls within the same file to share the same
|
|
25
|
+
* entry point (e.g. named exports from a single module).
|
|
26
|
+
*/
|
|
27
|
+
export function getEntryPoint() {
|
|
28
|
+
return __pendingEntryPoint;
|
|
22
29
|
}
|
|
23
30
|
/**
|
|
24
31
|
* Define a TypeScript-based API with input/output validation.
|
|
@@ -64,10 +71,10 @@ export function consumeEntryPoint() {
|
|
|
64
71
|
* throw new Error('User not found');
|
|
65
72
|
* }
|
|
66
73
|
*
|
|
67
|
-
* await ctx.integrations.notifier.
|
|
68
|
-
* channel: '#user-lookups',
|
|
69
|
-
*
|
|
70
|
-
*
|
|
74
|
+
* await ctx.integrations.notifier.apiRequest(
|
|
75
|
+
* { method: 'POST', path: '/chat.postMessage', body: { channel: '#user-lookups', text: `Fetched user ${user.name}` } },
|
|
76
|
+
* { response: z.object({ ok: z.boolean() }) }
|
|
77
|
+
* );
|
|
71
78
|
*
|
|
72
79
|
* return { user };
|
|
73
80
|
* },
|
|
@@ -80,7 +87,7 @@ export function api(config) {
|
|
|
80
87
|
const compiled = {
|
|
81
88
|
name: config.name,
|
|
82
89
|
description: config.description,
|
|
83
|
-
entryPoint:
|
|
90
|
+
entryPoint: getEntryPoint(),
|
|
84
91
|
inputSchema: config.input,
|
|
85
92
|
outputSchema: config.output,
|
|
86
93
|
run: config.run,
|
|
@@ -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,6EAA6E;AAC7E,4EAA4E;AAC5E,6EAA6E;AAC7E,8EAA8E;AAC9E,4EAA4E;AAC5E,kCAAkC;AAClC,8EAA8E;AAE9E,IAAI,mBAAuC,CAAC;AAE5C,qFAAqF;AACrF,MAAM,UAAU,eAAe,CAAC,UAAkB;IAChD,mBAAmB,GAAG,UAAU,CAAC;AACnC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,mBAAmB,CAAC;AAC7B,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,aAAa,EAAE;QAC3B,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"}
|