@superblocksteam/sdk-api 0.0.6 → 0.0.8
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 +118 -0
- package/dist/integrations/base/rest-api-client-base.js.map +1 -0
- package/dist/integrations/base/rest-api-integration-client.d.ts +18 -66
- package/dist/integrations/base/rest-api-integration-client.d.ts.map +1 -1
- package/dist/integrations/base/rest-api-integration-client.js +38 -173
- package/dist/integrations/base/rest-api-integration-client.js.map +1 -1
- package/dist/integrations/base/types.d.ts +59 -59
- package/dist/integrations/base/types.d.ts.map +1 -1
- package/dist/integrations/base/types.js +23 -1
- package/dist/integrations/base/types.js.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 +774 -0
- package/dist/integrations/documentation-resolver.test.js.map +1 -0
- package/dist/integrations/documentation.d.ts +9 -0
- package/dist/integrations/documentation.d.ts.map +1 -0
- package/dist/integrations/documentation.js +300 -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 +1 -8
- 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/client.test.d.ts +12 -0
- package/dist/integrations/restapiintegration/client.test.d.ts.map +1 -0
- package/dist/integrations/restapiintegration/client.test.js +236 -0
- package/dist/integrations/restapiintegration/client.test.js.map +1 -0
- 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 +7 -7
- 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 +3 -3
- package/src/integrations/base/rest-api-client-base.ts +158 -0
- package/src/integrations/base/rest-api-integration-client.ts +62 -237
- package/src/integrations/base/types.ts +68 -64
- 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 +893 -0
- package/src/integrations/documentation.test.ts +120 -0
- package/src/integrations/documentation.ts +473 -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 +10 -0
- package/src/integrations/graphql/overlays/dynamic-headers.md +34 -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 +7 -5
- 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/client.test.ts +359 -0
- package/src/integrations/restapiintegration/docs.manifest.json +14 -0
- package/src/integrations/restapiintegration/overlays/response-types-unsupported.md +5 -0
- package/src/integrations/restapiintegration/overlays/response-types.md +26 -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 -36
- package/dist/integrations/couchbase/client.d.ts.map +0 -1
- package/dist/integrations/couchbase/client.js +0 -148
- package/dist/integrations/couchbase/client.js.map +0 -1
- package/dist/integrations/couchbase/index.d.ts +0 -8
- package/dist/integrations/couchbase/index.d.ts.map +0 -1
- package/dist/integrations/couchbase/index.js +0 -7
- package/dist/integrations/couchbase/index.js.map +0 -1
- package/dist/integrations/couchbase/types.d.ts +0 -100
- package/dist/integrations/couchbase/types.d.ts.map +0 -1
- package/dist/integrations/couchbase/types.js +0 -5
- package/dist/integrations/couchbase/types.js.map +0 -1
- package/dist/integrations/kafka/client.d.ts +0 -25
- package/dist/integrations/kafka/client.d.ts.map +0 -1
- package/dist/integrations/kafka/client.js +0 -124
- package/dist/integrations/kafka/client.js.map +0 -1
- package/dist/integrations/kafka/index.d.ts +0 -8
- package/dist/integrations/kafka/index.d.ts.map +0 -1
- package/dist/integrations/kafka/index.js +0 -7
- package/dist/integrations/kafka/index.js.map +0 -1
- package/dist/integrations/kafka/types.d.ts +0 -113
- package/dist/integrations/kafka/types.d.ts.map +0 -1
- package/dist/integrations/kafka/types.js +0 -5
- package/dist/integrations/kafka/types.js.map +0 -1
- package/dist/integrations/kinesis/client.d.ts +0 -31
- package/dist/integrations/kinesis/client.d.ts.map +0 -1
- package/dist/integrations/kinesis/client.js +0 -101
- package/dist/integrations/kinesis/client.js.map +0 -1
- package/dist/integrations/kinesis/index.d.ts +0 -8
- package/dist/integrations/kinesis/index.d.ts.map +0 -1
- package/dist/integrations/kinesis/index.js +0 -7
- package/dist/integrations/kinesis/index.js.map +0 -1
- package/dist/integrations/kinesis/types.d.ts +0 -97
- package/dist/integrations/kinesis/types.d.ts.map +0 -1
- package/dist/integrations/kinesis/types.js +0 -7
- package/dist/integrations/kinesis/types.js.map +0 -1
- package/dist/integrations/python/client.d.ts +0 -42
- package/dist/integrations/python/client.d.ts.map +0 -1
- package/dist/integrations/python/client.js +0 -89
- package/dist/integrations/python/client.js.map +0 -1
- package/dist/integrations/python/client.test.d.ts +0 -5
- package/dist/integrations/python/client.test.d.ts.map +0 -1
- package/dist/integrations/python/client.test.js +0 -214
- package/dist/integrations/python/client.test.js.map +0 -1
- package/dist/integrations/python/index.d.ts +0 -6
- package/dist/integrations/python/index.d.ts.map +0 -1
- package/dist/integrations/python/index.js +0 -5
- package/dist/integrations/python/index.js.map +0 -1
- package/dist/integrations/python/types.d.ts +0 -85
- package/dist/integrations/python/types.d.ts.map +0 -1
- package/dist/integrations/python/types.js +0 -5
- package/dist/integrations/python/types.js.map +0 -1
- package/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 -224
- 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
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
# REST API Integration Client
|
|
2
|
+
|
|
3
|
+
Make HTTP requests to any REST API configured with a base URL and authentication in the integrations page.
|
|
4
|
+
|
|
5
|
+
This is the generic REST API Integration plugin. Unlike named integrations (Slack, GitHub, etc.) which target a specific service, this plugin works with **any** HTTP API you configure as an integration.
|
|
6
|
+
|
|
7
|
+
## Methods
|
|
8
|
+
|
|
9
|
+
| Method | Description |
|
|
10
|
+
| ---------------------------------------- | -------------------------------------------- |
|
|
11
|
+
| `apiRequest(options, schema, metadata?)` | Make any HTTP request with schema validation |
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Basic GET Request
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { api, z, restApiIntegration } from "@superblocksteam/sdk-api";
|
|
19
|
+
|
|
20
|
+
// Integration ID from the integrations panel
|
|
21
|
+
const MY_API = "a1b2c3d4-5678-90ab-cdef-111111111111";
|
|
22
|
+
|
|
23
|
+
const UsersResponseSchema = z.object({
|
|
24
|
+
users: z.array(
|
|
25
|
+
z.object({
|
|
26
|
+
id: z.string(),
|
|
27
|
+
name: z.string(),
|
|
28
|
+
email: z.string(),
|
|
29
|
+
}),
|
|
30
|
+
),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export default api({
|
|
34
|
+
name: "FetchUsers",
|
|
35
|
+
integrations: {
|
|
36
|
+
myApi: restApiIntegration(MY_API),
|
|
37
|
+
},
|
|
38
|
+
input: z.object({}),
|
|
39
|
+
output: z.object({
|
|
40
|
+
users: z.array(
|
|
41
|
+
z.object({ id: z.string(), name: z.string(), email: z.string() }),
|
|
42
|
+
),
|
|
43
|
+
}),
|
|
44
|
+
async run(ctx) {
|
|
45
|
+
const result = await ctx.integrations.myApi.apiRequest(
|
|
46
|
+
{
|
|
47
|
+
method: "GET",
|
|
48
|
+
path: "/users",
|
|
49
|
+
params: { limit: 50 },
|
|
50
|
+
},
|
|
51
|
+
{ response: UsersResponseSchema },
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
return { users: result.users };
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### POST Request with Body
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
const CreateRecordSchema = z.object({
|
|
63
|
+
id: z.string(),
|
|
64
|
+
created_at: z.string(),
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const record = await ctx.integrations.myApi.apiRequest(
|
|
68
|
+
{
|
|
69
|
+
method: "POST",
|
|
70
|
+
path: "/records",
|
|
71
|
+
body: {
|
|
72
|
+
title: "New Record",
|
|
73
|
+
description: "Created via Superblocks",
|
|
74
|
+
tags: ["automated"],
|
|
75
|
+
},
|
|
76
|
+
headers: {
|
|
77
|
+
"Content-Type": "application/json",
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{ response: CreateRecordSchema },
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
console.log(`Created record: ${record.id}`);
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### PATCH/PUT Request
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
const UpdateResponseSchema = z.object({
|
|
90
|
+
id: z.string(),
|
|
91
|
+
updated_at: z.string(),
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
await ctx.integrations.myApi.apiRequest(
|
|
95
|
+
{
|
|
96
|
+
method: "PATCH",
|
|
97
|
+
path: `/records/${recordId}`,
|
|
98
|
+
body: {
|
|
99
|
+
title: "Updated Title",
|
|
100
|
+
status: "published",
|
|
101
|
+
},
|
|
102
|
+
headers: {
|
|
103
|
+
"Content-Type": "application/json",
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
{ response: UpdateResponseSchema },
|
|
107
|
+
);
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### DELETE Request
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
await ctx.integrations.myApi.apiRequest(
|
|
114
|
+
{
|
|
115
|
+
method: "DELETE",
|
|
116
|
+
path: `/records/${recordId}`,
|
|
117
|
+
},
|
|
118
|
+
{ response: z.object({}).passthrough() },
|
|
119
|
+
);
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Search with Query Parameters
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
const SearchResponseSchema = z.object({
|
|
126
|
+
items: z.array(
|
|
127
|
+
z.object({
|
|
128
|
+
id: z.string(),
|
|
129
|
+
title: z.string(),
|
|
130
|
+
score: z.number().optional(),
|
|
131
|
+
}),
|
|
132
|
+
),
|
|
133
|
+
total: z.number(),
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const results = await ctx.integrations.myApi.apiRequest(
|
|
137
|
+
{
|
|
138
|
+
method: "GET",
|
|
139
|
+
path: "/search",
|
|
140
|
+
params: {
|
|
141
|
+
q: "my query",
|
|
142
|
+
page: 1,
|
|
143
|
+
per_page: 25,
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
{ response: SearchResponseSchema },
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
console.log(`Found ${results.total} results`);
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Using Multiple Integrations
|
|
153
|
+
|
|
154
|
+
You can use multiple REST API Integrations in a single API, each targeting a different service:
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
import { api, z, restApiIntegration, postgres } from "@superblocksteam/sdk-api";
|
|
158
|
+
|
|
159
|
+
const EXTERNAL_API = "a1b2c3d4-5678-90ab-cdef-111111111111";
|
|
160
|
+
const INTERNAL_API = "e5f6a7b8-9012-34cd-ef56-222222222222";
|
|
161
|
+
const MY_DB = "c3d4e5f6-7890-12ab-cdef-333333333333";
|
|
162
|
+
|
|
163
|
+
export default api({
|
|
164
|
+
name: "SyncData",
|
|
165
|
+
integrations: {
|
|
166
|
+
externalApi: restApiIntegration(EXTERNAL_API),
|
|
167
|
+
internalApi: restApiIntegration(INTERNAL_API),
|
|
168
|
+
db: postgres(MY_DB),
|
|
169
|
+
},
|
|
170
|
+
input: z.object({ query: z.string() }),
|
|
171
|
+
output: z.object({ synced: z.number() }),
|
|
172
|
+
async run(ctx, { query }) {
|
|
173
|
+
// Fetch from external API
|
|
174
|
+
const external = await ctx.integrations.externalApi.apiRequest(
|
|
175
|
+
{ method: "GET", path: "/data", params: { q: query } },
|
|
176
|
+
{ response: z.object({ items: z.array(z.unknown()) }) },
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
// Push to internal API
|
|
180
|
+
await ctx.integrations.internalApi.apiRequest(
|
|
181
|
+
{ method: "POST", path: "/import", body: { items: external.items } },
|
|
182
|
+
{ response: z.object({ imported: z.number() }) },
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
return { synced: external.items.length };
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Trace Metadata
|
|
191
|
+
|
|
192
|
+
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.
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
const result = await ctx.integrations.myApi.apiRequest(
|
|
196
|
+
{ method: "GET", path: "/users" },
|
|
197
|
+
{ response: UsersResponseSchema },
|
|
198
|
+
{ label: "myApi.getUsers", description: "Fetch all active users" },
|
|
199
|
+
);
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Common Pitfalls
|
|
203
|
+
|
|
204
|
+
### No `.request()` Method
|
|
205
|
+
|
|
206
|
+
The only public method is `apiRequest()`. There is no `.request()` method:
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
// WRONG - .request() does not exist
|
|
210
|
+
await ctx.integrations.myApi.request({
|
|
211
|
+
method: "GET",
|
|
212
|
+
path: "/users",
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// CORRECT - Use apiRequest with a response schema
|
|
216
|
+
await ctx.integrations.myApi.apiRequest(
|
|
217
|
+
{ method: "GET", path: "/users" },
|
|
218
|
+
{ response: UsersResponseSchema },
|
|
219
|
+
);
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Response Schema is Required
|
|
223
|
+
|
|
224
|
+
`apiRequest()` requires a response schema for type safety:
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
// WRONG - Missing response schema
|
|
228
|
+
const result = await ctx.integrations.myApi.apiRequest({
|
|
229
|
+
method: "GET",
|
|
230
|
+
path: "/users",
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
// CORRECT - Provide a response schema
|
|
234
|
+
const result = await ctx.integrations.myApi.apiRequest(
|
|
235
|
+
{ method: "GET", path: "/users" },
|
|
236
|
+
{ response: z.object({ users: z.array(z.unknown()) }) },
|
|
237
|
+
);
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Use `body` Instead of `JSON.stringify`
|
|
241
|
+
|
|
242
|
+
The `body` field is automatically serialized. Do not stringify it manually:
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
// WRONG - Manual stringify
|
|
246
|
+
await ctx.integrations.myApi.apiRequest(
|
|
247
|
+
{
|
|
248
|
+
method: "POST",
|
|
249
|
+
path: "/records",
|
|
250
|
+
body: JSON.stringify({ title: "New" }),
|
|
251
|
+
},
|
|
252
|
+
{ response: ResponseSchema },
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
// CORRECT - Pass object directly
|
|
256
|
+
await ctx.integrations.myApi.apiRequest(
|
|
257
|
+
{
|
|
258
|
+
method: "POST",
|
|
259
|
+
path: "/records",
|
|
260
|
+
body: { title: "New" },
|
|
261
|
+
},
|
|
262
|
+
{ response: ResponseSchema },
|
|
263
|
+
);
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Use `params` for Query Parameters
|
|
267
|
+
|
|
268
|
+
Query parameters go in the `params` field, not in the URL path:
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
// WRONG - Query params in path
|
|
272
|
+
await ctx.integrations.myApi.apiRequest(
|
|
273
|
+
{ method: "GET", path: "/search?q=hello&limit=10" },
|
|
274
|
+
{ response: ResponseSchema },
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
// CORRECT - Use params field
|
|
278
|
+
await ctx.integrations.myApi.apiRequest(
|
|
279
|
+
{
|
|
280
|
+
method: "GET",
|
|
281
|
+
path: "/search",
|
|
282
|
+
params: { q: "hello", limit: 10 },
|
|
283
|
+
},
|
|
284
|
+
{ response: ResponseSchema },
|
|
285
|
+
);
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Use `.passthrough()` for Flexible Schemas
|
|
289
|
+
|
|
290
|
+
When the response contains fields you don't need to validate, use `.passthrough()`:
|
|
291
|
+
|
|
292
|
+
```typescript
|
|
293
|
+
// Strict schema - will reject unknown fields
|
|
294
|
+
const StrictSchema = z.object({ id: z.string() });
|
|
295
|
+
|
|
296
|
+
// Flexible schema - allows additional fields
|
|
297
|
+
const FlexibleSchema = z.object({ id: z.string() }).passthrough();
|
|
298
|
+
|
|
299
|
+
// For dynamic responses
|
|
300
|
+
const GenericSchema = z.record(z.unknown());
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
## Error Handling
|
|
304
|
+
|
|
305
|
+
```typescript
|
|
306
|
+
import { RestApiValidationError } from "@superblocksteam/sdk-api";
|
|
307
|
+
|
|
308
|
+
try {
|
|
309
|
+
const result = await ctx.integrations.myApi.apiRequest(
|
|
310
|
+
{ method: "GET", path: "/users" },
|
|
311
|
+
{ response: UsersResponseSchema },
|
|
312
|
+
);
|
|
313
|
+
} catch (error) {
|
|
314
|
+
if (error instanceof RestApiValidationError) {
|
|
315
|
+
// Response didn't match the schema
|
|
316
|
+
console.error("Validation failed:", error.details.zodError);
|
|
317
|
+
console.error("Actual response:", error.details.data);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
```
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for RestApiIntegrationPluginClientImpl (generic REST API Integration).
|
|
3
|
+
*
|
|
4
|
+
* Covers the responseType passthrough:
|
|
5
|
+
* - default requests keep responseType "json"; callers that pass a
|
|
6
|
+
* response schema still get validated results
|
|
7
|
+
* - the responseType option is forwarded to the orchestrator request
|
|
8
|
+
* - non-JSON responses (e.g. XML with responseType "text") are returned
|
|
9
|
+
* raw when no response schema is provided
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { describe, it, expect, vi } from "vitest";
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
|
|
15
|
+
import { ActionResponseType } from "@superblocksteam/shared";
|
|
16
|
+
|
|
17
|
+
import { RestApiValidationError } from "../../errors.js";
|
|
18
|
+
import type { RestApiResponseType } from "../base/types.js";
|
|
19
|
+
import type { IntegrationConfig } from "../types.js";
|
|
20
|
+
import { RestApiIntegrationPluginClientImpl } from "./client.js";
|
|
21
|
+
|
|
22
|
+
// ── Wire-contract assertions (verified by `pnpm typecheck`) ────────
|
|
23
|
+
//
|
|
24
|
+
// The responseType strings are sent to the orchestrator as-is; the
|
|
25
|
+
// accepted values are defined by ActionResponseType. This assertion
|
|
26
|
+
// fails compilation if the SDK union drifts outside the wire values.
|
|
27
|
+
//
|
|
28
|
+
// The SDK union is a deliberate subset of the wire values: "auto" and
|
|
29
|
+
// "binary" are implemented by the orchestrator but not exposed (see the
|
|
30
|
+
// RestApiResponseType doc for why), and "raw" is streaming-only.
|
|
31
|
+
const _sdkValuesAreValidWireValues: Exclude<`${ActionResponseType}`, "raw">[] =
|
|
32
|
+
[] as RestApiResponseType[];
|
|
33
|
+
void _sdkValuesAreValidWireValues;
|
|
34
|
+
|
|
35
|
+
const TEST_CONFIG: IntegrationConfig = {
|
|
36
|
+
id: "restapi-test-id",
|
|
37
|
+
name: "Test REST API",
|
|
38
|
+
pluginId: "restapiintegration",
|
|
39
|
+
configuration: {},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const XML_RESPONSE = `<?xml version="1.0"?><note><body>hi</body></note>`;
|
|
43
|
+
|
|
44
|
+
function createClient(mockResult: unknown) {
|
|
45
|
+
const executeQuery = vi.fn().mockResolvedValue(mockResult);
|
|
46
|
+
const client = new RestApiIntegrationPluginClientImpl(
|
|
47
|
+
TEST_CONFIG,
|
|
48
|
+
executeQuery,
|
|
49
|
+
);
|
|
50
|
+
return { client, executeQuery };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
describe("RestApiIntegrationPluginClientImpl", () => {
|
|
54
|
+
// ── Default JSON behavior (must not regress) ────────────────────
|
|
55
|
+
|
|
56
|
+
describe("default JSON behavior", () => {
|
|
57
|
+
it("sends responseType json when the option is omitted", async () => {
|
|
58
|
+
const { client, executeQuery } = createClient({ id: "1" });
|
|
59
|
+
|
|
60
|
+
await client.apiRequest(
|
|
61
|
+
{ method: "GET", path: "/users" },
|
|
62
|
+
{ response: z.object({ id: z.string() }) },
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
expect(executeQuery).toHaveBeenCalledWith(
|
|
66
|
+
expect.objectContaining({ responseType: "json" }),
|
|
67
|
+
undefined,
|
|
68
|
+
undefined,
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("validates the response against the provided schema", async () => {
|
|
73
|
+
const { client } = createClient({ id: "1", extra: "stripped" });
|
|
74
|
+
|
|
75
|
+
const result = await client.apiRequest(
|
|
76
|
+
{ method: "GET", path: "/users" },
|
|
77
|
+
{ response: z.object({ id: z.string() }) },
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
expect(result).toEqual({ id: "1" });
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("throws RestApiValidationError when the response does not match the schema", async () => {
|
|
84
|
+
const { client } = createClient(XML_RESPONSE);
|
|
85
|
+
|
|
86
|
+
await expect(
|
|
87
|
+
client.apiRequest(
|
|
88
|
+
{ method: "GET", path: "/users" },
|
|
89
|
+
{ response: z.object({ id: z.string() }) },
|
|
90
|
+
),
|
|
91
|
+
).rejects.toThrow(RestApiValidationError);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// ── responseType passthrough ────────────────────────────────────
|
|
96
|
+
|
|
97
|
+
describe("responseType passthrough", () => {
|
|
98
|
+
it("forwards responseType text to the orchestrator request", async () => {
|
|
99
|
+
const { client, executeQuery } = createClient(XML_RESPONSE);
|
|
100
|
+
|
|
101
|
+
await client.apiRequest({
|
|
102
|
+
method: "GET",
|
|
103
|
+
path: "/report.xml",
|
|
104
|
+
responseType: "text",
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
expect(executeQuery).toHaveBeenCalledWith(
|
|
108
|
+
expect.objectContaining({ responseType: "text" }),
|
|
109
|
+
undefined,
|
|
110
|
+
undefined,
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("returns a raw XML string with responseType text and no response schema", async () => {
|
|
115
|
+
const { client } = createClient(XML_RESPONSE);
|
|
116
|
+
|
|
117
|
+
const result = await client.apiRequest({
|
|
118
|
+
method: "GET",
|
|
119
|
+
path: "/report.xml",
|
|
120
|
+
responseType: "text",
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
expect(result).toBe(XML_RESPONSE);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("still validates when a response schema is provided alongside responseType", async () => {
|
|
127
|
+
const { client, executeQuery } = createClient(XML_RESPONSE);
|
|
128
|
+
|
|
129
|
+
const result = await client.apiRequest(
|
|
130
|
+
{ method: "GET", path: "/report.xml", responseType: "text" },
|
|
131
|
+
{ response: z.string() },
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
expect(executeQuery).toHaveBeenCalledWith(
|
|
135
|
+
expect.objectContaining({ responseType: "text" }),
|
|
136
|
+
undefined,
|
|
137
|
+
undefined,
|
|
138
|
+
);
|
|
139
|
+
expect(result).toBe(XML_RESPONSE);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it("returns the raw response without validation when no schema is given", async () => {
|
|
143
|
+
const { client } = createClient({ ok: true, rows: [1, 2, 3] });
|
|
144
|
+
|
|
145
|
+
const result = await client.apiRequest({
|
|
146
|
+
method: "GET",
|
|
147
|
+
path: "/data",
|
|
148
|
+
responseType: "text",
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
expect(result).toEqual({ ok: true, rows: [1, 2, 3] });
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it("returns an empty string unchanged for responseType text", async () => {
|
|
155
|
+
// An empty text body legitimately decodes to "" — the null/undefined
|
|
156
|
+
// guard must not reject it.
|
|
157
|
+
const { client } = createClient("");
|
|
158
|
+
|
|
159
|
+
const result = await client.apiRequest({
|
|
160
|
+
method: "GET",
|
|
161
|
+
path: "/empty",
|
|
162
|
+
responseType: "text",
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
expect(result).toBe("");
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it("rejects null and undefined results for every response type", async () => {
|
|
169
|
+
// Neither value is a legitimate decode result for the exposed
|
|
170
|
+
// response types: JSON parses to a value the schema sees, and an
|
|
171
|
+
// empty text body decodes to "". Either means a broken execution
|
|
172
|
+
// contract, so both throw.
|
|
173
|
+
for (const badResult of [null, undefined]) {
|
|
174
|
+
const { client: textClient } = createClient(badResult);
|
|
175
|
+
await expect(
|
|
176
|
+
textClient.apiRequest({
|
|
177
|
+
method: "GET",
|
|
178
|
+
path: "/broken",
|
|
179
|
+
responseType: "text",
|
|
180
|
+
}),
|
|
181
|
+
).rejects.toThrow(RestApiValidationError);
|
|
182
|
+
|
|
183
|
+
// JSON mode always goes through the schema overload; the bad
|
|
184
|
+
// result is rejected before validation runs.
|
|
185
|
+
const { client: jsonClient } = createClient(badResult);
|
|
186
|
+
await expect(
|
|
187
|
+
jsonClient.apiRequest(
|
|
188
|
+
{ method: "GET", path: "/broken" },
|
|
189
|
+
{ response: z.object({}) },
|
|
190
|
+
),
|
|
191
|
+
).rejects.toThrow(RestApiValidationError);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// ── Request-body validation via the schema-less overload ────────
|
|
197
|
+
|
|
198
|
+
describe("request body validation", () => {
|
|
199
|
+
it("throws RestApiValidationError for an invalid body with a body-only schema", async () => {
|
|
200
|
+
const { client, executeQuery } = createClient({ ok: true });
|
|
201
|
+
|
|
202
|
+
// Runtime-invalid bodies reach this path via dynamic data (user
|
|
203
|
+
// input, parsed JSON) that the compiler cannot check.
|
|
204
|
+
const dynamicBody: unknown = JSON.parse('{"amount":"not-a-number"}');
|
|
205
|
+
|
|
206
|
+
await expect(
|
|
207
|
+
client.apiRequest(
|
|
208
|
+
{
|
|
209
|
+
method: "POST",
|
|
210
|
+
path: "/orders",
|
|
211
|
+
body: dynamicBody,
|
|
212
|
+
responseType: "text",
|
|
213
|
+
},
|
|
214
|
+
{ body: z.object({ amount: z.number() }) },
|
|
215
|
+
),
|
|
216
|
+
).rejects.toThrow(RestApiValidationError);
|
|
217
|
+
expect(executeQuery).not.toHaveBeenCalled();
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it("sends a valid body and returns the raw response with a body-only schema", async () => {
|
|
221
|
+
const { client, executeQuery } = createClient({ ok: true });
|
|
222
|
+
|
|
223
|
+
const result = await client.apiRequest(
|
|
224
|
+
{
|
|
225
|
+
method: "POST",
|
|
226
|
+
path: "/orders",
|
|
227
|
+
body: { amount: 42 },
|
|
228
|
+
responseType: "text",
|
|
229
|
+
},
|
|
230
|
+
{ body: z.object({ amount: z.number() }) },
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
expect(executeQuery).toHaveBeenCalledWith(
|
|
234
|
+
expect.objectContaining({
|
|
235
|
+
body: JSON.stringify({ amount: 42 }),
|
|
236
|
+
bodyType: "jsonBody",
|
|
237
|
+
}),
|
|
238
|
+
undefined,
|
|
239
|
+
undefined,
|
|
240
|
+
);
|
|
241
|
+
expect(result).toEqual({ ok: true });
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
// ── Runtime contract enforcement ─────────────────────────────────
|
|
246
|
+
//
|
|
247
|
+
// The overloads make these calls unrepresentable in TypeScript, but
|
|
248
|
+
// user API code executes as esbuild-bundled JS with no type
|
|
249
|
+
// enforcement — the same contract must hold at runtime.
|
|
250
|
+
|
|
251
|
+
describe("runtime contract enforcement", () => {
|
|
252
|
+
type UncheckedApiRequest = (...args: unknown[]) => Promise<unknown>;
|
|
253
|
+
|
|
254
|
+
it("rejects a schema-less call in default JSON mode without issuing the request", async () => {
|
|
255
|
+
const { client, executeQuery } = createClient({ ok: true });
|
|
256
|
+
|
|
257
|
+
await expect(
|
|
258
|
+
(client.apiRequest as UncheckedApiRequest)({
|
|
259
|
+
method: "GET",
|
|
260
|
+
path: "/users",
|
|
261
|
+
}),
|
|
262
|
+
).rejects.toThrow(RestApiValidationError);
|
|
263
|
+
expect(executeQuery).not.toHaveBeenCalled();
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
it("rejects a body-only schema in explicit JSON mode without issuing the request", async () => {
|
|
267
|
+
const { client, executeQuery } = createClient({ ok: true });
|
|
268
|
+
|
|
269
|
+
await expect(
|
|
270
|
+
(client.apiRequest as UncheckedApiRequest)(
|
|
271
|
+
{
|
|
272
|
+
method: "POST",
|
|
273
|
+
path: "/orders",
|
|
274
|
+
body: { amount: 42 },
|
|
275
|
+
responseType: "json",
|
|
276
|
+
},
|
|
277
|
+
{ body: z.object({ amount: z.number() }) },
|
|
278
|
+
),
|
|
279
|
+
).rejects.toThrow(RestApiValidationError);
|
|
280
|
+
expect(executeQuery).not.toHaveBeenCalled();
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it("rejects an unexposed responseType value without issuing the request", async () => {
|
|
284
|
+
const { client, executeQuery } = createClient({ ok: true });
|
|
285
|
+
|
|
286
|
+
await expect(
|
|
287
|
+
(client.apiRequest as UncheckedApiRequest)({
|
|
288
|
+
method: "GET",
|
|
289
|
+
path: "/report",
|
|
290
|
+
responseType: "auto",
|
|
291
|
+
}),
|
|
292
|
+
).rejects.toThrow(RestApiValidationError);
|
|
293
|
+
expect(executeQuery).not.toHaveBeenCalled();
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
// ── Compile-time overload contracts (verified by `pnpm typecheck`) ──
|
|
298
|
+
|
|
299
|
+
describe("overload resolution", () => {
|
|
300
|
+
it("keeps typed results for schema callers and unknown for schema-less calls", async () => {
|
|
301
|
+
const { client } = createClient({ id: "1" });
|
|
302
|
+
|
|
303
|
+
// With a response schema: resolves to the typed overload.
|
|
304
|
+
const typed: Promise<{ id: string }> = client.apiRequest(
|
|
305
|
+
{ method: "GET", path: "/users" },
|
|
306
|
+
{ response: z.object({ id: z.string() }) },
|
|
307
|
+
);
|
|
308
|
+
expect(await typed).toEqual({ id: "1" });
|
|
309
|
+
|
|
310
|
+
const { client: rawClient } = createClient(XML_RESPONSE);
|
|
311
|
+
|
|
312
|
+
// Without a schema: resolves to the raw overload returning unknown.
|
|
313
|
+
const raw: Promise<unknown> = rawClient.apiRequest({
|
|
314
|
+
method: "GET",
|
|
315
|
+
path: "/report.xml",
|
|
316
|
+
responseType: "text",
|
|
317
|
+
});
|
|
318
|
+
expect(await raw).toBe(XML_RESPONSE);
|
|
319
|
+
|
|
320
|
+
// @ts-expect-error schema-less apiRequest returns unknown, not a typed shape
|
|
321
|
+
const wrong: Promise<{ id: string }> = rawClient.apiRequest({
|
|
322
|
+
method: "GET",
|
|
323
|
+
path: "/report.xml",
|
|
324
|
+
responseType: "text",
|
|
325
|
+
});
|
|
326
|
+
await wrong;
|
|
327
|
+
|
|
328
|
+
// The remaining cases are rejected twice over: at compile time by
|
|
329
|
+
// the overloads (@ts-expect-error) and at runtime by the contract
|
|
330
|
+
// guards, since bundled user code carries no types.
|
|
331
|
+
|
|
332
|
+
// @ts-expect-error unvalidated JSON is unrepresentable — schema-less
|
|
333
|
+
// calls must opt into a non-JSON responseType
|
|
334
|
+
const unvalidatedJson = rawClient.apiRequest({
|
|
335
|
+
method: "GET",
|
|
336
|
+
path: "/users",
|
|
337
|
+
});
|
|
338
|
+
await expect(unvalidatedJson).rejects.toThrow(RestApiValidationError);
|
|
339
|
+
|
|
340
|
+
// "auto" and "binary" are valid wire values but deliberately not
|
|
341
|
+
// exposed in the SDK union (see RestApiResponseType).
|
|
342
|
+
const autoCall = rawClient.apiRequest({
|
|
343
|
+
method: "GET",
|
|
344
|
+
path: "/report.xml",
|
|
345
|
+
// @ts-expect-error "auto" is not an exposed responseType
|
|
346
|
+
responseType: "auto",
|
|
347
|
+
});
|
|
348
|
+
await expect(autoCall).rejects.toThrow(RestApiValidationError);
|
|
349
|
+
|
|
350
|
+
const binaryCall = rawClient.apiRequest({
|
|
351
|
+
method: "GET",
|
|
352
|
+
path: "/report.xml",
|
|
353
|
+
// @ts-expect-error "binary" is not an exposed responseType
|
|
354
|
+
responseType: "binary",
|
|
355
|
+
});
|
|
356
|
+
await expect(binaryCall).rejects.toThrow(RestApiValidationError);
|
|
357
|
+
});
|
|
358
|
+
});
|
|
359
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pluginId": "restapiintegration",
|
|
3
|
+
"base": "README.md",
|
|
4
|
+
"overlays": [
|
|
5
|
+
{
|
|
6
|
+
"file": "overlays/response-types.md",
|
|
7
|
+
"sdkVersionRange": ">=0.0.3"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"file": "overlays/response-types-unsupported.md",
|
|
11
|
+
"sdkVersionRange": "<0.0.3"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
## Non-JSON Responses
|
|
2
|
+
|
|
3
|
+
This organization's agent does not support the `responseType` option on `apiRequest()` — its worker runs an sdk-api version that decodes every response as JSON and always requires a response schema. Endpoints returning XML, CSV, or other non-JSON payloads cannot be consumed from SDK APIs until the agent is upgraded.
|
|
4
|
+
|
|
5
|
+
Do not generate code that passes a `responseType` value: it may typecheck against a newer local copy of the SDK but fails at runtime on this agent with a `RestApiValidationError` (for example, "Integration query returned ... — expected a JSON response object"). If the user needs to consume a non-JSON endpoint, tell them their Superblocks agent must be upgraded first.
|