@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
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* Base clients for integrations.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
export { RestApiClientBase } from "./rest-api-client-base.js";
|
|
5
6
|
export { RestApiIntegrationClient } from "./rest-api-integration-client.js";
|
|
6
|
-
export type { RestApiRequest } from "./rest-api-
|
|
7
|
+
export type { RestApiRequest } from "./rest-api-client-base.js";
|
|
7
8
|
export { GraphQLIntegrationClient } from "./graphql-integration-client.js";
|
|
8
9
|
export type {
|
|
9
10
|
ApiRequestOptions,
|
|
10
11
|
ApiRequestSchema,
|
|
12
|
+
RestApiResponseType,
|
|
11
13
|
SupportsApiRequest,
|
|
12
|
-
StreamApiRequestSchema,
|
|
13
|
-
SupportsStreamingApiRequest,
|
|
14
14
|
} from "./types.js";
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abstract base for REST API Integration clients.
|
|
3
|
+
*
|
|
4
|
+
* Owns the shared infrastructure that every REST-API-backed integration
|
|
5
|
+
* needs: config storage, parameter helpers, body validation, request
|
|
6
|
+
* construction, and query execution. Subclasses add their own
|
|
7
|
+
* `apiRequest` with whatever response-handling strategy they need
|
|
8
|
+
* (e.g. direct Zod validation, discriminated-union wrapping).
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { PartialMessage } from "@bufbuild/protobuf";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
|
|
14
|
+
import type { Property } from "@superblocksteam/types/dist/src/common/v1/plugin_pb";
|
|
15
|
+
import type { Plugin as RestApiIntegrationPlugin } from "@superblocksteam/types/dist/src/plugins/restapiintegration/v1/plugin_pb";
|
|
16
|
+
|
|
17
|
+
import { RestApiValidationError } from "../../errors.js";
|
|
18
|
+
import type { QueryExecutor, TraceMetadata } from "../registry.js";
|
|
19
|
+
import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
|
|
20
|
+
import { REST_API_RESPONSE_TYPES } from "./types.js";
|
|
21
|
+
import type { ApiRequestOptions } from "./types.js";
|
|
22
|
+
|
|
23
|
+
export type RestApiRequest = PartialMessage<RestApiIntegrationPlugin>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Shared base for all REST API Integration clients.
|
|
27
|
+
*
|
|
28
|
+
* Provides config fields, parameter helpers, body validation, request
|
|
29
|
+
* building, and query execution. Does NOT define `apiRequest` — each
|
|
30
|
+
* concrete subclass supplies its own return-type contract.
|
|
31
|
+
*/
|
|
32
|
+
export abstract class RestApiClientBase implements IntegrationClientImpl {
|
|
33
|
+
readonly name: string;
|
|
34
|
+
readonly pluginId: string;
|
|
35
|
+
readonly config: IntegrationConfig;
|
|
36
|
+
|
|
37
|
+
protected readonly executeQuery: QueryExecutor;
|
|
38
|
+
|
|
39
|
+
constructor(config: IntegrationConfig, executeQuery: QueryExecutor) {
|
|
40
|
+
this.name = config.name;
|
|
41
|
+
this.pluginId = config.pluginId;
|
|
42
|
+
this.config = config;
|
|
43
|
+
this.executeQuery = executeQuery;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Create a Property object for query params / headers.
|
|
48
|
+
*/
|
|
49
|
+
protected createParam(key: string, value: unknown): PartialMessage<Property> {
|
|
50
|
+
return {
|
|
51
|
+
key,
|
|
52
|
+
value: typeof value === "string" ? value : JSON.stringify(value),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Validate the request body, build the proto request, and execute it.
|
|
58
|
+
*
|
|
59
|
+
* Returns the raw (unvalidated) response from the orchestrator.
|
|
60
|
+
* Subclasses call this, then apply their own response handling.
|
|
61
|
+
*
|
|
62
|
+
* @param options - Request configuration (see {@link ApiRequestOptions})
|
|
63
|
+
* @param bodySchema - Optional Zod schema for body validation
|
|
64
|
+
* @param metadata - Optional trace metadata for observability
|
|
65
|
+
* @returns Raw response from the orchestrator
|
|
66
|
+
*/
|
|
67
|
+
protected async executeApiRequest<TBody>(
|
|
68
|
+
options: ApiRequestOptions<TBody>,
|
|
69
|
+
bodySchema?: z.ZodSchema<TBody>,
|
|
70
|
+
metadata?: TraceMetadata,
|
|
71
|
+
): Promise<unknown> {
|
|
72
|
+
// Validate request body if both body and schema are present.
|
|
73
|
+
if (options.body !== undefined && bodySchema) {
|
|
74
|
+
const bodyParseResult = bodySchema.safeParse(options.body);
|
|
75
|
+
if (!bodyParseResult.success) {
|
|
76
|
+
throw new RestApiValidationError(
|
|
77
|
+
`Request body validation failed: ${bodyParseResult.error.message}`,
|
|
78
|
+
{
|
|
79
|
+
zodError: bodyParseResult.error,
|
|
80
|
+
data: options.body,
|
|
81
|
+
},
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const headers: PartialMessage<Property>[] = [];
|
|
87
|
+
if (options.headers) {
|
|
88
|
+
for (const [key, value] of Object.entries(options.headers)) {
|
|
89
|
+
headers.push(this.createParam(key, value));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const params: PartialMessage<Property>[] = [];
|
|
94
|
+
if (options.params) {
|
|
95
|
+
for (const [key, value] of Object.entries(options.params)) {
|
|
96
|
+
params.push(this.createParam(key, value));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// The RestApiResponseType union is erased in the bundled JS user APIs
|
|
101
|
+
// run as, so values outside it (including wire values the orchestrator
|
|
102
|
+
// implements but the SDK deliberately does not expose, like "auto")
|
|
103
|
+
// must also be rejected at runtime, before the request is issued.
|
|
104
|
+
const responseTypeResult = z
|
|
105
|
+
.enum(REST_API_RESPONSE_TYPES)
|
|
106
|
+
.safeParse(options.responseType ?? "json");
|
|
107
|
+
if (!responseTypeResult.success) {
|
|
108
|
+
throw new RestApiValidationError(
|
|
109
|
+
`Unsupported responseType ${JSON.stringify(options.responseType)} — expected one of: ${REST_API_RESPONSE_TYPES.join(", ")}`,
|
|
110
|
+
{
|
|
111
|
+
zodError: responseTypeResult.error,
|
|
112
|
+
data: options.responseType,
|
|
113
|
+
},
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
const responseType = responseTypeResult.data;
|
|
117
|
+
|
|
118
|
+
const request: RestApiRequest = {
|
|
119
|
+
openApiAction: "genericHttpRequest",
|
|
120
|
+
httpMethod: options.method.toUpperCase(),
|
|
121
|
+
urlPath: options.path,
|
|
122
|
+
headers,
|
|
123
|
+
params,
|
|
124
|
+
responseType,
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
if (options.body !== undefined) {
|
|
128
|
+
request.body = JSON.stringify(options.body);
|
|
129
|
+
request.bodyType = "jsonBody";
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const result = await this.executeQuery(
|
|
133
|
+
request as Record<string, unknown>,
|
|
134
|
+
undefined,
|
|
135
|
+
metadata,
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
// Neither `null` nor `undefined` is a legitimate decode result for the
|
|
139
|
+
// exposed response types: JSON parses to a value the schema sees, and
|
|
140
|
+
// an empty text body decodes to "". Either value only arises from a
|
|
141
|
+
// broken execution contract, so both throw. (If "auto" is ever exposed,
|
|
142
|
+
// `null` becomes legitimate — it parses a literal `null` JSON body.)
|
|
143
|
+
if (result === null || result === undefined) {
|
|
144
|
+
const nonNullResult = z.object({}).safeParse(result);
|
|
145
|
+
if (!nonNullResult.success) {
|
|
146
|
+
throw new RestApiValidationError(
|
|
147
|
+
`Integration query returned ${String(result)} for responseType "${responseType}" — expected a response value`,
|
|
148
|
+
{
|
|
149
|
+
zodError: nonNullResult.error,
|
|
150
|
+
data: result,
|
|
151
|
+
},
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return result;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -1,137 +1,92 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Generic REST API Integration client with Zod response validation.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Extends RestApiClientBase with an apiRequest() that validates the
|
|
5
|
+
* full response against a caller-supplied Zod schema and throws
|
|
6
|
+
* RestApiValidationError on mismatch. When no response schema is
|
|
7
|
+
* provided, the raw result is returned without validation — useful for
|
|
8
|
+
* non-JSON responses (e.g. XML), which can alternatively be validated
|
|
9
|
+
* with a schema matching the decoded value (e.g. z.string()).
|
|
5
10
|
*/
|
|
6
11
|
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
import
|
|
10
|
-
import type {
|
|
11
|
-
import
|
|
12
|
-
QueryExecutor,
|
|
13
|
-
StreamingQueryExecutor,
|
|
14
|
-
TraceMetadata,
|
|
15
|
-
} from "../registry.js";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
|
|
14
|
+
import { RestApiValidationError } from "../../errors.js";
|
|
15
|
+
import type { TraceMetadata } from "../registry.js";
|
|
16
|
+
import { RestApiClientBase } from "./rest-api-client-base.js";
|
|
16
17
|
import type {
|
|
17
18
|
ApiRequestOptions,
|
|
18
19
|
ApiRequestSchema,
|
|
20
|
+
RestApiResponseType,
|
|
19
21
|
SupportsApiRequest,
|
|
20
|
-
StreamApiRequestSchema,
|
|
21
|
-
SupportsStreamingApiRequest,
|
|
22
22
|
} from "./types.js";
|
|
23
|
-
import {
|
|
24
|
-
RestApiValidationError,
|
|
25
|
-
StreamChunkValidationError,
|
|
26
|
-
} from "../../errors.js";
|
|
27
|
-
import type { z } from "zod";
|
|
28
|
-
|
|
29
|
-
export type RestApiRequest = PartialMessage<RestApiIntegrationPlugin>;
|
|
30
23
|
|
|
31
24
|
/**
|
|
32
25
|
* Base implementation for REST API Integration clients.
|
|
33
26
|
*
|
|
34
|
-
* All OpenAPI-based integration clients
|
|
35
|
-
*
|
|
36
|
-
*
|
|
27
|
+
* All OpenAPI-based integration clients (except those with
|
|
28
|
+
* integration-specific response handling) extend this class to
|
|
29
|
+
* inherit the generic apiRequest() method with runtime Zod validation.
|
|
37
30
|
*/
|
|
38
31
|
export abstract class RestApiIntegrationClient
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
SupportsApiRequest,
|
|
42
|
-
SupportsStreamingApiRequest
|
|
32
|
+
extends RestApiClientBase
|
|
33
|
+
implements SupportsApiRequest
|
|
43
34
|
{
|
|
44
|
-
readonly name: string;
|
|
45
|
-
readonly pluginId: string;
|
|
46
|
-
readonly config: IntegrationConfig;
|
|
47
|
-
|
|
48
|
-
protected readonly executeQuery: QueryExecutor;
|
|
49
|
-
protected readonly executeStreamingQuery?: StreamingQueryExecutor;
|
|
50
|
-
|
|
51
|
-
constructor(
|
|
52
|
-
config: IntegrationConfig,
|
|
53
|
-
executeQuery: QueryExecutor,
|
|
54
|
-
executeStreamingQuery?: StreamingQueryExecutor,
|
|
55
|
-
) {
|
|
56
|
-
this.name = config.name;
|
|
57
|
-
this.pluginId = config.pluginId;
|
|
58
|
-
this.config = config;
|
|
59
|
-
this.executeQuery = executeQuery;
|
|
60
|
-
this.executeStreamingQuery = executeStreamingQuery;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Helper to create a Property object for params.
|
|
65
|
-
*/
|
|
66
|
-
protected createParam(key: string, value: unknown): PartialMessage<Property> {
|
|
67
|
-
return {
|
|
68
|
-
key,
|
|
69
|
-
value: typeof value === "string" ? value : JSON.stringify(value),
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
35
|
async apiRequest<TBody, TResponse>(
|
|
74
36
|
options: ApiRequestOptions<TBody>,
|
|
75
37
|
schema: ApiRequestSchema<TBody, TResponse> & {
|
|
76
38
|
response: z.ZodSchema<TResponse>;
|
|
77
39
|
},
|
|
78
40
|
metadata?: TraceMetadata,
|
|
79
|
-
): Promise<TResponse
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Build the request using raw HTTP mode
|
|
112
|
-
const request: RestApiRequest = {
|
|
113
|
-
openApiAction: "genericHttpRequest",
|
|
114
|
-
httpMethod: options.method.toUpperCase(),
|
|
115
|
-
urlPath: options.path,
|
|
116
|
-
headers,
|
|
117
|
-
params,
|
|
118
|
-
responseType: "json",
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
// Add body if provided
|
|
122
|
-
if (options.body !== undefined) {
|
|
123
|
-
request.body = JSON.stringify(options.body);
|
|
124
|
-
request.bodyType = "jsonBody";
|
|
41
|
+
): Promise<TResponse>;
|
|
42
|
+
async apiRequest<TBody>(
|
|
43
|
+
options: ApiRequestOptions<TBody> & {
|
|
44
|
+
responseType: Exclude<RestApiResponseType, "json">;
|
|
45
|
+
},
|
|
46
|
+
schema?: ApiRequestSchema<TBody, unknown>,
|
|
47
|
+
metadata?: TraceMetadata,
|
|
48
|
+
): Promise<unknown>;
|
|
49
|
+
async apiRequest<TBody, TResponse>(
|
|
50
|
+
options: ApiRequestOptions<TBody>,
|
|
51
|
+
schema?: ApiRequestSchema<TBody, TResponse>,
|
|
52
|
+
metadata?: TraceMetadata,
|
|
53
|
+
): Promise<TResponse | unknown> {
|
|
54
|
+
// The overloads make schema-less JSON unrepresentable in TypeScript,
|
|
55
|
+
// but user API code executes as bundled JS with no type enforcement —
|
|
56
|
+
// enforce the same contract at runtime, before issuing the request.
|
|
57
|
+
if ((options.responseType ?? "json") === "json" && !schema?.response) {
|
|
58
|
+
throw new RestApiValidationError(
|
|
59
|
+
'apiRequest() with responseType "json" requires a response schema — provide one, or set responseType: "text" to receive a non-JSON payload unvalidated',
|
|
60
|
+
{
|
|
61
|
+
zodError: new z.ZodError([
|
|
62
|
+
{
|
|
63
|
+
code: z.ZodIssueCode.custom,
|
|
64
|
+
message: "response schema is required for JSON responses",
|
|
65
|
+
path: ["response"],
|
|
66
|
+
},
|
|
67
|
+
]),
|
|
68
|
+
data: undefined,
|
|
69
|
+
},
|
|
70
|
+
);
|
|
125
71
|
}
|
|
126
72
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
undefined,
|
|
73
|
+
const result = await this.executeApiRequest(
|
|
74
|
+
options,
|
|
75
|
+
schema?.body,
|
|
131
76
|
metadata,
|
|
132
77
|
);
|
|
133
78
|
|
|
134
|
-
//
|
|
79
|
+
// Without a response schema the raw result is returned as-is (typed
|
|
80
|
+
// unknown). Non-JSON responses (e.g. responseType "text" returning
|
|
81
|
+
// XML) can either omit the schema or pass one matching the decoded
|
|
82
|
+
// value, such as z.string(). Request-body validation is opt-in:
|
|
83
|
+
// executeApiRequest only validates options.body when schema.body is
|
|
84
|
+
// provided (unchanged from the previous contract, where schema.body
|
|
85
|
+
// was already optional).
|
|
86
|
+
if (!schema?.response) {
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
|
|
135
90
|
const responseParseResult = schema.response.safeParse(result);
|
|
136
91
|
|
|
137
92
|
if (!responseParseResult.success) {
|
|
@@ -146,134 +101,4 @@ export abstract class RestApiIntegrationClient
|
|
|
146
101
|
|
|
147
102
|
return responseParseResult.data;
|
|
148
103
|
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Execute a streaming API request with type-safe chunk validation.
|
|
152
|
-
*
|
|
153
|
-
* Returns an AsyncIterable that yields validated chunks as they arrive.
|
|
154
|
-
* Each chunk is validated against the provided schema before being yielded.
|
|
155
|
-
*
|
|
156
|
-
* @param options - Request configuration including method, path, params, and body
|
|
157
|
-
* @param schema - Zod schemas for request body and chunk validation
|
|
158
|
-
* @param metadata - Optional trace metadata for observability (label, description)
|
|
159
|
-
* @returns AsyncIterable yielding validated chunks
|
|
160
|
-
*
|
|
161
|
-
* @example
|
|
162
|
-
* ```typescript
|
|
163
|
-
* const ChunkSchema = z.object({
|
|
164
|
-
* id: z.string(),
|
|
165
|
-
* choices: z.array(z.object({
|
|
166
|
-
* delta: z.object({
|
|
167
|
-
* content: z.string().optional(),
|
|
168
|
-
* }),
|
|
169
|
-
* })),
|
|
170
|
-
* });
|
|
171
|
-
*
|
|
172
|
-
* const stream = client.streamApiRequest(
|
|
173
|
-
* {
|
|
174
|
-
* method: 'POST',
|
|
175
|
-
* path: '/v1/chat/completions',
|
|
176
|
-
* body: {
|
|
177
|
-
* model: 'gpt-4',
|
|
178
|
-
* stream: true,
|
|
179
|
-
* messages: [{ role: 'user', content: 'Hello!' }],
|
|
180
|
-
* },
|
|
181
|
-
* },
|
|
182
|
-
* { chunk: ChunkSchema },
|
|
183
|
-
* { label: 'openai.chatCompletions', description: 'Stream chat completion' }
|
|
184
|
-
* );
|
|
185
|
-
*
|
|
186
|
-
* for await (const chunk of stream) {
|
|
187
|
-
* console.log(chunk.choices[0]?.delta?.content);
|
|
188
|
-
* }
|
|
189
|
-
* ```
|
|
190
|
-
*/
|
|
191
|
-
async *streamApiRequest<TBody, TChunk>(
|
|
192
|
-
options: ApiRequestOptions<TBody>,
|
|
193
|
-
schema: StreamApiRequestSchema<TBody, TChunk>,
|
|
194
|
-
metadata?: TraceMetadata,
|
|
195
|
-
): AsyncIterable<TChunk> {
|
|
196
|
-
// Validate that streaming is supported
|
|
197
|
-
if (!this.executeStreamingQuery) {
|
|
198
|
-
throw new Error(
|
|
199
|
-
`Streaming is not supported for integration "${this.name}". ` +
|
|
200
|
-
"The orchestrator must provide a streaming query executor.",
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// Validate request body against schema if both are present.
|
|
205
|
-
// Body schema is optional — if not provided, the body is sent unvalidated.
|
|
206
|
-
if (options.body !== undefined && schema?.body) {
|
|
207
|
-
const bodyParseResult = schema.body.safeParse(options.body);
|
|
208
|
-
if (!bodyParseResult.success) {
|
|
209
|
-
throw new RestApiValidationError(
|
|
210
|
-
`Request body validation failed: ${bodyParseResult.error.message}`,
|
|
211
|
-
{
|
|
212
|
-
zodError: bodyParseResult.error,
|
|
213
|
-
data: options.body,
|
|
214
|
-
},
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// Convert headers to Property array
|
|
220
|
-
const headers: PartialMessage<Property>[] = [];
|
|
221
|
-
if (options.headers) {
|
|
222
|
-
for (const [key, value] of Object.entries(options.headers)) {
|
|
223
|
-
headers.push(this.createParam(key, value));
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// Convert query params to Property array
|
|
228
|
-
const params: PartialMessage<Property>[] = [];
|
|
229
|
-
if (options.params) {
|
|
230
|
-
for (const [key, value] of Object.entries(options.params)) {
|
|
231
|
-
params.push(this.createParam(key, value));
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
// Build the request using raw HTTP mode with streaming response
|
|
236
|
-
// Note: responseType must be "raw" for streaming - the orchestrator's
|
|
237
|
-
// Stream block expects SSE responses and only works with "raw" type.
|
|
238
|
-
const request: RestApiRequest = {
|
|
239
|
-
openApiAction: "genericHttpRequest",
|
|
240
|
-
httpMethod: options.method.toUpperCase(),
|
|
241
|
-
urlPath: options.path,
|
|
242
|
-
headers,
|
|
243
|
-
params,
|
|
244
|
-
responseType: "raw",
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
// Add body if provided
|
|
248
|
-
if (options.body !== undefined) {
|
|
249
|
-
request.body = JSON.stringify(options.body);
|
|
250
|
-
request.bodyType = "jsonBody";
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
// Execute the streaming request
|
|
254
|
-
const stream = this.executeStreamingQuery(
|
|
255
|
-
request as Record<string, unknown>,
|
|
256
|
-
metadata,
|
|
257
|
-
);
|
|
258
|
-
|
|
259
|
-
// Validate and yield each chunk
|
|
260
|
-
let chunkIndex = 0;
|
|
261
|
-
for await (const rawChunk of stream) {
|
|
262
|
-
const parseResult = schema.chunk.safeParse(rawChunk);
|
|
263
|
-
|
|
264
|
-
if (!parseResult.success) {
|
|
265
|
-
throw new StreamChunkValidationError(
|
|
266
|
-
`Chunk validation failed at index ${chunkIndex}: ${parseResult.error.message}`,
|
|
267
|
-
{
|
|
268
|
-
chunkIndex,
|
|
269
|
-
chunk: rawChunk,
|
|
270
|
-
zodError: parseResult.error,
|
|
271
|
-
},
|
|
272
|
-
);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
yield parseResult.data;
|
|
276
|
-
chunkIndex++;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
104
|
}
|