Adapter System Overview
Interface X uses an adapter pattern to communicate with any search API. Adapters handle the transformation of requests and responses between your application’s data models and the API’s format.What is an Adapter?
An adapter is a collection of endpoint adapters, one for each API endpoint you want to consume. Each endpoint adapter:- Transforms requests from your app’s format to the API’s expected format
- Makes HTTP requests to the API
- Transforms responses from the API’s format back to your app’s format
Core Concepts
Endpoint Adapter Factory
TheendpointAdapterFactory function creates endpoint adapters from configuration:
/home/daytona/workspace/source/packages/x-adapter/src/endpoint-adapter/endpoint-adapter.factory.ts:1
Request Mappers
Transform your application’s request into the API’s expected format:Response Mappers
Transform the API’s response into your application’s expected format:Creating an Endpoint Adapter
Here’s a complete example:/home/daytona/workspace/source/packages/x-adapter/README.md:69
Advanced Features
Dynamic Endpoints
Use path parameters in your endpoint URL:/home/daytona/workspace/source/packages/x-adapter/README.md:143
Custom HTTP Clients
By default, adapters use the Fetch API. You can provide a custom HTTP client:/home/daytona/workspace/source/packages/x-adapter/README.md:186
Default Request Options
Set default options for all requests:Extending Adapters
You can extend an existing adapter to create variations:/home/daytona/workspace/source/packages/x-adapter/README.md:642
Schema Mappers
For simple field mapping, use schema mappers instead of writing mapper functions:/home/daytona/workspace/source/packages/x-adapter/README.md:275
SubSchemas
Reuse schemas for nested objects:/home/daytona/workspace/source/packages/x-adapter/README.md:302
Mutable Schemas
Create schemas that can be modified or extended:/home/daytona/workspace/source/packages/x-adapter/README.md:410
Available Adapters
Platform Adapter
Pre-built adapter for Empathy Platform API
Custom API
Create adapters for custom search APIs
Package Information
The adapter system is provided by the Documentation: GitHub
@empathyco/x-adapter package.Installation:Next Steps
Platform Adapter
Use the pre-built Empathy Platform adapter
Custom API Integration
Build a custom adapter for your API
