@superblocksteam/sdk-api 0.0.4
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/LICENSE.txt +87 -0
- package/README.md +1554 -0
- package/dist/api/definition.d.ts +148 -0
- package/dist/api/definition.d.ts.map +1 -0
- package/dist/api/definition.js +91 -0
- package/dist/api/definition.js.map +1 -0
- package/dist/api/definition.test.d.ts +5 -0
- package/dist/api/definition.test.d.ts.map +1 -0
- package/dist/api/definition.test.js +263 -0
- package/dist/api/definition.test.js.map +1 -0
- package/dist/api/index.d.ts +8 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +7 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/streaming.d.ts +229 -0
- package/dist/api/streaming.d.ts.map +1 -0
- package/dist/api/streaming.js +107 -0
- package/dist/api/streaming.js.map +1 -0
- package/dist/api/streaming.test.d.ts +5 -0
- package/dist/api/streaming.test.d.ts.map +1 -0
- package/dist/api/streaming.test.js +364 -0
- package/dist/api/streaming.test.js.map +1 -0
- package/dist/errors.d.ts +131 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +84 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +113 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +75 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/airtable/client.d.ts +19 -0
- package/dist/integrations/airtable/client.d.ts.map +1 -0
- package/dist/integrations/airtable/client.js +18 -0
- package/dist/integrations/airtable/client.js.map +1 -0
- package/dist/integrations/airtable/index.d.ts +3 -0
- package/dist/integrations/airtable/index.d.ts.map +1 -0
- package/dist/integrations/airtable/index.js +2 -0
- package/dist/integrations/airtable/index.js.map +1 -0
- package/dist/integrations/airtable/types.d.ts +27 -0
- package/dist/integrations/airtable/types.d.ts.map +1 -0
- package/dist/integrations/airtable/types.js +5 -0
- package/dist/integrations/airtable/types.js.map +1 -0
- package/dist/integrations/anthropic/client.d.ts +19 -0
- package/dist/integrations/anthropic/client.d.ts.map +1 -0
- package/dist/integrations/anthropic/client.js +18 -0
- package/dist/integrations/anthropic/client.js.map +1 -0
- package/dist/integrations/anthropic/index.d.ts +3 -0
- package/dist/integrations/anthropic/index.d.ts.map +1 -0
- package/dist/integrations/anthropic/index.js +2 -0
- package/dist/integrations/anthropic/index.js.map +1 -0
- package/dist/integrations/anthropic/types.d.ts +78 -0
- package/dist/integrations/anthropic/types.d.ts.map +1 -0
- package/dist/integrations/anthropic/types.js +5 -0
- package/dist/integrations/anthropic/types.js.map +1 -0
- package/dist/integrations/asana/client.d.ts +19 -0
- package/dist/integrations/asana/client.d.ts.map +1 -0
- package/dist/integrations/asana/client.js +18 -0
- package/dist/integrations/asana/client.js.map +1 -0
- package/dist/integrations/asana/index.d.ts +3 -0
- package/dist/integrations/asana/index.d.ts.map +1 -0
- package/dist/integrations/asana/index.js +2 -0
- package/dist/integrations/asana/index.js.map +1 -0
- package/dist/integrations/asana/types.d.ts +33 -0
- package/dist/integrations/asana/types.d.ts.map +1 -0
- package/dist/integrations/asana/types.js +5 -0
- package/dist/integrations/asana/types.js.map +1 -0
- package/dist/integrations/athena/client.d.ts +37 -0
- package/dist/integrations/athena/client.d.ts.map +1 -0
- package/dist/integrations/athena/client.js +95 -0
- package/dist/integrations/athena/client.js.map +1 -0
- package/dist/integrations/athena/index.d.ts +8 -0
- package/dist/integrations/athena/index.d.ts.map +1 -0
- package/dist/integrations/athena/index.js +7 -0
- package/dist/integrations/athena/index.js.map +1 -0
- package/dist/integrations/athena/types.d.ts +55 -0
- package/dist/integrations/athena/types.d.ts.map +1 -0
- package/dist/integrations/athena/types.js +7 -0
- package/dist/integrations/athena/types.js.map +1 -0
- package/dist/integrations/base/graphql-integration-client.d.ts +57 -0
- package/dist/integrations/base/graphql-integration-client.d.ts.map +1 -0
- package/dist/integrations/base/graphql-integration-client.js +89 -0
- package/dist/integrations/base/graphql-integration-client.js.map +1 -0
- package/dist/integrations/base/index.d.ts +8 -0
- package/dist/integrations/base/index.d.ts.map +1 -0
- package/dist/integrations/base/index.js +6 -0
- package/dist/integrations/base/index.js.map +1 -0
- package/dist/integrations/base/rest-api-integration-client.d.ts +78 -0
- package/dist/integrations/base/rest-api-integration-client.d.ts.map +1 -0
- package/dist/integrations/base/rest-api-integration-client.js +194 -0
- package/dist/integrations/base/rest-api-integration-client.js.map +1 -0
- package/dist/integrations/base/types.d.ts +157 -0
- package/dist/integrations/base/types.d.ts.map +1 -0
- package/dist/integrations/base/types.js +5 -0
- package/dist/integrations/base/types.js.map +1 -0
- package/dist/integrations/bigquery/client.d.ts +37 -0
- package/dist/integrations/bigquery/client.d.ts.map +1 -0
- package/dist/integrations/bigquery/client.js +93 -0
- package/dist/integrations/bigquery/client.js.map +1 -0
- package/dist/integrations/bigquery/index.d.ts +8 -0
- package/dist/integrations/bigquery/index.d.ts.map +1 -0
- package/dist/integrations/bigquery/index.js +7 -0
- package/dist/integrations/bigquery/index.js.map +1 -0
- package/dist/integrations/bigquery/types.d.ts +55 -0
- package/dist/integrations/bigquery/types.d.ts.map +1 -0
- package/dist/integrations/bigquery/types.js +7 -0
- package/dist/integrations/bigquery/types.js.map +1 -0
- package/dist/integrations/bitbucket/client.d.ts +19 -0
- package/dist/integrations/bitbucket/client.d.ts.map +1 -0
- package/dist/integrations/bitbucket/client.js +18 -0
- package/dist/integrations/bitbucket/client.js.map +1 -0
- package/dist/integrations/bitbucket/index.d.ts +3 -0
- package/dist/integrations/bitbucket/index.d.ts.map +1 -0
- package/dist/integrations/bitbucket/index.js +2 -0
- package/dist/integrations/bitbucket/index.js.map +1 -0
- package/dist/integrations/bitbucket/types.d.ts +33 -0
- package/dist/integrations/bitbucket/types.d.ts.map +1 -0
- package/dist/integrations/bitbucket/types.js +5 -0
- package/dist/integrations/bitbucket/types.js.map +1 -0
- package/dist/integrations/box/client.d.ts +19 -0
- package/dist/integrations/box/client.d.ts.map +1 -0
- package/dist/integrations/box/client.js +18 -0
- package/dist/integrations/box/client.js.map +1 -0
- package/dist/integrations/box/index.d.ts +3 -0
- package/dist/integrations/box/index.d.ts.map +1 -0
- package/dist/integrations/box/index.js +2 -0
- package/dist/integrations/box/index.js.map +1 -0
- package/dist/integrations/box/types.d.ts +33 -0
- package/dist/integrations/box/types.d.ts.map +1 -0
- package/dist/integrations/box/types.js +5 -0
- package/dist/integrations/box/types.js.map +1 -0
- package/dist/integrations/circleci/client.d.ts +19 -0
- package/dist/integrations/circleci/client.d.ts.map +1 -0
- package/dist/integrations/circleci/client.js +18 -0
- package/dist/integrations/circleci/client.js.map +1 -0
- package/dist/integrations/circleci/index.d.ts +3 -0
- package/dist/integrations/circleci/index.d.ts.map +1 -0
- package/dist/integrations/circleci/index.js +2 -0
- package/dist/integrations/circleci/index.js.map +1 -0
- package/dist/integrations/circleci/types.d.ts +33 -0
- package/dist/integrations/circleci/types.d.ts.map +1 -0
- package/dist/integrations/circleci/types.js +5 -0
- package/dist/integrations/circleci/types.js.map +1 -0
- package/dist/integrations/cockroachdb/client.d.ts +37 -0
- package/dist/integrations/cockroachdb/client.d.ts.map +1 -0
- package/dist/integrations/cockroachdb/client.js +93 -0
- package/dist/integrations/cockroachdb/client.js.map +1 -0
- package/dist/integrations/cockroachdb/index.d.ts +8 -0
- package/dist/integrations/cockroachdb/index.d.ts.map +1 -0
- package/dist/integrations/cockroachdb/index.js +7 -0
- package/dist/integrations/cockroachdb/index.js.map +1 -0
- package/dist/integrations/cockroachdb/types.d.ts +55 -0
- package/dist/integrations/cockroachdb/types.d.ts.map +1 -0
- package/dist/integrations/cockroachdb/types.js +7 -0
- package/dist/integrations/cockroachdb/types.js.map +1 -0
- package/dist/integrations/cohere/client.d.ts +19 -0
- package/dist/integrations/cohere/client.d.ts.map +1 -0
- package/dist/integrations/cohere/client.js +18 -0
- package/dist/integrations/cohere/client.js.map +1 -0
- package/dist/integrations/cohere/index.d.ts +3 -0
- package/dist/integrations/cohere/index.d.ts.map +1 -0
- package/dist/integrations/cohere/index.js +2 -0
- package/dist/integrations/cohere/index.js.map +1 -0
- package/dist/integrations/cohere/types.d.ts +27 -0
- package/dist/integrations/cohere/types.d.ts.map +1 -0
- package/dist/integrations/cohere/types.js +5 -0
- package/dist/integrations/cohere/types.js.map +1 -0
- package/dist/integrations/confluence/client.d.ts +19 -0
- package/dist/integrations/confluence/client.d.ts.map +1 -0
- package/dist/integrations/confluence/client.js +18 -0
- package/dist/integrations/confluence/client.js.map +1 -0
- package/dist/integrations/confluence/index.d.ts +3 -0
- package/dist/integrations/confluence/index.d.ts.map +1 -0
- package/dist/integrations/confluence/index.js +2 -0
- package/dist/integrations/confluence/index.js.map +1 -0
- package/dist/integrations/confluence/types.d.ts +33 -0
- package/dist/integrations/confluence/types.d.ts.map +1 -0
- package/dist/integrations/confluence/types.js +5 -0
- package/dist/integrations/confluence/types.js.map +1 -0
- package/dist/integrations/cosmosdb/client.d.ts +39 -0
- package/dist/integrations/cosmosdb/client.d.ts.map +1 -0
- package/dist/integrations/cosmosdb/client.js +130 -0
- package/dist/integrations/cosmosdb/client.js.map +1 -0
- package/dist/integrations/cosmosdb/index.d.ts +8 -0
- package/dist/integrations/cosmosdb/index.d.ts.map +1 -0
- package/dist/integrations/cosmosdb/index.js +7 -0
- package/dist/integrations/cosmosdb/index.js.map +1 -0
- package/dist/integrations/cosmosdb/types.d.ts +113 -0
- package/dist/integrations/cosmosdb/types.d.ts.map +1 -0
- package/dist/integrations/cosmosdb/types.js +5 -0
- package/dist/integrations/cosmosdb/types.js.map +1 -0
- package/dist/integrations/couchbase/client.d.ts +30 -0
- package/dist/integrations/couchbase/client.d.ts.map +1 -0
- package/dist/integrations/couchbase/client.js +154 -0
- package/dist/integrations/couchbase/client.js.map +1 -0
- package/dist/integrations/couchbase/index.d.ts +8 -0
- package/dist/integrations/couchbase/index.d.ts.map +1 -0
- package/dist/integrations/couchbase/index.js +7 -0
- package/dist/integrations/couchbase/index.js.map +1 -0
- package/dist/integrations/couchbase/types.d.ts +100 -0
- package/dist/integrations/couchbase/types.d.ts.map +1 -0
- package/dist/integrations/couchbase/types.js +5 -0
- package/dist/integrations/couchbase/types.js.map +1 -0
- package/dist/integrations/databricks/client.d.ts +37 -0
- package/dist/integrations/databricks/client.d.ts.map +1 -0
- package/dist/integrations/databricks/client.js +95 -0
- package/dist/integrations/databricks/client.js.map +1 -0
- package/dist/integrations/databricks/index.d.ts +8 -0
- package/dist/integrations/databricks/index.d.ts.map +1 -0
- package/dist/integrations/databricks/index.js +7 -0
- package/dist/integrations/databricks/index.js.map +1 -0
- package/dist/integrations/databricks/types.d.ts +55 -0
- package/dist/integrations/databricks/types.d.ts.map +1 -0
- package/dist/integrations/databricks/types.js +7 -0
- package/dist/integrations/databricks/types.js.map +1 -0
- package/dist/integrations/datadog/client.d.ts +19 -0
- package/dist/integrations/datadog/client.d.ts.map +1 -0
- package/dist/integrations/datadog/client.js +18 -0
- package/dist/integrations/datadog/client.js.map +1 -0
- package/dist/integrations/datadog/index.d.ts +3 -0
- package/dist/integrations/datadog/index.d.ts.map +1 -0
- package/dist/integrations/datadog/index.js +2 -0
- package/dist/integrations/datadog/index.js.map +1 -0
- package/dist/integrations/datadog/types.d.ts +33 -0
- package/dist/integrations/datadog/types.d.ts.map +1 -0
- package/dist/integrations/datadog/types.js +5 -0
- package/dist/integrations/datadog/types.js.map +1 -0
- package/dist/integrations/declarations.d.ts +865 -0
- package/dist/integrations/declarations.d.ts.map +1 -0
- package/dist/integrations/declarations.js +753 -0
- package/dist/integrations/declarations.js.map +1 -0
- package/dist/integrations/declarations.test.d.ts +2 -0
- package/dist/integrations/declarations.test.d.ts.map +1 -0
- package/dist/integrations/declarations.test.js +40 -0
- package/dist/integrations/declarations.test.js.map +1 -0
- package/dist/integrations/dropbox/client.d.ts +19 -0
- package/dist/integrations/dropbox/client.d.ts.map +1 -0
- package/dist/integrations/dropbox/client.js +18 -0
- package/dist/integrations/dropbox/client.js.map +1 -0
- package/dist/integrations/dropbox/index.d.ts +3 -0
- package/dist/integrations/dropbox/index.d.ts.map +1 -0
- package/dist/integrations/dropbox/index.js +2 -0
- package/dist/integrations/dropbox/index.js.map +1 -0
- package/dist/integrations/dropbox/types.d.ts +33 -0
- package/dist/integrations/dropbox/types.d.ts.map +1 -0
- package/dist/integrations/dropbox/types.js +5 -0
- package/dist/integrations/dropbox/types.js.map +1 -0
- package/dist/integrations/dynamodb/client.d.ts +54 -0
- package/dist/integrations/dynamodb/client.d.ts.map +1 -0
- package/dist/integrations/dynamodb/client.js +169 -0
- package/dist/integrations/dynamodb/client.js.map +1 -0
- package/dist/integrations/dynamodb/index.d.ts +8 -0
- package/dist/integrations/dynamodb/index.d.ts.map +1 -0
- package/dist/integrations/dynamodb/index.js +7 -0
- package/dist/integrations/dynamodb/index.js.map +1 -0
- package/dist/integrations/dynamodb/types.d.ts +209 -0
- package/dist/integrations/dynamodb/types.d.ts.map +1 -0
- package/dist/integrations/dynamodb/types.js +8 -0
- package/dist/integrations/dynamodb/types.js.map +1 -0
- package/dist/integrations/elasticsearch/client.d.ts +19 -0
- package/dist/integrations/elasticsearch/client.d.ts.map +1 -0
- package/dist/integrations/elasticsearch/client.js +18 -0
- package/dist/integrations/elasticsearch/client.js.map +1 -0
- package/dist/integrations/elasticsearch/index.d.ts +3 -0
- package/dist/integrations/elasticsearch/index.d.ts.map +1 -0
- package/dist/integrations/elasticsearch/index.js +2 -0
- package/dist/integrations/elasticsearch/index.js.map +1 -0
- package/dist/integrations/elasticsearch/types.d.ts +33 -0
- package/dist/integrations/elasticsearch/types.d.ts.map +1 -0
- package/dist/integrations/elasticsearch/types.js +5 -0
- package/dist/integrations/elasticsearch/types.js.map +1 -0
- package/dist/integrations/fireworks/client.d.ts +19 -0
- package/dist/integrations/fireworks/client.d.ts.map +1 -0
- package/dist/integrations/fireworks/client.js +18 -0
- package/dist/integrations/fireworks/client.js.map +1 -0
- package/dist/integrations/fireworks/index.d.ts +3 -0
- package/dist/integrations/fireworks/index.d.ts.map +1 -0
- package/dist/integrations/fireworks/index.js +2 -0
- package/dist/integrations/fireworks/index.js.map +1 -0
- package/dist/integrations/fireworks/types.d.ts +33 -0
- package/dist/integrations/fireworks/types.d.ts.map +1 -0
- package/dist/integrations/fireworks/types.js +5 -0
- package/dist/integrations/fireworks/types.js.map +1 -0
- package/dist/integrations/front/client.d.ts +19 -0
- package/dist/integrations/front/client.d.ts.map +1 -0
- package/dist/integrations/front/client.js +18 -0
- package/dist/integrations/front/client.js.map +1 -0
- package/dist/integrations/front/index.d.ts +3 -0
- package/dist/integrations/front/index.d.ts.map +1 -0
- package/dist/integrations/front/index.js +2 -0
- package/dist/integrations/front/index.js.map +1 -0
- package/dist/integrations/front/types.d.ts +33 -0
- package/dist/integrations/front/types.d.ts.map +1 -0
- package/dist/integrations/front/types.js +5 -0
- package/dist/integrations/front/types.js.map +1 -0
- package/dist/integrations/gcs/client.d.ts +39 -0
- package/dist/integrations/gcs/client.d.ts.map +1 -0
- package/dist/integrations/gcs/client.js +128 -0
- package/dist/integrations/gcs/client.js.map +1 -0
- package/dist/integrations/gcs/index.d.ts +8 -0
- package/dist/integrations/gcs/index.d.ts.map +1 -0
- package/dist/integrations/gcs/index.js +7 -0
- package/dist/integrations/gcs/index.js.map +1 -0
- package/dist/integrations/gcs/types.d.ts +121 -0
- package/dist/integrations/gcs/types.d.ts.map +1 -0
- package/dist/integrations/gcs/types.js +5 -0
- package/dist/integrations/gcs/types.js.map +1 -0
- package/dist/integrations/gemini/client.d.ts +19 -0
- package/dist/integrations/gemini/client.d.ts.map +1 -0
- package/dist/integrations/gemini/client.js +18 -0
- package/dist/integrations/gemini/client.js.map +1 -0
- package/dist/integrations/gemini/index.d.ts +3 -0
- package/dist/integrations/gemini/index.d.ts.map +1 -0
- package/dist/integrations/gemini/index.js +2 -0
- package/dist/integrations/gemini/index.js.map +1 -0
- package/dist/integrations/gemini/types.d.ts +33 -0
- package/dist/integrations/gemini/types.d.ts.map +1 -0
- package/dist/integrations/gemini/types.js +5 -0
- package/dist/integrations/gemini/types.js.map +1 -0
- package/dist/integrations/github/client.d.ts +19 -0
- package/dist/integrations/github/client.d.ts.map +1 -0
- package/dist/integrations/github/client.js +18 -0
- package/dist/integrations/github/client.js.map +1 -0
- package/dist/integrations/github/index.d.ts +3 -0
- package/dist/integrations/github/index.d.ts.map +1 -0
- package/dist/integrations/github/index.js +2 -0
- package/dist/integrations/github/index.js.map +1 -0
- package/dist/integrations/github/types.d.ts +68 -0
- package/dist/integrations/github/types.d.ts.map +1 -0
- package/dist/integrations/github/types.js +5 -0
- package/dist/integrations/github/types.js.map +1 -0
- package/dist/integrations/googleanalytics/client.d.ts +19 -0
- package/dist/integrations/googleanalytics/client.d.ts.map +1 -0
- package/dist/integrations/googleanalytics/client.js +18 -0
- package/dist/integrations/googleanalytics/client.js.map +1 -0
- package/dist/integrations/googleanalytics/index.d.ts +3 -0
- package/dist/integrations/googleanalytics/index.d.ts.map +1 -0
- package/dist/integrations/googleanalytics/index.js +2 -0
- package/dist/integrations/googleanalytics/index.js.map +1 -0
- package/dist/integrations/googleanalytics/types.d.ts +33 -0
- package/dist/integrations/googleanalytics/types.d.ts.map +1 -0
- package/dist/integrations/googleanalytics/types.js +5 -0
- package/dist/integrations/googleanalytics/types.js.map +1 -0
- package/dist/integrations/googledrive/client.d.ts +19 -0
- package/dist/integrations/googledrive/client.d.ts.map +1 -0
- package/dist/integrations/googledrive/client.js +18 -0
- package/dist/integrations/googledrive/client.js.map +1 -0
- package/dist/integrations/googledrive/index.d.ts +3 -0
- package/dist/integrations/googledrive/index.d.ts.map +1 -0
- package/dist/integrations/googledrive/index.js +2 -0
- package/dist/integrations/googledrive/index.js.map +1 -0
- package/dist/integrations/googledrive/types.d.ts +33 -0
- package/dist/integrations/googledrive/types.d.ts.map +1 -0
- package/dist/integrations/googledrive/types.js +5 -0
- package/dist/integrations/googledrive/types.js.map +1 -0
- package/dist/integrations/graphql/client.d.ts +19 -0
- package/dist/integrations/graphql/client.d.ts.map +1 -0
- package/dist/integrations/graphql/client.js +18 -0
- package/dist/integrations/graphql/client.js.map +1 -0
- package/dist/integrations/graphql/index.d.ts +3 -0
- package/dist/integrations/graphql/index.d.ts.map +1 -0
- package/dist/integrations/graphql/index.js +2 -0
- package/dist/integrations/graphql/index.js.map +1 -0
- package/dist/integrations/graphql/types.d.ts +123 -0
- package/dist/integrations/graphql/types.d.ts.map +1 -0
- package/dist/integrations/graphql/types.js +5 -0
- package/dist/integrations/graphql/types.js.map +1 -0
- package/dist/integrations/groq/client.d.ts +19 -0
- package/dist/integrations/groq/client.d.ts.map +1 -0
- package/dist/integrations/groq/client.js +18 -0
- package/dist/integrations/groq/client.js.map +1 -0
- package/dist/integrations/groq/index.d.ts +3 -0
- package/dist/integrations/groq/index.d.ts.map +1 -0
- package/dist/integrations/groq/index.js +2 -0
- package/dist/integrations/groq/index.js.map +1 -0
- package/dist/integrations/groq/types.d.ts +33 -0
- package/dist/integrations/groq/types.d.ts.map +1 -0
- package/dist/integrations/groq/types.js +5 -0
- package/dist/integrations/groq/types.js.map +1 -0
- package/dist/integrations/gsheets/client.d.ts +22 -0
- package/dist/integrations/gsheets/client.d.ts.map +1 -0
- package/dist/integrations/gsheets/client.js +94 -0
- package/dist/integrations/gsheets/client.js.map +1 -0
- package/dist/integrations/gsheets/index.d.ts +8 -0
- package/dist/integrations/gsheets/index.d.ts.map +1 -0
- package/dist/integrations/gsheets/index.js +7 -0
- package/dist/integrations/gsheets/index.js.map +1 -0
- package/dist/integrations/gsheets/types.d.ts +88 -0
- package/dist/integrations/gsheets/types.d.ts.map +1 -0
- package/dist/integrations/gsheets/types.js +5 -0
- package/dist/integrations/gsheets/types.js.map +1 -0
- package/dist/integrations/hubspot/client.d.ts +19 -0
- package/dist/integrations/hubspot/client.d.ts.map +1 -0
- package/dist/integrations/hubspot/client.js +18 -0
- package/dist/integrations/hubspot/client.js.map +1 -0
- package/dist/integrations/hubspot/index.d.ts +3 -0
- package/dist/integrations/hubspot/index.d.ts.map +1 -0
- package/dist/integrations/hubspot/index.js +2 -0
- package/dist/integrations/hubspot/index.js.map +1 -0
- package/dist/integrations/hubspot/types.d.ts +33 -0
- package/dist/integrations/hubspot/types.d.ts.map +1 -0
- package/dist/integrations/hubspot/types.js +5 -0
- package/dist/integrations/hubspot/types.js.map +1 -0
- package/dist/integrations/index.d.ts +140 -0
- package/dist/integrations/index.d.ts.map +1 -0
- package/dist/integrations/index.js +81 -0
- package/dist/integrations/index.js.map +1 -0
- package/dist/integrations/intercom/client.d.ts +19 -0
- package/dist/integrations/intercom/client.d.ts.map +1 -0
- package/dist/integrations/intercom/client.js +18 -0
- package/dist/integrations/intercom/client.js.map +1 -0
- package/dist/integrations/intercom/index.d.ts +3 -0
- package/dist/integrations/intercom/index.d.ts.map +1 -0
- package/dist/integrations/intercom/index.js +2 -0
- package/dist/integrations/intercom/index.js.map +1 -0
- package/dist/integrations/intercom/types.d.ts +33 -0
- package/dist/integrations/intercom/types.d.ts.map +1 -0
- package/dist/integrations/intercom/types.js +5 -0
- package/dist/integrations/intercom/types.js.map +1 -0
- package/dist/integrations/jira/client.d.ts +19 -0
- package/dist/integrations/jira/client.d.ts.map +1 -0
- package/dist/integrations/jira/client.js +18 -0
- package/dist/integrations/jira/client.js.map +1 -0
- package/dist/integrations/jira/index.d.ts +3 -0
- package/dist/integrations/jira/index.d.ts.map +1 -0
- package/dist/integrations/jira/index.js +2 -0
- package/dist/integrations/jira/index.js.map +1 -0
- package/dist/integrations/jira/types.d.ts +33 -0
- package/dist/integrations/jira/types.d.ts.map +1 -0
- package/dist/integrations/jira/types.js +5 -0
- package/dist/integrations/jira/types.js.map +1 -0
- package/dist/integrations/kafka/client.d.ts +25 -0
- package/dist/integrations/kafka/client.d.ts.map +1 -0
- package/dist/integrations/kafka/client.js +124 -0
- package/dist/integrations/kafka/client.js.map +1 -0
- package/dist/integrations/kafka/index.d.ts +8 -0
- package/dist/integrations/kafka/index.d.ts.map +1 -0
- package/dist/integrations/kafka/index.js +7 -0
- package/dist/integrations/kafka/index.js.map +1 -0
- package/dist/integrations/kafka/types.d.ts +113 -0
- package/dist/integrations/kafka/types.d.ts.map +1 -0
- package/dist/integrations/kafka/types.js +5 -0
- package/dist/integrations/kafka/types.js.map +1 -0
- package/dist/integrations/kinesis/client.d.ts +31 -0
- package/dist/integrations/kinesis/client.d.ts.map +1 -0
- package/dist/integrations/kinesis/client.js +101 -0
- package/dist/integrations/kinesis/client.js.map +1 -0
- package/dist/integrations/kinesis/index.d.ts +8 -0
- package/dist/integrations/kinesis/index.d.ts.map +1 -0
- package/dist/integrations/kinesis/index.js +7 -0
- package/dist/integrations/kinesis/index.js.map +1 -0
- package/dist/integrations/kinesis/types.d.ts +97 -0
- package/dist/integrations/kinesis/types.d.ts.map +1 -0
- package/dist/integrations/kinesis/types.js +7 -0
- package/dist/integrations/kinesis/types.js.map +1 -0
- package/dist/integrations/lakebase/client.d.ts +36 -0
- package/dist/integrations/lakebase/client.d.ts.map +1 -0
- package/dist/integrations/lakebase/client.js +90 -0
- package/dist/integrations/lakebase/client.js.map +1 -0
- package/dist/integrations/lakebase/index.d.ts +8 -0
- package/dist/integrations/lakebase/index.d.ts.map +1 -0
- package/dist/integrations/lakebase/index.js +7 -0
- package/dist/integrations/lakebase/index.js.map +1 -0
- package/dist/integrations/lakebase/types.d.ts +52 -0
- package/dist/integrations/lakebase/types.d.ts.map +1 -0
- package/dist/integrations/lakebase/types.js +8 -0
- package/dist/integrations/lakebase/types.js.map +1 -0
- package/dist/integrations/launchdarkly/client.d.ts +19 -0
- package/dist/integrations/launchdarkly/client.d.ts.map +1 -0
- package/dist/integrations/launchdarkly/client.js +18 -0
- package/dist/integrations/launchdarkly/client.js.map +1 -0
- package/dist/integrations/launchdarkly/index.d.ts +3 -0
- package/dist/integrations/launchdarkly/index.d.ts.map +1 -0
- package/dist/integrations/launchdarkly/index.js +2 -0
- package/dist/integrations/launchdarkly/index.js.map +1 -0
- package/dist/integrations/launchdarkly/types.d.ts +33 -0
- package/dist/integrations/launchdarkly/types.d.ts.map +1 -0
- package/dist/integrations/launchdarkly/types.js +5 -0
- package/dist/integrations/launchdarkly/types.js.map +1 -0
- package/dist/integrations/mariadb/client.d.ts +37 -0
- package/dist/integrations/mariadb/client.d.ts.map +1 -0
- package/dist/integrations/mariadb/client.js +93 -0
- package/dist/integrations/mariadb/client.js.map +1 -0
- package/dist/integrations/mariadb/index.d.ts +8 -0
- package/dist/integrations/mariadb/index.d.ts.map +1 -0
- package/dist/integrations/mariadb/index.js +7 -0
- package/dist/integrations/mariadb/index.js.map +1 -0
- package/dist/integrations/mariadb/types.d.ts +55 -0
- package/dist/integrations/mariadb/types.d.ts.map +1 -0
- package/dist/integrations/mariadb/types.js +7 -0
- package/dist/integrations/mariadb/types.js.map +1 -0
- package/dist/integrations/mistral/client.d.ts +19 -0
- package/dist/integrations/mistral/client.d.ts.map +1 -0
- package/dist/integrations/mistral/client.js +18 -0
- package/dist/integrations/mistral/client.js.map +1 -0
- package/dist/integrations/mistral/index.d.ts +3 -0
- package/dist/integrations/mistral/index.d.ts.map +1 -0
- package/dist/integrations/mistral/index.js +2 -0
- package/dist/integrations/mistral/index.js.map +1 -0
- package/dist/integrations/mistral/types.d.ts +33 -0
- package/dist/integrations/mistral/types.d.ts.map +1 -0
- package/dist/integrations/mistral/types.js +5 -0
- package/dist/integrations/mistral/types.js.map +1 -0
- package/dist/integrations/mongodb/client.d.ts +22 -0
- package/dist/integrations/mongodb/client.d.ts.map +1 -0
- package/dist/integrations/mongodb/client.js +95 -0
- package/dist/integrations/mongodb/client.js.map +1 -0
- package/dist/integrations/mongodb/index.d.ts +8 -0
- package/dist/integrations/mongodb/index.d.ts.map +1 -0
- package/dist/integrations/mongodb/index.js +7 -0
- package/dist/integrations/mongodb/index.js.map +1 -0
- package/dist/integrations/mongodb/types.d.ts +83 -0
- package/dist/integrations/mongodb/types.d.ts.map +1 -0
- package/dist/integrations/mongodb/types.js +5 -0
- package/dist/integrations/mongodb/types.js.map +1 -0
- package/dist/integrations/mssql/client.d.ts +37 -0
- package/dist/integrations/mssql/client.d.ts.map +1 -0
- package/dist/integrations/mssql/client.js +93 -0
- package/dist/integrations/mssql/client.js.map +1 -0
- package/dist/integrations/mssql/index.d.ts +8 -0
- package/dist/integrations/mssql/index.d.ts.map +1 -0
- package/dist/integrations/mssql/index.js +7 -0
- package/dist/integrations/mssql/index.js.map +1 -0
- package/dist/integrations/mssql/types.d.ts +55 -0
- package/dist/integrations/mssql/types.d.ts.map +1 -0
- package/dist/integrations/mssql/types.js +7 -0
- package/dist/integrations/mssql/types.js.map +1 -0
- package/dist/integrations/mysql/client.d.ts +37 -0
- package/dist/integrations/mysql/client.d.ts.map +1 -0
- package/dist/integrations/mysql/client.js +93 -0
- package/dist/integrations/mysql/client.js.map +1 -0
- package/dist/integrations/mysql/index.d.ts +8 -0
- package/dist/integrations/mysql/index.d.ts.map +1 -0
- package/dist/integrations/mysql/index.js +7 -0
- package/dist/integrations/mysql/index.js.map +1 -0
- package/dist/integrations/mysql/types.d.ts +79 -0
- package/dist/integrations/mysql/types.d.ts.map +1 -0
- package/dist/integrations/mysql/types.js +7 -0
- package/dist/integrations/mysql/types.js.map +1 -0
- package/dist/integrations/notion/client.d.ts +19 -0
- package/dist/integrations/notion/client.d.ts.map +1 -0
- package/dist/integrations/notion/client.js +18 -0
- package/dist/integrations/notion/client.js.map +1 -0
- package/dist/integrations/notion/index.d.ts +3 -0
- package/dist/integrations/notion/index.d.ts.map +1 -0
- package/dist/integrations/notion/index.js +2 -0
- package/dist/integrations/notion/index.js.map +1 -0
- package/dist/integrations/notion/types.d.ts +70 -0
- package/dist/integrations/notion/types.d.ts.map +1 -0
- package/dist/integrations/notion/types.js +5 -0
- package/dist/integrations/notion/types.js.map +1 -0
- package/dist/integrations/openai_v2/client.d.ts +19 -0
- package/dist/integrations/openai_v2/client.d.ts.map +1 -0
- package/dist/integrations/openai_v2/client.js +18 -0
- package/dist/integrations/openai_v2/client.js.map +1 -0
- package/dist/integrations/openai_v2/index.d.ts +3 -0
- package/dist/integrations/openai_v2/index.d.ts.map +1 -0
- package/dist/integrations/openai_v2/index.js +2 -0
- package/dist/integrations/openai_v2/index.js.map +1 -0
- package/dist/integrations/openai_v2/types.d.ts +76 -0
- package/dist/integrations/openai_v2/types.d.ts.map +1 -0
- package/dist/integrations/openai_v2/types.js +5 -0
- package/dist/integrations/openai_v2/types.js.map +1 -0
- package/dist/integrations/oracledb/client.d.ts +37 -0
- package/dist/integrations/oracledb/client.d.ts.map +1 -0
- package/dist/integrations/oracledb/client.js +95 -0
- package/dist/integrations/oracledb/client.js.map +1 -0
- package/dist/integrations/oracledb/index.d.ts +8 -0
- package/dist/integrations/oracledb/index.d.ts.map +1 -0
- package/dist/integrations/oracledb/index.js +7 -0
- package/dist/integrations/oracledb/index.js.map +1 -0
- package/dist/integrations/oracledb/types.d.ts +55 -0
- package/dist/integrations/oracledb/types.d.ts.map +1 -0
- package/dist/integrations/oracledb/types.js +7 -0
- package/dist/integrations/oracledb/types.js.map +1 -0
- package/dist/integrations/pagerduty/client.d.ts +19 -0
- package/dist/integrations/pagerduty/client.d.ts.map +1 -0
- package/dist/integrations/pagerduty/client.js +18 -0
- package/dist/integrations/pagerduty/client.js.map +1 -0
- package/dist/integrations/pagerduty/index.d.ts +3 -0
- package/dist/integrations/pagerduty/index.d.ts.map +1 -0
- package/dist/integrations/pagerduty/index.js +2 -0
- package/dist/integrations/pagerduty/index.js.map +1 -0
- package/dist/integrations/pagerduty/types.d.ts +33 -0
- package/dist/integrations/pagerduty/types.d.ts.map +1 -0
- package/dist/integrations/pagerduty/types.js +5 -0
- package/dist/integrations/pagerduty/types.js.map +1 -0
- package/dist/integrations/perplexity/client.d.ts +19 -0
- package/dist/integrations/perplexity/client.d.ts.map +1 -0
- package/dist/integrations/perplexity/client.js +18 -0
- package/dist/integrations/perplexity/client.js.map +1 -0
- package/dist/integrations/perplexity/index.d.ts +3 -0
- package/dist/integrations/perplexity/index.d.ts.map +1 -0
- package/dist/integrations/perplexity/index.js +2 -0
- package/dist/integrations/perplexity/index.js.map +1 -0
- package/dist/integrations/perplexity/types.d.ts +33 -0
- package/dist/integrations/perplexity/types.d.ts.map +1 -0
- package/dist/integrations/perplexity/types.js +5 -0
- package/dist/integrations/perplexity/types.js.map +1 -0
- package/dist/integrations/postgres/client.d.ts +49 -0
- package/dist/integrations/postgres/client.d.ts.map +1 -0
- package/dist/integrations/postgres/client.js +96 -0
- package/dist/integrations/postgres/client.js.map +1 -0
- package/dist/integrations/postgres/index.d.ts +6 -0
- package/dist/integrations/postgres/index.d.ts.map +1 -0
- package/dist/integrations/postgres/index.js +5 -0
- package/dist/integrations/postgres/index.js.map +1 -0
- package/dist/integrations/postgres/types.d.ts +97 -0
- package/dist/integrations/postgres/types.d.ts.map +1 -0
- package/dist/integrations/postgres/types.js +5 -0
- package/dist/integrations/postgres/types.js.map +1 -0
- package/dist/integrations/python/client.d.ts +42 -0
- package/dist/integrations/python/client.d.ts.map +1 -0
- package/dist/integrations/python/client.js +89 -0
- package/dist/integrations/python/client.js.map +1 -0
- package/dist/integrations/python/client.test.d.ts +5 -0
- package/dist/integrations/python/client.test.d.ts.map +1 -0
- package/dist/integrations/python/client.test.js +214 -0
- package/dist/integrations/python/client.test.js.map +1 -0
- package/dist/integrations/python/index.d.ts +6 -0
- package/dist/integrations/python/index.d.ts.map +1 -0
- package/dist/integrations/python/index.js +5 -0
- package/dist/integrations/python/index.js.map +1 -0
- package/dist/integrations/python/types.d.ts +85 -0
- package/dist/integrations/python/types.d.ts.map +1 -0
- package/dist/integrations/python/types.js +5 -0
- package/dist/integrations/python/types.js.map +1 -0
- package/dist/integrations/redis/client.d.ts +43 -0
- package/dist/integrations/redis/client.d.ts.map +1 -0
- package/dist/integrations/redis/client.js +142 -0
- package/dist/integrations/redis/client.js.map +1 -0
- package/dist/integrations/redis/index.d.ts +8 -0
- package/dist/integrations/redis/index.d.ts.map +1 -0
- package/dist/integrations/redis/index.js +7 -0
- package/dist/integrations/redis/index.js.map +1 -0
- package/dist/integrations/redis/types.d.ts +137 -0
- package/dist/integrations/redis/types.d.ts.map +1 -0
- package/dist/integrations/redis/types.js +5 -0
- package/dist/integrations/redis/types.js.map +1 -0
- package/dist/integrations/redshift/client.d.ts +37 -0
- package/dist/integrations/redshift/client.d.ts.map +1 -0
- package/dist/integrations/redshift/client.js +93 -0
- package/dist/integrations/redshift/client.js.map +1 -0
- package/dist/integrations/redshift/index.d.ts +8 -0
- package/dist/integrations/redshift/index.d.ts.map +1 -0
- package/dist/integrations/redshift/index.js +7 -0
- package/dist/integrations/redshift/index.js.map +1 -0
- package/dist/integrations/redshift/types.d.ts +55 -0
- package/dist/integrations/redshift/types.d.ts.map +1 -0
- package/dist/integrations/redshift/types.js +7 -0
- package/dist/integrations/redshift/types.js.map +1 -0
- package/dist/integrations/registry.d.ts +169 -0
- package/dist/integrations/registry.d.ts.map +1 -0
- package/dist/integrations/registry.js +331 -0
- package/dist/integrations/registry.js.map +1 -0
- package/dist/integrations/registry.test.d.ts +2 -0
- package/dist/integrations/registry.test.d.ts.map +1 -0
- package/dist/integrations/registry.test.js +25 -0
- package/dist/integrations/registry.test.js.map +1 -0
- package/dist/integrations/restapiintegration/client.d.ts +19 -0
- package/dist/integrations/restapiintegration/client.d.ts.map +1 -0
- package/dist/integrations/restapiintegration/client.js +18 -0
- package/dist/integrations/restapiintegration/client.js.map +1 -0
- package/dist/integrations/restapiintegration/index.d.ts +6 -0
- package/dist/integrations/restapiintegration/index.d.ts.map +1 -0
- package/dist/integrations/restapiintegration/index.js +5 -0
- package/dist/integrations/restapiintegration/index.js.map +1 -0
- package/dist/integrations/restapiintegration/types.d.ts +33 -0
- package/dist/integrations/restapiintegration/types.d.ts.map +1 -0
- package/dist/integrations/restapiintegration/types.js +5 -0
- package/dist/integrations/restapiintegration/types.js.map +1 -0
- package/dist/integrations/s3/client.d.ts +39 -0
- package/dist/integrations/s3/client.d.ts.map +1 -0
- package/dist/integrations/s3/client.js +131 -0
- package/dist/integrations/s3/client.js.map +1 -0
- package/dist/integrations/s3/index.d.ts +8 -0
- package/dist/integrations/s3/index.d.ts.map +1 -0
- package/dist/integrations/s3/index.js +7 -0
- package/dist/integrations/s3/index.js.map +1 -0
- package/dist/integrations/s3/types.d.ts +123 -0
- package/dist/integrations/s3/types.d.ts.map +1 -0
- package/dist/integrations/s3/types.js +5 -0
- package/dist/integrations/s3/types.js.map +1 -0
- package/dist/integrations/salesforce/client.d.ts +42 -0
- package/dist/integrations/salesforce/client.d.ts.map +1 -0
- package/dist/integrations/salesforce/client.js +173 -0
- package/dist/integrations/salesforce/client.js.map +1 -0
- package/dist/integrations/salesforce/index.d.ts +8 -0
- package/dist/integrations/salesforce/index.d.ts.map +1 -0
- package/dist/integrations/salesforce/index.js +7 -0
- package/dist/integrations/salesforce/index.js.map +1 -0
- package/dist/integrations/salesforce/types.d.ts +135 -0
- package/dist/integrations/salesforce/types.d.ts.map +1 -0
- package/dist/integrations/salesforce/types.js +5 -0
- package/dist/integrations/salesforce/types.js.map +1 -0
- package/dist/integrations/segment/client.d.ts +19 -0
- package/dist/integrations/segment/client.d.ts.map +1 -0
- package/dist/integrations/segment/client.js +18 -0
- package/dist/integrations/segment/client.js.map +1 -0
- package/dist/integrations/segment/index.d.ts +3 -0
- package/dist/integrations/segment/index.d.ts.map +1 -0
- package/dist/integrations/segment/index.js +2 -0
- package/dist/integrations/segment/index.js.map +1 -0
- package/dist/integrations/segment/types.d.ts +33 -0
- package/dist/integrations/segment/types.d.ts.map +1 -0
- package/dist/integrations/segment/types.js +5 -0
- package/dist/integrations/segment/types.js.map +1 -0
- package/dist/integrations/sendgrid/client.d.ts +19 -0
- package/dist/integrations/sendgrid/client.d.ts.map +1 -0
- package/dist/integrations/sendgrid/client.js +18 -0
- package/dist/integrations/sendgrid/client.js.map +1 -0
- package/dist/integrations/sendgrid/index.d.ts +3 -0
- package/dist/integrations/sendgrid/index.d.ts.map +1 -0
- package/dist/integrations/sendgrid/index.js +2 -0
- package/dist/integrations/sendgrid/index.js.map +1 -0
- package/dist/integrations/sendgrid/types.d.ts +33 -0
- package/dist/integrations/sendgrid/types.d.ts.map +1 -0
- package/dist/integrations/sendgrid/types.js +5 -0
- package/dist/integrations/sendgrid/types.js.map +1 -0
- package/dist/integrations/slack/client.d.ts +19 -0
- package/dist/integrations/slack/client.d.ts.map +1 -0
- package/dist/integrations/slack/client.js +18 -0
- package/dist/integrations/slack/client.js.map +1 -0
- package/dist/integrations/slack/index.d.ts +6 -0
- package/dist/integrations/slack/index.d.ts.map +1 -0
- package/dist/integrations/slack/index.js +5 -0
- package/dist/integrations/slack/index.js.map +1 -0
- package/dist/integrations/slack/types.d.ts +48 -0
- package/dist/integrations/slack/types.d.ts.map +1 -0
- package/dist/integrations/slack/types.js +5 -0
- package/dist/integrations/slack/types.js.map +1 -0
- package/dist/integrations/smtp/client.d.ts +24 -0
- package/dist/integrations/smtp/client.d.ts.map +1 -0
- package/dist/integrations/smtp/client.js +49 -0
- package/dist/integrations/smtp/client.js.map +1 -0
- package/dist/integrations/smtp/index.d.ts +8 -0
- package/dist/integrations/smtp/index.d.ts.map +1 -0
- package/dist/integrations/smtp/index.js +7 -0
- package/dist/integrations/smtp/index.js.map +1 -0
- package/dist/integrations/smtp/types.d.ts +56 -0
- package/dist/integrations/smtp/types.d.ts.map +1 -0
- package/dist/integrations/smtp/types.js +7 -0
- package/dist/integrations/smtp/types.js.map +1 -0
- package/dist/integrations/snowflake/client.d.ts +37 -0
- package/dist/integrations/snowflake/client.d.ts.map +1 -0
- package/dist/integrations/snowflake/client.js +97 -0
- package/dist/integrations/snowflake/client.js.map +1 -0
- package/dist/integrations/snowflake/index.d.ts +8 -0
- package/dist/integrations/snowflake/index.d.ts.map +1 -0
- package/dist/integrations/snowflake/index.js +7 -0
- package/dist/integrations/snowflake/index.js.map +1 -0
- package/dist/integrations/snowflake/types.d.ts +79 -0
- package/dist/integrations/snowflake/types.d.ts.map +1 -0
- package/dist/integrations/snowflake/types.js +7 -0
- package/dist/integrations/snowflake/types.js.map +1 -0
- package/dist/integrations/snowflakecortex/client.d.ts +17 -0
- package/dist/integrations/snowflakecortex/client.d.ts.map +1 -0
- package/dist/integrations/snowflakecortex/client.js +16 -0
- package/dist/integrations/snowflakecortex/client.js.map +1 -0
- package/dist/integrations/snowflakecortex/index.d.ts +3 -0
- package/dist/integrations/snowflakecortex/index.d.ts.map +1 -0
- package/dist/integrations/snowflakecortex/index.js +2 -0
- package/dist/integrations/snowflakecortex/index.js.map +1 -0
- package/dist/integrations/snowflakecortex/types.d.ts +14 -0
- package/dist/integrations/snowflakecortex/types.d.ts.map +1 -0
- package/dist/integrations/snowflakecortex/types.js +5 -0
- package/dist/integrations/snowflakecortex/types.js.map +1 -0
- package/dist/integrations/snowflakepostgres/client.d.ts +12 -0
- package/dist/integrations/snowflakepostgres/client.d.ts.map +1 -0
- package/dist/integrations/snowflakepostgres/client.js +11 -0
- package/dist/integrations/snowflakepostgres/client.js.map +1 -0
- package/dist/integrations/snowflakepostgres/index.d.ts +8 -0
- package/dist/integrations/snowflakepostgres/index.d.ts.map +1 -0
- package/dist/integrations/snowflakepostgres/index.js +7 -0
- package/dist/integrations/snowflakepostgres/index.js.map +1 -0
- package/dist/integrations/snowflakepostgres/types.d.ts +52 -0
- package/dist/integrations/snowflakepostgres/types.d.ts.map +1 -0
- package/dist/integrations/snowflakepostgres/types.js +8 -0
- package/dist/integrations/snowflakepostgres/types.js.map +1 -0
- package/dist/integrations/stabilityai/client.d.ts +19 -0
- package/dist/integrations/stabilityai/client.d.ts.map +1 -0
- package/dist/integrations/stabilityai/client.js +18 -0
- package/dist/integrations/stabilityai/client.js.map +1 -0
- package/dist/integrations/stabilityai/index.d.ts +3 -0
- package/dist/integrations/stabilityai/index.d.ts.map +1 -0
- package/dist/integrations/stabilityai/index.js +2 -0
- package/dist/integrations/stabilityai/index.js.map +1 -0
- package/dist/integrations/stabilityai/types.d.ts +33 -0
- package/dist/integrations/stabilityai/types.d.ts.map +1 -0
- package/dist/integrations/stabilityai/types.js +5 -0
- package/dist/integrations/stabilityai/types.js.map +1 -0
- package/dist/integrations/stripe/client.d.ts +19 -0
- package/dist/integrations/stripe/client.d.ts.map +1 -0
- package/dist/integrations/stripe/client.js +18 -0
- package/dist/integrations/stripe/client.js.map +1 -0
- package/dist/integrations/stripe/index.d.ts +3 -0
- package/dist/integrations/stripe/index.d.ts.map +1 -0
- package/dist/integrations/stripe/index.js +2 -0
- package/dist/integrations/stripe/index.js.map +1 -0
- package/dist/integrations/stripe/types.d.ts +60 -0
- package/dist/integrations/stripe/types.d.ts.map +1 -0
- package/dist/integrations/stripe/types.js +5 -0
- package/dist/integrations/stripe/types.js.map +1 -0
- package/dist/integrations/superblocks-ocr/client.d.ts +16 -0
- package/dist/integrations/superblocks-ocr/client.d.ts.map +1 -0
- package/dist/integrations/superblocks-ocr/client.js +15 -0
- package/dist/integrations/superblocks-ocr/client.js.map +1 -0
- package/dist/integrations/superblocks-ocr/index.d.ts +8 -0
- package/dist/integrations/superblocks-ocr/index.d.ts.map +1 -0
- package/dist/integrations/superblocks-ocr/index.js +7 -0
- package/dist/integrations/superblocks-ocr/index.js.map +1 -0
- package/dist/integrations/superblocks-ocr/types.d.ts +37 -0
- package/dist/integrations/superblocks-ocr/types.d.ts.map +1 -0
- package/dist/integrations/superblocks-ocr/types.js +5 -0
- package/dist/integrations/superblocks-ocr/types.js.map +1 -0
- package/dist/integrations/twilio/client.d.ts +19 -0
- package/dist/integrations/twilio/client.d.ts.map +1 -0
- package/dist/integrations/twilio/client.js +18 -0
- package/dist/integrations/twilio/client.js.map +1 -0
- package/dist/integrations/twilio/index.d.ts +3 -0
- package/dist/integrations/twilio/index.d.ts.map +1 -0
- package/dist/integrations/twilio/index.js +2 -0
- package/dist/integrations/twilio/index.js.map +1 -0
- package/dist/integrations/twilio/types.d.ts +33 -0
- package/dist/integrations/twilio/types.d.ts.map +1 -0
- package/dist/integrations/twilio/types.js +5 -0
- package/dist/integrations/twilio/types.js.map +1 -0
- package/dist/integrations/types.d.ts +31 -0
- package/dist/integrations/types.d.ts.map +1 -0
- package/dist/integrations/types.js +5 -0
- package/dist/integrations/types.js.map +1 -0
- package/dist/integrations/utils.d.ts +12 -0
- package/dist/integrations/utils.d.ts.map +1 -0
- package/dist/integrations/utils.js +27 -0
- package/dist/integrations/utils.js.map +1 -0
- package/dist/integrations/zendesk/client.d.ts +19 -0
- package/dist/integrations/zendesk/client.d.ts.map +1 -0
- package/dist/integrations/zendesk/client.js +18 -0
- package/dist/integrations/zendesk/client.js.map +1 -0
- package/dist/integrations/zendesk/index.d.ts +3 -0
- package/dist/integrations/zendesk/index.d.ts.map +1 -0
- package/dist/integrations/zendesk/index.js +2 -0
- package/dist/integrations/zendesk/index.js.map +1 -0
- package/dist/integrations/zendesk/types.d.ts +33 -0
- package/dist/integrations/zendesk/types.d.ts.map +1 -0
- package/dist/integrations/zendesk/types.js +5 -0
- package/dist/integrations/zendesk/types.js.map +1 -0
- package/dist/integrations/zoom/client.d.ts +19 -0
- package/dist/integrations/zoom/client.d.ts.map +1 -0
- package/dist/integrations/zoom/client.js +18 -0
- package/dist/integrations/zoom/client.js.map +1 -0
- package/dist/integrations/zoom/index.d.ts +3 -0
- package/dist/integrations/zoom/index.d.ts.map +1 -0
- package/dist/integrations/zoom/index.js +2 -0
- package/dist/integrations/zoom/index.js.map +1 -0
- package/dist/integrations/zoom/types.d.ts +33 -0
- package/dist/integrations/zoom/types.d.ts.map +1 -0
- package/dist/integrations/zoom/types.js +5 -0
- package/dist/integrations/zoom/types.js.map +1 -0
- package/dist/runtime/context.d.ts +69 -0
- package/dist/runtime/context.d.ts.map +1 -0
- package/dist/runtime/context.js +93 -0
- package/dist/runtime/context.js.map +1 -0
- package/dist/runtime/errors.d.ts +74 -0
- package/dist/runtime/errors.d.ts.map +1 -0
- package/dist/runtime/errors.js +109 -0
- package/dist/runtime/errors.js.map +1 -0
- package/dist/runtime/execute.d.ts +128 -0
- package/dist/runtime/execute.d.ts.map +1 -0
- package/dist/runtime/execute.js +84 -0
- package/dist/runtime/execute.js.map +1 -0
- package/dist/runtime/executor.d.ts +113 -0
- package/dist/runtime/executor.d.ts.map +1 -0
- package/dist/runtime/executor.js +121 -0
- package/dist/runtime/executor.js.map +1 -0
- package/dist/runtime/index.d.ts +13 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +18 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/logger.d.ts +15 -0
- package/dist/runtime/logger.d.ts.map +1 -0
- package/dist/runtime/logger.js +34 -0
- package/dist/runtime/logger.js.map +1 -0
- package/dist/runtime/streaming-context.d.ts +49 -0
- package/dist/runtime/streaming-context.d.ts.map +1 -0
- package/dist/runtime/streaming-context.js +71 -0
- package/dist/runtime/streaming-context.js.map +1 -0
- package/dist/runtime/streaming-executor.d.ts +159 -0
- package/dist/runtime/streaming-executor.d.ts.map +1 -0
- package/dist/runtime/streaming-executor.js +229 -0
- package/dist/runtime/streaming-executor.js.map +1 -0
- package/dist/types.d.ts +168 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/package.json +52 -0
- package/src/api/definition.test.ts +378 -0
- package/src/api/definition.ts +210 -0
- package/src/api/index.ts +10 -0
- package/src/api/streaming.test.ts +432 -0
- package/src/api/streaming.ts +302 -0
- package/src/errors.ts +130 -0
- package/src/index.ts +359 -0
- package/src/integrations/airtable/README.md +421 -0
- package/src/integrations/airtable/client.ts +23 -0
- package/src/integrations/airtable/index.ts +2 -0
- package/src/integrations/airtable/types.ts +30 -0
- package/src/integrations/anthropic/README.md +509 -0
- package/src/integrations/anthropic/client.ts +24 -0
- package/src/integrations/anthropic/index.ts +2 -0
- package/src/integrations/anthropic/types.ts +88 -0
- package/src/integrations/asana/README.md +423 -0
- package/src/integrations/asana/client.ts +23 -0
- package/src/integrations/asana/index.ts +2 -0
- package/src/integrations/asana/types.ts +35 -0
- package/src/integrations/athena/README.md +169 -0
- package/src/integrations/athena/client.ts +140 -0
- package/src/integrations/athena/index.ts +8 -0
- package/src/integrations/athena/types.ts +64 -0
- package/src/integrations/base/graphql-integration-client.ts +115 -0
- package/src/integrations/base/index.ts +14 -0
- package/src/integrations/base/rest-api-integration-client.ts +279 -0
- package/src/integrations/base/types.ts +176 -0
- package/src/integrations/bigquery/README.md +194 -0
- package/src/integrations/bigquery/client.ts +140 -0
- package/src/integrations/bigquery/index.ts +8 -0
- package/src/integrations/bigquery/types.ts +64 -0
- package/src/integrations/bitbucket/README.md +428 -0
- package/src/integrations/bitbucket/client.ts +23 -0
- package/src/integrations/bitbucket/index.ts +2 -0
- package/src/integrations/bitbucket/types.ts +36 -0
- package/src/integrations/box/README.md +576 -0
- package/src/integrations/box/client.ts +23 -0
- package/src/integrations/box/index.ts +2 -0
- package/src/integrations/box/types.ts +35 -0
- package/src/integrations/circleci/README.md +475 -0
- package/src/integrations/circleci/client.ts +23 -0
- package/src/integrations/circleci/index.ts +2 -0
- package/src/integrations/circleci/types.ts +36 -0
- package/src/integrations/cockroachdb/README.md +153 -0
- package/src/integrations/cockroachdb/client.ts +140 -0
- package/src/integrations/cockroachdb/index.ts +8 -0
- package/src/integrations/cockroachdb/types.ts +64 -0
- package/src/integrations/cohere/README.md +318 -0
- package/src/integrations/cohere/client.ts +23 -0
- package/src/integrations/cohere/index.ts +2 -0
- package/src/integrations/cohere/types.ts +30 -0
- package/src/integrations/confluence/README.md +473 -0
- package/src/integrations/confluence/client.ts +23 -0
- package/src/integrations/confluence/index.ts +2 -0
- package/src/integrations/confluence/types.ts +36 -0
- package/src/integrations/cosmosdb/README.md +217 -0
- package/src/integrations/cosmosdb/client.ts +232 -0
- package/src/integrations/cosmosdb/index.ts +8 -0
- package/src/integrations/cosmosdb/types.ts +152 -0
- package/src/integrations/couchbase/README.md +138 -0
- package/src/integrations/couchbase/client.ts +237 -0
- package/src/integrations/couchbase/index.ts +8 -0
- package/src/integrations/couchbase/types.ts +125 -0
- package/src/integrations/databricks/README.md +160 -0
- package/src/integrations/databricks/client.ts +142 -0
- package/src/integrations/databricks/index.ts +8 -0
- package/src/integrations/databricks/types.ts +64 -0
- package/src/integrations/datadog/README.md +487 -0
- package/src/integrations/datadog/client.ts +23 -0
- package/src/integrations/datadog/index.ts +2 -0
- package/src/integrations/datadog/types.ts +36 -0
- package/src/integrations/declarations.test.ts +64 -0
- package/src/integrations/declarations.ts +1282 -0
- package/src/integrations/dropbox/README.md +509 -0
- package/src/integrations/dropbox/client.ts +23 -0
- package/src/integrations/dropbox/index.ts +2 -0
- package/src/integrations/dropbox/types.ts +36 -0
- package/src/integrations/dynamodb/README.md +280 -0
- package/src/integrations/dynamodb/client.ts +294 -0
- package/src/integrations/dynamodb/index.ts +8 -0
- package/src/integrations/dynamodb/types.ts +257 -0
- package/src/integrations/elasticsearch/README.md +599 -0
- package/src/integrations/elasticsearch/client.ts +23 -0
- package/src/integrations/elasticsearch/index.ts +2 -0
- package/src/integrations/elasticsearch/types.ts +36 -0
- package/src/integrations/fireworks/README.md +365 -0
- package/src/integrations/fireworks/client.ts +23 -0
- package/src/integrations/fireworks/index.ts +2 -0
- package/src/integrations/fireworks/types.ts +36 -0
- package/src/integrations/front/README.md +401 -0
- package/src/integrations/front/client.ts +23 -0
- package/src/integrations/front/index.ts +2 -0
- package/src/integrations/front/types.ts +35 -0
- package/src/integrations/gcs/README.md +149 -0
- package/src/integrations/gcs/client.ts +228 -0
- package/src/integrations/gcs/index.ts +13 -0
- package/src/integrations/gcs/types.ts +168 -0
- package/src/integrations/gemini/README.md +387 -0
- package/src/integrations/gemini/client.ts +23 -0
- package/src/integrations/gemini/index.ts +2 -0
- package/src/integrations/gemini/types.ts +36 -0
- package/src/integrations/github/README.md +447 -0
- package/src/integrations/github/client.ts +24 -0
- package/src/integrations/github/index.ts +2 -0
- package/src/integrations/github/types.ts +71 -0
- package/src/integrations/googleanalytics/README.md +414 -0
- package/src/integrations/googleanalytics/client.ts +23 -0
- package/src/integrations/googleanalytics/index.ts +2 -0
- package/src/integrations/googleanalytics/types.ts +36 -0
- package/src/integrations/googledrive/README.md +481 -0
- package/src/integrations/googledrive/client.ts +23 -0
- package/src/integrations/googledrive/index.ts +2 -0
- package/src/integrations/googledrive/types.ts +36 -0
- package/src/integrations/graphql/README.md +410 -0
- package/src/integrations/graphql/client.ts +23 -0
- package/src/integrations/graphql/index.ts +2 -0
- package/src/integrations/graphql/types.ts +131 -0
- package/src/integrations/groq/README.md +315 -0
- package/src/integrations/groq/client.ts +23 -0
- package/src/integrations/groq/index.ts +2 -0
- package/src/integrations/groq/types.ts +35 -0
- package/src/integrations/gsheets/README.md +192 -0
- package/src/integrations/gsheets/client.ts +135 -0
- package/src/integrations/gsheets/index.ts +12 -0
- package/src/integrations/gsheets/types.ts +102 -0
- package/src/integrations/hubspot/README.md +451 -0
- package/src/integrations/hubspot/client.ts +23 -0
- package/src/integrations/hubspot/index.ts +2 -0
- package/src/integrations/hubspot/types.ts +36 -0
- package/src/integrations/index.ts +476 -0
- package/src/integrations/intercom/README.md +377 -0
- package/src/integrations/intercom/client.ts +23 -0
- package/src/integrations/intercom/index.ts +2 -0
- package/src/integrations/intercom/types.ts +36 -0
- package/src/integrations/jira/README.md +485 -0
- package/src/integrations/jira/client.ts +23 -0
- package/src/integrations/jira/index.ts +2 -0
- package/src/integrations/jira/types.ts +35 -0
- package/src/integrations/kafka/README.md +144 -0
- package/src/integrations/kafka/client.ts +215 -0
- package/src/integrations/kafka/index.ts +14 -0
- package/src/integrations/kafka/types.ts +127 -0
- package/src/integrations/kinesis/README.md +153 -0
- package/src/integrations/kinesis/client.ts +146 -0
- package/src/integrations/kinesis/index.ts +14 -0
- package/src/integrations/kinesis/types.ts +114 -0
- package/src/integrations/lakebase/client.ts +147 -0
- package/src/integrations/lakebase/index.ts +8 -0
- package/src/integrations/lakebase/types.ts +61 -0
- package/src/integrations/launchdarkly/README.md +438 -0
- package/src/integrations/launchdarkly/client.ts +23 -0
- package/src/integrations/launchdarkly/index.ts +2 -0
- package/src/integrations/launchdarkly/types.ts +36 -0
- package/src/integrations/mariadb/README.md +132 -0
- package/src/integrations/mariadb/client.ts +138 -0
- package/src/integrations/mariadb/index.ts +8 -0
- package/src/integrations/mariadb/types.ts +64 -0
- package/src/integrations/mistral/README.md +345 -0
- package/src/integrations/mistral/client.ts +23 -0
- package/src/integrations/mistral/index.ts +2 -0
- package/src/integrations/mistral/types.ts +36 -0
- package/src/integrations/mongodb/README.md +252 -0
- package/src/integrations/mongodb/client.ts +137 -0
- package/src/integrations/mongodb/index.ts +8 -0
- package/src/integrations/mongodb/types.ts +105 -0
- package/src/integrations/mssql/README.md +160 -0
- package/src/integrations/mssql/client.ts +138 -0
- package/src/integrations/mssql/index.ts +8 -0
- package/src/integrations/mssql/types.ts +64 -0
- package/src/integrations/mysql/README.md +169 -0
- package/src/integrations/mysql/client.ts +138 -0
- package/src/integrations/mysql/index.ts +8 -0
- package/src/integrations/mysql/types.ts +88 -0
- package/src/integrations/notion/README.md +438 -0
- package/src/integrations/notion/client.ts +24 -0
- package/src/integrations/notion/index.ts +2 -0
- package/src/integrations/notion/types.ts +73 -0
- package/src/integrations/openai_v2/README.md +490 -0
- package/src/integrations/openai_v2/client.ts +24 -0
- package/src/integrations/openai_v2/index.ts +2 -0
- package/src/integrations/openai_v2/types.ts +86 -0
- package/src/integrations/oracledb/README.md +169 -0
- package/src/integrations/oracledb/client.ts +142 -0
- package/src/integrations/oracledb/index.ts +8 -0
- package/src/integrations/oracledb/types.ts +64 -0
- package/src/integrations/pagerduty/README.md +478 -0
- package/src/integrations/pagerduty/client.ts +23 -0
- package/src/integrations/pagerduty/index.ts +2 -0
- package/src/integrations/pagerduty/types.ts +36 -0
- package/src/integrations/perplexity/README.md +299 -0
- package/src/integrations/perplexity/client.ts +23 -0
- package/src/integrations/perplexity/index.ts +2 -0
- package/src/integrations/perplexity/types.ts +36 -0
- package/src/integrations/postgres/README.md +393 -0
- package/src/integrations/postgres/client.ts +145 -0
- package/src/integrations/postgres/index.ts +6 -0
- package/src/integrations/postgres/types.ts +106 -0
- package/src/integrations/python/README.md +566 -0
- package/src/integrations/python/client.test.ts +340 -0
- package/src/integrations/python/client.ts +134 -0
- package/src/integrations/python/index.ts +6 -0
- package/src/integrations/python/types.ts +91 -0
- package/src/integrations/redis/README.md +200 -0
- package/src/integrations/redis/client.ts +207 -0
- package/src/integrations/redis/index.ts +8 -0
- package/src/integrations/redis/types.ts +166 -0
- package/src/integrations/redshift/README.md +160 -0
- package/src/integrations/redshift/client.ts +140 -0
- package/src/integrations/redshift/index.ts +8 -0
- package/src/integrations/redshift/types.ts +64 -0
- package/src/integrations/registry.test.ts +32 -0
- package/src/integrations/registry.ts +551 -0
- package/src/integrations/restapiintegration/client.ts +21 -0
- package/src/integrations/restapiintegration/index.ts +6 -0
- package/src/integrations/restapiintegration/types.ts +40 -0
- package/src/integrations/s3/README.md +136 -0
- package/src/integrations/s3/client.ts +235 -0
- package/src/integrations/s3/index.ts +13 -0
- package/src/integrations/s3/types.ts +170 -0
- package/src/integrations/salesforce/README.md +241 -0
- package/src/integrations/salesforce/client.ts +296 -0
- package/src/integrations/salesforce/index.ts +12 -0
- package/src/integrations/salesforce/types.ts +193 -0
- package/src/integrations/segment/README.md +492 -0
- package/src/integrations/segment/client.ts +23 -0
- package/src/integrations/segment/index.ts +2 -0
- package/src/integrations/segment/types.ts +36 -0
- package/src/integrations/sendgrid/README.md +369 -0
- package/src/integrations/sendgrid/client.ts +23 -0
- package/src/integrations/sendgrid/index.ts +2 -0
- package/src/integrations/sendgrid/types.ts +36 -0
- package/src/integrations/slack/README.md +400 -0
- package/src/integrations/slack/client.ts +23 -0
- package/src/integrations/slack/index.ts +6 -0
- package/src/integrations/slack/types.ts +50 -0
- package/src/integrations/smtp/client.ts +72 -0
- package/src/integrations/smtp/index.ts +8 -0
- package/src/integrations/smtp/types.ts +65 -0
- package/src/integrations/snowflake/README.md +361 -0
- package/src/integrations/snowflake/client.ts +144 -0
- package/src/integrations/snowflake/index.ts +8 -0
- package/src/integrations/snowflake/types.ts +88 -0
- package/src/integrations/snowflakecortex/client.ts +22 -0
- package/src/integrations/snowflakecortex/index.ts +2 -0
- package/src/integrations/snowflakecortex/types.ts +24 -0
- package/src/integrations/snowflakepostgres/client.ts +14 -0
- package/src/integrations/snowflakepostgres/index.ts +8 -0
- package/src/integrations/snowflakepostgres/types.ts +61 -0
- package/src/integrations/stabilityai/README.md +460 -0
- package/src/integrations/stabilityai/client.ts +23 -0
- package/src/integrations/stabilityai/index.ts +2 -0
- package/src/integrations/stabilityai/types.ts +36 -0
- package/src/integrations/stripe/README.md +453 -0
- package/src/integrations/stripe/client.ts +24 -0
- package/src/integrations/stripe/index.ts +2 -0
- package/src/integrations/stripe/types.ts +63 -0
- package/src/integrations/superblocks-ocr/README.md +179 -0
- package/src/integrations/superblocks-ocr/client.ts +20 -0
- package/src/integrations/superblocks-ocr/index.ts +8 -0
- package/src/integrations/superblocks-ocr/types.ts +40 -0
- package/src/integrations/twilio/README.md +346 -0
- package/src/integrations/twilio/client.ts +23 -0
- package/src/integrations/twilio/index.ts +2 -0
- package/src/integrations/twilio/types.ts +36 -0
- package/src/integrations/types.ts +40 -0
- package/src/integrations/utils.ts +25 -0
- package/src/integrations/zendesk/README.md +446 -0
- package/src/integrations/zendesk/client.ts +23 -0
- package/src/integrations/zendesk/index.ts +2 -0
- package/src/integrations/zendesk/types.ts +36 -0
- package/src/integrations/zoom/README.md +459 -0
- package/src/integrations/zoom/client.ts +23 -0
- package/src/integrations/zoom/index.ts +2 -0
- package/src/integrations/zoom/types.ts +35 -0
- package/src/runtime/context.ts +177 -0
- package/src/runtime/errors.ts +132 -0
- package/src/runtime/execute.ts +221 -0
- package/src/runtime/executor.ts +214 -0
- package/src/runtime/index.ts +52 -0
- package/src/runtime/logger.ts +41 -0
- package/src/runtime/streaming-context.ts +164 -0
- package/src/runtime/streaming-executor.ts +367 -0
- package/src/types.ts +210 -0
package/README.md
ADDED
|
@@ -0,0 +1,1554 @@
|
|
|
1
|
+
# @superblocksteam/sdk-api
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for defining Superblocks APIs as simple, type-safe functions.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This SDK enables writing Superblocks APIs as TypeScript functions with:
|
|
8
|
+
|
|
9
|
+
- **Zod schemas** for input/output validation
|
|
10
|
+
- **Typed integration clients** for Postgres, Slack, OpenAI, Anthropic, Stripe, GitHub, Notion, and more
|
|
11
|
+
- **Full type inference** for inputs, outputs, and integrations
|
|
12
|
+
- **Upfront integration declarations** for type-safe access and pre-authentication
|
|
13
|
+
- **Runtime schema validation** with detailed error information for debugging
|
|
14
|
+
|
|
15
|
+
## Architecture & Execution
|
|
16
|
+
|
|
17
|
+
This section explains how the SDK works internally - what an API is, what `api()` produces, and how APIs are executed.
|
|
18
|
+
|
|
19
|
+
### What is an API?
|
|
20
|
+
|
|
21
|
+
An **API** in this SDK is a self-contained, typed function definition that:
|
|
22
|
+
|
|
23
|
+
1. **Declares its contract** - Input/output schemas define what data it accepts and returns
|
|
24
|
+
2. **Declares its dependencies** - Integration references specify which external services it needs
|
|
25
|
+
3. **Implements logic** - The `run` function contains the business logic
|
|
26
|
+
4. **Is portable** - Can be executed by any compatible runtime (local, server, orchestrator)
|
|
27
|
+
|
|
28
|
+
An API is **not** just a function - it's a complete definition that includes metadata, schemas, and dependencies, enabling the runtime to:
|
|
29
|
+
|
|
30
|
+
- Validate inputs before execution
|
|
31
|
+
- Pre-authenticate integrations
|
|
32
|
+
- Validate outputs after execution
|
|
33
|
+
- Provide detailed error information
|
|
34
|
+
|
|
35
|
+
### What `api()` Produces
|
|
36
|
+
|
|
37
|
+
The `api()` function compiles your configuration into a `CompiledApi` object:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
interface CompiledApi<TInput, TOutput> {
|
|
41
|
+
/** Name for identification in logs and debugging */
|
|
42
|
+
readonly name: string;
|
|
43
|
+
|
|
44
|
+
/** Zod schema for validating inputs */
|
|
45
|
+
readonly inputSchema: z.ZodType<TInput>;
|
|
46
|
+
|
|
47
|
+
/** Zod schema for validating outputs */
|
|
48
|
+
readonly outputSchema: z.ZodType<TOutput>;
|
|
49
|
+
|
|
50
|
+
/** The implementation function */
|
|
51
|
+
readonly run: (ctx: ApiContext, input: TInput) => Promise<TOutput>;
|
|
52
|
+
|
|
53
|
+
/** Integration declarations for upfront authentication */
|
|
54
|
+
readonly integrations: ReadonlyArray<IntegrationDeclaration>;
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
#### Identifying an API
|
|
59
|
+
|
|
60
|
+
You can inspect a `CompiledApi` to understand what it is:
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import { api, z, postgres } from "@superblocksteam/sdk-api";
|
|
64
|
+
|
|
65
|
+
const myApi = api({
|
|
66
|
+
name: "GetUsers",
|
|
67
|
+
integrations: { db: postgres("prod-postgres-id") },
|
|
68
|
+
input: z.object({ limit: z.number() }),
|
|
69
|
+
output: z.object({ users: z.array(z.object({ id: z.string() })) }),
|
|
70
|
+
async run(ctx, { limit }) {
|
|
71
|
+
/* ... */
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Inspect the compiled API
|
|
76
|
+
console.log(myApi.name); // 'GetUsers'
|
|
77
|
+
console.log(myApi.integrations); // [{ key: 'db', pluginId: 'postgres', integrationId: 'prod-postgres-id' }]
|
|
78
|
+
|
|
79
|
+
// Schemas can be used for validation or type extraction
|
|
80
|
+
type Input = z.infer<typeof myApi.inputSchema>; // { limit: number }
|
|
81
|
+
type Output = z.infer<typeof myApi.outputSchema>; // { users: { id: string }[] }
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### How APIs are Executed
|
|
85
|
+
|
|
86
|
+
The `execute()` function runs a compiled API with the required inputs:
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import { execute } from '@superblocksteam/sdk-api';
|
|
90
|
+
|
|
91
|
+
const response = await execute(myApi, {
|
|
92
|
+
// Raw input data (will be validated against inputSchema)
|
|
93
|
+
input: { limit: 10 },
|
|
94
|
+
|
|
95
|
+
// Integration configurations (provided by the runtime)
|
|
96
|
+
integrations: [
|
|
97
|
+
{ id: 'prod-postgres-id', name: 'Production DB', pluginId: 'postgres', configuration: {...} }
|
|
98
|
+
],
|
|
99
|
+
|
|
100
|
+
// Unique ID for tracing/debugging
|
|
101
|
+
executionId: 'exec_abc123',
|
|
102
|
+
|
|
103
|
+
// Environment variables accessible via ctx.env
|
|
104
|
+
env: { NODE_ENV: 'production' },
|
|
105
|
+
|
|
106
|
+
// Callback to execute integration operations (see below)
|
|
107
|
+
executeQuery: async (integrationId, request, bindings) => {
|
|
108
|
+
return await orchestrator.execute(integrationId, request, bindings);
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// Response is a discriminated union
|
|
113
|
+
if (response.success) {
|
|
114
|
+
console.log(response.output); // Typed as { users: { id: string }[] }
|
|
115
|
+
} else {
|
|
116
|
+
console.error(response.error.code, response.error.message);
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
#### Execution Flow
|
|
121
|
+
|
|
122
|
+
1. **Input Validation** - Raw input is validated against `api.inputSchema`
|
|
123
|
+
2. **Context Creation** - `ApiContext` is created with integration clients and logger
|
|
124
|
+
3. **API Execution** - The `run` function is called with context and validated input
|
|
125
|
+
4. **Output Validation** - Return value is validated against `api.outputSchema`
|
|
126
|
+
5. **Response** - Returns `{ success: true, output }` or `{ success: false, error }`
|
|
127
|
+
|
|
128
|
+
### The Callback Architecture
|
|
129
|
+
|
|
130
|
+
The SDK doesn't directly communicate with databases or external APIs. Instead, it uses **callbacks** that the runtime provides. This enables the SDK to run in any environment.
|
|
131
|
+
|
|
132
|
+
#### `executeQuery` Callback
|
|
133
|
+
|
|
134
|
+
When an integration client (like `ctx.integrations.db`) makes a request, it calls the `executeQuery` callback:
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
// Inside PostgresClient.query():
|
|
138
|
+
const result = await executeQuery(
|
|
139
|
+
"prod-postgres-id", // Integration ID
|
|
140
|
+
{
|
|
141
|
+
// Plugin-specific request (matches protobuf schema)
|
|
142
|
+
body: "SELECT * FROM users WHERE id = $1",
|
|
143
|
+
},
|
|
144
|
+
{ userId: "123" }, // Optional bindings for language plugins
|
|
145
|
+
);
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
The runtime (orchestrator) receives this callback and:
|
|
149
|
+
|
|
150
|
+
1. Looks up the integration configuration
|
|
151
|
+
2. Authenticates with the external service
|
|
152
|
+
3. Executes the actual operation (SQL query, API call, etc.)
|
|
153
|
+
4. Returns the result to the SDK
|
|
154
|
+
|
|
155
|
+
This architecture means:
|
|
156
|
+
|
|
157
|
+
- **SDK is environment-agnostic** - Same code runs locally, in tests, or in production
|
|
158
|
+
- **Authentication is centralized** - The runtime handles all credentials
|
|
159
|
+
- **Operations are auditable** - The runtime can log/trace all operations
|
|
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
|
+
### Execution Request Interface
|
|
183
|
+
|
|
184
|
+
The complete request interface for `execute()`:
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
interface UnifiedExecuteApiRequest {
|
|
188
|
+
/** Raw input data to be validated */
|
|
189
|
+
input: unknown;
|
|
190
|
+
|
|
191
|
+
/** Available integration configurations */
|
|
192
|
+
integrations: IntegrationConfig[];
|
|
193
|
+
|
|
194
|
+
/** Unique execution ID for tracing */
|
|
195
|
+
executionId: string;
|
|
196
|
+
|
|
197
|
+
/** Environment variables available via ctx.env */
|
|
198
|
+
env: Record<string, string>;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Callback to execute integration operations.
|
|
202
|
+
* Called by integration clients (postgres, slack, etc.) to perform actual operations.
|
|
203
|
+
*/
|
|
204
|
+
executeQuery: (
|
|
205
|
+
integrationId: string,
|
|
206
|
+
request: Record<string, unknown>, // Plugin-specific request matching protobuf schema
|
|
207
|
+
bindings?: Record<string, unknown>, // For language plugins (Python/JavaScript)
|
|
208
|
+
) => 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
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Execution Response
|
|
222
|
+
|
|
223
|
+
Regular APIs return a discriminated union:
|
|
224
|
+
|
|
225
|
+
```typescript
|
|
226
|
+
type ExecuteApiResponse<TOutput> =
|
|
227
|
+
| { success: true; output: TOutput }
|
|
228
|
+
| {
|
|
229
|
+
success: false;
|
|
230
|
+
error: { code: string; message: string; details?: unknown };
|
|
231
|
+
};
|
|
232
|
+
```
|
|
233
|
+
|
|
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
|
+
### Integration Configuration
|
|
246
|
+
|
|
247
|
+
Each integration in the `integrations` array has this structure:
|
|
248
|
+
|
|
249
|
+
```typescript
|
|
250
|
+
interface IntegrationConfig {
|
|
251
|
+
/** Unique integration ID (referenced in api() config) */
|
|
252
|
+
id: string;
|
|
253
|
+
|
|
254
|
+
/** Display name */
|
|
255
|
+
name: string;
|
|
256
|
+
|
|
257
|
+
/** Plugin type (e.g., 'postgres', 'slack', 'openai_v2') */
|
|
258
|
+
pluginId: string;
|
|
259
|
+
|
|
260
|
+
/** Plugin-specific configuration (credentials, endpoints, etc.) */
|
|
261
|
+
configuration: Record<string, unknown>;
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
The SDK matches integration declarations in your API (`integrations: { db: postgres('id') }`) with configurations in the request by ID.
|
|
266
|
+
|
|
267
|
+
## Installation
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
pnpm add @superblocksteam/sdk-api
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## Quick Start
|
|
274
|
+
|
|
275
|
+
```typescript
|
|
276
|
+
import { api, z, postgres } from "@superblocksteam/sdk-api";
|
|
277
|
+
|
|
278
|
+
// Integration IDs from the integrations panel - store in constants
|
|
279
|
+
const PROD_POSTGRES = "a1b2c3d4-5678-90ab-cdef-ghijklmnopqr";
|
|
280
|
+
|
|
281
|
+
const UserSchema = z.object({
|
|
282
|
+
id: z.string(),
|
|
283
|
+
name: z.string(),
|
|
284
|
+
email: z.string().email(),
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
export default api({
|
|
288
|
+
name: "GetUserById",
|
|
289
|
+
|
|
290
|
+
// Declare integrations upfront for type safety
|
|
291
|
+
integrations: {
|
|
292
|
+
db: postgres(PROD_POSTGRES),
|
|
293
|
+
},
|
|
294
|
+
|
|
295
|
+
input: z.object({
|
|
296
|
+
userId: z.string().uuid(),
|
|
297
|
+
}),
|
|
298
|
+
|
|
299
|
+
output: z.object({
|
|
300
|
+
user: UserSchema,
|
|
301
|
+
}),
|
|
302
|
+
|
|
303
|
+
async run(ctx, { userId }) {
|
|
304
|
+
// ctx.integrations.db is fully typed as PostgresClient
|
|
305
|
+
const users = await ctx.integrations.db.query(
|
|
306
|
+
"SELECT * FROM users WHERE id = $1",
|
|
307
|
+
UserSchema, // Schema is REQUIRED
|
|
308
|
+
[userId],
|
|
309
|
+
);
|
|
310
|
+
|
|
311
|
+
if (users.length === 0) {
|
|
312
|
+
throw new Error("User not found");
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return { user: users[0] };
|
|
316
|
+
},
|
|
317
|
+
});
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
## API Reference
|
|
321
|
+
|
|
322
|
+
### `api(config)`
|
|
323
|
+
|
|
324
|
+
Defines a TypeScript-based API with input/output validation. Returns a complete result when the `run` function completes.
|
|
325
|
+
|
|
326
|
+
For streaming responses (e.g., LLM token streaming), see [`streamingApi()`](#streamingapiconfig) below.
|
|
327
|
+
|
|
328
|
+
#### Required Fields
|
|
329
|
+
|
|
330
|
+
| Field | Type | Description |
|
|
331
|
+
| -------------- | --------------------------------- | ---------------------------------------------- |
|
|
332
|
+
| `name` | `string` | **Required.** Unique identifier for the API |
|
|
333
|
+
| `input` | `z.ZodType` | **Required.** Zod schema for input validation |
|
|
334
|
+
| `output` | `z.ZodType` | **Required.** Zod schema for output validation |
|
|
335
|
+
| `run` | `(ctx, input) => Promise<Output>` | **Required.** The implementation function |
|
|
336
|
+
| `integrations` | `Record<string, IntegrationRef>` | Optional. Integration declarations for the API |
|
|
337
|
+
|
|
338
|
+
```typescript
|
|
339
|
+
import { api, z } from "@superblocksteam/sdk-api";
|
|
340
|
+
|
|
341
|
+
const myApi = api({
|
|
342
|
+
// REQUIRED: name is used for identification in logs and debugging
|
|
343
|
+
name: "GreetUser",
|
|
344
|
+
|
|
345
|
+
// REQUIRED: Zod schema for input validation
|
|
346
|
+
input: z.object({
|
|
347
|
+
name: z.string(),
|
|
348
|
+
count: z.number().int().positive(),
|
|
349
|
+
}),
|
|
350
|
+
|
|
351
|
+
// REQUIRED: Zod schema for output validation
|
|
352
|
+
output: z.object({
|
|
353
|
+
greeting: z.string(),
|
|
354
|
+
items: z.array(z.string()),
|
|
355
|
+
}),
|
|
356
|
+
|
|
357
|
+
// REQUIRED: API implementation
|
|
358
|
+
async run(ctx, { name, count }) {
|
|
359
|
+
return {
|
|
360
|
+
greeting: `Hello, ${name}!`,
|
|
361
|
+
items: Array(count).fill("item"),
|
|
362
|
+
};
|
|
363
|
+
},
|
|
364
|
+
});
|
|
365
|
+
```
|
|
366
|
+
|
|
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
|
+
### Context (`ctx`) and Input
|
|
444
|
+
|
|
445
|
+
The `run` function receives two arguments:
|
|
446
|
+
|
|
447
|
+
1. **`ctx`** - Context object with integrations, logging, and environment
|
|
448
|
+
2. **`input`** - Typed, validated input data matching your input schema
|
|
449
|
+
|
|
450
|
+
```typescript
|
|
451
|
+
async run(ctx, { userId, options }) {
|
|
452
|
+
// Input is destructured from the second parameter
|
|
453
|
+
// and is fully typed based on your input schema
|
|
454
|
+
}
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
#### `ctx.integrations`
|
|
458
|
+
|
|
459
|
+
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.
|
|
460
|
+
|
|
461
|
+
```typescript
|
|
462
|
+
import { api, z, postgres, slack, openai, anthropic, stripe, github, notion, python } from "@superblocksteam/sdk-api";
|
|
463
|
+
|
|
464
|
+
// Integration IDs from the integrations panel - store in constants
|
|
465
|
+
const PROD_POSTGRES = "a1b2c3d4-5678-90ab-cdef-ghijklmnopqr";
|
|
466
|
+
const OPS_SLACK = "b2c3d4e5-6789-01ab-cdef-ghijklmnopqr";
|
|
467
|
+
const PROD_OPENAI = "c3d4e5f6-7890-12ab-cdef-ghijklmnopqr";
|
|
468
|
+
const PROD_ANTHROPIC = "d4e5f6g7-8901-23ab-cdef-ghijklmnopqr";
|
|
469
|
+
const PROD_STRIPE = "e5f6g7h8-9012-34ab-cdef-ghijklmnopqr";
|
|
470
|
+
const PROD_GITHUB = "f6g7h8i9-0123-45ab-cdef-ghijklmnopqr";
|
|
471
|
+
const PROD_NOTION = "g7h8i9j0-1234-56ab-cdef-ghijklmnopqr";
|
|
472
|
+
const PYTHON_RUNTIME = "h8i9j0k1-2345-67ab-cdef-ghijklmnopqr";
|
|
473
|
+
|
|
474
|
+
export default api({
|
|
475
|
+
name: "ProcessUserWorkflow",
|
|
476
|
+
|
|
477
|
+
// Declare all integrations you'll use
|
|
478
|
+
integrations: {
|
|
479
|
+
// Database
|
|
480
|
+
db: postgres(PROD_POSTGRES),
|
|
481
|
+
|
|
482
|
+
// Messaging
|
|
483
|
+
notifier: slack(OPS_SLACK),
|
|
484
|
+
|
|
485
|
+
// AI/LLM
|
|
486
|
+
ai: openai(PROD_OPENAI),
|
|
487
|
+
claude: anthropic(PROD_ANTHROPIC),
|
|
488
|
+
|
|
489
|
+
// Payment Processing
|
|
490
|
+
payments: stripe(PROD_STRIPE),
|
|
491
|
+
|
|
492
|
+
// Developer Tools
|
|
493
|
+
repo: github(PROD_GITHUB),
|
|
494
|
+
|
|
495
|
+
// Productivity
|
|
496
|
+
wiki: notion(PROD_NOTION),
|
|
497
|
+
|
|
498
|
+
// Code Execution
|
|
499
|
+
runtime: python(PYTHON_RUNTIME),
|
|
500
|
+
},
|
|
501
|
+
|
|
502
|
+
input: z.object({ userId: z.string() }),
|
|
503
|
+
output: z.object({ success: z.boolean() }),
|
|
504
|
+
|
|
505
|
+
async run(ctx, { userId }) {
|
|
506
|
+
// Each integration is fully typed based on its declaration
|
|
507
|
+
const users = await ctx.integrations.db.query(...);
|
|
508
|
+
await ctx.integrations.notifier.apiRequest(...);
|
|
509
|
+
const completion = await ctx.integrations.ai.apiRequest(...);
|
|
510
|
+
|
|
511
|
+
return { success: true };
|
|
512
|
+
},
|
|
513
|
+
});
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
#### `ctx.log`
|
|
517
|
+
|
|
518
|
+
Structured logging utilities.
|
|
519
|
+
|
|
520
|
+
```typescript
|
|
521
|
+
async run(ctx, { userId }) {
|
|
522
|
+
ctx.log.info('Processing request', { userId });
|
|
523
|
+
ctx.log.warn('Rate limit approaching');
|
|
524
|
+
ctx.log.error('Operation failed', { error: 'details' });
|
|
525
|
+
ctx.log.debug('Debug info');
|
|
526
|
+
}
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
## Integration Clients
|
|
530
|
+
|
|
531
|
+
### Integration Client Methods Reference
|
|
532
|
+
|
|
533
|
+
**IMPORTANT:** Before using any integration client, verify available methods below. Do NOT assume methods exist based on the external service's API.
|
|
534
|
+
|
|
535
|
+
#### Method Availability by Client
|
|
536
|
+
|
|
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)`, `streamApiRequest(options, schema)` | Supports streaming for real-time token output |
|
|
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)`, `streamApiRequest(options, schema)` | Supports streaming for real-time token output |
|
|
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
|
+
|
|
579
|
+
#### Common Mistakes to Avoid
|
|
580
|
+
|
|
581
|
+
---
|
|
582
|
+
|
|
583
|
+
**WRONG - Hallucinated method:**
|
|
584
|
+
|
|
585
|
+
```typescript
|
|
586
|
+
// These methods DO NOT EXIST
|
|
587
|
+
await openai.createChatCompletion({ ... });
|
|
588
|
+
await anthropic.createMessage({ ... });
|
|
589
|
+
await stripe.createCustomer({ ... });
|
|
590
|
+
await github.createIssue({ ... });
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
**CORRECT - Use apiRequest:**
|
|
594
|
+
|
|
595
|
+
```typescript
|
|
596
|
+
// Use the generic apiRequest method
|
|
597
|
+
await openai.apiRequest(
|
|
598
|
+
{ method: 'POST', path: '/v1/chat/completions', body: { ... } },
|
|
599
|
+
{ response: ResponseSchema }
|
|
600
|
+
);
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
---
|
|
604
|
+
|
|
605
|
+
**WRONG - Missing schema parameter:**
|
|
606
|
+
|
|
607
|
+
```typescript
|
|
608
|
+
// Schema is REQUIRED for query()
|
|
609
|
+
const users = await ctx.integrations.db.query(
|
|
610
|
+
"SELECT * FROM users WHERE id = $1",
|
|
611
|
+
[userId],
|
|
612
|
+
);
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
**CORRECT - Include schema:**
|
|
616
|
+
|
|
617
|
+
```typescript
|
|
618
|
+
const UserSchema = z.object({ id: z.string(), name: z.string() });
|
|
619
|
+
const users = await ctx.integrations.db.query(
|
|
620
|
+
"SELECT * FROM users WHERE id = $1",
|
|
621
|
+
UserSchema, // Schema is REQUIRED
|
|
622
|
+
[userId],
|
|
623
|
+
);
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
#### Finding Type Definitions
|
|
627
|
+
|
|
628
|
+
To verify available methods and signatures:
|
|
629
|
+
|
|
630
|
+
- **README**: This document contains complete method signatures for all clients
|
|
631
|
+
- **Type files**: Check `node_modules/@superblocksteam/sdk-api/src/integrations/<client>/types.ts`
|
|
632
|
+
- **API Context**: See `node_modules/@superblocksteam/sdk-api/src/types.ts` for the ApiContext interface
|
|
633
|
+
|
|
634
|
+
### Integration Documentation
|
|
635
|
+
|
|
636
|
+
Each integration client has detailed documentation with examples and common pitfalls. Click on an integration below for its full README:
|
|
637
|
+
|
|
638
|
+
#### SQL Databases
|
|
639
|
+
|
|
640
|
+
- [PostgreSQL](./src/integrations/postgres/README.md) - Query PostgreSQL databases with schema validation
|
|
641
|
+
- [Snowflake](./src/integrations/snowflake/README.md) - Query Snowflake data warehouses
|
|
642
|
+
|
|
643
|
+
#### GraphQL
|
|
644
|
+
|
|
645
|
+
- [GraphQL](./src/integrations/graphql/README.md) - Execute queries and mutations against GraphQL endpoints
|
|
646
|
+
|
|
647
|
+
#### AI/LLM
|
|
648
|
+
|
|
649
|
+
- [OpenAI](./src/integrations/openai_v2/README.md) - Chat completions, embeddings, DALL-E, and more
|
|
650
|
+
- [Anthropic](./src/integrations/anthropic/README.md) - Claude models for chat and analysis
|
|
651
|
+
- [Cohere](./src/integrations/cohere/README.md) - Text generation, embeddings, classification
|
|
652
|
+
- [Gemini](./src/integrations/gemini/README.md) - Google's multimodal AI models
|
|
653
|
+
- [Groq](./src/integrations/groq/README.md) - Fast inference for LLM completions
|
|
654
|
+
- [Mistral](./src/integrations/mistral/README.md) - Open-weight language models
|
|
655
|
+
- [Perplexity](./src/integrations/perplexity/README.md) - Search-augmented AI responses
|
|
656
|
+
- [Fireworks](./src/integrations/fireworks/README.md) - Fast model inference
|
|
657
|
+
|
|
658
|
+
#### Messaging & Communication
|
|
659
|
+
|
|
660
|
+
- [Slack](./src/integrations/slack/README.md) - Send messages, manage channels, Block Kit
|
|
661
|
+
- [Twilio](./src/integrations/twilio/README.md) - SMS, voice calls, phone lookups
|
|
662
|
+
- [SendGrid](./src/integrations/sendgrid/README.md) - Transactional and marketing emails
|
|
663
|
+
- [Intercom](./src/integrations/intercom/README.md) - Customer messaging and support
|
|
664
|
+
- [Front](./src/integrations/front/README.md) - Shared inbox and team communication
|
|
665
|
+
|
|
666
|
+
#### Productivity & Collaboration
|
|
667
|
+
|
|
668
|
+
- [Notion](./src/integrations/notion/README.md) - Databases, pages, and blocks
|
|
669
|
+
- [Airtable](./src/integrations/airtable/README.md) - Spreadsheet-database hybrid
|
|
670
|
+
- [Asana](./src/integrations/asana/README.md) - Project and task management
|
|
671
|
+
- [Jira](./src/integrations/jira/README.md) - Issue tracking and project management
|
|
672
|
+
- [Confluence](./src/integrations/confluence/README.md) - Team wikis and documentation
|
|
673
|
+
- [Zoom](./src/integrations/zoom/README.md) - Video meetings and webinars
|
|
674
|
+
|
|
675
|
+
#### Developer Tools
|
|
676
|
+
|
|
677
|
+
- [GitHub](./src/integrations/github/README.md) - Repositories, issues, pull requests
|
|
678
|
+
- [Bitbucket](./src/integrations/bitbucket/README.md) - Git repositories and pipelines
|
|
679
|
+
- [CircleCI](./src/integrations/circleci/README.md) - CI/CD pipelines and jobs
|
|
680
|
+
|
|
681
|
+
#### Business & Enterprise
|
|
682
|
+
|
|
683
|
+
- [Stripe](./src/integrations/stripe/README.md) - Payments, subscriptions, invoicing
|
|
684
|
+
- [HubSpot](./src/integrations/hubspot/README.md) - CRM, contacts, deals
|
|
685
|
+
- [Zendesk](./src/integrations/zendesk/README.md) - Support tickets and customer service
|
|
686
|
+
- [PagerDuty](./src/integrations/pagerduty/README.md) - Incident management and on-call
|
|
687
|
+
- [LaunchDarkly](./src/integrations/launchdarkly/README.md) - Feature flags and experimentation
|
|
688
|
+
|
|
689
|
+
#### Analytics & Monitoring
|
|
690
|
+
|
|
691
|
+
- [Google Analytics](./src/integrations/googleanalytics/README.md) - GA4 reports and real-time data
|
|
692
|
+
- [Datadog](./src/integrations/datadog/README.md) - Metrics, monitors, and logs
|
|
693
|
+
- [Segment](./src/integrations/segment/README.md) - Customer data platform
|
|
694
|
+
|
|
695
|
+
#### Cloud Storage
|
|
696
|
+
|
|
697
|
+
- [Google Drive](./src/integrations/googledrive/README.md) - Files, folders, and sharing
|
|
698
|
+
- [Dropbox](./src/integrations/dropbox/README.md) - Cloud file storage
|
|
699
|
+
- [Box](./src/integrations/box/README.md) - Enterprise content management
|
|
700
|
+
|
|
701
|
+
#### Code Execution
|
|
702
|
+
|
|
703
|
+
- [Python](./src/integrations/python/README.md) - Execute Python scripts with type-safe inputs and outputs
|
|
704
|
+
|
|
705
|
+
#### Other
|
|
706
|
+
|
|
707
|
+
- [Elasticsearch](./src/integrations/elasticsearch/README.md) - Search and analytics engine
|
|
708
|
+
- [Stability AI](./src/integrations/stabilityai/README.md) - Image generation and editing
|
|
709
|
+
|
|
710
|
+
## Generic API Requests
|
|
711
|
+
|
|
712
|
+
All REST API-based integration clients support the `apiRequest()` method for making custom API calls. **Response schema validation is required** for type safety.
|
|
713
|
+
|
|
714
|
+
```typescript
|
|
715
|
+
import { api, z, slack } from "@superblocksteam/sdk-api";
|
|
716
|
+
|
|
717
|
+
// Integration ID from the integrations panel
|
|
718
|
+
const OPS_SLACK = "b2c3d4e5-6789-01ab-cdef-ghijklmnopqr";
|
|
719
|
+
|
|
720
|
+
export default api({
|
|
721
|
+
name: "PostSlackMessage",
|
|
722
|
+
|
|
723
|
+
integrations: {
|
|
724
|
+
notifier: slack(OPS_SLACK),
|
|
725
|
+
},
|
|
726
|
+
|
|
727
|
+
input: z.object({}),
|
|
728
|
+
output: z.object({ ts: z.string() }),
|
|
729
|
+
|
|
730
|
+
async run(ctx) {
|
|
731
|
+
// Define request and response schemas
|
|
732
|
+
const PostMessageBodySchema = z.object({
|
|
733
|
+
channel: z.string(),
|
|
734
|
+
text: z.string(),
|
|
735
|
+
blocks: z.array(z.any()).optional(),
|
|
736
|
+
});
|
|
737
|
+
|
|
738
|
+
const PostMessageResponseSchema = z.object({
|
|
739
|
+
ok: z.boolean(),
|
|
740
|
+
ts: z.string(),
|
|
741
|
+
channel: z.string(),
|
|
742
|
+
});
|
|
743
|
+
|
|
744
|
+
// Response schema is REQUIRED
|
|
745
|
+
const result = await ctx.integrations.notifier.apiRequest(
|
|
746
|
+
{
|
|
747
|
+
method: "POST",
|
|
748
|
+
path: "/chat.postMessage",
|
|
749
|
+
body: {
|
|
750
|
+
channel: "#alerts",
|
|
751
|
+
text: "Deployment completed!",
|
|
752
|
+
},
|
|
753
|
+
},
|
|
754
|
+
{
|
|
755
|
+
body: PostMessageBodySchema,
|
|
756
|
+
response: PostMessageResponseSchema, // Required!
|
|
757
|
+
},
|
|
758
|
+
);
|
|
759
|
+
|
|
760
|
+
// result is fully typed as PostMessageResponse
|
|
761
|
+
return { ts: result.ts };
|
|
762
|
+
},
|
|
763
|
+
});
|
|
764
|
+
```
|
|
765
|
+
|
|
766
|
+
### ApiRequestOptions
|
|
767
|
+
|
|
768
|
+
| Property | Type | Description |
|
|
769
|
+
| ---------- | ------------------------- | ------------------------------------------ |
|
|
770
|
+
| `method` | `string` | HTTP method (GET, POST, PUT, DELETE, etc.) |
|
|
771
|
+
| `path` | `string` | API endpoint path |
|
|
772
|
+
| `body?` | `TBody` | Request body (for POST, PUT, PATCH) |
|
|
773
|
+
| `params?` | `Record<string, unknown>` | Query parameters |
|
|
774
|
+
| `headers?` | `Record<string, string>` | HTTP headers |
|
|
775
|
+
|
|
776
|
+
### ApiRequestSchema
|
|
777
|
+
|
|
778
|
+
| Property | Type | Description |
|
|
779
|
+
| ---------- | ------------------------ | ------------------------------------------------------------------------------ |
|
|
780
|
+
| `body?` | `z.ZodSchema<TBody>` | Optional Zod schema for request body validation (required if body is provided) |
|
|
781
|
+
| `response` | `z.ZodSchema<TResponse>` | **Required** Zod schema for response validation |
|
|
782
|
+
|
|
783
|
+
## Streaming API Requests
|
|
784
|
+
|
|
785
|
+
For real-time streaming responses (e.g., LLM token streaming), use `streamApiRequest()`. This method returns an `AsyncIterable` that yields validated chunks as they arrive.
|
|
786
|
+
|
|
787
|
+
```typescript
|
|
788
|
+
import { streamingApi, z, anthropic } from "@superblocksteam/sdk-api";
|
|
789
|
+
|
|
790
|
+
// Integration ID from the integrations panel
|
|
791
|
+
const PROD_ANTHROPIC = "d4e5f6g7-8901-23ab-cdef-ghijklmnopqr";
|
|
792
|
+
|
|
793
|
+
// Define schema for Anthropic SSE events
|
|
794
|
+
const AnthropicStreamEventSchema = z.discriminatedUnion("type", [
|
|
795
|
+
z.object({
|
|
796
|
+
type: z.literal("content_block_delta"),
|
|
797
|
+
index: z.number(),
|
|
798
|
+
delta: z.object({
|
|
799
|
+
type: z.literal("text_delta"),
|
|
800
|
+
text: z.string(),
|
|
801
|
+
}),
|
|
802
|
+
}),
|
|
803
|
+
z.object({ type: z.literal("message_start"), message: z.any() }),
|
|
804
|
+
z.object({
|
|
805
|
+
type: z.literal("content_block_start"),
|
|
806
|
+
index: z.number(),
|
|
807
|
+
content_block: z.any(),
|
|
808
|
+
}),
|
|
809
|
+
z.object({ type: z.literal("content_block_stop"), index: z.number() }),
|
|
810
|
+
z.object({
|
|
811
|
+
type: z.literal("message_delta"),
|
|
812
|
+
delta: z.any(),
|
|
813
|
+
usage: z.any(),
|
|
814
|
+
}),
|
|
815
|
+
z.object({ type: z.literal("message_stop") }),
|
|
816
|
+
z.object({ type: z.literal("ping") }),
|
|
817
|
+
]);
|
|
818
|
+
|
|
819
|
+
export default streamingApi({
|
|
820
|
+
name: "StreamAnthropicChat",
|
|
821
|
+
|
|
822
|
+
integrations: {
|
|
823
|
+
ai: anthropic(PROD_ANTHROPIC),
|
|
824
|
+
},
|
|
825
|
+
|
|
826
|
+
input: z.object({ prompt: z.string() }),
|
|
827
|
+
chunk: z.object({ type: z.literal("text"), text: z.string() }),
|
|
828
|
+
|
|
829
|
+
async *run(ctx, { prompt }) {
|
|
830
|
+
const stream = ctx.integrations.ai.streamApiRequest(
|
|
831
|
+
{
|
|
832
|
+
method: "POST",
|
|
833
|
+
path: "/v1/messages",
|
|
834
|
+
body: {
|
|
835
|
+
model: "claude-3-5-sonnet-20241022",
|
|
836
|
+
max_tokens: 1024,
|
|
837
|
+
stream: true,
|
|
838
|
+
messages: [{ role: "user", content: prompt }],
|
|
839
|
+
},
|
|
840
|
+
},
|
|
841
|
+
{ chunk: AnthropicStreamEventSchema },
|
|
842
|
+
);
|
|
843
|
+
|
|
844
|
+
for await (const event of stream) {
|
|
845
|
+
if (event.type === "content_block_delta") {
|
|
846
|
+
yield { type: "text" as const, text: event.delta.text };
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
},
|
|
850
|
+
});
|
|
851
|
+
```
|
|
852
|
+
|
|
853
|
+
### StreamApiRequestOptions
|
|
854
|
+
|
|
855
|
+
Same as `ApiRequestOptions` - see above.
|
|
856
|
+
|
|
857
|
+
### StreamApiRequestSchema
|
|
858
|
+
|
|
859
|
+
| Property | Type | Description |
|
|
860
|
+
| -------- | --------------------- | ------------------------------------------------------------------------------ |
|
|
861
|
+
| `body?` | `z.ZodSchema<TBody>` | Optional Zod schema for request body validation (required if body is provided) |
|
|
862
|
+
| `chunk` | `z.ZodSchema<TChunk>` | **Required** Zod schema for validating each streamed chunk |
|
|
863
|
+
|
|
864
|
+
### Supported Integrations
|
|
865
|
+
|
|
866
|
+
Streaming is supported by REST API-based integrations that connect to services with SSE (Server-Sent Events) endpoints:
|
|
867
|
+
|
|
868
|
+
- **AnthropicClient** - Claude streaming messages
|
|
869
|
+
- **OpenAIClient** - GPT streaming chat completions
|
|
870
|
+
- **CohereClient** - Streaming text generation
|
|
871
|
+
- **GroqClient** - Streaming completions
|
|
872
|
+
- **MistralClient** - Streaming chat
|
|
873
|
+
- **FireworksClient** - Streaming inference
|
|
874
|
+
- **PerplexityClient** - Streaming search responses
|
|
875
|
+
|
|
876
|
+
## Trace Metadata
|
|
877
|
+
|
|
878
|
+
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.
|
|
879
|
+
|
|
880
|
+
> **Warning:** Do not include secrets, passwords, access tokens, or other sensitive/PII data in trace metadata, as it may be stored in logs or trace payloads and visible to others with access to diagnostics.
|
|
881
|
+
|
|
882
|
+
```typescript
|
|
883
|
+
interface TraceMetadata {
|
|
884
|
+
/** Short human-readable label for this call (e.g., "Fetch active users"). */
|
|
885
|
+
label?: string;
|
|
886
|
+
/** Longer description of what this call does and why. */
|
|
887
|
+
description?: string;
|
|
888
|
+
}
|
|
889
|
+
```
|
|
890
|
+
|
|
891
|
+
### Usage
|
|
892
|
+
|
|
893
|
+
Pass metadata as the last argument to any integration method:
|
|
894
|
+
|
|
895
|
+
```typescript
|
|
896
|
+
// SQL clients (query, execute)
|
|
897
|
+
const users = await ctx.integrations.db.query(
|
|
898
|
+
"SELECT * FROM users WHERE status = $1",
|
|
899
|
+
UserSchema,
|
|
900
|
+
["active"],
|
|
901
|
+
{
|
|
902
|
+
label: "Fetch active users",
|
|
903
|
+
description: "Load users for the dashboard list view",
|
|
904
|
+
},
|
|
905
|
+
);
|
|
906
|
+
|
|
907
|
+
await ctx.integrations.db.execute(
|
|
908
|
+
"UPDATE users SET last_login = NOW() WHERE id = $1",
|
|
909
|
+
[userId],
|
|
910
|
+
{ label: "Update last login" },
|
|
911
|
+
);
|
|
912
|
+
|
|
913
|
+
// REST API clients (apiRequest, streamApiRequest)
|
|
914
|
+
const result = await ctx.integrations.slack.apiRequest(
|
|
915
|
+
{ method: "POST", path: "/chat.postMessage", body: { channel, text } },
|
|
916
|
+
{ body: BodySchema, response: ResponseSchema },
|
|
917
|
+
{ label: "Send alert to Slack" },
|
|
918
|
+
);
|
|
919
|
+
|
|
920
|
+
// Other clients (MongoDB, Redis, S3, etc.)
|
|
921
|
+
const doc = await ctx.integrations.mongo.run(
|
|
922
|
+
"users",
|
|
923
|
+
"findOne",
|
|
924
|
+
ResultSchema,
|
|
925
|
+
{ filter: { _id: userId } },
|
|
926
|
+
{ label: "Look up user by ID" },
|
|
927
|
+
);
|
|
928
|
+
|
|
929
|
+
await ctx.integrations.cache.get("session:" + sessionId, {
|
|
930
|
+
label: "Check session cache",
|
|
931
|
+
});
|
|
932
|
+
```
|
|
933
|
+
|
|
934
|
+
### When to Use
|
|
935
|
+
|
|
936
|
+
Trace metadata is optional and purely for observability. Use it when:
|
|
937
|
+
|
|
938
|
+
- You want labeled traces in the diagnostics panel for easier debugging
|
|
939
|
+
- An API makes multiple calls to the same integration and you need to distinguish them
|
|
940
|
+
- You want to document the intent of each integration call for your team
|
|
941
|
+
|
|
942
|
+
Metadata has no effect on execution - it only appears in diagnostics when `includeDiagnostics` is enabled.
|
|
943
|
+
|
|
944
|
+
## Error Handling
|
|
945
|
+
|
|
946
|
+
The SDK provides structured error types for different failure scenarios:
|
|
947
|
+
|
|
948
|
+
```typescript
|
|
949
|
+
import {
|
|
950
|
+
InputValidationError,
|
|
951
|
+
OutputValidationError,
|
|
952
|
+
QueryValidationError,
|
|
953
|
+
RestApiValidationError,
|
|
954
|
+
StreamChunkValidationError,
|
|
955
|
+
IntegrationNotFoundError,
|
|
956
|
+
ExecutionError,
|
|
957
|
+
ErrorCode,
|
|
958
|
+
} from "@superblocksteam/sdk-api";
|
|
959
|
+
```
|
|
960
|
+
|
|
961
|
+
| Error Type | Code | Description |
|
|
962
|
+
| ---------------------------- | ----------------------- | -------------------------------------------------- |
|
|
963
|
+
| `InputValidationError` | `INPUT_VALIDATION` | Input failed Zod validation |
|
|
964
|
+
| `OutputValidationError` | `OUTPUT_VALIDATION` | Output failed Zod validation |
|
|
965
|
+
| `QueryValidationError` | N/A | Database query result validation failed (Postgres) |
|
|
966
|
+
| `RestApiValidationError` | N/A | REST API request/response validation failed |
|
|
967
|
+
| `StreamChunkValidationError` | N/A | Streaming chunk failed schema validation |
|
|
968
|
+
| `IntegrationNotFoundError` | `INTEGRATION_NOT_FOUND` | Integration not configured |
|
|
969
|
+
| `IntegrationError` | `INTEGRATION_ERROR` | Integration operation failed |
|
|
970
|
+
| `ExecutionError` | `EXECUTION_ERROR` | User code threw an error |
|
|
971
|
+
|
|
972
|
+
### QueryValidationError (Postgres)
|
|
973
|
+
|
|
974
|
+
Thrown when database query results fail schema validation. Includes the row index, field-level errors, and the actual row data.
|
|
975
|
+
|
|
976
|
+
```typescript
|
|
977
|
+
try {
|
|
978
|
+
const users = await ctx.integrations.db.query<User>(
|
|
979
|
+
"SELECT * FROM users",
|
|
980
|
+
UserSchema,
|
|
981
|
+
[],
|
|
982
|
+
);
|
|
983
|
+
} catch (error) {
|
|
984
|
+
if (error instanceof QueryValidationError) {
|
|
985
|
+
console.error("Validation failed for row:", error.details.rowIndex);
|
|
986
|
+
console.error("Field errors:", error.details.errors);
|
|
987
|
+
console.error("Row data:", error.details.row);
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
```
|
|
991
|
+
|
|
992
|
+
### RestApiValidationError
|
|
993
|
+
|
|
994
|
+
Thrown when REST API request bodies or responses fail schema validation. Includes the complete Zod error object with all validation metadata and the actual data that failed.
|
|
995
|
+
|
|
996
|
+
```typescript
|
|
997
|
+
try {
|
|
998
|
+
const result = await ctx.integrations.ai.apiRequest(
|
|
999
|
+
{ method: 'POST', path: '/v1/chat/completions', body: { ... } },
|
|
1000
|
+
{ body: RequestSchema, response: ResponseSchema }
|
|
1001
|
+
);
|
|
1002
|
+
} catch (error) {
|
|
1003
|
+
if (error instanceof RestApiValidationError) {
|
|
1004
|
+
// Full Zod error with all validation details
|
|
1005
|
+
console.error('Zod error:', error.details.zodError);
|
|
1006
|
+
console.error('Issues:', error.details.zodError.issues);
|
|
1007
|
+
|
|
1008
|
+
// The actual data that failed validation
|
|
1009
|
+
console.error('Failed data:', error.details.data);
|
|
1010
|
+
|
|
1011
|
+
// Access Zod utility methods
|
|
1012
|
+
const formatted = error.details.zodError.format();
|
|
1013
|
+
const flattened = error.details.zodError.flatten();
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
```
|
|
1017
|
+
|
|
1018
|
+
The `RestApiValidationError` provides complete context for debugging:
|
|
1019
|
+
|
|
1020
|
+
- **Full Zod error object** (`zodError`) with all validation information
|
|
1021
|
+
- **Validation codes** (e.g., `"invalid_type"`, `"too_small"`, `"invalid_email"`)
|
|
1022
|
+
- **Expected vs received** values for type mismatches
|
|
1023
|
+
- **Constraint information** (e.g., minimum/maximum values)
|
|
1024
|
+
- **The actual data** that failed validation
|
|
1025
|
+
- **Utility methods** like `format()` and `flatten()` for different error representations
|
|
1026
|
+
|
|
1027
|
+
### StreamChunkValidationError
|
|
1028
|
+
|
|
1029
|
+
Thrown when a streamed chunk fails schema validation. Includes the chunk index, the raw chunk data, and the Zod error.
|
|
1030
|
+
|
|
1031
|
+
```typescript
|
|
1032
|
+
import { execute, StreamChunkValidationError } from "@superblocksteam/sdk-api";
|
|
1033
|
+
|
|
1034
|
+
try {
|
|
1035
|
+
// execute() returns an AsyncGenerator for streaming APIs
|
|
1036
|
+
for await (const chunk of execute(streamingApi, request)) {
|
|
1037
|
+
// Process chunk
|
|
1038
|
+
}
|
|
1039
|
+
} catch (error) {
|
|
1040
|
+
if (error instanceof StreamChunkValidationError) {
|
|
1041
|
+
console.error("Chunk index:", error.details.chunkIndex);
|
|
1042
|
+
console.error("Raw chunk:", error.details.chunk);
|
|
1043
|
+
console.error("Validation error:", error.details.zodError);
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
```
|
|
1047
|
+
|
|
1048
|
+
The `StreamChunkValidationError` provides:
|
|
1049
|
+
|
|
1050
|
+
- **Chunk index** (`chunkIndex`) - Which chunk in the stream failed
|
|
1051
|
+
- **Raw chunk data** (`chunk`) - The actual data that failed validation
|
|
1052
|
+
- **Full Zod error** (`zodError`) - Complete validation error details
|
|
1053
|
+
|
|
1054
|
+
## Best Practices
|
|
1055
|
+
|
|
1056
|
+
### Push Filtering Down to the Data Source
|
|
1057
|
+
|
|
1058
|
+
Always filter data at the source (database, API) rather than fetching everything and filtering in code. This reduces network transfer, memory usage, and processing time.
|
|
1059
|
+
|
|
1060
|
+
**Inefficient - Fetching all rows and filtering in code:**
|
|
1061
|
+
|
|
1062
|
+
```typescript
|
|
1063
|
+
const AllUsersSchema = z.array(
|
|
1064
|
+
z.object({ id: z.string(), status: z.string(), region: z.string() }),
|
|
1065
|
+
);
|
|
1066
|
+
|
|
1067
|
+
// Fetches ALL users, then filters - wasteful!
|
|
1068
|
+
async run(ctx, { region }) {
|
|
1069
|
+
const allUsers = await ctx.integrations.db.query("SELECT * FROM users", AllUsersSchema);
|
|
1070
|
+
const activeUsersInRegion = allUsers.filter(
|
|
1071
|
+
(u) => u.status === "active" && u.region === region,
|
|
1072
|
+
);
|
|
1073
|
+
}
|
|
1074
|
+
```
|
|
1075
|
+
|
|
1076
|
+
**Efficient - Filtering in the database query:**
|
|
1077
|
+
|
|
1078
|
+
```typescript
|
|
1079
|
+
const UserSchema = z.object({
|
|
1080
|
+
id: z.string(),
|
|
1081
|
+
status: z.string(),
|
|
1082
|
+
region: z.string(),
|
|
1083
|
+
});
|
|
1084
|
+
|
|
1085
|
+
// Database does the filtering - only matching rows are transferred
|
|
1086
|
+
async run(ctx, { region }) {
|
|
1087
|
+
const activeUsersInRegion = await ctx.integrations.db.query(
|
|
1088
|
+
"SELECT * FROM users WHERE status = $1 AND region = $2",
|
|
1089
|
+
UserSchema,
|
|
1090
|
+
["active", region],
|
|
1091
|
+
);
|
|
1092
|
+
}
|
|
1093
|
+
```
|
|
1094
|
+
|
|
1095
|
+
The same principle applies to REST APIs - use query parameters to filter at the source:
|
|
1096
|
+
|
|
1097
|
+
**Inefficient:**
|
|
1098
|
+
|
|
1099
|
+
```typescript
|
|
1100
|
+
// Fetches all issues, then filters client-side
|
|
1101
|
+
const allIssues = await ctx.integrations.repo.apiRequest(
|
|
1102
|
+
{ method: "GET", path: "/repos/owner/repo/issues" },
|
|
1103
|
+
{ response: IssuesSchema },
|
|
1104
|
+
);
|
|
1105
|
+
const openBugs = allIssues.filter(
|
|
1106
|
+
(i) => i.state === "open" && i.labels.includes("bug"),
|
|
1107
|
+
);
|
|
1108
|
+
```
|
|
1109
|
+
|
|
1110
|
+
**Efficient:**
|
|
1111
|
+
|
|
1112
|
+
```typescript
|
|
1113
|
+
// API does the filtering - only matching issues returned
|
|
1114
|
+
const openBugs = await ctx.integrations.repo.apiRequest(
|
|
1115
|
+
{
|
|
1116
|
+
method: "GET",
|
|
1117
|
+
path: "/repos/owner/repo/issues",
|
|
1118
|
+
params: { state: "open", labels: "bug" },
|
|
1119
|
+
},
|
|
1120
|
+
{ response: IssuesSchema },
|
|
1121
|
+
);
|
|
1122
|
+
```
|
|
1123
|
+
|
|
1124
|
+
### Select Only the Fields You Need
|
|
1125
|
+
|
|
1126
|
+
Avoid `SELECT *` in database queries. Fetch only the columns you actually use to reduce data transfer and improve query performance.
|
|
1127
|
+
|
|
1128
|
+
**Inefficient:**
|
|
1129
|
+
|
|
1130
|
+
```typescript
|
|
1131
|
+
// Fetches all columns even though we only need id and email
|
|
1132
|
+
const users = await ctx.integrations.db.query(
|
|
1133
|
+
"SELECT * FROM users WHERE status = $1",
|
|
1134
|
+
UserSchema,
|
|
1135
|
+
["active"],
|
|
1136
|
+
);
|
|
1137
|
+
const emails = users.map((u) => u.email);
|
|
1138
|
+
```
|
|
1139
|
+
|
|
1140
|
+
**Efficient:**
|
|
1141
|
+
|
|
1142
|
+
```typescript
|
|
1143
|
+
const UserEmailSchema = z.object({ id: z.string(), email: z.string() });
|
|
1144
|
+
|
|
1145
|
+
// Fetches only the columns we need
|
|
1146
|
+
const users = await ctx.integrations.db.query(
|
|
1147
|
+
"SELECT id, email FROM users WHERE status = $1",
|
|
1148
|
+
UserEmailSchema,
|
|
1149
|
+
["active"],
|
|
1150
|
+
);
|
|
1151
|
+
```
|
|
1152
|
+
|
|
1153
|
+
### Use Pagination and Limits
|
|
1154
|
+
|
|
1155
|
+
When working with large datasets, use pagination to process data in chunks rather than loading everything into memory.
|
|
1156
|
+
|
|
1157
|
+
```typescript
|
|
1158
|
+
const PageSchema = z.object({
|
|
1159
|
+
id: z.string(),
|
|
1160
|
+
name: z.string(),
|
|
1161
|
+
createdAt: z.string(),
|
|
1162
|
+
});
|
|
1163
|
+
|
|
1164
|
+
// Process in batches of 100
|
|
1165
|
+
const PAGE_SIZE = 100;
|
|
1166
|
+
let offset = 0;
|
|
1167
|
+
let hasMore = true;
|
|
1168
|
+
|
|
1169
|
+
while (hasMore) {
|
|
1170
|
+
const batch = await ctx.integrations.db.query(
|
|
1171
|
+
"SELECT id, name, created_at FROM orders ORDER BY created_at LIMIT $1 OFFSET $2",
|
|
1172
|
+
PageSchema,
|
|
1173
|
+
[PAGE_SIZE, offset],
|
|
1174
|
+
);
|
|
1175
|
+
|
|
1176
|
+
// Process this batch
|
|
1177
|
+
for (const order of batch) {
|
|
1178
|
+
await processOrder(order);
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
hasMore = batch.length === PAGE_SIZE;
|
|
1182
|
+
offset += PAGE_SIZE;
|
|
1183
|
+
}
|
|
1184
|
+
```
|
|
1185
|
+
|
|
1186
|
+
### Avoid N+1 Query Patterns
|
|
1187
|
+
|
|
1188
|
+
Don't fetch related data one item at a time in a loop. Use JOINs or batch queries instead.
|
|
1189
|
+
|
|
1190
|
+
**N+1 Problem - One query per order:**
|
|
1191
|
+
|
|
1192
|
+
```typescript
|
|
1193
|
+
const orders = await ctx.integrations.db.query(
|
|
1194
|
+
"SELECT * FROM orders",
|
|
1195
|
+
OrderSchema,
|
|
1196
|
+
);
|
|
1197
|
+
|
|
1198
|
+
// BAD: This makes N additional queries!
|
|
1199
|
+
for (const order of orders) {
|
|
1200
|
+
const items = await ctx.integrations.db.query(
|
|
1201
|
+
"SELECT * FROM order_items WHERE order_id = $1",
|
|
1202
|
+
ItemSchema,
|
|
1203
|
+
[order.id],
|
|
1204
|
+
);
|
|
1205
|
+
order.items = items;
|
|
1206
|
+
}
|
|
1207
|
+
```
|
|
1208
|
+
|
|
1209
|
+
**Efficient - Single query with JOIN:**
|
|
1210
|
+
|
|
1211
|
+
```typescript
|
|
1212
|
+
const OrderWithItemsSchema = z.object({
|
|
1213
|
+
orderId: z.string(),
|
|
1214
|
+
orderTotal: z.number(),
|
|
1215
|
+
itemId: z.string(),
|
|
1216
|
+
itemName: z.string(),
|
|
1217
|
+
quantity: z.number(),
|
|
1218
|
+
});
|
|
1219
|
+
|
|
1220
|
+
// Single query fetches everything
|
|
1221
|
+
const rows = await ctx.integrations.db.query(
|
|
1222
|
+
`SELECT o.id as order_id, o.total as order_total,
|
|
1223
|
+
i.id as item_id, i.name as item_name, i.quantity
|
|
1224
|
+
FROM orders o
|
|
1225
|
+
JOIN order_items i ON i.order_id = o.id`,
|
|
1226
|
+
OrderWithItemsSchema,
|
|
1227
|
+
);
|
|
1228
|
+
```
|
|
1229
|
+
|
|
1230
|
+
**Alternative - Batch fetch with IN clause:**
|
|
1231
|
+
|
|
1232
|
+
```typescript
|
|
1233
|
+
const orders = await ctx.integrations.db.query(
|
|
1234
|
+
"SELECT * FROM orders",
|
|
1235
|
+
OrderSchema,
|
|
1236
|
+
);
|
|
1237
|
+
const orderIds = orders.map((o) => o.id);
|
|
1238
|
+
|
|
1239
|
+
// Single query for all items
|
|
1240
|
+
const items = await ctx.integrations.db.query(
|
|
1241
|
+
"SELECT * FROM order_items WHERE order_id = ANY($1)",
|
|
1242
|
+
ItemSchema,
|
|
1243
|
+
[orderIds],
|
|
1244
|
+
);
|
|
1245
|
+
```
|
|
1246
|
+
|
|
1247
|
+
### Batch API Requests When Possible
|
|
1248
|
+
|
|
1249
|
+
Some APIs support batch operations. Use them instead of making individual requests.
|
|
1250
|
+
|
|
1251
|
+
**Inefficient - Individual requests:**
|
|
1252
|
+
|
|
1253
|
+
```typescript
|
|
1254
|
+
// Makes 100 separate API calls!
|
|
1255
|
+
for (const userId of userIds) {
|
|
1256
|
+
await ctx.integrations.notifier.apiRequest(
|
|
1257
|
+
{
|
|
1258
|
+
method: "POST",
|
|
1259
|
+
path: "/chat.postMessage",
|
|
1260
|
+
body: { channel: userId, text: "Hello!" },
|
|
1261
|
+
},
|
|
1262
|
+
{ response: MessageSchema },
|
|
1263
|
+
);
|
|
1264
|
+
}
|
|
1265
|
+
```
|
|
1266
|
+
|
|
1267
|
+
**Efficient - Use batch endpoints when available:**
|
|
1268
|
+
|
|
1269
|
+
```typescript
|
|
1270
|
+
// Check if the API supports batch operations
|
|
1271
|
+
// For Slack, consider using chat.postMessage with multiple channel webhooks
|
|
1272
|
+
// or processing in controlled parallel batches
|
|
1273
|
+
const BATCH_SIZE = 10;
|
|
1274
|
+
for (let i = 0; i < userIds.length; i += BATCH_SIZE) {
|
|
1275
|
+
const batch = userIds.slice(i, i + BATCH_SIZE);
|
|
1276
|
+
await Promise.all(
|
|
1277
|
+
batch.map((userId) =>
|
|
1278
|
+
ctx.integrations.notifier.apiRequest(
|
|
1279
|
+
{
|
|
1280
|
+
method: "POST",
|
|
1281
|
+
path: "/chat.postMessage",
|
|
1282
|
+
body: { channel: userId, text: "Hello!" },
|
|
1283
|
+
},
|
|
1284
|
+
{ response: MessageSchema },
|
|
1285
|
+
),
|
|
1286
|
+
),
|
|
1287
|
+
);
|
|
1288
|
+
}
|
|
1289
|
+
```
|
|
1290
|
+
|
|
1291
|
+
### Use Precise Schemas
|
|
1292
|
+
|
|
1293
|
+
Define schemas that match exactly what you expect. This improves type safety and catches data issues early.
|
|
1294
|
+
|
|
1295
|
+
```typescript
|
|
1296
|
+
// Be specific about field types and constraints
|
|
1297
|
+
const UserSchema = z.object({
|
|
1298
|
+
id: z.string().uuid(),
|
|
1299
|
+
email: z.string().email(),
|
|
1300
|
+
age: z.number().int().min(0).max(150),
|
|
1301
|
+
status: z.enum(["active", "inactive", "pending"]),
|
|
1302
|
+
createdAt: z.string().datetime(),
|
|
1303
|
+
});
|
|
1304
|
+
|
|
1305
|
+
// Use .pick() or .omit() to create variants
|
|
1306
|
+
const UserSummarySchema = UserSchema.pick({ id: true, email: true });
|
|
1307
|
+
const UserUpdateSchema = UserSchema.omit({ id: true, createdAt: true });
|
|
1308
|
+
```
|
|
1309
|
+
|
|
1310
|
+
## Using APIs in the Frontend
|
|
1311
|
+
|
|
1312
|
+
The app template provides automatic type inference for API calls using a tRPC-style pattern.
|
|
1313
|
+
|
|
1314
|
+
### Adding a New API (2 Steps)
|
|
1315
|
+
|
|
1316
|
+
**Step 1**: Create your API file (e.g., `server/apis/GetUsers/api.ts`)
|
|
1317
|
+
|
|
1318
|
+
**Step 2**: Add it to the registry at `server/apis/index.ts`:
|
|
1319
|
+
|
|
1320
|
+
```typescript
|
|
1321
|
+
import GetUsers from "./GetUsers/api.js";
|
|
1322
|
+
import CreateOrder from "./CreateOrder/api.js";
|
|
1323
|
+
|
|
1324
|
+
const apis = {
|
|
1325
|
+
GetUsers,
|
|
1326
|
+
CreateOrder,
|
|
1327
|
+
// Add new APIs here
|
|
1328
|
+
} as const;
|
|
1329
|
+
|
|
1330
|
+
export default apis;
|
|
1331
|
+
export type ApiRegistry = typeof apis;
|
|
1332
|
+
```
|
|
1333
|
+
|
|
1334
|
+
That's it! Types automatically flow to the frontend.
|
|
1335
|
+
|
|
1336
|
+
> **Note**: Always use `.js` extension in imports (required for ESM module resolution).
|
|
1337
|
+
|
|
1338
|
+
### Calling APIs from React Components
|
|
1339
|
+
|
|
1340
|
+
Import `useApi` from the template's pre-configured hook:
|
|
1341
|
+
|
|
1342
|
+
```typescript
|
|
1343
|
+
import { useApi } from '@/hooks/useApi.js';
|
|
1344
|
+
|
|
1345
|
+
function MyComponent() {
|
|
1346
|
+
// ✅ Full type inference - input and output types are automatic
|
|
1347
|
+
const { run } = useApi("GetUsers");
|
|
1348
|
+
|
|
1349
|
+
const handleClick = async () => {
|
|
1350
|
+
// TypeScript knows the exact input type required
|
|
1351
|
+
const result = await run({ email: "test@example.com", name: null });
|
|
1352
|
+
|
|
1353
|
+
if (result) {
|
|
1354
|
+
// TypeScript knows result.users exists with correct shape
|
|
1355
|
+
console.log(result.users);
|
|
1356
|
+
}
|
|
1357
|
+
};
|
|
1358
|
+
|
|
1359
|
+
return <button onClick={handleClick}>Fetch Users</button>;
|
|
1360
|
+
}
|
|
1361
|
+
```
|
|
1362
|
+
|
|
1363
|
+
### How It Works
|
|
1364
|
+
|
|
1365
|
+
The template includes two files that work together:
|
|
1366
|
+
|
|
1367
|
+
1. **`server/apis/index.ts`** - Registry you update when adding APIs
|
|
1368
|
+
2. **`client/hooks/useApi.ts`** - Pre-configured typed hook (don't modify)
|
|
1369
|
+
|
|
1370
|
+
The hook uses `import type` to pull in only the type information from the registry, keeping server code out of the client bundle.
|
|
1371
|
+
|
|
1372
|
+
**Key benefits**:
|
|
1373
|
+
|
|
1374
|
+
- **Single source of truth**: Just update `server/apis/index.ts`
|
|
1375
|
+
- **No server code in client bundle**: Type-only imports are erased at compile time
|
|
1376
|
+
- **Full type safety**: Autocomplete for API names, type errors for invalid inputs/outputs
|
|
1377
|
+
|
|
1378
|
+
### Alternative: Explicit Type Parameter
|
|
1379
|
+
|
|
1380
|
+
For testing or when the registry isn't available:
|
|
1381
|
+
|
|
1382
|
+
```typescript
|
|
1383
|
+
import { useApi } from "@superblocksteam/library";
|
|
1384
|
+
import type GetUsersApi from "../../server/apis/GetUsers/api.js";
|
|
1385
|
+
|
|
1386
|
+
const { run } = useApi<typeof GetUsersApi>("GetUsers");
|
|
1387
|
+
```
|
|
1388
|
+
|
|
1389
|
+
## Complete Example
|
|
1390
|
+
|
|
1391
|
+
```typescript
|
|
1392
|
+
import { api, z, postgres, slack, openai } from "@superblocksteam/sdk-api";
|
|
1393
|
+
|
|
1394
|
+
// Integration IDs from the integrations panel
|
|
1395
|
+
const PROD_POSTGRES = "a1b2c3d4-5678-90ab-cdef-ghijklmnopqr";
|
|
1396
|
+
const OPS_SLACK = "b2c3d4e5-6789-01ab-cdef-ghijklmnopqr";
|
|
1397
|
+
const PROD_OPENAI = "c3d4e5f6-7890-12ab-cdef-ghijklmnopqr";
|
|
1398
|
+
|
|
1399
|
+
// Define reusable schemas
|
|
1400
|
+
const OrderItemSchema = z.object({
|
|
1401
|
+
productId: z.string(),
|
|
1402
|
+
quantity: z.number().int().positive(),
|
|
1403
|
+
});
|
|
1404
|
+
|
|
1405
|
+
const CompletionRequestSchema = z.object({
|
|
1406
|
+
model: z.string(),
|
|
1407
|
+
messages: z.array(
|
|
1408
|
+
z.object({
|
|
1409
|
+
role: z.string(),
|
|
1410
|
+
content: z.string(),
|
|
1411
|
+
}),
|
|
1412
|
+
),
|
|
1413
|
+
});
|
|
1414
|
+
|
|
1415
|
+
const CompletionResponseSchema = z.object({
|
|
1416
|
+
choices: z.array(
|
|
1417
|
+
z.object({
|
|
1418
|
+
message: z.object({
|
|
1419
|
+
content: z.string(),
|
|
1420
|
+
}),
|
|
1421
|
+
}),
|
|
1422
|
+
),
|
|
1423
|
+
});
|
|
1424
|
+
|
|
1425
|
+
const CustomerSchema = z.object({
|
|
1426
|
+
id: z.string(),
|
|
1427
|
+
email: z.string().email(),
|
|
1428
|
+
});
|
|
1429
|
+
|
|
1430
|
+
const SlackPostMessageResponseSchema = z.object({
|
|
1431
|
+
ok: z.boolean(),
|
|
1432
|
+
ts: z.string().optional(),
|
|
1433
|
+
});
|
|
1434
|
+
|
|
1435
|
+
export default api({
|
|
1436
|
+
name: "CreateOrder",
|
|
1437
|
+
|
|
1438
|
+
// Declare all integrations upfront
|
|
1439
|
+
integrations: {
|
|
1440
|
+
db: postgres(PROD_POSTGRES),
|
|
1441
|
+
notifier: slack(OPS_SLACK),
|
|
1442
|
+
ai: openai(PROD_OPENAI),
|
|
1443
|
+
},
|
|
1444
|
+
|
|
1445
|
+
input: z.object({
|
|
1446
|
+
customerId: z.string().uuid(),
|
|
1447
|
+
items: z.array(OrderItemSchema).min(1),
|
|
1448
|
+
sendAiSummary: z.boolean().default(false),
|
|
1449
|
+
}),
|
|
1450
|
+
|
|
1451
|
+
output: z.object({
|
|
1452
|
+
orderId: z.string(),
|
|
1453
|
+
total: z.number(),
|
|
1454
|
+
itemCount: z.number(),
|
|
1455
|
+
aiSummary: z.string().optional(),
|
|
1456
|
+
}),
|
|
1457
|
+
|
|
1458
|
+
async run(ctx, { customerId, items, sendAiSummary }) {
|
|
1459
|
+
ctx.log.info("Creating order", { customerId, itemCount: items.length });
|
|
1460
|
+
|
|
1461
|
+
// Get customer from database
|
|
1462
|
+
const customers = await ctx.integrations.db.query(
|
|
1463
|
+
"SELECT id, email FROM customers WHERE id = $1",
|
|
1464
|
+
CustomerSchema,
|
|
1465
|
+
[customerId],
|
|
1466
|
+
);
|
|
1467
|
+
const customer = customers[0];
|
|
1468
|
+
|
|
1469
|
+
if (!customer) {
|
|
1470
|
+
throw new Error(`Customer not found: ${customerId}`);
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
// Calculate total
|
|
1474
|
+
const total = items.reduce((sum, item) => {
|
|
1475
|
+
// In real code, you'd look up prices
|
|
1476
|
+
return sum + item.quantity * 10;
|
|
1477
|
+
}, 0);
|
|
1478
|
+
|
|
1479
|
+
// Insert order
|
|
1480
|
+
await ctx.integrations.db.execute(
|
|
1481
|
+
"INSERT INTO orders (customer_id, total, item_count) VALUES ($1, $2, $3)",
|
|
1482
|
+
[customerId, total, items.length],
|
|
1483
|
+
);
|
|
1484
|
+
|
|
1485
|
+
const orderId = `ord_${Date.now()}`;
|
|
1486
|
+
|
|
1487
|
+
// Notify via Slack
|
|
1488
|
+
await ctx.integrations.notifier.apiRequest(
|
|
1489
|
+
{
|
|
1490
|
+
method: "POST",
|
|
1491
|
+
path: "/chat.postMessage",
|
|
1492
|
+
body: {
|
|
1493
|
+
channel: "#orders",
|
|
1494
|
+
text: `New order ${orderId} from ${customer.email}: $${total.toFixed(2)}`,
|
|
1495
|
+
},
|
|
1496
|
+
},
|
|
1497
|
+
{ response: SlackPostMessageResponseSchema },
|
|
1498
|
+
);
|
|
1499
|
+
|
|
1500
|
+
// Generate AI summary if requested
|
|
1501
|
+
let aiSummary: string | undefined;
|
|
1502
|
+
if (sendAiSummary) {
|
|
1503
|
+
const completion = await ctx.integrations.ai.apiRequest(
|
|
1504
|
+
{
|
|
1505
|
+
method: "POST",
|
|
1506
|
+
path: "/v1/chat/completions",
|
|
1507
|
+
body: {
|
|
1508
|
+
model: "gpt-4",
|
|
1509
|
+
messages: [
|
|
1510
|
+
{
|
|
1511
|
+
role: "user",
|
|
1512
|
+
content: `Summarize this order: ${items.length} items, total $${total}`,
|
|
1513
|
+
},
|
|
1514
|
+
],
|
|
1515
|
+
},
|
|
1516
|
+
},
|
|
1517
|
+
{
|
|
1518
|
+
body: CompletionRequestSchema,
|
|
1519
|
+
response: CompletionResponseSchema,
|
|
1520
|
+
},
|
|
1521
|
+
);
|
|
1522
|
+
|
|
1523
|
+
aiSummary = completion.choices[0]?.message.content;
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
return {
|
|
1527
|
+
orderId,
|
|
1528
|
+
total,
|
|
1529
|
+
itemCount: items.length,
|
|
1530
|
+
aiSummary,
|
|
1531
|
+
};
|
|
1532
|
+
},
|
|
1533
|
+
});
|
|
1534
|
+
```
|
|
1535
|
+
|
|
1536
|
+
## Development
|
|
1537
|
+
|
|
1538
|
+
```bash
|
|
1539
|
+
# Install dependencies
|
|
1540
|
+
pnpm install
|
|
1541
|
+
|
|
1542
|
+
# Type check
|
|
1543
|
+
pnpm typecheck
|
|
1544
|
+
|
|
1545
|
+
# Run tests
|
|
1546
|
+
pnpm test
|
|
1547
|
+
|
|
1548
|
+
# Build
|
|
1549
|
+
pnpm build
|
|
1550
|
+
```
|
|
1551
|
+
|
|
1552
|
+
## License
|
|
1553
|
+
|
|
1554
|
+
Superblocks Community Software License
|