@superblocksteam/sdk-api 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +351 -427
- package/dist/api/definition.d.ts +12 -7
- package/dist/api/definition.d.ts.map +1 -1
- package/dist/api/definition.js +19 -12
- package/dist/api/definition.js.map +1 -1
- package/dist/api/definition.test.js +39 -15
- package/dist/api/definition.test.js.map +1 -1
- package/dist/api/index.d.ts +0 -2
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +0 -2
- package/dist/api/index.js.map +1 -1
- package/dist/errors.d.ts +1 -45
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +1 -33
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +16 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -15
- package/dist/index.js.map +1 -1
- package/dist/integrations/anthropic/types.d.ts +3 -22
- package/dist/integrations/anthropic/types.d.ts.map +1 -1
- package/dist/integrations/athena/client.d.ts +1 -1
- package/dist/integrations/athena/client.d.ts.map +1 -1
- package/dist/integrations/athena/client.js.map +1 -1
- package/dist/integrations/athena/types.d.ts +2 -2
- package/dist/integrations/athena/types.d.ts.map +1 -1
- package/dist/integrations/base/graphql-integration-client.d.ts +8 -4
- package/dist/integrations/base/graphql-integration-client.d.ts.map +1 -1
- package/dist/integrations/base/graphql-integration-client.js +18 -5
- package/dist/integrations/base/graphql-integration-client.js.map +1 -1
- package/dist/integrations/base/index.d.ts +3 -2
- package/dist/integrations/base/index.d.ts.map +1 -1
- package/dist/integrations/base/index.js +1 -0
- package/dist/integrations/base/index.js.map +1 -1
- package/dist/integrations/base/rest-api-client-base.d.ts +48 -0
- package/dist/integrations/base/rest-api-client-base.d.ts.map +1 -0
- package/dist/integrations/base/rest-api-client-base.js +98 -0
- package/dist/integrations/base/rest-api-client-base.js.map +1 -0
- package/dist/integrations/base/rest-api-integration-client.d.ts +11 -65
- package/dist/integrations/base/rest-api-integration-client.d.ts.map +1 -1
- package/dist/integrations/base/rest-api-integration-client.js +11 -174
- package/dist/integrations/base/rest-api-integration-client.js.map +1 -1
- package/dist/integrations/base/types.d.ts +1 -67
- package/dist/integrations/base/types.d.ts.map +1 -1
- package/dist/integrations/bigquery/client.d.ts +1 -1
- package/dist/integrations/bigquery/client.d.ts.map +1 -1
- package/dist/integrations/bigquery/client.js.map +1 -1
- package/dist/integrations/bigquery/types.d.ts +3 -3
- package/dist/integrations/bigquery/types.d.ts.map +1 -1
- package/dist/integrations/box/types.d.ts +1 -1
- package/dist/integrations/cockroachdb/client.d.ts +1 -1
- package/dist/integrations/cockroachdb/client.d.ts.map +1 -1
- package/dist/integrations/cockroachdb/client.js.map +1 -1
- package/dist/integrations/cockroachdb/types.d.ts.map +1 -1
- package/dist/integrations/cosmosdb/client.d.ts +1 -1
- package/dist/integrations/cosmosdb/client.d.ts.map +1 -1
- package/dist/integrations/cosmosdb/client.js.map +1 -1
- package/dist/integrations/cosmosdb/client.test.js.map +1 -1
- package/dist/integrations/cosmosdb/types.d.ts.map +1 -1
- package/dist/integrations/databricks/client.d.ts +1 -1
- package/dist/integrations/databricks/client.d.ts.map +1 -1
- package/dist/integrations/databricks/client.js.map +1 -1
- package/dist/integrations/databricks/types.d.ts +3 -3
- package/dist/integrations/databricks/types.d.ts.map +1 -1
- package/dist/integrations/declarations.d.ts +36 -104
- package/dist/integrations/declarations.d.ts.map +1 -1
- package/dist/integrations/declarations.js +5 -68
- package/dist/integrations/declarations.js.map +1 -1
- package/dist/integrations/declarations.test.js.map +1 -1
- package/dist/integrations/documentation-resolver.test.d.ts +2 -0
- package/dist/integrations/documentation-resolver.test.d.ts.map +1 -0
- package/dist/integrations/documentation-resolver.test.js +608 -0
- package/dist/integrations/documentation-resolver.test.js.map +1 -0
- package/dist/integrations/documentation.d.ts +8 -0
- package/dist/integrations/documentation.d.ts.map +1 -0
- package/dist/integrations/documentation.js +277 -0
- package/dist/integrations/documentation.js.map +1 -0
- package/dist/integrations/documentation.test.d.ts +2 -0
- package/dist/integrations/documentation.test.d.ts.map +1 -0
- package/dist/integrations/documentation.test.js +81 -0
- package/dist/integrations/documentation.test.js.map +1 -0
- package/dist/integrations/dynamodb/client.d.ts +1 -1
- package/dist/integrations/dynamodb/client.d.ts.map +1 -1
- package/dist/integrations/dynamodb/client.js.map +1 -1
- package/dist/integrations/dynamodb/types.d.ts.map +1 -1
- package/dist/integrations/gcs/client.d.ts +1 -1
- package/dist/integrations/gcs/client.d.ts.map +1 -1
- package/dist/integrations/gcs/client.js.map +1 -1
- package/dist/integrations/gcs/types.d.ts.map +1 -1
- package/dist/integrations/googledrive/types.d.ts +1 -1
- package/dist/integrations/graphql/client.test.d.ts +15 -0
- package/dist/integrations/graphql/client.test.d.ts.map +1 -0
- package/dist/integrations/graphql/client.test.js +148 -0
- package/dist/integrations/graphql/client.test.js.map +1 -0
- package/dist/integrations/graphql/types.d.ts +22 -3
- package/dist/integrations/graphql/types.d.ts.map +1 -1
- package/dist/integrations/gsheets/client.d.ts +1 -1
- package/dist/integrations/gsheets/client.d.ts.map +1 -1
- package/dist/integrations/gsheets/client.js.map +1 -1
- package/dist/integrations/gsheets/types.d.ts.map +1 -1
- package/dist/integrations/index.d.ts +2 -12
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/index.js +2 -8
- package/dist/integrations/index.js.map +1 -1
- package/dist/integrations/lakebase/client.d.ts +1 -1
- package/dist/integrations/lakebase/client.d.ts.map +1 -1
- package/dist/integrations/lakebase/client.js.map +1 -1
- package/dist/integrations/lakebase/types.d.ts +4 -4
- package/dist/integrations/lakebase/types.d.ts.map +1 -1
- package/dist/integrations/mariadb/client.d.ts +1 -1
- package/dist/integrations/mariadb/client.d.ts.map +1 -1
- package/dist/integrations/mariadb/client.js.map +1 -1
- package/dist/integrations/mariadb/types.d.ts +2 -2
- package/dist/integrations/mariadb/types.d.ts.map +1 -1
- package/dist/integrations/mongodb/client.d.ts +1 -1
- package/dist/integrations/mongodb/client.d.ts.map +1 -1
- package/dist/integrations/mongodb/client.js.map +1 -1
- package/dist/integrations/mongodb/types.d.ts.map +1 -1
- package/dist/integrations/mssql/client.d.ts +1 -1
- package/dist/integrations/mssql/client.d.ts.map +1 -1
- package/dist/integrations/mssql/client.js.map +1 -1
- package/dist/integrations/mssql/types.d.ts +2 -2
- package/dist/integrations/mssql/types.d.ts.map +1 -1
- package/dist/integrations/mysql/client.d.ts +1 -1
- package/dist/integrations/mysql/client.d.ts.map +1 -1
- package/dist/integrations/mysql/client.js.map +1 -1
- package/dist/integrations/mysql/types.d.ts +4 -4
- package/dist/integrations/mysql/types.d.ts.map +1 -1
- package/dist/integrations/openai_v2/types.d.ts +4 -22
- package/dist/integrations/openai_v2/types.d.ts.map +1 -1
- package/dist/integrations/oracledb/client.d.ts +1 -1
- package/dist/integrations/oracledb/client.d.ts.map +1 -1
- package/dist/integrations/oracledb/client.js.map +1 -1
- package/dist/integrations/oracledb/types.d.ts +2 -2
- package/dist/integrations/oracledb/types.d.ts.map +1 -1
- package/dist/integrations/postgres/client.d.ts +2 -2
- package/dist/integrations/postgres/client.d.ts.map +1 -1
- package/dist/integrations/postgres/client.js.map +1 -1
- package/dist/integrations/postgres/types.d.ts.map +1 -1
- package/dist/integrations/redshift/client.d.ts +1 -1
- package/dist/integrations/redshift/client.d.ts.map +1 -1
- package/dist/integrations/redshift/client.js.map +1 -1
- package/dist/integrations/redshift/types.d.ts.map +1 -1
- package/dist/integrations/registry.d.ts +6 -27
- package/dist/integrations/registry.d.ts.map +1 -1
- package/dist/integrations/registry.js +64 -88
- package/dist/integrations/registry.js.map +1 -1
- package/dist/integrations/registry.test.js +1 -3
- package/dist/integrations/registry.test.js.map +1 -1
- package/dist/integrations/restapiintegration/types.d.ts +2 -2
- package/dist/integrations/restapiintegration/types.d.ts.map +1 -1
- package/dist/integrations/s3/client.d.ts +1 -1
- package/dist/integrations/s3/client.d.ts.map +1 -1
- package/dist/integrations/s3/client.js.map +1 -1
- package/dist/integrations/s3/types.d.ts +3 -1
- package/dist/integrations/s3/types.d.ts.map +1 -1
- package/dist/integrations/salesforce/client.d.ts +1 -1
- package/dist/integrations/salesforce/client.d.ts.map +1 -1
- package/dist/integrations/salesforce/client.js.map +1 -1
- package/dist/integrations/salesforce/types.d.ts.map +1 -1
- package/dist/integrations/slack/client.d.ts +13 -9
- package/dist/integrations/slack/client.d.ts.map +1 -1
- package/dist/integrations/slack/client.js +60 -8
- package/dist/integrations/slack/client.js.map +1 -1
- package/dist/integrations/slack/client.test.d.ts +11 -0
- package/dist/integrations/slack/client.test.d.ts.map +1 -0
- package/dist/integrations/slack/client.test.js +368 -0
- package/dist/integrations/slack/client.test.js.map +1 -0
- package/dist/integrations/slack/index.d.ts +2 -1
- package/dist/integrations/slack/index.d.ts.map +1 -1
- package/dist/integrations/slack/index.js +1 -0
- package/dist/integrations/slack/index.js.map +1 -1
- package/dist/integrations/slack/types.d.ts +127 -28
- package/dist/integrations/slack/types.d.ts.map +1 -1
- package/dist/integrations/slack/types.js +27 -1
- package/dist/integrations/slack/types.js.map +1 -1
- package/dist/integrations/smtp/client.d.ts +1 -1
- package/dist/integrations/smtp/client.d.ts.map +1 -1
- package/dist/integrations/smtp/client.js.map +1 -1
- package/dist/integrations/snowflake/client.d.ts +3 -3
- package/dist/integrations/snowflake/client.d.ts.map +1 -1
- package/dist/integrations/snowflake/client.js +2 -2
- package/dist/integrations/snowflake/client.js.map +1 -1
- package/dist/integrations/snowflake/types.d.ts.map +1 -1
- package/dist/integrations/snowflakecortex/client.d.ts +1 -2
- package/dist/integrations/snowflakecortex/client.d.ts.map +1 -1
- package/dist/integrations/snowflakecortex/client.js +1 -2
- package/dist/integrations/snowflakecortex/client.js.map +1 -1
- package/dist/integrations/snowflakecortex/types.d.ts +3 -4
- package/dist/integrations/snowflakecortex/types.d.ts.map +1 -1
- package/dist/integrations/snowflakepostgres/client.d.ts +1 -1
- package/dist/integrations/snowflakepostgres/client.d.ts.map +1 -1
- package/dist/integrations/snowflakepostgres/client.js.map +1 -1
- package/dist/integrations/snowflakepostgres/types.d.ts.map +1 -1
- package/dist/runtime/context.d.ts +3 -3
- package/dist/runtime/context.d.ts.map +1 -1
- package/dist/runtime/context.js.map +1 -1
- package/dist/runtime/executor.d.ts +2 -2
- package/dist/runtime/index.d.ts +0 -3
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +1 -6
- package/dist/runtime/index.js.map +1 -1
- package/dist/types.d.ts +15 -6
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/api/definition.test.ts +41 -15
- package/src/api/definition.ts +20 -13
- package/src/api/index.ts +0 -4
- package/src/errors.ts +1 -49
- package/src/index.ts +20 -61
- package/src/integrations/airtable/docs.manifest.json +5 -0
- package/src/integrations/anthropic/README.md +5 -101
- package/src/integrations/anthropic/docs.manifest.json +5 -0
- package/src/integrations/anthropic/types.ts +3 -29
- package/src/integrations/asana/README.md +12 -12
- package/src/integrations/asana/docs.manifest.json +5 -0
- package/src/integrations/athena/README.md +4 -4
- package/src/integrations/athena/client.ts +5 -3
- package/src/integrations/athena/docs.manifest.json +5 -0
- package/src/integrations/athena/types.ts +3 -2
- package/src/integrations/base/graphql-integration-client.ts +27 -5
- package/src/integrations/base/index.ts +2 -3
- package/src/integrations/base/rest-api-client-base.ts +134 -0
- package/src/integrations/base/rest-api-integration-client.ts +15 -239
- package/src/integrations/base/types.ts +4 -74
- package/src/integrations/bigquery/README.md +28 -3
- package/src/integrations/bigquery/client.ts +5 -3
- package/src/integrations/bigquery/docs.manifest.json +5 -0
- package/src/integrations/bigquery/types.ts +4 -3
- package/src/integrations/bitbucket/README.md +19 -19
- package/src/integrations/bitbucket/docs.manifest.json +5 -0
- package/src/integrations/box/README.md +24 -24
- package/src/integrations/box/docs.manifest.json +5 -0
- package/src/integrations/box/types.ts +1 -1
- package/src/integrations/circleci/README.md +18 -18
- package/src/integrations/circleci/docs.manifest.json +5 -0
- package/src/integrations/cockroachdb/client.ts +5 -3
- package/src/integrations/cockroachdb/docs.manifest.json +5 -0
- package/src/integrations/cockroachdb/types.ts +1 -0
- package/src/integrations/cohere/README.md +11 -11
- package/src/integrations/cohere/docs.manifest.json +5 -0
- package/src/integrations/confluence/docs.manifest.json +5 -0
- package/src/integrations/cosmosdb/client.test.ts +2 -1
- package/src/integrations/cosmosdb/client.ts +5 -3
- package/src/integrations/cosmosdb/docs.manifest.json +5 -0
- package/src/integrations/cosmosdb/types.ts +1 -0
- package/src/integrations/databricks/README.md +29 -4
- package/src/integrations/databricks/client.ts +5 -3
- package/src/integrations/databricks/docs.manifest.json +5 -0
- package/src/integrations/databricks/types.ts +4 -3
- package/src/integrations/datadog/docs.manifest.json +5 -0
- package/src/integrations/declarations.test.ts +1 -0
- package/src/integrations/declarations.ts +36 -136
- package/src/integrations/documentation-resolver.test.ts +704 -0
- package/src/integrations/documentation.test.ts +120 -0
- package/src/integrations/documentation.ts +421 -0
- package/src/integrations/dropbox/docs.manifest.json +5 -0
- package/src/integrations/dynamodb/client.ts +3 -2
- package/src/integrations/dynamodb/docs.manifest.json +5 -0
- package/src/integrations/dynamodb/types.ts +1 -0
- package/src/integrations/elasticsearch/docs.manifest.json +5 -0
- package/src/integrations/fireworks/README.md +43 -17
- package/src/integrations/fireworks/docs.manifest.json +5 -0
- package/src/integrations/front/docs.manifest.json +5 -0
- package/src/integrations/gcs/client.ts +5 -3
- package/src/integrations/gcs/docs.manifest.json +5 -0
- package/src/integrations/gcs/types.ts +1 -0
- package/src/integrations/gemini/docs.manifest.json +5 -0
- package/src/integrations/github/docs.manifest.json +5 -0
- package/src/integrations/googleanalytics/README.md +2 -2
- package/src/integrations/googleanalytics/docs.manifest.json +5 -0
- package/src/integrations/googledrive/README.md +27 -24
- package/src/integrations/googledrive/docs.manifest.json +5 -0
- package/src/integrations/googledrive/types.ts +1 -1
- package/src/integrations/graphql/README.md +2 -2
- package/src/integrations/graphql/client.test.ts +220 -0
- package/src/integrations/graphql/docs.manifest.json +5 -0
- package/src/integrations/graphql/types.ts +23 -1
- package/src/integrations/groq/README.md +49 -42
- package/src/integrations/groq/docs.manifest.json +5 -0
- package/src/integrations/gsheets/README.md +2 -2
- package/src/integrations/gsheets/client.ts +5 -3
- package/src/integrations/gsheets/docs.manifest.json +5 -0
- package/src/integrations/gsheets/types.ts +1 -0
- package/src/integrations/hubspot/docs.manifest.json +5 -0
- package/src/integrations/index.ts +1 -52
- package/src/integrations/intercom/docs.manifest.json +5 -0
- package/src/integrations/jira/docs.manifest.json +5 -0
- package/src/integrations/lakebase/README.md +242 -0
- package/src/integrations/lakebase/client.ts +6 -4
- package/src/integrations/lakebase/docs.manifest.json +5 -0
- package/src/integrations/lakebase/types.ts +5 -4
- package/src/integrations/launchdarkly/README.md +2 -2
- package/src/integrations/launchdarkly/docs.manifest.json +5 -0
- package/src/integrations/mariadb/README.md +3 -3
- package/src/integrations/mariadb/client.ts +5 -3
- package/src/integrations/mariadb/docs.manifest.json +5 -0
- package/src/integrations/mariadb/types.ts +3 -2
- package/src/integrations/mistral/README.md +39 -13
- package/src/integrations/mistral/docs.manifest.json +5 -0
- package/src/integrations/mongodb/README.md +65 -12
- package/src/integrations/mongodb/client.ts +5 -3
- package/src/integrations/mongodb/docs.manifest.json +5 -0
- package/src/integrations/mongodb/types.ts +1 -0
- package/src/integrations/mssql/README.md +3 -3
- package/src/integrations/mssql/client.ts +5 -3
- package/src/integrations/mssql/docs.manifest.json +5 -0
- package/src/integrations/mssql/types.ts +3 -2
- package/src/integrations/mysql/README.md +4 -4
- package/src/integrations/mysql/client.ts +5 -3
- package/src/integrations/mysql/docs.manifest.json +5 -0
- package/src/integrations/mysql/types.ts +5 -4
- package/src/integrations/notion/docs.manifest.json +5 -0
- package/src/integrations/openai_v2/README.md +44 -116
- package/src/integrations/openai_v2/docs.manifest.json +5 -0
- package/src/integrations/openai_v2/types.ts +4 -29
- package/src/integrations/oracledb/README.md +3 -3
- package/src/integrations/oracledb/client.ts +5 -3
- package/src/integrations/oracledb/docs.manifest.json +5 -0
- package/src/integrations/oracledb/types.ts +3 -2
- package/src/integrations/pagerduty/README.md +2 -2
- package/src/integrations/pagerduty/docs.manifest.json +5 -0
- package/src/integrations/perplexity/README.md +39 -47
- package/src/integrations/perplexity/docs.manifest.json +5 -0
- package/src/integrations/postgres/client.ts +6 -4
- package/src/integrations/postgres/docs.manifest.json +5 -0
- package/src/integrations/postgres/types.ts +1 -0
- package/src/integrations/redshift/client.ts +5 -3
- package/src/integrations/redshift/docs.manifest.json +5 -0
- package/src/integrations/redshift/types.ts +1 -0
- package/src/integrations/registry.test.ts +2 -3
- package/src/integrations/registry.ts +69 -188
- package/src/integrations/restapiintegration/README.md +320 -0
- package/src/integrations/restapiintegration/docs.manifest.json +5 -0
- package/src/integrations/restapiintegration/types.ts +2 -8
- package/src/integrations/s3/client.ts +5 -3
- package/src/integrations/s3/docs.manifest.json +5 -0
- package/src/integrations/s3/types.ts +4 -1
- package/src/integrations/salesforce/README.md +11 -9
- package/src/integrations/salesforce/client.ts +3 -2
- package/src/integrations/salesforce/docs.manifest.json +5 -0
- package/src/integrations/salesforce/types.ts +1 -0
- package/src/integrations/segment/docs.manifest.json +5 -0
- package/src/integrations/sendgrid/README.md +2 -2
- package/src/integrations/sendgrid/docs.manifest.json +5 -0
- package/src/integrations/slack/README.md +62 -19
- package/src/integrations/slack/client.test.ts +553 -0
- package/src/integrations/slack/client.ts +92 -12
- package/src/integrations/slack/docs.manifest.json +5 -0
- package/src/integrations/slack/index.ts +6 -1
- package/src/integrations/slack/types.ts +142 -29
- package/src/integrations/smtp/README.md +220 -0
- package/src/integrations/smtp/client.ts +4 -2
- package/src/integrations/smtp/docs.manifest.json +5 -0
- package/src/integrations/snowflake/client.ts +7 -5
- package/src/integrations/snowflake/docs.manifest.json +5 -0
- package/src/integrations/snowflake/types.ts +1 -0
- package/src/integrations/snowflakecortex/README.md +167 -0
- package/src/integrations/snowflakecortex/client.ts +2 -3
- package/src/integrations/snowflakecortex/docs.manifest.json +5 -0
- package/src/integrations/snowflakecortex/types.ts +3 -11
- package/src/integrations/snowflakepostgres/README.md +233 -0
- package/src/integrations/snowflakepostgres/client.ts +1 -1
- package/src/integrations/snowflakepostgres/docs.manifest.json +5 -0
- package/src/integrations/snowflakepostgres/types.ts +1 -0
- package/src/integrations/stabilityai/README.md +2 -2
- package/src/integrations/stabilityai/docs.manifest.json +5 -0
- package/src/integrations/stripe/docs.manifest.json +5 -0
- package/src/integrations/superblocks-ocr/docs.manifest.json +5 -0
- package/src/integrations/twilio/docs.manifest.json +5 -0
- package/src/integrations/zendesk/docs.manifest.json +5 -0
- package/src/integrations/zoom/README.md +15 -15
- package/src/integrations/zoom/docs.manifest.json +5 -0
- package/src/runtime/context.ts +11 -11
- package/src/runtime/executor.ts +2 -2
- package/src/runtime/index.ts +1 -23
- package/src/types.ts +16 -6
- package/dist/api/streaming.d.ts +0 -229
- package/dist/api/streaming.d.ts.map +0 -1
- package/dist/api/streaming.js +0 -107
- package/dist/api/streaming.js.map +0 -1
- package/dist/api/streaming.test.d.ts +0 -5
- package/dist/api/streaming.test.d.ts.map +0 -1
- package/dist/api/streaming.test.js +0 -364
- package/dist/api/streaming.test.js.map +0 -1
- package/dist/integrations/couchbase/client.d.ts +0 -30
- package/dist/integrations/couchbase/client.d.ts.map +0 -1
- package/dist/integrations/couchbase/client.js +0 -154
- package/dist/integrations/couchbase/client.js.map +0 -1
- package/dist/integrations/couchbase/index.d.ts +0 -8
- package/dist/integrations/couchbase/index.d.ts.map +0 -1
- package/dist/integrations/couchbase/index.js +0 -7
- package/dist/integrations/couchbase/index.js.map +0 -1
- package/dist/integrations/couchbase/types.d.ts +0 -100
- package/dist/integrations/couchbase/types.d.ts.map +0 -1
- package/dist/integrations/couchbase/types.js +0 -5
- package/dist/integrations/couchbase/types.js.map +0 -1
- package/dist/integrations/kafka/client.d.ts +0 -25
- package/dist/integrations/kafka/client.d.ts.map +0 -1
- package/dist/integrations/kafka/client.js +0 -124
- package/dist/integrations/kafka/client.js.map +0 -1
- package/dist/integrations/kafka/index.d.ts +0 -8
- package/dist/integrations/kafka/index.d.ts.map +0 -1
- package/dist/integrations/kafka/index.js +0 -7
- package/dist/integrations/kafka/index.js.map +0 -1
- package/dist/integrations/kafka/types.d.ts +0 -113
- package/dist/integrations/kafka/types.d.ts.map +0 -1
- package/dist/integrations/kafka/types.js +0 -5
- package/dist/integrations/kafka/types.js.map +0 -1
- package/dist/integrations/kinesis/client.d.ts +0 -31
- package/dist/integrations/kinesis/client.d.ts.map +0 -1
- package/dist/integrations/kinesis/client.js +0 -101
- package/dist/integrations/kinesis/client.js.map +0 -1
- package/dist/integrations/kinesis/index.d.ts +0 -8
- package/dist/integrations/kinesis/index.d.ts.map +0 -1
- package/dist/integrations/kinesis/index.js +0 -7
- package/dist/integrations/kinesis/index.js.map +0 -1
- package/dist/integrations/kinesis/types.d.ts +0 -97
- package/dist/integrations/kinesis/types.d.ts.map +0 -1
- package/dist/integrations/kinesis/types.js +0 -7
- package/dist/integrations/kinesis/types.js.map +0 -1
- package/dist/integrations/python/client.d.ts +0 -42
- package/dist/integrations/python/client.d.ts.map +0 -1
- package/dist/integrations/python/client.js +0 -89
- package/dist/integrations/python/client.js.map +0 -1
- package/dist/integrations/python/client.test.d.ts +0 -5
- package/dist/integrations/python/client.test.d.ts.map +0 -1
- package/dist/integrations/python/client.test.js +0 -214
- package/dist/integrations/python/client.test.js.map +0 -1
- package/dist/integrations/python/index.d.ts +0 -6
- package/dist/integrations/python/index.d.ts.map +0 -1
- package/dist/integrations/python/index.js +0 -5
- package/dist/integrations/python/index.js.map +0 -1
- package/dist/integrations/python/types.d.ts +0 -85
- package/dist/integrations/python/types.d.ts.map +0 -1
- package/dist/integrations/python/types.js +0 -5
- package/dist/integrations/python/types.js.map +0 -1
- package/dist/integrations/redis/client.d.ts +0 -43
- package/dist/integrations/redis/client.d.ts.map +0 -1
- package/dist/integrations/redis/client.js +0 -142
- package/dist/integrations/redis/client.js.map +0 -1
- package/dist/integrations/redis/index.d.ts +0 -8
- package/dist/integrations/redis/index.d.ts.map +0 -1
- package/dist/integrations/redis/index.js +0 -7
- package/dist/integrations/redis/index.js.map +0 -1
- package/dist/integrations/redis/types.d.ts +0 -137
- package/dist/integrations/redis/types.d.ts.map +0 -1
- package/dist/integrations/redis/types.js +0 -5
- package/dist/integrations/redis/types.js.map +0 -1
- package/dist/runtime/execute.d.ts +0 -128
- package/dist/runtime/execute.d.ts.map +0 -1
- package/dist/runtime/execute.js +0 -84
- package/dist/runtime/execute.js.map +0 -1
- package/dist/runtime/streaming-context.d.ts +0 -49
- package/dist/runtime/streaming-context.d.ts.map +0 -1
- package/dist/runtime/streaming-context.js +0 -71
- package/dist/runtime/streaming-context.js.map +0 -1
- package/dist/runtime/streaming-executor.d.ts +0 -159
- package/dist/runtime/streaming-executor.d.ts.map +0 -1
- package/dist/runtime/streaming-executor.js +0 -229
- package/dist/runtime/streaming-executor.js.map +0 -1
- package/src/api/streaming.test.ts +0 -432
- package/src/api/streaming.ts +0 -302
- package/src/integrations/couchbase/README.md +0 -138
- package/src/integrations/couchbase/client.ts +0 -237
- package/src/integrations/couchbase/index.ts +0 -8
- package/src/integrations/couchbase/types.ts +0 -125
- package/src/integrations/kafka/README.md +0 -144
- package/src/integrations/kafka/client.ts +0 -215
- package/src/integrations/kafka/index.ts +0 -14
- package/src/integrations/kafka/types.ts +0 -127
- package/src/integrations/kinesis/README.md +0 -153
- package/src/integrations/kinesis/client.ts +0 -146
- package/src/integrations/kinesis/index.ts +0 -14
- package/src/integrations/kinesis/types.ts +0 -114
- package/src/integrations/python/README.md +0 -566
- package/src/integrations/python/client.test.ts +0 -340
- package/src/integrations/python/client.ts +0 -134
- package/src/integrations/python/index.ts +0 -6
- package/src/integrations/python/types.ts +0 -91
- package/src/integrations/redis/README.md +0 -200
- package/src/integrations/redis/client.ts +0 -207
- package/src/integrations/redis/index.ts +0 -8
- package/src/integrations/redis/types.ts +0 -166
- package/src/runtime/execute.ts +0 -221
- package/src/runtime/streaming-context.ts +0 -164
- package/src/runtime/streaming-executor.ts +0 -367
package/src/api/streaming.ts
DELETED
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Streaming API definition function.
|
|
3
|
-
*
|
|
4
|
-
* This module provides the `streamingApi()` function used to define TypeScript-based APIs
|
|
5
|
-
* that yield chunks over time, enabling real-time streaming from LLMs and other sources.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { z } from "zod";
|
|
9
|
-
import type { ApiContext, AnyIntegrationRef } from "../types.js";
|
|
10
|
-
import {
|
|
11
|
-
extractIntegrationDeclarations,
|
|
12
|
-
type IntegrationDeclaration,
|
|
13
|
-
} from "../integrations/declarations.js";
|
|
14
|
-
import { consumeEntryPoint } from "./definition.js";
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Configuration for defining a streaming TypeScript-based API.
|
|
18
|
-
*
|
|
19
|
-
* @template TInput - Zod schema type for input validation
|
|
20
|
-
* @template TChunk - Zod schema type for each streamed chunk
|
|
21
|
-
* @template TIntegrations - Record of integration declarations
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```typescript
|
|
25
|
-
* import { streamingApi, z, anthropic } from '@superblocksteam/sdk-api';
|
|
26
|
-
*
|
|
27
|
-
* export default streamingApi({
|
|
28
|
-
* integrations: {
|
|
29
|
-
* ai: anthropic('Production Anthropic'),
|
|
30
|
-
* },
|
|
31
|
-
*
|
|
32
|
-
* input: z.object({
|
|
33
|
-
* prompt: z.string(),
|
|
34
|
-
* }),
|
|
35
|
-
*
|
|
36
|
-
* chunk: z.object({
|
|
37
|
-
* type: z.literal('text-delta'),
|
|
38
|
-
* text: z.string(),
|
|
39
|
-
* }),
|
|
40
|
-
*
|
|
41
|
-
* async *run(ctx, { prompt }) {
|
|
42
|
-
* const stream = ctx.integrations.ai.streamApiRequest(
|
|
43
|
-
* {
|
|
44
|
-
* method: 'POST',
|
|
45
|
-
* path: '/v1/messages',
|
|
46
|
-
* body: {
|
|
47
|
-
* model: 'claude-3-5-sonnet-20241022',
|
|
48
|
-
* max_tokens: 1024,
|
|
49
|
-
* stream: true,
|
|
50
|
-
* messages: [{ role: 'user', content: prompt }],
|
|
51
|
-
* },
|
|
52
|
-
* },
|
|
53
|
-
* { chunk: AnthropicStreamEventSchema }
|
|
54
|
-
* );
|
|
55
|
-
*
|
|
56
|
-
* for await (const event of stream) {
|
|
57
|
-
* if (event.type === 'content_block_delta') {
|
|
58
|
-
* yield { type: 'text-delta' as const, text: event.delta.text };
|
|
59
|
-
* }
|
|
60
|
-
* }
|
|
61
|
-
* },
|
|
62
|
-
* });
|
|
63
|
-
* ```
|
|
64
|
-
*/
|
|
65
|
-
export interface StreamingApiConfig<
|
|
66
|
-
TInput extends z.ZodType,
|
|
67
|
-
TChunk extends z.ZodType,
|
|
68
|
-
TIntegrations extends Record<string, AnyIntegrationRef> = Record<
|
|
69
|
-
string,
|
|
70
|
-
never
|
|
71
|
-
>,
|
|
72
|
-
> {
|
|
73
|
-
/**
|
|
74
|
-
* Name for this API.
|
|
75
|
-
*
|
|
76
|
-
* Used for identification in execution logs and debugging.
|
|
77
|
-
*/
|
|
78
|
-
name: string;
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Plain-language summary of what this API does and which integrations it uses,
|
|
82
|
-
* written for a non-technical audience.
|
|
83
|
-
*
|
|
84
|
-
* This field is auto-generated by the AI agent when creating or editing an API.
|
|
85
|
-
*/
|
|
86
|
-
description?: string;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Integration declarations for this API.
|
|
90
|
-
*
|
|
91
|
-
* Declare integrations upfront to enable type-safe access via `ctx.integrations`
|
|
92
|
-
* and to allow the runtime to authenticate integrations before execution.
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* ```typescript
|
|
96
|
-
* integrations: {
|
|
97
|
-
* ai: anthropic('Production Anthropic'),
|
|
98
|
-
* db: postgres('Cache DB'),
|
|
99
|
-
* }
|
|
100
|
-
* ```
|
|
101
|
-
*/
|
|
102
|
-
integrations?: TIntegrations;
|
|
103
|
-
|
|
104
|
-
/** Zod schema for input validation */
|
|
105
|
-
input: TInput;
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Zod schema for validating each streamed chunk.
|
|
109
|
-
*
|
|
110
|
-
* Every chunk yielded by the run function is validated against this schema.
|
|
111
|
-
* Validation errors will terminate the stream.
|
|
112
|
-
*/
|
|
113
|
-
chunk: TChunk;
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* The streaming API implementation function (async generator).
|
|
117
|
-
*
|
|
118
|
-
* @param ctx - Execution context with access to integrations
|
|
119
|
-
* @param input - Validated input parameters (can be destructured)
|
|
120
|
-
* @yields Chunks that are validated against the chunk schema
|
|
121
|
-
*/
|
|
122
|
-
run: (
|
|
123
|
-
ctx: ApiContext<TIntegrations>,
|
|
124
|
-
input: z.infer<TInput>,
|
|
125
|
-
) => AsyncIterable<z.infer<TChunk>>;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* A compiled streaming API definition ready for execution.
|
|
130
|
-
*
|
|
131
|
-
* @template TInput - The inferred input type
|
|
132
|
-
* @template TChunk - The inferred chunk type
|
|
133
|
-
*/
|
|
134
|
-
export interface CompiledStreamingApi<TInput = unknown, TChunk = unknown> {
|
|
135
|
-
/** Name of the API for identification in logs and debugging */
|
|
136
|
-
readonly name: string;
|
|
137
|
-
|
|
138
|
-
/** Plain-language summary of what this API does */
|
|
139
|
-
readonly description?: string;
|
|
140
|
-
/**
|
|
141
|
-
* Source file path relative to the app root (e.g. "server/apis/Chat/api.ts").
|
|
142
|
-
* Injected automatically by the Vite plugin — not authored by the user.
|
|
143
|
-
*/
|
|
144
|
-
readonly entryPoint?: string;
|
|
145
|
-
|
|
146
|
-
/** Zod schema for validating inputs */
|
|
147
|
-
readonly inputSchema: z.ZodType<TInput>;
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Zod schema for validating each streamed chunk.
|
|
151
|
-
*
|
|
152
|
-
* Every chunk yielded by the API is validated against this schema
|
|
153
|
-
* before being sent to the client.
|
|
154
|
-
*/
|
|
155
|
-
readonly chunkSchema: z.ZodType<TChunk>;
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* The streaming API implementation function.
|
|
159
|
-
*
|
|
160
|
-
* @param ctx - Execution context
|
|
161
|
-
* @param input - Validated input parameters
|
|
162
|
-
* @returns AsyncIterable yielding validated chunks
|
|
163
|
-
*/
|
|
164
|
-
readonly run: (
|
|
165
|
-
ctx: ApiContext<Record<string, AnyIntegrationRef>>,
|
|
166
|
-
input: TInput,
|
|
167
|
-
) => AsyncIterable<TChunk>;
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Declared integrations for upfront authentication.
|
|
171
|
-
*
|
|
172
|
-
* This array contains all integrations declared in the API config,
|
|
173
|
-
* allowing the runtime to authenticate them before API execution.
|
|
174
|
-
*/
|
|
175
|
-
readonly integrations: ReadonlyArray<IntegrationDeclaration>;
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Runtime flag indicating this is a streaming API.
|
|
179
|
-
*
|
|
180
|
-
* Always `true` for streaming APIs. Use `isStreamingApi()` type guard
|
|
181
|
-
* to distinguish streaming APIs from regular APIs at runtime.
|
|
182
|
-
*/
|
|
183
|
-
readonly isStreaming: true;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Define a streaming TypeScript-based API with chunk validation.
|
|
188
|
-
*
|
|
189
|
-
* This function creates a compiled streaming API definition that yields
|
|
190
|
-
* chunks over time. Each chunk is validated against the provided schema.
|
|
191
|
-
*
|
|
192
|
-
* Use this for:
|
|
193
|
-
* - Real-time LLM token streaming (OpenAI, Anthropic, etc.)
|
|
194
|
-
* - Server-sent events
|
|
195
|
-
* - Long-running operations with progress updates
|
|
196
|
-
* - Any API that produces output incrementally
|
|
197
|
-
*
|
|
198
|
-
* @param config - The streaming API configuration
|
|
199
|
-
* @returns A compiled streaming API definition
|
|
200
|
-
*
|
|
201
|
-
* @example
|
|
202
|
-
* ```typescript
|
|
203
|
-
* import { streamingApi, z, openai } from '@superblocksteam/sdk-api';
|
|
204
|
-
*
|
|
205
|
-
* export default streamingApi({
|
|
206
|
-
* integrations: {
|
|
207
|
-
* ai: openai('Production OpenAI'),
|
|
208
|
-
* },
|
|
209
|
-
*
|
|
210
|
-
* input: z.object({
|
|
211
|
-
* prompt: z.string(),
|
|
212
|
-
* }),
|
|
213
|
-
*
|
|
214
|
-
* chunk: z.object({
|
|
215
|
-
* content: z.string(),
|
|
216
|
-
* }),
|
|
217
|
-
*
|
|
218
|
-
* async *run(ctx, { prompt }) {
|
|
219
|
-
* const stream = ctx.integrations.ai.streamApiRequest(
|
|
220
|
-
* {
|
|
221
|
-
* method: 'POST',
|
|
222
|
-
* path: '/v1/chat/completions',
|
|
223
|
-
* body: {
|
|
224
|
-
* model: 'gpt-4',
|
|
225
|
-
* stream: true,
|
|
226
|
-
* messages: [{ role: 'user', content: prompt }],
|
|
227
|
-
* },
|
|
228
|
-
* },
|
|
229
|
-
* { chunk: OpenAIChunkSchema }
|
|
230
|
-
* );
|
|
231
|
-
*
|
|
232
|
-
* for await (const chunk of stream) {
|
|
233
|
-
* const content = chunk.choices[0]?.delta?.content;
|
|
234
|
-
* if (content) {
|
|
235
|
-
* yield { content };
|
|
236
|
-
* }
|
|
237
|
-
* }
|
|
238
|
-
* },
|
|
239
|
-
* });
|
|
240
|
-
* ```
|
|
241
|
-
*/
|
|
242
|
-
export function streamingApi<
|
|
243
|
-
TInput extends z.ZodType,
|
|
244
|
-
TChunk extends z.ZodType,
|
|
245
|
-
TIntegrations extends Record<string, AnyIntegrationRef> = Record<
|
|
246
|
-
string,
|
|
247
|
-
never
|
|
248
|
-
>,
|
|
249
|
-
>(
|
|
250
|
-
config: StreamingApiConfig<TInput, TChunk, TIntegrations>,
|
|
251
|
-
): CompiledStreamingApi<z.infer<TInput>, z.infer<TChunk>> {
|
|
252
|
-
// Extract integration declarations for upfront auth
|
|
253
|
-
const integrations = extractIntegrationDeclarations(config.integrations);
|
|
254
|
-
|
|
255
|
-
const compiled: CompiledStreamingApi<z.infer<TInput>, z.infer<TChunk>> = {
|
|
256
|
-
name: config.name,
|
|
257
|
-
description: config.description,
|
|
258
|
-
entryPoint: consumeEntryPoint(),
|
|
259
|
-
inputSchema: config.input,
|
|
260
|
-
chunkSchema: config.chunk,
|
|
261
|
-
run: config.run as (
|
|
262
|
-
ctx: ApiContext<Record<string, AnyIntegrationRef>>,
|
|
263
|
-
input: z.infer<TInput>,
|
|
264
|
-
) => AsyncIterable<z.infer<TChunk>>,
|
|
265
|
-
integrations,
|
|
266
|
-
isStreaming: true,
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
return compiled;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
/**
|
|
273
|
-
* Type guard to check if an API is a streaming API.
|
|
274
|
-
*
|
|
275
|
-
* @param api - The API to check
|
|
276
|
-
* @returns `true` if the API is a streaming API, `false` otherwise
|
|
277
|
-
*
|
|
278
|
-
* @example
|
|
279
|
-
* ```typescript
|
|
280
|
-
* import { isStreamingApi, executeApi, executeStreamingApi } from '@superblocksteam/sdk-api';
|
|
281
|
-
*
|
|
282
|
-
* if (isStreamingApi(api)) {
|
|
283
|
-
* await executeStreamingApi(api, request);
|
|
284
|
-
* } else {
|
|
285
|
-
* await executeApi(api, request);
|
|
286
|
-
* }
|
|
287
|
-
* ```
|
|
288
|
-
*/
|
|
289
|
-
export function isStreamingApi(
|
|
290
|
-
api: unknown,
|
|
291
|
-
): api is CompiledStreamingApi<unknown, unknown> {
|
|
292
|
-
return (
|
|
293
|
-
typeof api === "object" &&
|
|
294
|
-
api !== null &&
|
|
295
|
-
"isStreaming" in api &&
|
|
296
|
-
(api as Record<string, unknown>).isStreaming === true &&
|
|
297
|
-
"inputSchema" in api &&
|
|
298
|
-
"chunkSchema" in api &&
|
|
299
|
-
"run" in api &&
|
|
300
|
-
typeof (api as Record<string, unknown>).run === "function"
|
|
301
|
-
);
|
|
302
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
# Couchbase Client
|
|
2
|
-
|
|
3
|
-
Interact with Couchbase databases with full type safety and runtime validation.
|
|
4
|
-
|
|
5
|
-
## Methods
|
|
6
|
-
|
|
7
|
-
| Method | Description |
|
|
8
|
-
| ------------------------------------------------ | -------------------------------------------- |
|
|
9
|
-
| `query(bucket, sql, schema, params?, metadata?)` | Execute a SQL++ query with schema validation |
|
|
10
|
-
| `insert(key, value, identifier, metadata?)` | Insert a document into a collection |
|
|
11
|
-
| `get(key, schema, identifier, metadata?)` | Get a document by key with schema validation |
|
|
12
|
-
| `remove(key, identifier, metadata?)` | Remove a document by key |
|
|
13
|
-
|
|
14
|
-
## Usage
|
|
15
|
-
|
|
16
|
-
### SQL++ Query
|
|
17
|
-
|
|
18
|
-
```typescript
|
|
19
|
-
import { api, z, couchbase } from "@superblocksteam/sdk-api";
|
|
20
|
-
|
|
21
|
-
// Integration ID from the integrations panel
|
|
22
|
-
const PROD_COUCHBASE = "a1b2c3d4-5678-90ab-cdef-couchbase001";
|
|
23
|
-
|
|
24
|
-
const UserSchema = z.object({
|
|
25
|
-
id: z.string(),
|
|
26
|
-
name: z.string(),
|
|
27
|
-
email: z.string(),
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
export default api({
|
|
31
|
-
name: "CouchbaseExample",
|
|
32
|
-
integrations: {
|
|
33
|
-
cb: couchbase(PROD_COUCHBASE),
|
|
34
|
-
},
|
|
35
|
-
input: z.object({
|
|
36
|
-
status: z.string(),
|
|
37
|
-
}),
|
|
38
|
-
output: z.object({
|
|
39
|
-
users: z.array(UserSchema),
|
|
40
|
-
}),
|
|
41
|
-
async run(ctx, { status }) {
|
|
42
|
-
const users = await ctx.integrations.cb.query(
|
|
43
|
-
"my-bucket",
|
|
44
|
-
`SELECT META().id, name, email FROM bucket WHERE status = "${status}"`,
|
|
45
|
-
UserSchema,
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
return { users };
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### Parameterized Query
|
|
54
|
-
|
|
55
|
-
```typescript
|
|
56
|
-
const users = await ctx.integrations.cb.query(
|
|
57
|
-
"my-bucket",
|
|
58
|
-
"SELECT META().id, name, email FROM bucket WHERE status = $1",
|
|
59
|
-
UserSchema,
|
|
60
|
-
[status],
|
|
61
|
-
);
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### Insert Document
|
|
65
|
-
|
|
66
|
-
```typescript
|
|
67
|
-
await ctx.integrations.cb.insert(
|
|
68
|
-
"user::123",
|
|
69
|
-
{ name: "Alice", email: "alice@example.com", status: "active" },
|
|
70
|
-
{ bucket: "my-bucket", scope: "_default", collection: "_default" },
|
|
71
|
-
);
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### Get Document
|
|
75
|
-
|
|
76
|
-
```typescript
|
|
77
|
-
const UserSchema = z.object({
|
|
78
|
-
name: z.string(),
|
|
79
|
-
email: z.string(),
|
|
80
|
-
status: z.string(),
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
const user = await ctx.integrations.cb.get("user::123", UserSchema, {
|
|
84
|
-
bucket: "my-bucket",
|
|
85
|
-
scope: "_default",
|
|
86
|
-
collection: "_default",
|
|
87
|
-
});
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Remove Document
|
|
91
|
-
|
|
92
|
-
```typescript
|
|
93
|
-
await ctx.integrations.cb.remove("user::123", {
|
|
94
|
-
bucket: "my-bucket",
|
|
95
|
-
scope: "_default",
|
|
96
|
-
collection: "_default",
|
|
97
|
-
});
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
## Trace Metadata
|
|
101
|
-
|
|
102
|
-
All methods accept an optional `metadata` parameter as the last argument for diagnostics labeling. See the [root SDK README](../../../README.md#trace-metadata) for details.
|
|
103
|
-
|
|
104
|
-
## Error Handling
|
|
105
|
-
|
|
106
|
-
```typescript
|
|
107
|
-
import {
|
|
108
|
-
QueryValidationError,
|
|
109
|
-
RestApiValidationError,
|
|
110
|
-
} from "@superblocksteam/sdk-api";
|
|
111
|
-
|
|
112
|
-
try {
|
|
113
|
-
const users = await ctx.integrations.cb.query(
|
|
114
|
-
"my-bucket",
|
|
115
|
-
"SELECT * FROM bucket",
|
|
116
|
-
UserSchema,
|
|
117
|
-
);
|
|
118
|
-
} catch (error) {
|
|
119
|
-
if (error instanceof QueryValidationError) {
|
|
120
|
-
// Query result row failed schema validation
|
|
121
|
-
console.error(
|
|
122
|
-
"Row",
|
|
123
|
-
error.details.rowIndex,
|
|
124
|
-
"failed:",
|
|
125
|
-
error.details.errors,
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
if (error instanceof RestApiValidationError) {
|
|
129
|
-
// Document get result failed schema validation
|
|
130
|
-
console.error("Validation failed:", error.details.zodError);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
## API Reference
|
|
136
|
-
|
|
137
|
-
- [SQL++ Query Language](https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/index.html)
|
|
138
|
-
- [Couchbase Key-Value Operations](https://docs.couchbase.com/server/current/learn/data/data.html)
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Couchbase client implementation.
|
|
3
|
-
*
|
|
4
|
-
* Uses the native Couchbase plugin type from @superblocksteam/types.
|
|
5
|
-
* Builds proto-style request objects for SQL++ queries, document insert,
|
|
6
|
-
* get, and remove operations against Couchbase buckets.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import type { z } from "zod";
|
|
10
|
-
import type { PartialMessage } from "@bufbuild/protobuf";
|
|
11
|
-
import type { Plugin as CouchbasePlugin } from "@superblocksteam/types/dist/src/plugins/couchbase/v1/plugin_pb";
|
|
12
|
-
import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
|
|
13
|
-
import type { QueryExecutor, TraceMetadata } from "../registry.js";
|
|
14
|
-
import { QueryValidationError, RestApiValidationError } from "../../errors.js";
|
|
15
|
-
import { IntegrationError } from "../../runtime/errors.js";
|
|
16
|
-
import { describeType } from "../utils.js";
|
|
17
|
-
import type { CouchbaseClient, CouchbaseIdentifier } from "./types.js";
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Couchbase request type derived from proto definition.
|
|
21
|
-
*/
|
|
22
|
-
type CouchbaseRequest = PartialMessage<CouchbasePlugin>;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Internal implementation of CouchbaseClient.
|
|
26
|
-
*
|
|
27
|
-
* Communicates with the orchestrator using the native Couchbase plugin
|
|
28
|
-
* proto format, supporting SQL++ queries and key-value document operations.
|
|
29
|
-
* All operations require a bucket name.
|
|
30
|
-
*/
|
|
31
|
-
export class CouchbaseClientImpl
|
|
32
|
-
implements CouchbaseClient, IntegrationClientImpl
|
|
33
|
-
{
|
|
34
|
-
readonly config: IntegrationConfig;
|
|
35
|
-
private readonly executeQuery: QueryExecutor;
|
|
36
|
-
|
|
37
|
-
constructor(config: IntegrationConfig, executeQuery: QueryExecutor) {
|
|
38
|
-
this.config = config;
|
|
39
|
-
this.executeQuery = executeQuery;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
get name(): string {
|
|
43
|
-
return this.config.name;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
get pluginId(): string {
|
|
47
|
-
return this.config.pluginId;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
async query<T>(
|
|
51
|
-
bucket: string,
|
|
52
|
-
sql: string,
|
|
53
|
-
schema: z.ZodSchema<T>,
|
|
54
|
-
params?: unknown[],
|
|
55
|
-
metadata?: TraceMetadata,
|
|
56
|
-
): Promise<T[]> {
|
|
57
|
-
const hasParams = params && params.length > 0;
|
|
58
|
-
const request: CouchbaseRequest = {
|
|
59
|
-
bucketName: bucket,
|
|
60
|
-
couchbaseAction: {
|
|
61
|
-
case: "runSql",
|
|
62
|
-
value: {
|
|
63
|
-
sqlBody: sql,
|
|
64
|
-
parameters: hasParams ? JSON.stringify(params) : undefined,
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
try {
|
|
70
|
-
const result = await this.executeQuery(
|
|
71
|
-
request as Record<string, unknown>,
|
|
72
|
-
undefined,
|
|
73
|
-
metadata,
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
if (!Array.isArray(result)) {
|
|
77
|
-
throw new IntegrationError(
|
|
78
|
-
this.config.name,
|
|
79
|
-
"query",
|
|
80
|
-
`Expected array result from Couchbase query, got: ${describeType(result)}`,
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const validated: T[] = [];
|
|
85
|
-
for (let i = 0; i < result.length; i++) {
|
|
86
|
-
const row = result[i];
|
|
87
|
-
const parseResult = schema.safeParse(row);
|
|
88
|
-
|
|
89
|
-
if (!parseResult.success) {
|
|
90
|
-
throw new QueryValidationError(
|
|
91
|
-
`Row ${i} failed validation: ${parseResult.error.message}`,
|
|
92
|
-
{
|
|
93
|
-
rowIndex: i,
|
|
94
|
-
errors: parseResult.error.errors,
|
|
95
|
-
row,
|
|
96
|
-
},
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
validated.push(parseResult.data);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return validated;
|
|
104
|
-
} catch (error) {
|
|
105
|
-
if (
|
|
106
|
-
error instanceof QueryValidationError ||
|
|
107
|
-
error instanceof IntegrationError
|
|
108
|
-
) {
|
|
109
|
-
throw error;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
throw new IntegrationError(this.config.name, "query", error);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async insert(
|
|
117
|
-
key: string,
|
|
118
|
-
value: unknown,
|
|
119
|
-
identifier: CouchbaseIdentifier,
|
|
120
|
-
metadata?: TraceMetadata,
|
|
121
|
-
): Promise<void> {
|
|
122
|
-
const request: CouchbaseRequest = {
|
|
123
|
-
bucketName: identifier.bucket,
|
|
124
|
-
couchbaseAction: {
|
|
125
|
-
case: "insert",
|
|
126
|
-
value: {
|
|
127
|
-
key,
|
|
128
|
-
value: typeof value === "string" ? value : JSON.stringify(value),
|
|
129
|
-
identifier: {
|
|
130
|
-
scope: identifier.scope,
|
|
131
|
-
collection: identifier.collection,
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
try {
|
|
138
|
-
await this.executeQuery(
|
|
139
|
-
request as Record<string, unknown>,
|
|
140
|
-
undefined,
|
|
141
|
-
metadata,
|
|
142
|
-
);
|
|
143
|
-
} catch (error) {
|
|
144
|
-
if (error instanceof IntegrationError) {
|
|
145
|
-
throw error;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
throw new IntegrationError(this.config.name, "insert", error);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
async get<T>(
|
|
153
|
-
key: string,
|
|
154
|
-
schema: z.ZodSchema<T>,
|
|
155
|
-
identifier: CouchbaseIdentifier,
|
|
156
|
-
metadata?: TraceMetadata,
|
|
157
|
-
): Promise<T> {
|
|
158
|
-
const request: CouchbaseRequest = {
|
|
159
|
-
bucketName: identifier.bucket,
|
|
160
|
-
couchbaseAction: {
|
|
161
|
-
case: "get",
|
|
162
|
-
value: {
|
|
163
|
-
key,
|
|
164
|
-
identifier: {
|
|
165
|
-
scope: identifier.scope,
|
|
166
|
-
collection: identifier.collection,
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
try {
|
|
173
|
-
const result = await this.executeQuery(
|
|
174
|
-
request as Record<string, unknown>,
|
|
175
|
-
undefined,
|
|
176
|
-
metadata,
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
const parseResult = schema.safeParse(result);
|
|
180
|
-
|
|
181
|
-
if (!parseResult.success) {
|
|
182
|
-
throw new RestApiValidationError(
|
|
183
|
-
`Result validation failed: ${parseResult.error.message}`,
|
|
184
|
-
{
|
|
185
|
-
zodError: parseResult.error,
|
|
186
|
-
data: result,
|
|
187
|
-
},
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
return parseResult.data;
|
|
192
|
-
} catch (error) {
|
|
193
|
-
if (
|
|
194
|
-
error instanceof RestApiValidationError ||
|
|
195
|
-
error instanceof IntegrationError
|
|
196
|
-
) {
|
|
197
|
-
throw error;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
throw new IntegrationError(this.config.name, "get", error);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
async remove(
|
|
205
|
-
key: string,
|
|
206
|
-
identifier: CouchbaseIdentifier,
|
|
207
|
-
metadata?: TraceMetadata,
|
|
208
|
-
): Promise<void> {
|
|
209
|
-
const request: CouchbaseRequest = {
|
|
210
|
-
bucketName: identifier.bucket,
|
|
211
|
-
couchbaseAction: {
|
|
212
|
-
case: "remove",
|
|
213
|
-
value: {
|
|
214
|
-
key,
|
|
215
|
-
identifier: {
|
|
216
|
-
scope: identifier.scope,
|
|
217
|
-
collection: identifier.collection,
|
|
218
|
-
},
|
|
219
|
-
},
|
|
220
|
-
},
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
try {
|
|
224
|
-
await this.executeQuery(
|
|
225
|
-
request as Record<string, unknown>,
|
|
226
|
-
undefined,
|
|
227
|
-
metadata,
|
|
228
|
-
);
|
|
229
|
-
} catch (error) {
|
|
230
|
-
if (error instanceof IntegrationError) {
|
|
231
|
-
throw error;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
throw new IntegrationError(this.config.name, "remove", error);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|