Add Salesforce Data 360 (Data Cloud) API support#94
Conversation
…ile, Metadata) Co-authored-by: jlantz <1697127+jlantz@users.noreply.github.com>
|
@copilot please resolve the build failures for clippy, docs, integration tests, MSRV, Test, and WASM Bridge Integration Tests. And we need to have integration tests that test against a real scratch org. If we need changes to the scratchdef, that should be available here in the repo |
…ud integration tests Co-authored-by: jlantz <1697127+jlantz@users.noreply.github.com>
Addressed in commit MSRV (pre-existing): Added Test / Clippy / Docs: These use Integration Tests / WASM Bridge Tests: The Data Cloud integration tests ( Scratch org definition ( |
Replaced GH_TOKEN_BUILDS with KANTEXT_BUILDS_GITHUB_TOKEN for git credentials in CI workflow. Signed-off-by: Jason Lantz <jason@muselab.com>
Signed-off-by: Jason Lantz <jason@muselab.com>
Adds typed client support for Salesforce Data Cloud (Data 360) APIs, covering SQL query, async query management, vector search (RAG), unified profile lookup, and metadata discovery. Also adds the Data Cloud token exchange flow required to obtain a TSE-scoped access token. Includes real-org integration tests and CI/scratch org fixes.
sf-auth: Data Cloud token exchange
DataCloudTokenResponse— holds the TSE URL + Data Cloud access token;access_tokenandsignatureare redacted inDebugOAuthClient::exchange_for_data_cloud(sf_access_token, login_url)— performs the RFC 8693 token exchange (grant_type=urn:salesforce:grant-type:external:cdp). Theclient_idis intentionally omitted from the request body — the subject token alone identifies the caller for this grant type.sf-rest:
DataCloudClient+ typesNew
DataCloudClientstruct targeting the TSE URL (separate infrastructure from standard SF REST). Default API version64.0.query_sql()POST /services/data/v{ver}/ssot/query-sqlquery_status()GET …/query-sql/{queryId}query_rows()GET …/query-sql/{queryId}/rowsvector_search()POST …/ssot/search-vectorprofile(dmo, filters)GET /api/v1/profile/{dmo}?filters=…metadata(entity_type)GET /api/v1/metadata?entityType=…New types:
DataCloudQueryRequest/Response,QueryMetadata,ColumnInfo,AsyncQueryStatus,VectorSearchRequest/Response/Result,DataCloudMetadataResponse/Object.ColumnInfopreserves original API casing (relevant since the 2026 casing change from lowercase to e.g.ssot__Id__c).Integration tests (
tests/integration/data_cloud.rs)Seven real-org integration tests covering the full Data Cloud surface. All tests fail loudly if Data Cloud is not provisioned (no silent skipping):
test_data_cloud_token_exchange_returns_tse_url_and_tokentest_data_cloud_metadata_discovery_returns_entities/api/v1/metadata?entityType=DataModelObjectreturns ≥1 DMOtest_data_cloud_metadata_discovery_without_filtertest_data_cloud_sql_query_returns_column_metadataSELECT * FROM <dmo> LIMIT 0returns column schema (no data dependency)test_data_cloud_async_sql_query_returns_query_idqueryId; status poll + row fetch succeedtest_data_cloud_vector_search_endpoint_is_reachabletest_data_cloud_profile_endpoint_is_reachableDMO names from the metadata API are validated as safe SQL identifiers before interpolation.
Scratch org definition (
config/project-scratch-def.json)Added
"DataCloud"to the scratch orgfeatureslist so orgs created viasf org create scratch -f config/project-scratch-def.jsonhave Salesforce Data Cloud provisioned.CI fix (
.github/workflows/ci.yml)Added
environment: GitHub composable-deliveryand the git-credentials configuration step to the MSRV job, matching what Clippy/Test/Docs already have. The job was always failing because it had no access toGH_TOKEN_BUILDS, which is required to resolve thebusbar-capabilityoptional dependency insf-bridge.Usage
Original prompt
This section details on the original issue you should resolve
<issue_title>Add Data 360 API endpoints</issue_title>
<issue_description>### Salesforce API
REST API (sf-rest)
Endpoint(s)
1. Data Cloud Query API (SQL/SOQL)
2. Profile & Calculated Insights API
3. Vector Search API (For RAG)
Implementation Mapping for busbar-sf-api
Handle the Token Exchange flow. Data Cloud often requires a "secondary" token (the Offcore Token) for the TSE endpoints.
Response Schemas
Note that as of late 2025, Salesforce rebranded these as Data 360 APIs, but the internal URI paths usually retain ssot or c360a.
1. The Core Query Endpoint (SQL)
This is the most critical endpoint for your petgraph engine to fetch structured context.
Recommended Rust Structs (serde):
Rust
Warning for 2026: Be sure your parser handles case-insensitive column names. Recent updates changed the default output from lowercase to the original API name casing (e.g., ssot__Id__c instead of ssot__id__c).
2. The Vector Search Endpoint (RAG)
JSON
3. The Unified Profile API (v1)
4. Metadata Discovery API
If you want your Rust engine to "know" what fields are available (for auto-complete or validation), you need the metadata endpoint.
Summary Table for busbar-sf-api
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.