|
| 1 | +# Database Models |
| 2 | + |
| 3 | +We document each model including all fields, relationships and what they are used for. |
| 4 | + |
| 5 | +## ApiConnection |
| 6 | + |
| 7 | +Stores API configurations including: |
| 8 | + |
| 9 | +- `id` (Primary Key) |
| 10 | +- `name` (string) - Human-readable name for the API connection |
| 11 | +- `base_url` (string) - Base URL of the API |
| 12 | +- `api_type` (enum) - Defines API type (`REST`, `GraphQL`) |
| 13 | +- `auth_type` (enum) - Authentication type (e.g., Bearer, Basic, OAuth) |
| 14 | +- `auth_credentials` (json) - Stores API keys, tokens, or credentials |
| 15 | +- `headers` (json) - Default headers to be sent with requests |
| 16 | +- `rate_limit` (integer) - Maximum requests per minute/hour |
| 17 | +- `lang_param` (string) - Parameter name used for language selection |
| 18 | +- `default_locale` (string) - Default language to be used in API calls |
| 19 | +- `status` (enum) - New, Unused, Active, Error and Disabled |
| 20 | +- `notify_on_failure` (boolean, default: `true`) |
| 21 | +- `notify_on_error` (boolean, default: `true`) |
| 22 | +- `notify_email` (string, nullable) - Email to notify on failure |
| 23 | +- `last_used` (timestamp) - Last time the API was used |
| 24 | +- `last_error` (timestamp) - Last time the API had an error |
| 25 | +- `error_window` (integer, default: 3600) - Seconds after which we should reset the error count |
| 26 | +- `error_count` (integer, default: 0) - Count of errors per error_window |
| 27 | +- `error_limit` (integer, default: 10) - Count of errors before we disable an API |
| 28 | +- `created_at` (timestamp) |
| 29 | +- `updated_at` (timestamp) |
| 30 | + |
| 31 | +## ApiEndpoint |
| 32 | + |
| 33 | +API endpoints, methods (REST), queries/mutations (GraphQL), expected responses: |
| 34 | + |
| 35 | +- `id` (Primary Key) |
| 36 | +- `name` (string) - Human-readable name for the API endpoint |
| 37 | +- `direct_access` (boolean, default: false) - Allow direct API calls |
| 38 | +- `api_connection_id` (Foreign Key) - Links to `ApiConnection` |
| 39 | +- `path` (string, nullable) - API endpoint path (for REST, e.g., `/users`) |
| 40 | +- `method` (enum, nullable) - HTTP method (GET, POST, PUT, DELETE, PATCH) for REST APIs |
| 41 | +- `query` (text, nullable) - GraphQL query or mutation |
| 42 | +- `variables` (json, nullable) - JSON object of GraphQL variables |
| 43 | +- `response_map` (json, nullable) - Defines how to extract and store fields from the GraphQL response |
| 44 | +- `expected_response` (json) - Schema of the expected response |
| 45 | +- `field_mappings` (json, nullable) - Stores Filament Repeater mappings for syncing API data to DB fields |
| 46 | +- `lang_override` (string, nullable) - Optional override for language in this specific endpoint |
| 47 | +- `rate_limit` (integer, nullable) - Custom rate limit for this endpoint |
| 48 | +- `transformers` (json, nullable) - Transformers for this endpoint |
| 49 | +- `rate_window` (integer, nullable) - Custom time window for rate limiting |
| 50 | +- `status` (enum) - New, Unused, Active, Error and Disabled |
| 51 | +- `last_used` (timestamp) - Last time the API was used |
| 52 | +- `last_error` (timestamp) - Last time the API had an error |
| 53 | +- `error_count` (integer, default: 0) - Count of errors |
| 54 | +- `timeout` (integer, default: 30) - Request timeout in seconds |
| 55 | +- `created_at` (timestamp) |
| 56 | +- `updated_at` (timestamp) |
| 57 | + |
| 58 | +## ApiSyncJob |
| 59 | + |
| 60 | +Define and track API synchronization jobs and their execution statuses: |
| 61 | + |
| 62 | +- `id` (Primary Key) |
| 63 | +- `name` (string) - Human-readable name for the API sync job |
| 64 | +- `direct_access` (boolean, default: false) - Allow direct job execution |
| 65 | +- `api_endpoint_ids` (json) - Array of API Endpoints to process in order |
| 66 | +- `status` (enum) - Status of sync (pending, running, completed, failed) |
| 67 | +- `last_sync_at` (timestamp) - Last successful sync timestamp |
| 68 | +- `chained_job_id`(foreign_key, nulable) - Links to another `ApiSyncJob` for chaining |
| 69 | +- `chained_parameters`(json) - stores the source fields to target params |
| 70 | +- `batch`(bool) - create a batch |
| 71 | +- `batch_size`(int) - create a batch |
| 72 | +- `batch_mode`(enum: `sequential`, `parallel`) |
| 73 | +- `batch_delay` (integer, nullable) - seconds |
| 74 | +- `freshness_ttl` (int) - e. g. 86400 |
| 75 | +- `last_fresh_at` (timestamp) - updated every time the job successfully completes |
| 76 | +- `auto_refresh`(bool) - should the job be called from the frontend when stale |
| 77 | +- `auto_refresh_mode`(bool) - queue / sync |
| 78 | +- `max_retries` (integer) - after how many errors should we stay in error state |
| 79 | +- `retry_strategy` (enum: `fixed`, `exponential`, `linear`) |
| 80 | +- `retry_delay` (integer, default 60 sec) |
| 81 | +- `notify_on_failure` (boolean, default: `true`) |
| 82 | +- `timeout` (integer, default: 300) - Total job timeout |
| 83 | +- `created_at` (timestamp) |
| 84 | +- `updated_at` (timestamp) |
| 85 | + |
| 86 | +### Chained Parameters |
| 87 | + |
| 88 | +```json |
| 89 | +[ |
| 90 | + { |
| 91 | + "source_field": "data[].id", |
| 92 | + "target_param": "{id}" |
| 93 | + } |
| 94 | +] |
| 95 | +``` |
| 96 | + |
| 97 | +## ApiLog |
| 98 | + |
| 99 | +Logs for API sync jobs and direct API calls: |
| 100 | + |
| 101 | +- `id` (Primary Key) |
| 102 | +- `name` (string) - Human-readable name for the API sync job |
| 103 | +- `api_sync_job_id` (foreign_key) |
| 104 | +- `request_data` |
| 105 | +- `response_data` |
| 106 | +- `status_code` |
| 107 | +- `error_message` |
| 108 | +- `created_at` (timestamp) |
0 commit comments